x86/pv: Move hv_compat_vstart into pv_domain

The hv_compat_vstart variable is hidden behind CONFIG_PV32 but lives in
arch_domain.  Moving it into pv_domain is an obvious improvement.

Its value however is less obvious, and is a mess.

In !PV32 builds, it's uniformly treated as 0, but in PV32 builds it's ~0U (HVM
guests), __HYPERVISOR_COMPAT_VIRT_START (PV guests), or custom (PV32 dom0).
This seems to work because users are guarded behind is_pv32_{domain,vcpu}().

Simplify things by leaving it as 0 in PV32 builds for most domains,
initialising it in only in switch_compat() when a domain becomes 32bit PV.
dom0_construct() adjusts the value after calling switch_compat().

Suggested-by: Grygorii Strashko <grygorii_strashko@epam.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2025-12-10 14:48:45 +00:00
1 parent 156e27e497
commit 0eff073ff8
5 files changed
+8 -11

No files matched your search

-5
View File
@@ -890,11 +890,6 @@ int arch_domain_create(struct domain *d,
}
d->arch.emulation_flags = emflags;
#ifdef CONFIG_PV32
d->arch.hv_compat_vstart =
is_pv_domain(d) ? __HYPERVISOR_COMPAT_VIRT_START : ~0u;
#endif
spec_ctrl_init_domain(d);
if ( (rc = paging_domain_init(d)) != 0 )
+1 -1
View File
@@ -201,7 +201,7 @@
/* This is not a fixed value, just a lower limit. */
#define __HYPERVISOR_COMPAT_VIRT_START 0xF5800000
#define HYPERVISOR_COMPAT_VIRT_START(d) ((d)->arch.hv_compat_vstart)
#define HYPERVISOR_COMPAT_VIRT_START(d) ((d)->arch.pv.hv_compat_vstart)
#else /* !CONFIG_PV32 */
+4 -4
View File
@@ -288,6 +288,10 @@ struct pv_domain
/* Mitigate L1TF with shadow/crashing? */
bool check_l1tf;
#ifdef CONFIG_PV32
unsigned int hv_compat_vstart;
#endif
/* map_domain_page() mapping cache. */
struct mapcache_domain mapcache;
@@ -315,10 +319,6 @@ struct arch_domain
{
struct page_info *perdomain_l3_pg;
#ifdef CONFIG_PV32
unsigned int hv_compat_vstart;
#endif
/* Maximum physical-address bitwidth supported by this guest. */
unsigned int physaddr_bitsize;
+1 -1
View File
@@ -521,7 +521,7 @@ static int __init dom0_construct(const struct boot_domain *bd)
printk("Dom0 expects too high a hypervisor start address\n");
return -ERANGE;
}
d->arch.hv_compat_vstart =
d->arch.pv.hv_compat_vstart =
max_t(unsigned int, m2p_compat_vstart, value);
}
+2
View File
@@ -254,6 +254,8 @@ int switch_compat(struct domain *d)
goto undo_and_fail;
}
d->arch.pv.hv_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START;
if ( MACH2PHYS_COMPAT_NR_ENTRIES(d) < max_page )
d->arch.physaddr_bitsize =
/* 2^n entries can be contained in guest's p2m mapping space */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.