From: Jan Beulich Date: Mon, 24 Aug 2020 13:38:48 +0000 (+0200) Subject: x86/PV: also check kernel endianness when building Dom0 X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~1748 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=347384331ee0eee22a4dc10f805847e658e523ac;p=xen.git x86/PV: also check kernel endianness when building Dom0 While big endian x86 images are pretty unlikely to appear, merely logging endianness isn't of much use. Reported-by: Andrew Cooper Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 171519e285..d79503d6a9 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -288,7 +288,8 @@ int __init dom0_construct_pv(struct domain *d, module_t *initrd, char *cmdline) { - int i, rc, compatible, order, machine; + int i, rc, order, machine; + bool compatible; struct cpu_user_regs *regs; unsigned long pfn, mfn; unsigned long nr_pages; @@ -358,7 +359,7 @@ int __init dom0_construct_pv(struct domain *d, /* compatibility check */ printk(" Xen kernel: 64-bit, lsb%s\n", IS_ENABLED(CONFIG_PV32) ? ", compat32" : ""); - compatible = 0; + compatible = false; machine = elf_uval(&elf, elf.ehdr, e_machine); #ifdef CONFIG_PV32 @@ -374,13 +375,16 @@ int __init dom0_construct_pv(struct domain *d, return rc; } - compatible = 1; + compatible = true; } } #endif if ( elf_64bit(&elf) && machine == EM_X86_64 ) - compatible = 1; + compatible = true; + + if ( elf_msb(&elf) ) + compatible = false; printk(" Dom0 kernel: %s-bit%s, %s, paddr %#" PRIx64 " -> %#" PRIx64 "\n", elf_64bit(&elf) ? "64" : elf_32bit(&elf) ? "32" : "??",