From owner-dev-commits-src-all@freebsd.org Tue Feb 16 14:27:16 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2BC71539D68; Tue, 16 Feb 2021 14:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dg3Fv5cr8z3wMq; Tue, 16 Feb 2021 14:27:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F36312850; Tue, 16 Feb 2021 14:27:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11GERFmD080029; Tue, 16 Feb 2021 14:27:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11GERFJw080028; Tue, 16 Feb 2021 14:27:15 GMT (envelope-from git) Date: Tue, 16 Feb 2021 14:27:15 GMT Message-Id: <202102161427.11GERFJw080028@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Roger Pau Monné Subject: git: a2495c36678c - main - xen/boot: allow specifying boot method when booted from Xen MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a2495c36678cb16597758ce150da5456cdd90331 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2021 14:27:16 -0000 The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=a2495c36678cb16597758ce150da5456cdd90331 commit a2495c36678cb16597758ce150da5456cdd90331 Author: Roger Pau Monné AuthorDate: 2021-02-08 10:28:36 +0000 Commit: Roger Pau Monné CommitDate: 2021-02-16 14:26:11 +0000 xen/boot: allow specifying boot method when booted from Xen Allow setting the bootmethod variable from the Xen PVH entry point, in order to be able to correctly set the underlying firmware mode when booted as a dom0. Move the bootmethod variable to be defined in x86/cpu_machdep.c instead so it can be shared by both i386 and amd64. Sponsored by: Citrix Systems R&D Reviewed by: kib Differential revision: https://reviews.freebsd.org/D28619 --- sys/amd64/amd64/machdep.c | 4 ---- sys/i386/i386/machdep.c | 7 +++---- sys/x86/include/x86_var.h | 1 + sys/x86/x86/cpu_machdep.c | 4 ++++ sys/x86/xen/pv.c | 8 ++++++++ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index a21a93610e51..569e32207a2c 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1169,10 +1169,6 @@ add_efi_map_entries(struct efi_map_header *efihdr, vm_paddr_t *physmap, } } -static char bootmethod[16] = ""; -SYSCTL_STRING(_machdep, OID_AUTO, bootmethod, CTLFLAG_RD, bootmethod, 0, - "System firmware boot method"); - static void native_parse_memmap(caddr_t kmdp, vm_paddr_t *physmap, int *physmap_idx) { diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index e847d97b8bcf..a9749d331f89 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1237,10 +1237,6 @@ u_long bootdev; /* not a struct cdev *- encoding is different */ SYSCTL_ULONG(_machdep, OID_AUTO, guessed_bootdev, CTLFLAG_RD, &bootdev, 0, "Maybe the Boot device (not in struct cdev *format)"); -static char bootmethod[16] = "BIOS"; -SYSCTL_STRING(_machdep, OID_AUTO, bootmethod, CTLFLAG_RD, bootmethod, 0, - "System firmware boot method"); - /* * Initialize 386 and configure to run kernel */ @@ -2348,6 +2344,9 @@ init386(int first) /* Init basic tunables, hz etc */ init_param1(); + /* Set bootmethod to BIOS: it's the only supported on i386. */ + strlcpy(bootmethod, "BIOS", sizeof(bootmethod)); + /* * Make gdt memory segments. All segments cover the full 4GB * of address space and permissions are enforced at page level. diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index c1425755b5d1..f31dcd47fff5 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -95,6 +95,7 @@ extern int x86_taa_enable; extern int cpu_flush_rsb_ctxsw; extern int x86_rngds_mitg_enable; extern int cpu_amdc1e_bug; +extern char bootmethod[16]; struct pcb; struct thread; diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c index 4798f913d5b2..5bac8eb91eac 100644 --- a/sys/x86/x86/cpu_machdep.c +++ b/sys/x86/x86/cpu_machdep.c @@ -111,6 +111,10 @@ static u_int cpu_reset_proxyid; static volatile u_int cpu_reset_proxy_active; #endif +char bootmethod[16]; +SYSCTL_STRING(_machdep, OID_AUTO, bootmethod, CTLFLAG_RD, bootmethod, 0, + "System firmware boot method"); + struct msr_op_arg { u_int msr; int op; diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c index 2fd698772f9d..a2424423aded 100644 --- a/sys/x86/xen/pv.c +++ b/sys/x86/xen/pv.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -65,6 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -630,6 +632,11 @@ xen_pvh_parse_preload_data(uint64_t modulep) if (envp != NULL) envp += off; xen_pvh_set_env(envp, reject_option); + + if (MD_FETCH(kmdp, MODINFOMD_EFI_MAP, void *) != NULL) + strlcpy(bootmethod, "UEFI", sizeof(bootmethod)); + else + strlcpy(bootmethod, "BIOS", sizeof(bootmethod)); } else { /* Parse the extra boot information given by Xen */ if (start_info->cmdline_paddr != 0) @@ -637,6 +644,7 @@ xen_pvh_parse_preload_data(uint64_t modulep) (char *)(start_info->cmdline_paddr + KERNBASE), ","); kmdp = NULL; + strlcpy(bootmethod, "XEN", sizeof(bootmethod)); } boothowto |= boot_env_to_howto();