Module Name:    src
Committed By:   bouyer
Date:           Fri Dec  6 10:53:42 UTC 2024

Modified Files:
        src/sys/arch/x86/acpi: acpi_machdep.c
        src/sys/arch/x86/include: cpu.h
        src/sys/arch/x86/x86: x86_autoconf.c x86_machdep.c
        src/sys/arch/xen/xen: hypervisor.c

Log Message:
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.37 -r1.38 src/sys/arch/x86/acpi/acpi_machdep.c
cvs rdiff -u -r1.137 -r1.138 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/x86/x86/x86_autoconf.c
cvs rdiff -u -r1.155 -r1.156 src/sys/arch/x86/x86/x86_machdep.c
cvs rdiff -u -r1.97 -r1.98 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/x86/acpi/acpi_machdep.c
diff -u src/sys/arch/x86/acpi/acpi_machdep.c:1.37 src/sys/arch/x86/acpi/acpi_machdep.c:1.38
--- src/sys/arch/x86/acpi/acpi_machdep.c:1.37	Mon Dec  2 13:31:32 2024
+++ src/sys/arch/x86/acpi/acpi_machdep.c	Fri Dec  6 10:53:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.37 2024/12/02 13:31:32 bouyer Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.38 2024/12/06 10:53:41 bouyer Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.37 2024/12/02 13:31:32 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.38 2024/12/06 10:53:41 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -158,7 +158,7 @@ out:
 	}
 #else
 #ifdef XEN
-	if (vm_guest == VM_GUEST_XENPVH || vm_guest == VM_GUEST_GENPVH) {
+	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.137 src/sys/arch/x86/include/cpu.h:1.138
--- src/sys/arch/x86/include/cpu.h:1.137	Mon Dec  2 13:31:32 2024
+++ src/sys/arch/x86/include/cpu.h	Fri Dec  6 10:53:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.137 2024/12/02 13:31:32 bouyer Exp $	*/
+/*	$NetBSD: cpu.h,v 1.138 2024/12/06 10:53:41 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -546,6 +546,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/x86_autoconf.c
diff -u src/sys/arch/x86/x86/x86_autoconf.c:1.88 src/sys/arch/x86/x86/x86_autoconf.c:1.89
--- src/sys/arch/x86/x86/x86_autoconf.c:1.88	Mon Dec  2 13:31:33 2024
+++ src/sys/arch/x86/x86/x86_autoconf.c	Fri Dec  6 10:53:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_autoconf.c,v 1.88 2024/12/02 13:31:33 bouyer Exp $	*/
+/*	$NetBSD: x86_autoconf.c,v 1.89 2024/12/06 10:53:41 bouyer 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.88 2024/12/02 13:31:33 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.89 2024/12/06 10:53:41 bouyer 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 || vm_guest == VM_GUEST_GENPVH) {
+	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.155 src/sys/arch/x86/x86/x86_machdep.c:1.156
--- src/sys/arch/x86/x86/x86_machdep.c:1.155	Mon Dec  2 13:31:33 2024
+++ src/sys/arch/x86/x86/x86_machdep.c	Fri Dec  6 10:53:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: x86_machdep.c,v 1.155 2024/12/02 13:31:33 bouyer Exp $	*/
+/*	$NetBSD: x86_machdep.c,v 1.156 2024/12/06 10:53:41 bouyer 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.155 2024/12/02 13:31:33 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.156 2024/12/06 10:53:41 bouyer Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -911,7 +911,7 @@ init_x86_clusters(void)
 	 * the boot program).
 	 */
 #ifdef XEN
-	if (vm_guest == VM_GUEST_XENPVH || vm_guest == VM_GUEST_GENPVH) {
+	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.97 src/sys/arch/xen/xen/hypervisor.c:1.98
--- src/sys/arch/xen/xen/hypervisor.c:1.97	Mon Dec  2 13:31:33 2024
+++ src/sys/arch/xen/xen/hypervisor.c	Fri Dec  6 10:53:42 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.97 2024/12/02 13:31:33 bouyer Exp $ */
+/* $NetBSD: hypervisor.c,v 1.98 2024/12/06 10:53:42 bouyer Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -53,7 +53,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.97 2024/12/02 13:31:33 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.98 2024/12/06 10:53:42 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -241,7 +241,7 @@ void
 init_xen_early(void)
 {
 	const char *cmd_line;
-	if (vm_guest != VM_GUEST_XENPVH && vm_guest != VM_GUEST_GENPVH)
+	if (!vm_guest_is_pvh())
 		return;
 
 	hvm_start_info = (void *)((uintptr_t)hvm_start_paddr + KERNBASE);

Reply via email to