Module Name: src Committed By: martin Date: Sat Mar 29 10:32:44 UTC 2025
Modified Files: src/sys/arch/amd64/amd64 [netbsd-10]: genassym.cf locore.S machdep.c src/sys/arch/x86/acpi [netbsd-10]: acpi_machdep.c src/sys/arch/x86/include [netbsd-10]: cpu.h src/sys/arch/x86/x86 [netbsd-10]: consinit.c identcpu.c x86_autoconf.c x86_machdep.c src/sys/arch/xen/xen [netbsd-10]: hypervisor.c Log Message: Pull up following revision(s) (requested by imil in ticket #1074): sys/arch/x86/x86/x86_machdep.c: revision 1.155 sys/arch/x86/include/cpu.h: revision 1.137 sys/arch/x86/x86/x86_machdep.c: revision 1.156 sys/arch/x86/include/cpu.h: revision 1.138 sys/arch/x86/x86/consinit.c: revision 1.40 sys/arch/x86/acpi/acpi_machdep.c: revision 1.37 sys/arch/x86/acpi/acpi_machdep.c: revision 1.38 sys/arch/amd64/amd64/machdep.c: revision 1.370 sys/arch/xen/xen/hypervisor.c: revision 1.97 sys/arch/xen/xen/hypervisor.c: revision 1.98 sys/arch/amd64/amd64/genassym.cf: revision 1.98 sys/arch/x86/x86/x86_autoconf.c: revision 1.88 sys/arch/x86/x86/x86_autoconf.c: revision 1.89 sys/arch/amd64/amd64/locore.S: revision 1.226 sys/arch/amd64/amd64/locore.S: revision 1.227 sys/arch/x86/x86/identcpu.c: revision 1.131 Add support for non-Xen PVH guests to amd64. Patch from Emile 'iMil' Heitor in PR kern/57813, with some cosmetic tweaks by me. Tested on bare metal, Xen PV and Xen PVH by me. Get one more change from PR kern/57813, needed for non-Xen PVH. Introduce vm_guest_is_pvh() and use it in place of (vm_guest == VM_GUEST_XENPVH || vm_guest == VM_GUEST_GENPVH) To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.89.4.1 src/sys/arch/amd64/amd64/genassym.cf cvs rdiff -u -r1.214.4.2 -r1.214.4.3 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.366 -r1.366.2.1 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.34.2.1 -r1.34.2.2 src/sys/arch/x86/acpi/acpi_machdep.c cvs rdiff -u -r1.133.4.1 -r1.133.4.2 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.35.4.2 -r1.35.4.3 src/sys/arch/x86/x86/consinit.c cvs rdiff -u -r1.123.4.2 -r1.123.4.3 src/sys/arch/x86/x86/identcpu.c cvs rdiff -u -r1.87 -r1.87.4.1 src/sys/arch/x86/x86/x86_autoconf.c cvs rdiff -u -r1.152.4.1 -r1.152.4.2 src/sys/arch/x86/x86/x86_machdep.c cvs rdiff -u -r1.96 -r1.96.4.1 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/amd64/amd64/genassym.cf diff -u src/sys/arch/amd64/amd64/genassym.cf:1.89 src/sys/arch/amd64/amd64/genassym.cf:1.89.4.1 --- src/sys/arch/amd64/amd64/genassym.cf:1.89 Wed Sep 7 00:40:18 2022 +++ src/sys/arch/amd64/amd64/genassym.cf Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.89 2022/09/07 00:40:18 knakahara Exp $ +# $NetBSD: genassym.cf,v 1.89.4.1 2025/03/29 10:32:43 martin Exp $ # # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -365,6 +365,7 @@ define BST_TYPE offsetof(struct bus_spa define VM_GUEST_XENPV VM_GUEST_XENPV define VM_GUEST_XENPVH VM_GUEST_XENPVH +define VM_GUEST_GENPVH VM_GUEST_GENPVH ifdef XEN define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu) @@ -373,6 +374,12 @@ define SIR_XENIPL_VM SIR_XENIPL_VM define SIR_XENIPL_SCHED SIR_XENIPL_SCHED define SIR_XENIPL_HIGH SIR_XENIPL_HIGH define EVTCHN_UPCALL_MASK offsetof(struct vcpu_info, evtchn_upcall_mask) +define HVM_START_INFO_SIZE sizeof(struct hvm_start_info) +define START_INFO_VERSION offsetof(struct hvm_start_info, version) +define MMAP_PADDR offsetof(struct hvm_start_info, memmap_paddr) +define MMAP_ENTRIES offsetof(struct hvm_start_info, memmap_entries) +define MMAP_ENTRY_SIZE sizeof(struct hvm_memmap_table_entry) +define CMDLINE_PADDR offsetof(struct hvm_start_info, cmdline_paddr) ifdef XENPV define XEN_PT_BASE offsetof(struct start_info, pt_base) define XEN_NR_PT_FRAMES offsetof(struct start_info, nr_pt_frames) Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.214.4.2 src/sys/arch/amd64/amd64/locore.S:1.214.4.3 --- src/sys/arch/amd64/amd64/locore.S:1.214.4.2 Wed Oct 18 15:19:09 2023 +++ src/sys/arch/amd64/amd64/locore.S Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.214.4.2 2023/10/18 15:19:09 martin Exp $ */ +/* $NetBSD: locore.S,v 1.214.4.3 2025/03/29 10:32:43 martin Exp $ */ /* * Copyright-o-rama! @@ -278,11 +278,12 @@ #ifdef XEN #define __ASSEMBLY__ +#include <xen/include/public/arch-x86/cpuid.h> #include <xen/include/public/elfnote.h> #include <xen/include/public/xen.h> #define ELFNOTE(name, type, desctype, descdata...) \ -.pushsection .note.name ; \ +.pushsection .note.name, "a", @note ; \ .align 4 ; \ .long 2f - 1f /* namesz */ ; \ .long 4f - 3f /* descsz */ ; \ @@ -306,7 +307,7 @@ ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad, start) #else ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .quad, 0) - ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .long, RELOC(start_xen32)) + ELFNOTE(Xen, XEN_ELFNOTE_PHYS32_ENTRY, .long, RELOC(start_pvh)) #endif /* XENPV */ ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad, hypercall_page) ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, .quad, HYPERVISOR_VIRT_START) @@ -1021,7 +1022,7 @@ END(start) # if !defined(XENPV) /* entry point for Xen PVH */ .code32 -ENTRY(start_xen32) +ENTRY(start_pvh) /* Xen doesn't start us with a valid gdt */ movl $RELOC(gdtdesc32), %eax lgdt (%eax) @@ -1045,6 +1046,93 @@ ENTRY(start_xen32) stosb /* + * Here, we have 2 cases : + * + * 1) We have been started by Xen + * 2) We have been started by another VMM (Qemu, Firecracker, ...) + * + * The main difference is that, when we are started by Xen, + * %ebx (addr of the hvm_start_info structure) is pointing to a + * location that will be mapped correctly later. + * + * In the second case, we have to copy this structure (and all + * the information contained in it) to a location that will be + * mapped later : __kernel_end + * + * To distinguish between the 2 cases, we'll use the 'cpuid' instruction + */ + + push %ebx + xorl %eax, %eax + cpuid + cmpl $0x1, %eax /* Check if we can call CPUID with eax=1 */ + jb .start_genpvh + xorl %eax, %eax + inc %eax + cpuid + shr $31, %ecx + testb $1, %cl /* Check if bit 31 of ECX (hypervisor) is set */ + jz .start_genpvh + xorl %eax, %eax + inc %eax + shl $30, %eax + cpuid /* Calling cpuid with eax=0x40000000 */ + cmp $XEN_CPUID_SIGNATURE_EBX, %ebx /* "VneX" */ + je .start_xen32 + + /* We have been started by a VMM that is *not* Xen */ + +.start_genpvh: + + /* First, copy the hvm_start_info structure to __kernel_end */ + pop %ebx + movl %ebx, %esi + movl $RELOC(__kernel_end), %edi + movl $HVM_START_INFO_SIZE, %ecx + shrl $2, %ecx + rep movsl + + /* Copy cmdline_paddr after hvm_start_info */ + movl CMDLINE_PADDR(%ebx), %esi + movl $RELOC(__kernel_end), %ecx + movl %edi, CMDLINE_PADDR(%ecx) /* Set new cmdline_paddr in hvm_start_info */ + .cmdline_copy: + movb (%esi), %al + movsb + cmp $0, %al + jne .cmdline_copy + + /* Copy memmap_paddr after cmdline (only if hvm_start_info->version != 0) */ + xorl %eax, %eax + cmpl START_INFO_VERSION(%ebx), %eax + je .reload_ebx + movl MMAP_PADDR(%ebx), %esi + movl $RELOC(__kernel_end), %ecx + movl %edi, MMAP_PADDR(%ecx) /* Set new memmap_paddr in hvm_start_info */ + movl MMAP_ENTRIES(%ebx), %eax /* Get memmap_entries */ + movl $MMAP_ENTRY_SIZE, %ebx + mull %ebx /* eax * ebx => edx:eax */ + movl %eax, %ecx + shrl $2, %ecx + rep movsl + +.reload_ebx: + movl $RELOC(__kernel_end), %ebx + + /* announce ourself */ + movl $VM_GUEST_GENPVH, RELOC(vm_guest) + + jmp .save_hvm_start_paddr + +.start_xen32: + pop %ebx + movl $VM_GUEST_XENPVH, RELOC(vm_guest) + +.save_hvm_start_paddr: + /* + * save addr of the hvm_start_info structure. This is also the end + * of the symbol table + /* * save addr of the hvm_start_info structure. This is also the end * of the symbol table */ @@ -1055,6 +1143,9 @@ ENTRY(start_xen32) movl %eax,(%ebp) movl $KERNBASE_HI,4(%ebp) /* get a page for HYPERVISOR_shared_info */ + /* this is only needed if we are running on Xen */ + cmpl $VM_GUEST_XENPVH, RELOC(vm_guest) + jne .add_hvm_start_info_page addl $PAGE_SIZE, %ebx addl $PGOFSET,%ebx andl $~PGOFSET,%ebx @@ -1062,6 +1153,7 @@ ENTRY(start_xen32) movl %ebx,(%ebp) movl $0,4(%ebp) /* XXX assume hvm_start_info+dependant structure fits in a single page */ +.add_hvm_start_info_page: addl $PAGE_SIZE, %ebx addl $PGOFSET,%ebx andl $~PGOFSET,%ebx @@ -1070,10 +1162,8 @@ ENTRY(start_xen32) movl %ebx,(%ebp) movl $KERNBASE_HI,4(%ebp) - /* announce ourself */ - movl $VM_GUEST_XENPVH, RELOC(vm_guest) jmp .Lbiosbasemem_finished -END(start_xen32) +END(start_pvh) .code64 # endif /* !XENPV */ /* space for the hypercall call page */ Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.366 src/sys/arch/amd64/amd64/machdep.c:1.366.2.1 --- src/sys/arch/amd64/amd64/machdep.c:1.366 Wed Oct 26 23:38:06 2022 +++ src/sys/arch/amd64/amd64/machdep.c Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.366 2022/10/26 23:38:06 riastradh Exp $ */ +/* $NetBSD: machdep.c,v 1.366.2.1 2025/03/29 10:32:43 martin Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -110,7 +110,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.366 2022/10/26 23:38:06 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.366.2.1 2025/03/29 10:32:43 martin Exp $"); #include "opt_modular.h" #include "opt_user_ldt.h" @@ -1525,8 +1525,10 @@ init_x86_64_ksyms(void) } else { uintptr_t endp = (uintptr_t)(void *)&end; - ksyms_addsyms_elf(*(long *)endp, - ((long *)endp) + 1, esym); + if (vm_guest == VM_GUEST_GENPVH) + ksyms_addsyms_elf(0, ((long *)endp) + 1, esym); + else + ksyms_addsyms_elf(*(long *)endp, ((long *)endp) + 1, esym); } #endif } @@ -1710,7 +1712,7 @@ init_x86_64(paddr_t first_avail) #endif #ifdef XEN - if (vm_guest == VM_GUEST_XENPVH) + if (vm_guest == VM_GUEST_XENPVH || vm_guest == VM_GUEST_GENPVH) xen_parse_cmdline(XEN_PARSE_BOOTFLAGS, NULL); #endif init_pte(); Index: src/sys/arch/x86/acpi/acpi_machdep.c diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.34.2.1 src/sys/arch/x86/acpi/acpi_machdep.c:1.34.2.2 --- src/sys/arch/x86/acpi/acpi_machdep.c:1.34.2.1 Wed Oct 18 15:14:24 2023 +++ src/sys/arch/x86/acpi/acpi_machdep.c Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_machdep.c,v 1.34.2.1 2023/10/18 15:14:24 martin Exp $ */ +/* $NetBSD: acpi_machdep.c,v 1.34.2.2 2025/03/29 10:32:43 martin Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.34.2.1 2023/10/18 15:14:24 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.34.2.2 2025/03/29 10:32:43 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -158,7 +158,7 @@ out: } #else #ifdef XEN - if (vm_guest == VM_GUEST_XENPVH) { + if (vm_guest_is_pvh()) { PhysicalAddress = hvm_start_info->rsdp_paddr; if (PhysicalAddress) return PhysicalAddress; Index: src/sys/arch/x86/include/cpu.h diff -u src/sys/arch/x86/include/cpu.h:1.133.4.1 src/sys/arch/x86/include/cpu.h:1.133.4.2 --- src/sys/arch/x86/include/cpu.h:1.133.4.1 Wed Aug 9 17:42:01 2023 +++ src/sys/arch/x86/include/cpu.h Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.133.4.1 2023/08/09 17:42:01 martin Exp $ */ +/* $NetBSD: cpu.h,v 1.133.4.2 2025/03/29 10:32:43 martin Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -514,6 +514,7 @@ typedef enum vm_guest { VM_GUEST_VMWARE, VM_GUEST_KVM, VM_GUEST_VIRTUALBOX, + VM_GUEST_GENPVH, VM_LAST } vm_guest_t; extern vm_guest_t vm_guest; @@ -543,6 +544,18 @@ vm_guest_is_xenpvh_or_pvhvm(void) } } +static __inline bool __unused +vm_guest_is_pvh(void) +{ + switch(vm_guest) { + case VM_GUEST_XENPVH: + case VM_GUEST_GENPVH: + return true; + default: + return false; + } +} + /* cpu_topology.c */ void x86_cpu_topology(struct cpu_info *); Index: src/sys/arch/x86/x86/consinit.c diff -u src/sys/arch/x86/x86/consinit.c:1.35.4.2 src/sys/arch/x86/x86/consinit.c:1.35.4.3 --- src/sys/arch/x86/x86/consinit.c:1.35.4.2 Wed Oct 18 16:53:03 2023 +++ src/sys/arch/x86/x86/consinit.c Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: consinit.c,v 1.35.4.2 2023/10/18 16:53:03 martin Exp $ */ +/* $NetBSD: consinit.c,v 1.35.4.3 2025/03/29 10:32:43 martin Exp $ */ /* * Copyright (c) 1998 @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.35.4.2 2023/10/18 16:53:03 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.35.4.3 2025/03/29 10:32:43 martin Exp $"); #include "opt_kgdb.h" #include "opt_puc.h" @@ -171,6 +171,7 @@ consinit(void) #if (NCOM > 0) int rv; #endif + char console_devname[16] = ""; #ifdef XENPVHVM if (vm_guest == VM_GUEST_XENPVH) { @@ -178,6 +179,13 @@ consinit(void) return; /* fallback to native console selection, usefull for dom0 PVH */ } + if (vm_guest == VM_GUEST_GENPVH) { + union xen_cmdline_parseinfo xcp; + /* get console= parameter from generic PVH VMM */ + xen_parse_cmdline(XEN_PARSE_CONSOLE, &xcp); + strncpy(console_devname, xcp.xcp_console, + sizeof(console_devname)); + } #endif if (initted) return; @@ -188,7 +196,10 @@ consinit(void) if (!consinfo) #endif consinfo = &default_consinfo; - + /* console= parameter was not passed via a generic PVH VMM */ + if (!console_devname[0]) + strncpy(console_devname, consinfo->devname, + sizeof(console_devname)); #if (NGENFB > 0) #if defined(XENPVHVM) && defined(DOM0OPS) if (vm_guest == VM_GUEST_XENPVH && xendomain_is_dom0()) @@ -197,8 +208,7 @@ consinit(void) #endif /* XENPVHVM */ fbinfo = lookup_bootinfo(BTINFO_FRAMEBUFFER); #endif - - if (!strcmp(consinfo->devname, "pc")) { + if (!strcmp(console_devname, "pc")) { int error; #if (NGENFB > 0) if (fbinfo && fbinfo->physaddr > 0) { @@ -254,7 +264,7 @@ dokbd: return; } #if (NCOM > 0) - if (!strcmp(consinfo->devname, "com")) { + if (!strcmp(console_devname, "com")) { int addr = consinfo->addr; int speed = consinfo->speed; @@ -278,14 +288,14 @@ dokbd: } #endif #if (NNULLCONS > 0) - if (!strcmp(consinfo->devname, "nullcons")) { + if (!strcmp(console_devname, "nullcons")) { void nullcninit(struct consdev *cn); nullcninit(0); return; } #endif - panic("invalid console device %s", consinfo->devname); + panic("invalid console device %s", console_devname); } #ifdef KGDB Index: src/sys/arch/x86/x86/identcpu.c diff -u src/sys/arch/x86/x86/identcpu.c:1.123.4.2 src/sys/arch/x86/x86/identcpu.c:1.123.4.3 --- src/sys/arch/x86/x86/identcpu.c:1.123.4.2 Sun Feb 2 14:51:59 2025 +++ src/sys/arch/x86/x86/identcpu.c Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: identcpu.c,v 1.123.4.2 2025/02/02 14:51:59 martin Exp $ */ +/* $NetBSD: identcpu.c,v 1.123.4.3 2025/03/29 10:32:43 martin Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.123.4.2 2025/02/02 14:51:59 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.123.4.3 2025/03/29 10:32:43 martin Exp $"); #include "opt_xen.h" @@ -1086,6 +1086,7 @@ static const struct vm_name_guest vm_bio { "BHYVE", VM_GUEST_VM }, /* bhyve */ { "Seabios", VM_GUEST_VM }, /* KVM */ { "innotek GmbH", VM_GUEST_VIRTUALBOX }, /* Oracle VirtualBox */ + { "Generic PVH", VM_GUEST_GENPVH}, /* Generic PVH */ }; static const struct vm_name_guest vm_system_products[] = { @@ -1107,6 +1108,7 @@ identify_hypervisor(void) switch (vm_guest) { case VM_GUEST_XENPV: case VM_GUEST_XENPVH: + case VM_GUEST_GENPVH: /* guest type already known, no bios info */ return; default: Index: src/sys/arch/x86/x86/x86_autoconf.c diff -u src/sys/arch/x86/x86/x86_autoconf.c:1.87 src/sys/arch/x86/x86/x86_autoconf.c:1.87.4.1 --- src/sys/arch/x86/x86/x86_autoconf.c:1.87 Sat Mar 19 13:51:35 2022 +++ src/sys/arch/x86/x86/x86_autoconf.c Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_autoconf.c,v 1.87 2022/03/19 13:51:35 hannken Exp $ */ +/* $NetBSD: x86_autoconf.c,v 1.87.4.1 2025/03/29 10:32:43 martin Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.87 2022/03/19 13:51:35 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.87.4.1 2025/03/29 10:32:43 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -540,7 +540,7 @@ void cpu_bootconf(void) { #ifdef XEN - if (vm_guest == VM_GUEST_XENPVH) { + if (vm_guest_is_pvh()) { xen_bootconf(); return; } Index: src/sys/arch/x86/x86/x86_machdep.c diff -u src/sys/arch/x86/x86/x86_machdep.c:1.152.4.1 src/sys/arch/x86/x86/x86_machdep.c:1.152.4.2 --- src/sys/arch/x86/x86/x86_machdep.c:1.152.4.1 Sat Dec 24 09:26:56 2022 +++ src/sys/arch/x86/x86/x86_machdep.c Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_machdep.c,v 1.152.4.1 2022/12/24 09:26:56 martin Exp $ */ +/* $NetBSD: x86_machdep.c,v 1.152.4.2 2025/03/29 10:32:43 martin Exp $ */ /*- * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.152.4.1 2022/12/24 09:26:56 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.152.4.2 2025/03/29 10:32:43 martin Exp $"); #include "opt_modular.h" #include "opt_physmem.h" @@ -913,7 +913,7 @@ init_x86_clusters(void) * the boot program). */ #ifdef XEN - if (vm_guest == VM_GUEST_XENPVH) { + if (vm_guest_is_pvh()) { x86_add_xen_clusters(); } #endif /* XEN */ Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.96 src/sys/arch/xen/xen/hypervisor.c:1.96.4.1 --- src/sys/arch/xen/xen/hypervisor.c:1.96 Thu Jun 23 14:32:16 2022 +++ src/sys/arch/xen/xen/hypervisor.c Sat Mar 29 10:32:43 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.96 2022/06/23 14:32:16 bouyer Exp $ */ +/* $NetBSD: hypervisor.c,v 1.96.4.1 2025/03/29 10:32:43 martin Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,7 +53,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.96 2022/06/23 14:32:16 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.96.4.1 2025/03/29 10:32:43 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -241,10 +241,25 @@ void init_xen_early(void) { const char *cmd_line; + if (!vm_guest_is_pvh()) + return; + + hvm_start_info = (void *)((uintptr_t)hvm_start_paddr + KERNBASE); + + if (hvm_start_info->cmdline_paddr != 0) { + cmd_line = + (void *)((uintptr_t)hvm_start_info->cmdline_paddr + KERNBASE); + strlcpy(xen_start_info.cmd_line, cmd_line, + sizeof(xen_start_info.cmd_line)); + } else { + xen_start_info.cmd_line[0] = '\0'; + } + xen_start_info.flags = hvm_start_info->flags; + if (vm_guest != VM_GUEST_XENPVH) return; + xen_init_hypercall_page(); - hvm_start_info = (void *)((uintptr_t)hvm_start_paddr + KERNBASE); HYPERVISOR_shared_info = (void *)((uintptr_t)HYPERVISOR_shared_info_pa + KERNBASE); struct xen_add_to_physmap xmap = { @@ -262,15 +277,6 @@ init_xen_early(void) } delay_func = x86_delay = xen_delay; x86_initclock_func = xen_initclocks; - if (hvm_start_info->cmdline_paddr != 0) { - cmd_line = - (void *)((uintptr_t)hvm_start_info->cmdline_paddr + KERNBASE); - strlcpy(xen_start_info.cmd_line, cmd_line, - sizeof(xen_start_info.cmd_line)); - } else { - xen_start_info.cmd_line[0] = '\0'; - } - xen_start_info.flags = hvm_start_info->flags; }