|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v5 10/45] x86/domain_page: drop redundant is_pv_vcpu() checks
The is_pv_vcpu() checks after mapcache_current_vcpu() never fail: they
have been redundant since 622c9a5ba95d ("x86/mm: accurately track
which vCPU page-tables are loaded") made mapcache_current_vcpu() do
the check itself. mapcache_current_vcpu() is now guaranteed to return
a PV vCPU with a caching structure (which is what is needed for the
subsequent dcache->inuse check): either a scheduled PV vCPU, or this
CPU's idle vCPU (possibly after finishing a lazy context switch).
Drop the checks; their speculation barriers (evaluate_nospec()) go
too.
mapcache_current_vcpu() returns NULL if this CPU's pgtable_vcpu is not
yet set (early boot) or is not a PV vCPU. Otherwise it reads
pgtable_vcpu again and returns that. In between, pgtable_vcpu changes
only when a lazy context switch from a PV vCPU is completed, by
mapcache_current_vcpu() itself (sync_local_execstate()) or first by an
interrupt such as a FLUSH_VCPU_STATE IPI; completing it loads the idle
vCPU's page-tables and sets pgtable_vcpu to the idle vCPU. No other
writer of pgtable_vcpu runs in an interrupt that returns to the code it
interrupted. During an EFI runtime call pgtable_vcpu is the idle
vCPU: efi_rs_enter() completes any lazy switch, then loads EFI's
page-tables, which carry the directmap. So the vCPU returned is either
the PV vCPU checked or this CPU's idle vCPU.
The idle vCPU passes is_pv_vcpu(), as the idle domain is created
without XEN_DOMCTL_CDF_hvm, but its mapcache is never set up:
domain_create() returns for the idle domain before calling
arch_domain_create(), which is what calls mapcache_domain_init(). With
its dcache->inuse NULL, map_domain_page() uses the directmap, and
unmap_domain_page()'s ASSERT() on dcache->inuse still catches a
mapcache address unmapped with no mapcache in use. In builds without
CONFIG_PV, is_pv_vcpu() is always false and mapcache_current_vcpu()
always returns NULL.
No functional change.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Changes in v4:
- New in this version, split out of "x86/domain_page: prepare the
mapcache for per-vCPU accounting", with a justification of its own.
NB I've included Claude's complete analysis in the commit message.
I've reworded the commit message so that the middle two paragraphs can
be dropped, or reworded more briefly on commit.
---
xen/arch/x86/domain_page.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c
index f3e65e2d44..ed68483695 100644
--- a/xen/arch/x86/domain_page.c
+++ b/xen/arch/x86/domain_page.c
@@ -74,7 +74,7 @@ void *map_domain_page(mfn_t mfn)
#endif
v = mapcache_current_vcpu();
- if ( !v || !is_pv_vcpu(v) )
+ if ( !v )
return mfn_to_virt(mfn_x(mfn));
dcache = &v->domain->arch.pv.mapcache;
@@ -179,7 +179,7 @@ void unmap_domain_page(const void *ptr)
ASSERT(va >= MAPCACHE_VIRT_START && va < MAPCACHE_VIRT_END);
v = mapcache_current_vcpu();
- ASSERT(v && is_pv_vcpu(v));
+ ASSERT(v);
dcache = &v->domain->arch.pv.mapcache;
ASSERT(dcache->inuse);
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |