[PATCH v3] xen/x86: restrict XENFEAT_pae_pgdir_above_4gb setting to PV guests

Roger Pau Monne posted 1 patch 2 weeks, 5 days ago
xen/common/kernel.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH v3] xen/x86: restrict XENFEAT_pae_pgdir_above_4gb setting to PV guests
Posted by Roger Pau Monne 2 weeks, 5 days ago
XENFEAT_pae_pgdir_above_4gb is only used by 32bit PV guests, hence limit
its setting in XENVER_get_features to the is_pv_domain() guarded section,
with the rest of the PV specific features.  Add an additional build time
guard to short-circuit the setting of XENFEAT_pae_pgdir_above_4gb if the
hypervisor has no PV 32bit support.

Signed-off-by: Roger Pau Monné <roger@xenproject.org>
---
Changes since v2:
 - Add IS_ENABLED(CONFIG_PV32).
---
 xen/common/kernel.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index f4bbd8818fa8..499023fae6fd 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -677,8 +677,6 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
                         (1U << XENFEAT_vcpu_time_phys_area) |
 #endif
                         (1U << XENFEAT_runstate_phys_area);
-            if ( VM_ASSIST(d, pae_extended_cr3) )
-                fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb);
             if ( paging_mode_translate(d) )
                 fi.submap |=
                     (1U << XENFEAT_writable_page_tables) |
@@ -690,9 +688,13 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 #endif
 #ifdef CONFIG_X86
             if ( is_pv_domain(d) )
+            {
                 fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
                              (1U << XENFEAT_highmem_assist) |
                              (1U << XENFEAT_gnttab_map_avail_bits);
+                if ( IS_ENABLED(CONFIG_PV32) && VM_ASSIST(d, pae_extended_cr3) )
+                    fi.submap |= (1U << XENFEAT_pae_pgdir_above_4gb);
+            }
             else
                 fi.submap |= (1U << XENFEAT_hvm_safe_pvclock) |
                              (1U << XENFEAT_hvm_callback_vector) |
-- 
2.55.0


Re: [PATCH v3] xen/x86: restrict XENFEAT_pae_pgdir_above_4gb setting to PV guests
Posted by Jan Beulich 2 weeks, 5 days ago
On 05.10.2026 16:43, Roger Pau Monne wrote:
> XENFEAT_pae_pgdir_above_4gb is only used by 32bit PV guests, hence limit
> its setting in XENVER_get_features to the is_pv_domain() guarded section,
> with the rest of the PV specific features.  Add an additional build time
> guard to short-circuit the setting of XENFEAT_pae_pgdir_above_4gb if the
> hypervisor has no PV 32bit support.
> 
> Signed-off-by: Roger Pau Monné <roger@xenproject.org>

Reviewed-by: Jan Beulich <jbeulich@suse.com>