From nobody Thu Nov 28 08:31:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1673889721; cv=none; d=zohomail.com; s=zohoarc; b=lcpDetS6xnYg6k3VDH5lSyOwFEJpd7oBqCAIOSCUYFTdNz3s7iEp+HePasiwpn5Ue9Bw6lVBNfjMdR1/TABvOppGJ8scqt6Btal9UOru1uIpQzvYjjVtwuOLbH/pZQV8C9Tb+1790+ceXBDBDpqC4zoxSPHextepQpCDwGzEr+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673889721; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=iqKqXyp79lfgTilPjHf8y0g/gkqc93NUiB/qfTf8nSQ=; b=HtJnOrrOiJfoueE5efjNg2cYI3/8JSaJviP0Dx1iQEN9p1b2VT+KTeF6KXTV+JhGO7PxwwcWBOvy8oScpCYteGXa8VsyvAShWDE5aYTV6v1UxZEJks5DxOQa2gs/LEJCS2U1a7vrDe+kI6hHF5Dw1B3mQ414FVz73L6UC/0FSnA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1673889721207686.5099861273102; Mon, 16 Jan 2023 09:22:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.478906.742411 (Exim 4.92) (envelope-from ) id 1pHTAr-0000qd-K5; Mon, 16 Jan 2023 17:21:33 +0000 Received: by outflank-mailman (output) from mailman id 478906.742411; Mon, 16 Jan 2023 17:21:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pHTAr-0000qW-HC; Mon, 16 Jan 2023 17:21:33 +0000 Received: by outflank-mailman (input) for mailman id 478906; Mon, 16 Jan 2023 17:21:32 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pHTAp-0000bM-RT for xen-devel@lists.xenproject.org; Mon, 16 Jan 2023 17:21:32 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3671308b-95c2-11ed-91b6-6bf2151ebd3b; Mon, 16 Jan 2023 18:21:30 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3671308b-95c2-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1673889690; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1dIIAJGKQFvYG4Z5OuWe803RqRSo1zkhts0L1OnLzO4=; b=Q8SaAoEnA6mYrku5zMearzkQfQViC+NMtuuOB4ZUt0wVutT8vcDo/ouw LcvPxGzKCP7JjcLC/3DFK9XPMsh6baCxKL5z1ufsCuspbURaN1DHFu4Kc dKSuXQRsldRIi/IhqxgtosJm4KFBdQJ/1lMGlwiv2m4xQrhpzRg0WaGab s=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 95317181 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:Ge2N/a6kM7g4IlWUOb0jNgxRtD/HchMFZxGqfqrLsTDasY5as4F+v mMcCmiBaPjYZTGgKNh3aonk90kO6p/dyd5lTldkqn8zHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraBYnoqLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9VU+45wehBtC5gZlPakS4geE/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5m/ OQoNAstMxa5qee53q/rUsJ2v+8oFZy+VG8fkikIITDxCP8nRdbIQrnQ5M8e1zA17ixMNa+AP YxDM2MpNUmeJUQVYT/7C7pn9AusrkHyaXtyqVaOqII84nTJzRw327/oWDbQUo3XHpwKxxbBz o7A12SkKFI5P92N9TmUzW6Ql8vOsgXDZatHQdVU8dY12QbOlwT/EiY+Sl+TsfS/zEmkVLp3O 0ESvyYjs6U23EiqVcXmGQ21pmaeuRwRUMYWFPc1gCmPwKfJ5weSBkAfUyVMLtchsacLqScCj wHT2YmzXHo27ePTECjGnluJkd+sESENHXM5RXICdyUA7Mf+8JkYlCvkRe82RcZZkebJ9SHML yGi9XZh3OhM05JQjs1X7nic3Wvy+8Ghohodo1yOAzn7tl4RiJuNPdTA1LTN0RpXwG91pHGlt WNMpcWR5ftm4XqlxH3UG7Vl8F1ECp+43Nzgbb1HRcNJG8yFoSLLQGyq3BlwJV1yLuEPciLzb UnYtGt5vcEMZyvyMvEsMtjqVazGKJQM8vy8BpjpgidmOMAtJGdrAgkzDaJv44wduBd1yvxuU XtqWc2tEWwbGcxaIMmeHo8gPUsQ7nlmnwv7HMmrpylLJJLCPBa9U6keClKSY4gRteXcyOkj2 4oFZpTiJtQ2eLGWXxQ7BqZIfQFXdCFnVc2twyGVH8baSjdb9KgaI6e56dscl0ZNw8y5Ss+gE qmBZ3Jl IronPort-HdrOrdr: A9a23:+kxhMK5uBIp/bZ8tOgPXwMzXdLJyesId70hD6qkRc3Bom6mj/P xG88516faZslgssRMb+exoSZPgfZq0z/cci+Qs1NyZLWrbUQWTXeVfxLqn7zr8GzDvss5xvJ 0QFJSW0eeAb2SSW/yKhTWFLw== X-IronPort-AV: E=Sophos;i="5.97,221,1669093200"; d="scan'208";a="95317181" From: Per Bilse To: CC: Per Bilse , Jan Beulich , "Andrew Cooper" , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH] Create a Kconfig option to set preferred reboot method Date: Mon, 16 Jan 2023 17:21:02 +0000 Message-ID: <20230116172102.43469-1-per.bilse@citrix.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1673889722786100001 Content-Type: text/plain; charset="utf-8" This patch provides the option to compile in a preferred reboot method, as an alternative to specifying it on the Xen command line. It uses the same internals as the command line 'reboot' parameter, and will be overridden by a choice on the command line. I have referred to this as 'reboot method' rather than 'reboot type' as used in the code. A 'type' suggests something to happen after the reboot, akin to a UNIX run level, whereas 'method' clearly identifies how the reboot will be achieved. I thought it best for this to be clear in an outward facing utility. Signed-off-by: Per Bilse --- xen/arch/x86/Kconfig | 95 +++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/shutdown.c | 11 +++++ 2 files changed, 106 insertions(+) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 6a7825f4ba..d35b14aa17 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -306,6 +306,101 @@ config MEM_SHARING bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED depends on HVM =20 +config REBOOT_SYSTEM_DEFAULT + default y + bool "Xen-defined reboot method" + help + Xen will choose the most appropriate reboot method, + which will be EFI, ACPI, or by way of the keyboard + controller, depending on system features. Disabling + this will allow you to choose exactly how the system + will be rebooted. + +choice + bool "Choose reboot method" + depends on !REBOOT_SYSTEM_DEFAULT + default REBOOT_METHOD_ACPI + help + This is a compiled-in alternative to specifying the + reboot method on the Xen command line. Specifying a + method on the command line will override this choice. + + warm Don't set the cold reboot flag + cold Set the cold reboot flag + none Suppress automatic reboot after panics or crashes + triple Force a triple fault (init) + kbd Use the keyboard controller, cold reset + acpi Use the RESET_REG in the FADT + pci Use the so-called "PCI reset register", CF9 + power Like 'pci' but for a full power-cyle reset + efi Use the EFI reboot (if running under EFI) + xen Use Xen SCHEDOP hypercall (if running under Xen as a guest) + + config REBOOT_METHOD_WARM + bool "warm" + help + Don't set the cold reboot flag. + + config REBOOT_METHOD_COLD + bool "cold" + help + Set the cold reboot flag. + + config REBOOT_METHOD_NONE + bool "none" + help + Suppress automatic reboot after panics or crashes. + + config REBOOT_METHOD_TRIPLE + bool "triple" + help + Force a triple fault (init). + + config REBOOT_METHOD_KBD + bool "kbd" + help + Use the keyboard controller, cold reset. + + config REBOOT_METHOD_ACPI + bool "acpi" + help + Use the RESET_REG in the FADT. + + config REBOOT_METHOD_PCI + bool "pci" + help + Use the so-called "PCI reset register", CF9. + + config REBOOT_METHOD_POWER + bool "power" + help + Like 'pci' but for a full power-cyle reset. + + config REBOOT_METHOD_EFI + bool "efi" + help + Use the EFI reboot (if running under EFI). + + config REBOOT_METHOD_XEN + bool "xen" + help + Use Xen SCHEDOP hypercall (if running under Xen as a guest). + +endchoice + +config REBOOT_METHOD + string + default "w" if REBOOT_METHOD_WARM + default "c" if REBOOT_METHOD_COLD + default "n" if REBOOT_METHOD_NONE + default "t" if REBOOT_METHOD_TRIPLE + default "k" if REBOOT_METHOD_KBD + default "a" if REBOOT_METHOD_ACPI + default "p" if REBOOT_METHOD_PCI + default "P" if REBOOT_METHOD_POWER + default "e" if REBOOT_METHOD_EFI + default "x" if REBOOT_METHOD_XEN + endmenu =20 source "common/Kconfig" diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c index 7619544d14..f44a188e2a 100644 --- a/xen/arch/x86/shutdown.c +++ b/xen/arch/x86/shutdown.c @@ -28,6 +28,7 @@ #include #include =20 +/* NOTE: these constants are duplicated in arch/x86/Kconfig; keep in synch= */ enum reboot_type { BOOT_INVALID, BOOT_TRIPLE =3D 't', @@ -143,6 +144,8 @@ void machine_halt(void) __machine_halt(NULL); } =20 +#ifdef CONFIG_REBOOT_SYSTEM_DEFAULT + static void default_reboot_type(void) { if ( reboot_type !=3D BOOT_INVALID ) @@ -533,6 +536,8 @@ static const struct dmi_system_id __initconstrel reboot= _dmi_table[] =3D { { } }; =20 +#endif /* CONFIG_REBOOT_SYSTEM_DEFAULT */ + static int __init cf_check reboot_init(void) { /* @@ -542,8 +547,12 @@ static int __init cf_check reboot_init(void) if ( reboot_type !=3D BOOT_INVALID ) return 0; =20 +#ifdef CONFIG_REBOOT_SYSTEM_DEFAULT default_reboot_type(); dmi_check_system(reboot_dmi_table); +#else + set_reboot_type(CONFIG_REBOOT_METHOD); +#endif return 0; } __initcall(reboot_init); @@ -595,8 +604,10 @@ void machine_restart(unsigned int delay_millisecs) tboot_shutdown(TB_SHUTDOWN_REBOOT); } =20 +#ifdef CONFIG_REBOOT_SYSTEM_DEFAULT /* Just in case reboot_init() didn't run yet. */ default_reboot_type(); +#endif orig_reboot_type =3D reboot_type; =20 /* Rebooting needs to touch the page at absolute address 0. */ --=20 2.31.1