lib: Implement sfence.vma correctly.

Currently, OpenSBI doesn't distinguish between sfence.vma
and sfence.vm asid calls. Moreover, it ignores the page
ranges and just flush entire TLB everytime.

Fix the sfence implementation by keeping all the tlb flush
info in scratch area.

The relevant Linux kernel code was added by
https://patchwork.kernel.org/project/linux-riscv/list/?series=89695

However, this patch is backward compatible with older version kernel
that doesn't have the above patches as well.

Fixes #87
Signed-off-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
Atish Patra
2019-03-09 12:57:20 -08:00
committed by Anup Patel
parent 508a27204c
commit 90cb4917b5
6 changed files with 106 additions and 16 deletions

View File

@@ -35,16 +35,14 @@
/** Offset of ipi_type in sbi_ipi_data */
#define SBI_IPI_DATA_IPI_TYPE_OFFSET (15 * __SIZEOF_POINTER__)
#define SBI_SCRATCH_TLB_INFO_OFFSET (16 * __SIZEOF_POINTER__)
/** Maximum size of sbi_scratch and sbi_ipi_data */
#define SBI_SCRATCH_SIZE (32 * __SIZEOF_POINTER__)
#ifndef __ASSEMBLY__
#include <sbi/sbi_types.h>
struct sbi_ipi_data {
unsigned long ipi_type;
};
#include <sbi/sbi_ipi.h>
/** Representation of per-HART scratch space */
struct sbi_scratch {
@@ -80,6 +78,10 @@ struct sbi_scratch {
#define sbi_ipi_data_ptr(scratch) \
((struct sbi_ipi_data *)(void*)scratch + SBI_IPI_DATA_IPI_TYPE_OFFSET)
/** Get pointer to tlb flush info from sbi_scratch */
#define sbi_tlb_info_ptr(scratch) \
((struct sbi_tlb_info *)(void*)scratch + SBI_SCRATCH_TLB_INFO_OFFSET)
#endif
#endif