|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v3 04/39] xen/riscv: request a G-stage flush on vmenter when VMIDs are disabled
vmid_handle_vmenter() reports that no flush is needed when VMIDs are
unavailable (e.g. vmid=off, or hardware with no more than one VMID bit).
Every domain then runs under VMID 0 with nothing flushed in between, so as
soon as a hart runs more than one domain, a domain entered there can use
the G-stage translations left behind by the domain which ran before it.
Report that a flush is needed on every entry instead.
Update the comment in p2m_handle_vmenter() accordingly: without VMIDs the
VS-stage TLB doesn't need a separate flush either, as the G-stage flush now
done on every entry already covers it.
While at it, spell the other early return as a bool literal.
Fixes: bff3b9ea4696 ("xen/riscv: introduce VMID allocation and manegement")
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
Changes in v3:
- Update the commit message.
---
Changes in v2:
- New patch.
---
---
xen/arch/riscv/p2m.c | 4 +++-
xen/arch/riscv/vmid.c | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c
index 1cea86512c8c..de25607247a6 100644
--- a/xen/arch/riscv/p2m.c
+++ b/xen/arch/riscv/p2m.c
@@ -1584,7 +1584,9 @@ void p2m_handle_vmenter(void)
/*
* There is also no need to flush the VS-stage TLB: even if speculation
* occurs (VSATP + old HGATP were used), it will use the old VMID, which
- * won't be reused until need_flush is set to true.
+ * won't be reused until need_flush is set to true. When VMIDs aren't
+ * available there is no old VMID to rely on, but then need_flush is set
+ * on every entry, so the flush above covers that case.
*/
}
diff --git a/xen/arch/riscv/vmid.c b/xen/arch/riscv/vmid.c
index 11c7e9d6d6c8..93714b359534 100644
--- a/xen/arch/riscv/vmid.c
+++ b/xen/arch/riscv/vmid.c
@@ -141,7 +141,7 @@ bool vmid_handle_vmenter(struct vcpu_vmid *vmid)
/* Test if VCPU has valid VMID. */
if ( read_atomic(&vmid->generation) == data->generation )
- return 0;
+ return false;
/* If there are no free VMIDs, need to go to a new generation. */
if ( unlikely(data->next_vmid > data->max_vmid) )
@@ -164,7 +164,7 @@ bool vmid_handle_vmenter(struct vcpu_vmid *vmid)
disabled:
vmid->vmid = 0;
- return 0;
+ return true;
}
/*
--
2.55.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |