Skip to contentSkip to conversation

x86/pv: Provide more helpful error when CONFIG_PV32 is absent

PATCH In review Jane Malalane 2 participants 2 messages Aug 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pv: Provide more helpful error when CONFIG_PV32 is absent

Currently, when booting a 32bit dom0 kernel, the message isn't very helpful:

(XEN) Xen kernel: 64-bit, lsb
(XEN) Dom0 kernel: 32-bit, PAE, lsb, paddr 0x100000 -> 0x112000 (XEN) Mismatch between Xen and DOM0 kernel
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) Could not construct domain 0
(XEN) ****************************************

With this adjustment, it now looks like this:

(XEN) Xen kernel: 64-bit, lsb
(XEN) Found 32-bit PV kernel, but CONFIG_PV32 missing (XEN)
(XEN) **************************************** (XEN) Panic on CPU 0:
(XEN) Could not construct domain 0
(XEN) ****************************************

---
CC: Jan Beulich <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: "Roger Pau Monné" <[email protected]>
CC: Wei Liu <[email protected]>

---
 xen/arch/x86/pv/dom0_build.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
xen/arch/x86/pv/dom0_build.c +6 -2
index af47615b22..80e6c6e35b 100644
@@ -362,9 +362,9 @@ int __init dom0_construct_pv(struct domain *d,
     compatible = false;
     machine = elf_uval(&elf, elf.ehdr, e_machine);
 
-#ifdef CONFIG_PV32
     if ( elf_32bit(&elf) )
     {
+#ifdef CONFIG_PV32
         if ( parms.pae == XEN_PAE_BIMODAL )
             parms.pae = XEN_PAE_EXTCR3;
         if ( parms.pae && machine == EM_386 )
@@ -377,8 +377,12 @@ int __init dom0_construct_pv(struct domain *d,
 
             compatible = true;
         }
-    }
+#else
+        printk("Found 32-bit PV kernel, but CONFIG_PV32 missing\n");
+        rc = -ENODEV;
+        goto out;
 #endif
+    }
 
     compat = is_pv_32bit_domain(d);
 
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 49 lines · Jane Malalane

Currently, when booting a 32bit dom0 kernel, the message isn't very helpful:

(XEN) Xen kernel: 64-bit, lsb
(XEN) Dom0 kernel: 32-bit, PAE, lsb, paddr 0x100000 -> 0x112000 (XEN) Mismatch between Xen and DOM0 kernel
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) Could not construct domain 0
(XEN) ****************************************

With this adjustment, it now looks like this:

(XEN) Xen kernel: 64-bit, lsb
(XEN) Found 32-bit PV kernel, but CONFIG_PV32 missing (XEN)
(XEN) **************************************** (XEN) Panic on CPU 0:
(XEN) Could not construct domain 0
(XEN) ****************************************

---
CC: Jan Beulich <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: "Roger Pau Monné" <[email protected]>
CC: Wei Liu <[email protected]>

---
 xen/arch/x86/pv/dom0_build.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
xen/arch/x86/pv/dom0_build.c +1 -1
index af47615b22..80e6c6e35b 100644
@@ -362,9 +362,9 @@ int __init dom0_construct_pv(struct domain *d,
     compatible = false;
     machine = elf_uval(&elf, elf.ehdr, e_machine);
 
-#ifdef CONFIG_PV32
     if ( elf_32bit(&elf) )
     {
+#ifdef CONFIG_PV32
         if ( parms.pae == XEN_PAE_BIMODAL )
             parms.pae = XEN_PAE_EXTCR3;
         if ( parms.pae && machine == EM_386 )

xen/arch/x86/pv/dom0_build.c int __init dom0_construct_pv(struct domain *d, · line 383

Quoted 8 lines
xen/arch/x86/pv/dom0_build.c +4 -1
@@ -377,8 +377,12 @@ int __init dom0_construct_pv(struct domain *d,
 
             compatible = true;
         }
-    }
+#else
+        printk("Found 32-bit PV kernel, but CONFIG_PV32 missing\n");
+        rc = -ENODEV;
+        goto out;

I don't see the "goto" as warranted here, not the least because the code fragment right above the "#else" you add also uses plain "return". With just "return -ENODEV;" (or maybe better "return -EOPNOTSUPP;")

In fact I think most "goto out;" are unwarranted in this function. The only two places that want elf_check_broken() to be invoked are after elf_xen_parse() and after elf_load_binary(). You'd be welcome to add a 2nd patch to clean this up.

Jan