@@ -56,6 +56,7 @@ nestedhvm_vcpu_reset(struct vcpu *v)
nv->nv_vvmcxaddr = INVALID_PADDR;
nv->nv_flushp2m = 0;
nv->nv_p2m = NULL;
+ nv->np2m_generation = 0;
hvm_asid_flush_vcpu_asid(&nv->nv_n2asid);
@@ -73,6 +73,7 @@ static int p2m_initialise(struct domain *d, struct p2m_domain *p2m)
p2m->p2m_class = p2m_host;
p2m->np2m_base = P2M_BASE_EADDR;
+ p2m->np2m_generation = 0;
for ( i = 0; i < ARRAY_SIZE(p2m->pod.mrp.list); ++i )
p2m->pod.mrp.list[i] = gfn_x(INVALID_GFN);
@@ -1732,6 +1733,7 @@ p2m_flush_table_locked(struct p2m_domain *p2m)
/* This is no longer a valid nested p2m for any address space */
p2m->np2m_base = P2M_BASE_EADDR;
+ p2m->np2m_generation++;
/* Make sure nobody else is using this p2m table */
nestedhvm_vmcx_flushtlb(p2m);
@@ -1806,6 +1808,7 @@ static void assign_np2m(struct vcpu *v, struct p2m_domain *p2m)
nv->nv_flushp2m = 0;
nv->nv_p2m = p2m;
+ nv->np2m_generation = p2m->np2m_generation;
cpumask_set_cpu(v->processor, p2m->dirty_cpumask);
}
@@ -115,6 +115,7 @@ struct nestedvcpu {
bool_t nv_flushp2m; /* True, when p2m table must be flushed */
struct p2m_domain *nv_p2m; /* used p2m table for this vcpu */
+ uint64_t np2m_generation;
struct hvm_vcpu_asid nv_n2asid;
@@ -209,6 +209,7 @@ struct p2m_domain {
* to set it to any other value. */
#define P2M_BASE_EADDR (~0ULL)
uint64_t np2m_base;
+ uint64_t np2m_generation;
/* Nested p2ms: linked list of n2pms allocated to this domain.
* The host p2m hasolds the head of the list and the np2ms are
Add np2m_generation element to both p2m_domain and nestedvcpu. np2m's generation will be incremented each time the np2m is flushed. This will allow to detect if a nested vcpu has the stale np2m. Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> --- xen/arch/x86/hvm/nestedhvm.c | 1 + xen/arch/x86/mm/p2m.c | 3 +++ xen/include/asm-x86/hvm/vcpu.h | 1 + xen/include/asm-x86/p2m.h | 1 + 4 files changed, 6 insertions(+)