Skip to contentSkip to conversation

xen/x86: restrict XENFEAT_pae_pgdir_above_4gb setting to PV guests

PATCH Superseded Roger Pau Monne 4 participants 6 messages Sep 30 – Oct 1

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/x86: restrict XENFEAT_pae_pgdir_above_4gb setting to PV guests

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.

No functional change intended.

---
 xen/common/kernel.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/common/kernel.c +3 -3
index f4bbd8818fa8..95cf56827317 100644
@@ -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) |
@@ -692,7 +690,9 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             if ( is_pv_domain(d) )
                 fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
                              (1U << XENFEAT_highmem_assist) |
-                             (1U << XENFEAT_gnttab_map_avail_bits);
+                             (1U << XENFEAT_gnttab_map_avail_bits) |
+                             (VM_ASSIST(d, pae_extended_cr3) ?
+                              (1U << XENFEAT_pae_pgdir_above_4gb) : 0);
             else
                 fi.submap |= (1U << XENFEAT_hvm_safe_pvclock) |
                              (1U << XENFEAT_hvm_callback_vector) |
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw

Le 30/09/2026 à 21:14, Roger Pau Monne a écrit :

Quoted 25 lines

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.

No functional change intended.

---
  xen/common/kernel.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
xen/common/kernel.c +0 -2
index f4bbd8818fa8..95cf56827317 100644
@@ -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) |

xen/common/kernel.c long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 698

Quoted 10 lines
xen/common/kernel.c +3 -1
@@ -692,7 +690,9 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
              if ( is_pv_domain(d) )
                  fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
                               (1U << XENFEAT_highmem_assist) |
-                             (1U << XENFEAT_gnttab_map_avail_bits);
+                             (1U << XENFEAT_gnttab_map_avail_bits) |
+                             (VM_ASSIST(d, pae_extended_cr3) ?
+                              (1U << XENFEAT_pae_pgdir_above_4gb) : 0);
              else
                  fi.submap |= (1U << XENFEAT_hvm_safe_pvclock) |
                               (1U << XENFEAT_hvm_callback_vector) |

Teddy

#2 lore raw
In reply to Roger Pau Monne

xen/common/kernel.c long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 695

Quoted 8 lines · Roger Pau Monne
xen/common/kernel.c +3 -1
@@ -692,7 +690,9 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             if ( is_pv_domain(d) )
                 fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
                              (1U << XENFEAT_highmem_assist) |
-                             (1U << XENFEAT_gnttab_map_avail_bits);
+                             (1U << XENFEAT_gnttab_map_avail_bits) |
+                             (VM_ASSIST(d, pae_extended_cr3) ?
+                              (1U << XENFEAT_pae_pgdir_above_4gb) : 0);

Nit: Unlike binary operators, which we want to have placed at the end of wrapped lines, we generally prefer the ternary operator to be wrapped differently. E.g.

                             (VM_ASSIST(d, pae_extended_cr3)
                              ? (1U << XENFEAT_pae_pgdir_above_4gb) : 0);

or

                             (VM_ASSIST(d, pae_extended_cr3)
                              ? (1U << XENFEAT_pae_pgdir_above_4gb)
                              : 0);

This isn't written down anywhere, so I'm not going to insist.

Furthermore, wouldn't it be plausible to also add IS_ENABLED(CONFIG_PV32) (or, imo less desirably, opt_pv32)?

Jan

#3 lore raw
Quoted 17 lines · Jan Beulich

xen/common/kernel.c long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 695

Quoted 8 lines · Roger Pau Monne
xen/common/kernel.c +3 -1
@@ -692,7 +690,9 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             if ( is_pv_domain(d) )
                 fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
                              (1U << XENFEAT_highmem_assist) |
-                             (1U << XENFEAT_gnttab_map_avail_bits);
+                             (1U << XENFEAT_gnttab_map_avail_bits) |
+                             (VM_ASSIST(d, pae_extended_cr3) ?
+                              (1U << XENFEAT_pae_pgdir_above_4gb) : 0);

Nit: Unlike binary operators, which we want to have placed at the end of wrapped lines, we generally prefer the ternary operator to be wrapped differently. E.g.

                             (VM_ASSIST(d, pae_extended_cr3)
                              ? (1U << XENFEAT_pae_pgdir_above_4gb) : 0);
Quoted 7 lines

or

                             (VM_ASSIST(d, pae_extended_cr3)
                              ? (1U << XENFEAT_pae_pgdir_above_4gb)
                              : 0);

This isn't written down anywhere, so I'm not going to insist.

I had it written as your first proposal, but then moved the ternary operator at the end of the line as I've assumed it would be prefer to match the position of the binary ones.

Quoted 2 lines

Furthermore, wouldn't it be plausible to also add IS_ENABLED(CONFIG_PV32) (or, imo less desirably, opt_pv32)?

I could do:

if ( IS_ENABLED(CONFIG_PV32) && VM_ASSIST(d, pae_extended_cr3) )

    fi.submap |= 1U << XENFEAT_pae_pgdir_above_4gb

As I think adding the IS_ENABLED(CONFIG_PV32) check to the previous expression is too much.

Let me know your preference.

Thanks, Roger.

#4 lore raw
Quoted 32 lines · Roger Pau Monné
Quoted 16 lines · Jan Beulich

Review long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 695

Quoted 8 lines · Roger Pau Monne
(quoted diff) +3 -1
@@ -692,7 +690,9 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             if ( is_pv_domain(d) )
                 fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
                              (1U << XENFEAT_highmem_assist) |
-                             (1U << XENFEAT_gnttab_map_avail_bits);
+                             (1U << XENFEAT_gnttab_map_avail_bits) |
+                             (VM_ASSIST(d, pae_extended_cr3) ?
+                              (1U << XENFEAT_pae_pgdir_above_4gb) : 0);

Nit: Unlike binary operators, which we want to have placed at the end of wrapped lines, we generally prefer the ternary operator to be wrapped differently. E.g.

                             (VM_ASSIST(d, pae_extended_cr3)
                              ? (1U << XENFEAT_pae_pgdir_above_4gb) : 0);
Quoted 7 lines

or

                             (VM_ASSIST(d, pae_extended_cr3)
                              ? (1U << XENFEAT_pae_pgdir_above_4gb)
                              : 0);

This isn't written down anywhere, so I'm not going to insist.

I had it written as your first proposal, but then moved the ternary operator at the end of the line as I've assumed it would be prefer to match the position of the binary ones.

Quoted 2 lines

Furthermore, wouldn't it be plausible to also add IS_ENABLED(CONFIG_PV32) (or, imo less desirably, opt_pv32)?

I could do:

Quoted 7 lines

if ( IS_ENABLED(CONFIG_PV32) && VM_ASSIST(d, pae_extended_cr3) )

    fi.submap |= 1U << XENFEAT_pae_pgdir_above_4gb

As I think adding the IS_ENABLED(CONFIG_PV32) check to the previous expression is too much.

Let me know your preference.

xen/common/kernel.c +0 -0
index f4bbd8818fa8..6811599f95fd 100644
@@ -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 ( 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) |

Please don't try to be clever trying to fold this logic.   All that does is require someone to revert it later when it inevitably gets too complicated follow sensibly.

~Andrew

#5 lore raw
In reply to Roger Pau Monné
Quoted 35 lines · Roger Pau Monné
Quoted 17 lines · Jan Beulich

xen/common/kernel.c long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) · line 695

Quoted 8 lines · Roger Pau Monne
xen/common/kernel.c +3 -1
@@ -692,7 +690,9 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             if ( is_pv_domain(d) )
                 fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) |
                              (1U << XENFEAT_highmem_assist) |
-                             (1U << XENFEAT_gnttab_map_avail_bits);
+                             (1U << XENFEAT_gnttab_map_avail_bits) |
+                             (VM_ASSIST(d, pae_extended_cr3) ?
+                              (1U << XENFEAT_pae_pgdir_above_4gb) : 0);

Nit: Unlike binary operators, which we want to have placed at the end of wrapped lines, we generally prefer the ternary operator to be wrapped differently. E.g.

                             (VM_ASSIST(d, pae_extended_cr3)
                              ? (1U << XENFEAT_pae_pgdir_above_4gb) : 0);
Quoted 7 lines

or

                             (VM_ASSIST(d, pae_extended_cr3)
                              ? (1U << XENFEAT_pae_pgdir_above_4gb)
                              : 0);

This isn't written down anywhere, so I'm not going to insist.

I had it written as your first proposal, but then moved the ternary operator at the end of the line as I've assumed it would be prefer to match the position of the binary ones.

Quoted 2 lines

Furthermore, wouldn't it be plausible to also add IS_ENABLED(CONFIG_PV32) (or, imo less desirably, opt_pv32)?

I could do:

Quoted 7 lines

if ( IS_ENABLED(CONFIG_PV32) && VM_ASSIST(d, pae_extended_cr3) )

    fi.submap |= 1U << XENFEAT_pae_pgdir_above_4gb

As I think adding the IS_ENABLED(CONFIG_PV32) check to the previous expression is too much.

Let me know your preference.

I'm okay with the if() variant, but as you know I'm also not afraid of long-ish ternary expressions.

Jan