mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 07:41:42 +01:00
lib: sbi: Correctly limit flushes to a single ASID/VMID
Per the SBI specification, the effects of these functions are limited to a specific ASID and/or VMID. This applies even when flushing the entire address space. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
3e21b96003
commit
a140a4e862
@@ -111,12 +111,7 @@ void sbi_tlb_local_hfence_vvma_asid(struct sbi_tlb_info *tinfo)
|
|||||||
hgatp = csr_swap(CSR_HGATP,
|
hgatp = csr_swap(CSR_HGATP,
|
||||||
(vmid << HGATP_VMID_SHIFT) & HGATP_VMID_MASK);
|
(vmid << HGATP_VMID_SHIFT) & HGATP_VMID_MASK);
|
||||||
|
|
||||||
if (start == 0 && size == 0) {
|
if ((start == 0 && size == 0) || (size == SBI_TLB_FLUSH_ALL)) {
|
||||||
__sbi_hfence_vvma_all();
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size == SBI_TLB_FLUSH_ALL) {
|
|
||||||
__sbi_hfence_vvma_asid(asid);
|
__sbi_hfence_vvma_asid(asid);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -138,12 +133,7 @@ void sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo)
|
|||||||
|
|
||||||
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_VMID_RCVD);
|
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_VMID_RCVD);
|
||||||
|
|
||||||
if (start == 0 && size == 0) {
|
if ((start == 0 && size == 0) || (size == SBI_TLB_FLUSH_ALL)) {
|
||||||
__sbi_hfence_gvma_all();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (size == SBI_TLB_FLUSH_ALL) {
|
|
||||||
__sbi_hfence_gvma_vmid(vmid);
|
__sbi_hfence_gvma_vmid(vmid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -162,13 +152,8 @@ void sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo)
|
|||||||
|
|
||||||
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_ASID_RCVD);
|
sbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_ASID_RCVD);
|
||||||
|
|
||||||
if (start == 0 && size == 0) {
|
|
||||||
tlb_flush_all();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Flush entire MM context for a given ASID */
|
/* Flush entire MM context for a given ASID */
|
||||||
if (size == SBI_TLB_FLUSH_ALL) {
|
if ((start == 0 && size == 0) || (size == SBI_TLB_FLUSH_ALL)) {
|
||||||
__asm__ __volatile__("sfence.vma x0, %0"
|
__asm__ __volatile__("sfence.vma x0, %0"
|
||||||
:
|
:
|
||||||
: "r"(asid)
|
: "r"(asid)
|
||||||
|
Reference in New Issue
Block a user