Introduce needs_tlb_flush that indicate that the vCPU related TLB
needs to be flushed before entering this domain. This is intended
to be used later for using the same ASID for all vCPU of a domain.
Also track vCPU context switch to determine :
- per vcpu "latest_cpu" that tracks which pCPU last ran this vCPU,
this is used to know whether our current TLB (of our pCPU) state
is stale.
Schedule a TLB flush if the vCPU ran on another pCPU previously.
- per pCPU "latest_vcpu" (per domain) that tracks which vCPU the
TLB+ASID/VPID is holding onto.
Schedule a TLB flush if this pCPU hasn't ran this vCPU previously
(which can happen if we context-switch multiples vCPUs of a same
domain on a same pCPU).
If ASID use is disabled, unconditionnaly perform a TLB flush.
Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
v2: Merge several patches into one, move logic to context_switch(),
move fields to arch_vcpu/arch_domain, consider !asid_enabled case.
---
xen/arch/x86/domain.c | 26 ++++++++++++++++++++++++++
xen/arch/x86/include/asm/domain.h | 6 ++++++
2 files changed, 32 insertions(+)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 996b50af7a..27155546ca 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -38,6 +38,7 @@
#include <xen/smp.h>
#include <xen/softirq.h>
#include <xen/wait.h>
+#include <xen/xvmalloc.h>
#include <asm/amd.h>
#include <asm/cpu-policy.h>
@@ -874,6 +875,13 @@ int arch_domain_create(struct domain *d,
spec_ctrl_init_domain(d);
+ rc = -ENOMEM;
+ d->arch.latest_vcpu = xvmalloc_array(int, nr_cpu_ids);