Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nik.borisov@suse.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kuppuswamy Sathyanarayanan
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	Elena Reshetova <elena.reshetova@intel.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	"Kalra, Ashish" <ashish.kalra@amd.com>,
	Sean Christopherson <seanjc@google.com>,
	"Huang, Kai" <kai.huang@intel.com>, Baoquan He <bhe@redhat.com>,
	kexec@lists.infradead.org, linux-coco@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHv5 16/16] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method
Date: Mon, 15 Jan 2024 15:19:43 +0200	[thread overview]
Message-ID: <fa1e3873-6218-461b-85fa-1ff353380532@suse.com> (raw)
In-Reply-To: <20231222235209.32143-17-kirill.shutemov@linux.intel.com>



On 23.12.23 г. 1:52 ч., Kirill A. Shutemov wrote:
> MADT Multiprocessor Wakeup structure version 1 brings support of CPU
> offlining: BIOS provides a reset vector where the CPU has to jump to
> for offlining itself. The new TEST mailbox command can be used to test
> whether the CPU offlined itself which means the BIOS has control over
> the CPU and can online it again via the ACPI MADT wakeup method.
> 
> Add CPU offling support for the ACPI MADT wakeup method by implementing
> custom cpu_die(), play_dead() and stop_this_cpu() SMP operations.
> 
> CPU offlining makes is possible to hand over secondary CPUs over kexec,
> not limiting the second kernel to a single CPU.
> 
> The change conforms to the approved ACPI spec change proposal. See the
> Link.
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Link: https://lore.kernel.org/all/13356251.uLZWGnKmhe@kreacher
> ---
>   arch/x86/include/asm/acpi.h          |   2 +
>   arch/x86/kernel/acpi/Makefile        |   2 +-
>   arch/x86/kernel/acpi/madt_playdead.S |  29 +++++
>   arch/x86/kernel/acpi/madt_wakeup.c   | 184 ++++++++++++++++++++++++++-
>   include/acpi/actbl2.h                |  15 ++-
>   5 files changed, 228 insertions(+), 4 deletions(-)
>   create mode 100644 arch/x86/kernel/acpi/madt_playdead.S
> 
> diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
> index 2625b915ae7f..021cafa214c2 100644
> --- a/arch/x86/include/asm/acpi.h
> +++ b/arch/x86/include/asm/acpi.h
> @@ -81,6 +81,8 @@ union acpi_subtable_headers;
>   int __init acpi_parse_mp_wake(union acpi_subtable_headers *header,
>   			      const unsigned long end);
>   
> +void asm_acpi_mp_play_dead(u64 reset_vector, u64 pgd_pa);
> +
>   /*
>    * Check if the CPU can handle C2 and deeper
>    */
> diff --git a/arch/x86/kernel/acpi/Makefile b/arch/x86/kernel/acpi/Makefile
> index 8c7329c88a75..37b1f28846de 100644
> --- a/arch/x86/kernel/acpi/Makefile
> +++ b/arch/x86/kernel/acpi/Makefile
> @@ -4,7 +4,7 @@ obj-$(CONFIG_ACPI)			+= boot.o
>   obj-$(CONFIG_ACPI_SLEEP)		+= sleep.o wakeup_$(BITS).o
>   obj-$(CONFIG_ACPI_APEI)			+= apei.o
>   obj-$(CONFIG_ACPI_CPPC_LIB)		+= cppc.o
> -obj-$(CONFIG_X86_ACPI_MADT_WAKEUP)	+= madt_wakeup.o
> +obj-$(CONFIG_X86_ACPI_MADT_WAKEUP)	+= madt_wakeup.o madt_playdead.o
>   
>   ifneq ($(CONFIG_ACPI_PROCESSOR),)
>   obj-y					+= cstate.o
> diff --git a/arch/x86/kernel/acpi/madt_playdead.S b/arch/x86/kernel/acpi/madt_playdead.S
> new file mode 100644
> index 000000000000..e48049959513
> --- /dev/null
> +++ b/arch/x86/kernel/acpi/madt_playdead.S
> @@ -0,0 +1,29 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#include <linux/linkage.h>
> +#include <asm/nospec-branch.h>
> +#include <asm/page_types.h>
> +#include <asm/processor-flags.h>
> +
> +	.text
> +	.align PAGE_SIZE
> +
> +/*
> + * asm_acpi_mp_play_dead() - Hand over control of the CPU to the BIOS
> + *
> + * rdi: Address of the ACPI MADT MPWK ResetVector
> + * rsi: PGD of the identity mapping
> + */
> +SYM_FUNC_START(asm_acpi_mp_play_dead)
> +	/* Turn off global entries. Following CR3 write will flush them. */
> +	movq	%cr4, %rdx
> +	andq	$~(X86_CR4_PGE), %rdx
> +	movq	%rdx, %cr4
> +
> +	/* Switch to identity mapping */
> +	movq	%rsi, %rax
> +	movq	%rax, %cr3

nit: Can't you move directly to cr3

> +
> +	/* Jump to reset vector */
> +	ANNOTATE_RETPOLINE_SAFE
> +	jmp	*%rdi
> +SYM_FUNC_END(asm_acpi_mp_play_dead)

<snip>

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2024-01-15 13:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22 23:51 [PATCHv5 00/16] x86/tdx: Add kexec support Kirill A. Shutemov
2023-12-22 23:51 ` [PATCHv5 01/16] x86/acpi: Extract ACPI MADT wakeup code into a separate file Kirill A. Shutemov
2023-12-22 23:51 ` [PATCHv5 02/16] x86/apic: Mark acpi_mp_wake_* variables as __ro_after_init Kirill A. Shutemov
2023-12-22 23:51 ` [PATCHv5 03/16] cpu/hotplug: Add support for declaring CPU offlining not supported Kirill A. Shutemov
2023-12-22 23:51 ` [PATCHv5 04/16] cpu/hotplug, x86/acpi: Disable CPU offlining for ACPI MADT wakeup Kirill A. Shutemov
2023-12-22 23:51 ` [PATCHv5 05/16] x86/kvm: Do not try to disable kvmclock if it was not enabled Kirill A. Shutemov
2023-12-22 23:51 ` [PATCHv5 06/16] x86/kexec: Keep CR4.MCE set during kexec for TDX guest Kirill A. Shutemov
2023-12-22 23:51 ` [PATCHv5 07/16] x86/mm: Make x86_platform.guest.enc_status_change_*() return errno Kirill A. Shutemov
2023-12-22 23:52 ` [PATCHv5 08/16] x86/mm: Return correct level from lookup_address() if pte is none Kirill A. Shutemov
2023-12-22 23:52 ` [PATCHv5 09/16] x86/tdx: Account shared memory Kirill A. Shutemov
2023-12-22 23:52 ` [PATCHv5 10/16] x86/tdx: Convert shared memory back to private on kexec Kirill A. Shutemov
2024-01-05 19:38   ` Edgecombe, Rick P
2024-01-06  0:59     ` kirill.shutemov
2024-01-06  1:12       ` Edgecombe, Rick P
2024-01-15 10:53   ` Nikolay Borisov
2024-01-16  7:28     ` Kirill A. Shutemov
2024-01-16  8:01       ` Nikolay Borisov
2024-01-16 10:45         ` Kirill A. Shutemov
2024-01-16 10:53       ` Kirill A. Shutemov
2023-12-22 23:52 ` [PATCHv5 11/16] x86/mm: Make e820_end_ram_pfn() cover E820_TYPE_ACPI ranges Kirill A. Shutemov
2023-12-22 23:52 ` [PATCHv5 12/16] x86/acpi: Rename fields in acpi_madt_multiproc_wakeup structure Kirill A. Shutemov
2023-12-22 23:52 ` [PATCHv5 13/16] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case Kirill A. Shutemov
2023-12-22 23:52 ` [PATCHv5 14/16] x86/smp: Add smp_ops.stop_this_cpu() callback Kirill A. Shutemov
2023-12-25  8:05   ` [PATCHv5.1 " Kirill A. Shutemov
2024-01-08  3:04     ` Huang, Kai
2024-01-08 10:15       ` kirill.shutemov
2024-01-09  3:04         ` Huang, Kai
2023-12-22 23:52 ` [PATCHv5 15/16] x86/mm: Introduce kernel_ident_mapping_free() Kirill A. Shutemov
2024-01-08  3:13   ` Huang, Kai
2024-01-08  3:30     ` Huang, Kai
2024-01-08 10:17       ` kirill.shutemov
2024-01-08 13:13         ` Huang, Kai
2024-01-08 13:35           ` kirill.shutemov
2023-12-22 23:52 ` [PATCHv5 16/16] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method Kirill A. Shutemov
2024-01-15 13:19   ` Nikolay Borisov [this message]
2024-01-16  6:50     ` Kirill A. Shutemov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa1e3873-6218-461b-85fa-1ff353380532@suse.com \
    --to=nik.borisov@suse.com \
    --cc=adrian.hunter@intel.com \
    --cc=ashish.kalra@amd.com \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=elena.reshetova@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=kai.huang@intel.com \
    --cc=kexec@lists.infradead.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox