diff options
| author | Anup Patel <[email protected]> | 2021-10-26 16:25:21 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2021-11-02 16:02:08 +0530 |
| commit | 013ba4ef3d94de67d040376535131012134ed54f (patch) | |
| tree | 215cb1ff0032b25bb1033f655146894f7492dd3e /lib/sbi | |
| parent | c891acca172dfc60719419e19338508a83d97931 (diff) | |
lib: sbi: Fix GPA passed to __sbi_hfence_gvma_xyz() functions
The parameter passed to HFENCE.GVMA instruction in rs1 register
is guest physical address right shifted by 2 (i.e. divided by 4).
Unfortunately, we overlooked the semantics of rs1 registers for
HFENCE.GVMA instruction and never right shifted guest physical
address by 2. This issue did not manifest for hypervisors till
now because all H-extension implementations (such as QEMU, Spike,
Rocket Core FPGA, etc) we tried till now were conservatively
flushing everything upon any HFENCE.GVMA instruction.
This patch fixes GPA passed to __sbi_hfence_gvma_vmid_gpa()
and __sbi_hfence_gvma_gpa() functions.
Fixes: 331ff6a162c1 ("lib: Support stage1 and stage2 tlb flushing")
Reported-by: Ian Huang <[email protected]>
Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Xiang W <[email protected]>
Reviewed-by: Dong Du <[email protected]>
Diffstat (limited to 'lib/sbi')
| -rw-r--r-- | lib/sbi/sbi_hfence.S | 4 | ||||
| -rw-r--r-- | lib/sbi/sbi_tlb.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/sbi/sbi_hfence.S b/lib/sbi/sbi_hfence.S index d05becbf..e11e6505 100644 --- a/lib/sbi/sbi_hfence.S +++ b/lib/sbi/sbi_hfence.S @@ -27,7 +27,7 @@ .global __sbi_hfence_gvma_vmid_gpa __sbi_hfence_gvma_vmid_gpa: /* - * rs1 = a0 (GPA) + * rs1 = a0 (GPA >> 2) * rs2 = a1 (VMID) * HFENCE.GVMA a0, a1 * 0110001 01011 01010 000 00000 1110011 @@ -51,7 +51,7 @@ __sbi_hfence_gvma_vmid: .global __sbi_hfence_gvma_gpa __sbi_hfence_gvma_gpa: /* - * rs1 = a0 (GPA) + * rs1 = a0 (GPA >> 2) * rs2 = zero * HFENCE.GVMA a0 * 0110001 00000 01010 000 00000 1110011 diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index efa74a75..4c142ea3 100644 --- a/lib/sbi/sbi_tlb.c +++ b/lib/sbi/sbi_tlb.c @@ -72,7 +72,7 @@ void sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo) } for (i = 0; i < size; i += PAGE_SIZE) { - __sbi_hfence_gvma_gpa(start+i); + __sbi_hfence_gvma_gpa((start + i) >> 2); } } @@ -148,7 +148,7 @@ void sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo) } for (i = 0; i < size; i += PAGE_SIZE) { - __sbi_hfence_gvma_vmid_gpa(start + i, vmid); + __sbi_hfence_gvma_vmid_gpa((start + i) >> 2, vmid); } } |
