[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/pv: Move hv_compat_vstart into pv_domain



commit 0eff073ff8ee41ff76a6a1fb3196e8e51943f549
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Tue Dec 9 17:01:10 2025 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Dec 10 14:48:45 2025 +0000

    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@xxxxxxxx>
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/domain.c             | 5 -----
 xen/arch/x86/include/asm/config.h | 2 +-
 xen/arch/x86/include/asm/domain.h | 8 ++++----
 xen/arch/x86/pv/dom0_build.c      | 2 +-
 xen/arch/x86/pv/domain.c          | 2 ++
 5 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index d33a42c882..5e37bfbd17 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -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 )
diff --git a/xen/arch/x86/include/asm/config.h 
b/xen/arch/x86/include/asm/config.h
index 1563696954..cc80f2c623 100644
--- a/xen/arch/x86/include/asm/config.h
+++ b/xen/arch/x86/include/asm/config.h
@@ -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 */
 
diff --git a/xen/arch/x86/include/asm/domain.h 
b/xen/arch/x86/include/asm/domain.h
index 386ec61745..7e5cbd11a4 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -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;
 
diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
index fed03dc15d..418b453ba8 100644
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -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);
         }
 
diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c
index 11db6a6d83..ca5f692051 100644
--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -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 */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.