Re: [PATCHv10 10/18] x86/tdx: Convert shared memory back to private on kexec

2024-05-08 Thread Kirill A. Shutemov
On Wed, May 08, 2024 at 02:04:22PM +0200, Borislav Petkov wrote: > On Mon, May 06, 2024 at 06:37:19PM +0300, Kirill A. Shutemov wrote: > > "second kernel" is nomenclature kexec folks are using, but okay. > > And the "third kernel" is the one which got kexec-ed

Re: [PATCHv10 10/18] x86/tdx: Convert shared memory back to private on kexec

2024-05-06 Thread Kirill A. Shutemov
On Sun, May 05, 2024 at 02:13:19PM +0200, Borislav Petkov wrote: > On Tue, Apr 09, 2024 at 02:30:02PM +0300, Kirill A. Shutemov wrote: > > TDX guests allocate shared buffers to perform I/O. It is done by > > allocating pages normally from the buddy allocator and converting the

Re: [PATCHv10.1 09/18] x86/mm: Adding callbacks to prepare encrypted memory for kexec

2024-05-06 Thread Kirill A. Shutemov
down(void) > > #ifdef CONFIG_X86_64 > > x86_platform.iommu_shutdown(); > > #endif > > + > > + if (kexec_in_progress) > > + x86_platform.guest.enc_kexec_unshare_mem(); > > ... but they're split here. > > And I don't know why and nothing tells me... I do. See comment just above enc_kexec_stop_conversion() call. Do you want also comment for enc_kexec_unshare_mem() ? -- Kiryl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv10 05/18] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2024-04-30 Thread Kirill A. Shutemov
On Tue, Apr 30, 2024 at 03:03:23PM +0200, Borislav Petkov wrote: > On Tue, Apr 09, 2024 at 02:29:57PM +0300, Kirill A. Shutemov wrote: > > +1: > > + testq $X86_CR4_MCE, %r13 > > + jz 1f > > + ALTERNATIVE "", __stringify(orl $X86_CR4_MCE, %ea

Re: [PATCHv10 05/18] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2024-04-29 Thread Kirill A. Shutemov
On Mon, Apr 29, 2024 at 04:45:08PM +0200, Borislav Petkov wrote: > On Mon, Apr 29, 2024 at 04:17:38PM +0300, Kirill A. Shutemov wrote: > > As I mentioned above, clearing CR4.MCE triggers #VE. It is quirk of the > > platform. > > You mean when identity_mapped() runs as part

Re: [PATCHv10 06/18] x86/mm: Make x86_platform.guest.enc_status_change_*() return errno

2024-04-29 Thread Kirill A. Shutemov
On Sun, Apr 28, 2024 at 07:25:57PM +0200, Borislav Petkov wrote: > On Tue, Apr 09, 2024 at 02:29:58PM +0300, Kirill A. Shutemov wrote: > > TDX is going to have more than one reason to fail > > enc_status_change_prepare(). > > > > Change the callback to return err

Re: [PATCHv10 05/18] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2024-04-29 Thread Kirill A. Shutemov
On Sun, Apr 28, 2024 at 07:11:11PM +0200, Borislav Petkov wrote: > On Tue, Apr 09, 2024 at 06:26:05PM +0300, Kirill A. Shutemov wrote: > > From 6be428e3b1c6fb494b2c48ba6a7c133514a0b2b4 Mon Sep 17 00:00:00 2001 > > From: "Kirill A. Shutemov" > > Date: Fri, 10 Feb

Re: [PATCHv10 04/18] cpu/hotplug, x86/acpi: Disable CPU offlining for ACPI MADT wakeup

2024-04-24 Thread Kirill A. Shutemov
On Wed, Apr 24, 2024 at 03:50:52PM +0200, Borislav Petkov wrote: > On Wed, Apr 24, 2024 at 11:38:42AM +0300, Kirill A. Shutemov wrote: > > It was wrong from beginning. If ACPI MADT wake up method is used on the > > platform, we cannot handle offline, regardless if it is TDX or n

Re: [PATCHv10 04/18] cpu/hotplug, x86/acpi: Disable CPU offlining for ACPI MADT wakeup

2024-04-24 Thread Kirill A. Shutemov
MADT is the only wakeup method supported in TDX guests. But offline is broken is because of ACPI MADT, not because of TDX. -- Kiryl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv10 03/18] cpu/hotplug: Add support for declaring CPU offlining not supported

2024-04-19 Thread Kirill A. Shutemov
On Thu, Apr 18, 2024 at 04:37:09PM +0200, Borislav Petkov wrote: > On Tue, Apr 09, 2024 at 02:29:55PM +0300, Kirill A. Shutemov wrote: > > +/* Declare CPU offlining not supported */ > > +void cpu_hotplug_disable_offlining(void) > > +{ > > + cpu_maps_update_begin();

Re: [PATCHv10 01/18] x86/acpi: Extract ACPI MADT wakeup code into a separate file

2024-04-19 Thread Kirill A. Shutemov
On Thu, Apr 18, 2024 at 06:03:24PM +0200, Borislav Petkov wrote: > On Tue, Apr 09, 2024 at 02:29:53PM +0300, Kirill A. Shutemov wrote: > > diff --git a/arch/x86/kernel/acpi/Makefile b/arch/x86/kernel/acpi/Makefile > > index fc17b3f136fe..8c7329c88a75 100644 > > --- a/arch/x86

Re: [PATCHv10 05/18] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2024-04-09 Thread Kirill A. Shutemov
On Tue, Apr 09, 2024 at 07:22:24AM -0700, Sean Christopherson wrote: > On Tue, Apr 09, 2024, Kirill A. Shutemov wrote: > > Depending on setup, TDX guests might be allowed to clear CR4.MCE. > > Attempt to clear it leads to #VE. > > > > Use alternatives to keep the flag

Re: [PATCHv9 00/17] x86/tdx: Add kexec support

2024-04-07 Thread Kirill A. Shutemov
yl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv9 05/17] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2024-04-04 Thread Kirill A. Shutemov
On Thu, Apr 04, 2024 at 10:40:34AM +1300, Huang, Kai wrote: > > > On 3/04/2024 4:42 am, Kirill A. Shutemov wrote: > > On Fri, Mar 29, 2024 at 06:48:21PM +0200, Kirill A. Shutemov wrote: > > > On Fri, Mar 29, 2024 at 11:21:32PM +0800, Xiaoyao Li wrote: > > &g

Re: [PATCHv9 05/17] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2024-04-02 Thread Kirill A. Shutemov
On Fri, Mar 29, 2024 at 06:48:21PM +0200, Kirill A. Shutemov wrote: > On Fri, Mar 29, 2024 at 11:21:32PM +0800, Xiaoyao Li wrote: > > On 3/25/2024 6:38 PM, Kirill A. Shutemov wrote: > > > TDX guests are not allowed to clear CR4.MCE. Attempt to clear it leads > > > to #VE

Re: [PATCHv9 05/17] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2024-03-29 Thread Kirill A. Shutemov
On Fri, Mar 29, 2024 at 11:21:32PM +0800, Xiaoyao Li wrote: > On 3/25/2024 6:38 PM, Kirill A. Shutemov wrote: > > TDX guests are not allowed to clear CR4.MCE. Attempt to clear it leads > > to #VE. > > Will we consider making it more safe and compatible for futu

Re: [PATCH v2 2/3] x86/mm: Do not zap page table entries mapping unaccepted memory table during kdump.

2024-03-21 Thread Kirill A. Shutemov
the reserved crashkernel memory. > > Signed-off-by: Ashish Kalra Acked-by: Kirill A. Shutemov I guess it would be better if I take this patch into my kexec patchset. I guess I just got lucky not to step onto the issue. -- Kiryl Shutsemau / Kirill A. Shutemov __

Re: [PATCHv8 00/17, CORRECTED] x86/tdx: Add kexec support

2024-03-06 Thread Kirill A. Shutemov
On Tue, Feb 27, 2024 at 11:24:35PM +0200, Kirill A. Shutemov wrote: > The patchset adds bits and pieces to get kexec (and crashkernel) work on > TDX guest. > > The last patch implements CPU offlining according to the approved ACPI > spec change poposal[1]. It unlocks kexec with a

Re: [PATCHv8 17/17] ACPI: tables: Print MULTIPROC_WAKEUP when MADT is parsed

2024-02-28 Thread Kirill A. Shutemov
On Wed, Feb 28, 2024 at 11:08:38AM +1300, Huang, Kai wrote: > > > On 28/02/2024 10:24 am, Kirill A. Shutemov wrote: > > When MADT is parsed, print MULTIPROC_WAKEUP information: > > > > ACPI: MP Wakeup (version[1], mailbox[0x7fffd000], reset[0x7fffe068]) >

Re: [PATCHv8 00/16] x86/tdx: Add kexec support

2024-02-27 Thread Kirill A. Shutemov
Please disregard. I've sent old patches by mistake. -- Kiryl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv7 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-02-26 Thread Kirill A. Shutemov
On Sun, Feb 25, 2024 at 04:58:46PM +0200, Kirill A. Shutemov wrote: > On Fri, Feb 23, 2024 at 11:39:07AM -0800, Dave Hansen wrote: > > On 2/12/24 02:44, Kirill A. Shutemov wrote: > > > +static void tdx_kexec_stop_conversion(bool crash) > > > +{ > > > + /* S

Re: [PATCHv7 08/16] x86/tdx: Account shared memory

2024-02-25 Thread Kirill A. Shutemov
On Fri, Feb 23, 2024 at 11:08:18AM -0800, Dave Hansen wrote: > On 2/12/24 02:44, Kirill A. Shutemov wrote: > > The kernel will convert all shared memory back to private during kexec. > > The direct mapping page tables will provide information on which memory > > is shared. >

Re: [PATCHv7 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-02-25 Thread Kirill A. Shutemov
On Fri, Feb 23, 2024 at 11:39:07AM -0800, Dave Hansen wrote: > On 2/12/24 02:44, Kirill A. Shutemov wrote: > > +static void tdx_kexec_stop_conversion(bool crash) > > +{ > > + /* Stop new private<->shared conversions */ > > + conversion_allowed = false; >

Re: [PATCHv7 07/16] x86/mm: Return correct level from lookup_address() if pte is none

2024-02-22 Thread Kirill A. Shutemov
On Thu, Feb 22, 2024 at 07:01:41PM +0800, Baoquan He wrote: > On 02/21/24 at 04:15pm, Kirill A. Shutemov wrote: > > On Wed, Feb 21, 2024 at 10:37:29AM +0800, Baoquan He wrote: > > > > diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c > > > >

Re: [PATCH 2/2] x86/snp: Convert shared memory back to private on kexec

2024-02-22 Thread Kirill A. Shutemov
> > + * conversions_in_progress. > > +*/ > > + barrier(); > > This should be smp_wmb(). > Why? -- Kiryl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv7 07/16] x86/mm: Return correct level from lookup_address() if pte is none

2024-02-21 Thread Kirill A. Shutemov
> > * > > - * Note: We return pud and pmd either when the entry is marked large > > - * or when the present bit is not set. Otherwise we would return a > > - * pointer to a nonexisting mapping. > > + * Note: the function returns p4d, pud and pmd either when the entry

Re: [PATCH 1/2] x86/mm: Do not zap PMD entry mapping unaccepted memory table during kdump.

2024-02-20 Thread Kirill A. Shutemov
> + E820_TYPE_ACPI)) > set_pmd_init(pmd, __pmd(0), init); > continue; Why do you single out phys_pmd_init()? I think it has to be addressed for all page table levels as we do for E820_TYPE_RAM and E820_TYPE_RESERVED_KERN. --

Re: [PATCHv7 07/16] x86/mm: Return correct level from lookup_address() if pte is none

2024-02-20 Thread Kirill A. Shutemov
pud and pmd either when the entry is marked + * large or when the present bit is not set. Otherwise it returns NULL. */ pte_t *lookup_address(unsigned long address, unsigned int *level) { -- Kiryl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv7 07/16] x86/mm: Return correct level from lookup_address() if pte is none

2024-02-19 Thread Kirill A. Shutemov
On Mon, Feb 19, 2024 at 01:12:32PM +0800, Baoquan He wrote: > On 02/12/24 at 12:44pm, Kirill A. Shutemov wrote: > > lookup_address() only returns correct page table level for the entry if > > the entry is not none. > > > > Make the helper to always return correct 'lev

Re: [PATCHv7 01/16] x86/acpi: Extract ACPI MADT wakeup code into a separate file

2024-02-19 Thread Kirill A. Shutemov
viewed-by: Baoquan He Thanks! >From 23b7f9856a3d6b91c702def1e03872a60ae07d0e Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Mon, 19 Feb 2024 11:58:19 +0200 Subject: [PATCH] ACPI: tables: Print MULTIPROC_WAKEUP when MADT is parse When MADT is parsed, print MULTIPROC_WAKEU

Re: [PATCHv6 00/16] x86/tdx: Add kexec support

2024-01-30 Thread Kirill A. Shutemov
On Tue, Jan 30, 2024 at 03:59:34PM +0100, Paolo Bonzini wrote: > On Tue, Jan 30, 2024 at 3:34 PM Kirill A. Shutemov > wrote: > > > > On Tue, Jan 30, 2024 at 02:43:15PM +0100, Paolo Bonzini wrote: > > > On 1/24/24 13:55, Kirill A. Shutemov wrote: > > > > T

Re: [PATCHv6 00/16] x86/tdx: Add kexec support

2024-01-30 Thread Kirill A. Shutemov
On Tue, Jan 30, 2024 at 02:43:15PM +0100, Paolo Bonzini wrote: > On 1/24/24 13:55, Kirill A. Shutemov wrote: > > The patchset adds bits and pieces to get kexec (and crashkernel) work on > > TDX guest. > > > > The last patch implements CPU offlining according to the ap

Re: [PATCHv6 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-01-29 Thread Kirill A. Shutemov
On Mon, Jan 29, 2024 at 07:09:37AM -0600, Kalra, Ashish wrote: > Hello Kirill, > > On 1/29/2024 4:36 AM, Kirill A. Shutemov wrote: > > On Mon, Jan 29, 2024 at 04:24:09AM -0600, Kalra, Ashish wrote: > > > In case of SNP and crash/kdump case, we need to prevent th

Re: [PATCHv6 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-01-29 Thread Kirill A. Shutemov
st.enc_kexec_unshare_mem(); + } + crash_save_cpu(regs, safe_smp_processor_id()); } -- Kiryl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv6 16/16] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-01-27 Thread Kirill A. Shutemov
+ > > + if (!timeout) > Nit: IMO, since you are dumping failure error message (not timeout > message), you can use non zero acpi_mp_wake_mailbox->command > check. But it is up to you. I think my version is pretty idiomatic. The same pattern used in other places. For instance,

Re: [PATCHv5 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-01-16 Thread Kirill A. Shutemov
On Tue, Jan 16, 2024 at 10:28:22AM +0300, Kirill A. Shutemov wrote: > > > @@ -809,12 +823,25 @@ static bool tdx_enc_status_changed(unsigned long > > > vaddr, int numpages, bool enc) > > > static int tdx_enc_status_change_prepare(unsigned long

Re: [PATCHv5 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-01-16 Thread Kirill A. Shutemov
On Tue, Jan 16, 2024 at 10:01:47AM +0200, Nikolay Borisov wrote: > > > On 16.01.24 г. 9:28 ч., Kirill A. Shutemov wrote: > > > > > > > @@ -41,6 +44,9 @@ > > > >static atomic_long_t nr_shared; > > > > +static atomic_t conversions_in_pr

Re: [PATCHv5 10/16] x86/tdx: Convert shared memory back to private on kexec

2024-01-15 Thread Kirill A. Shutemov
On Mon, Jan 15, 2024 at 12:53:42PM +0200, Nikolay Borisov wrote: > > > On 23.12.23 г. 1:52 ч., Kirill A. Shutemov wrote: > > TDX guests allocate shared buffers to perform I/O. It is done by > > allocating pages normally from the buddy allocator and converti

Re: [PATCHv5 16/16] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-01-15 Thread Kirill A. Shutemov
On Mon, Jan 15, 2024 at 03:19:43PM +0200, Nikolay Borisov wrote: > > + /* Switch to identity mapping */ > > + movq%rsi, %rax > > + movq%rax, %cr3 > > nit: Can't you move directly to cr3 For some reason, I thought I couldn't. Will fix. -- Kiryl Shutse

Re: [PATCHv4 05/14] x86/kvm: Do not try to disable kvmclock if it was not enabled

2024-01-04 Thread Kirill A. Shutemov
On Wed, Dec 13, 2023 at 09:22:34AM -0800, Sean Christopherson wrote: > On Tue, Dec 12, 2023, Kirill A. Shutemov wrote: > > On Tue, Dec 05, 2023 at 03:45:01AM +0300, Kirill A. Shutemov wrote: > > > kvm_guest_cpu_offline() tries to disable kvmclock regardless if it is >

[PATCHv5.1 14/16] x86/smp: Add smp_ops.stop_this_cpu() callback

2023-12-25 Thread Kirill A. Shutemov
If the helper is defined, it is called instead of halt() to stop the CPU at the end of stop_this_cpu() and on crash CPU shutdown. ACPI MADT will use it to hand over the CPU to BIOS in order to be able to wake it up again after kexec. Signed-off-by: Kirill A. Shutemov --- v5.1: - Fix build

[PATCHv5 14/16] x86/smp: Add smp_ops.stop_this_cpu() callback

2023-12-22 Thread Kirill A. Shutemov
If the helper is defined, it is called instead of halt() to stop the CPU at the end of stop_this_cpu() and on crash CPU shutdown. ACPI MADT will use it to hand over the CPU to BIOS in order to be able to wake it up again after kexec. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm

[PATCHv5 15/16] x86/mm: Introduce kernel_ident_mapping_free()

2023-12-22 Thread Kirill A. Shutemov
() callback hooked up and the pgd_t to free. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/init.h | 3 ++ arch/x86/mm/ident_map.c | 73 + 2 files changed, 76 insertions(+) diff --git a/arch/x86/include/asm/init.h b/arch/x86/include/asm/init.h

[PATCHv5 06/16] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2023-12-22 Thread Kirill A. Shutemov
TDX guests are not allowed to clear CR4.MCE. Attempt to clear it leads to #VE. Use alternatives to keep the flag during kexec for TDX guests. The change doesn't affect non-TDX-guest environments. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang --- arch/x86/kernel/relocate_kernel_64

[PATCHv5 16/16] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2023-12-22 Thread Kirill A. Shutemov
CPU. The change conforms to the approved ACPI spec change proposal. See the Link. Signed-off-by: Kirill A. Shutemov 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

[PATCHv5 12/16] x86/acpi: Rename fields in acpi_madt_multiproc_wakeup structure

2023-12-22 Thread Kirill A. Shutemov
confusion. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang Reviewed-by: Kuppuswamy Sathyanarayanan --- arch/x86/kernel/acpi/madt_wakeup.c | 2 +- include/acpi/actbl2.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c

[PATCHv5 09/16] x86/tdx: Account shared memory

2023-12-22 Thread Kirill A. Shutemov
it. Keep track of the number of shared pages. This will allow for cross-checking against the shared information in the direct mapping and reporting if the shared bit is lost. Include a debugfs interface that allows for the check to be performed at any point. Signed-off-by: Kirill A. Shutemov --- arch

[PATCHv5 10/16] x86/tdx: Convert shared memory back to private on kexec

2023-12-22 Thread Kirill A. Shutemov
with code that may access shared memory. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe --- arch/x86/coco/tdx/tdx.c | 119 +++- arch/x86/include/asm/x86_init.h | 2 + arch/x86/kernel/crash.c | 6 ++ arch/x86/kernel/reboot.c

[PATCHv5 04/16] cpu/hotplug, x86/acpi: Disable CPU offlining for ACPI MADT wakeup

2023-12-22 Thread Kirill A. Shutemov
-off-by: Kirill A. Shutemov Reviewed-by: Thomas Gleixner --- arch/x86/coco/core.c | 1 - arch/x86/kernel/acpi/madt_wakeup.c | 3 +++ include/linux/cc_platform.h| 10 -- kernel/cpu.c | 3 +-- 4 files changed, 4 insertions(+), 13 deletions

[PATCHv5 05/16] x86/kvm: Do not try to disable kvmclock if it was not enabled

2023-12-22 Thread Kirill A. Shutemov
: 0x8110687c (kvmclock_disable+0x1c/0x30) kvmclock enabling is gated by CLOCKSOURCE and CLOCKSOURCE2 KVM paravirt features. Do not disable kvmclock if it was not enabled. Signed-off-by: Kirill A. Shutemov Fixes: c02027b5742b ("x86/kvm: Disable kvmclock on all CPUs on shutdown") Reviewe

[PATCHv5 07/16] x86/mm: Make x86_platform.guest.enc_status_change_*() return errno

2023-12-22 Thread Kirill A. Shutemov
TDX is going to have more than one reason to fail enc_status_change_prepare(). Change the callback to return errno instead of assuming -EIO; enc_status_change_finish() changed too to keep the interface symmetric. Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdx.c | 20

[PATCHv5 01/16] x86/acpi: Extract ACPI MADT wakeup code into a separate file

2023-12-22 Thread Kirill A. Shutemov
In order to prepare for the expansion of support for the ACPI MADT wakeup method, move the relevant code into a separate file. Introduce a new configuration option to clearly indicate dependencies without the use of ifdefs. There have been no functional changes. Signed-off-by: Kirill

[PATCHv5 13/16] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case

2023-12-22 Thread Kirill A. Shutemov
it. This is safe as the booting kernel has the mailbox address cached already and acpi_wakeup_cpu() uses the cached value to bring up the secondary CPUs. Note: This is a Linux specific convention and not covered by the ACPI specification. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai

[PATCHv5 08/16] x86/mm: Return correct level from lookup_address() if pte is none

2023-12-22 Thread Kirill A. Shutemov
by one PGD entry in 5-level paging mode. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe --- arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/pat/set_memory.c | 8 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm

[PATCHv5 00/16] x86/tdx: Add kexec support

2023-12-22 Thread Kirill A. Shutemov
ted()/cpu_hotplug_disable_offlining()/; - use play_dead_common() to implement acpi_mp_play_dead(); - cond_resched() in tdx_shared_memory_show(); - s/target kernel/second kernel/; - Update commit messages and comments; Kirill A. Shutemov (16): x86/acpi: Extract ACPI MADT wakeup code into a separate f

[PATCHv5 03/16] cpu/hotplug: Add support for declaring CPU offlining not supported

2023-12-22 Thread Kirill A. Shutemov
CC_ATTR_HOTPLUG_DISABLED for ACPI MADT wakeup method. Signed-off-by: Kirill A. Shutemov Reviewed-by: Thomas Gleixner --- include/linux/cpu.h | 2 ++ kernel/cpu.c| 13 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index fc8094419084

[PATCHv5 11/16] x86/mm: Make e820_end_ram_pfn() cover E820_TYPE_ACPI ranges

2023-12-22 Thread Kirill A. Shutemov
guest. TDX guest uses E820_TYPE_ACPI to store the unaccepted memory bitmap and pass it between the kernels on kexec. Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/e820.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820

[PATCHv5 02/16] x86/apic: Mark acpi_mp_wake_* variables as __ro_after_init

2023-12-22 Thread Kirill A. Shutemov
acpi_mp_wake_mailbox_paddr and acpi_mp_wake_mailbox initialized once during ACPI MADT init and never changed. Signed-off-by: Kirill A. Shutemov Acked-by: Kai Huang --- arch/x86/kernel/acpi/madt_wakeup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel

Re: [PATCHv4 14/14] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2023-12-22 Thread Kirill A. Shutemov
ve addressed all your feedback, but this gave me pause. Looks like none of kernel_ident_mapping_init() users frees memory on failure. Is it okay to get this part as is and I will follow up with patchset that fixes memory handling for all kernel_ident_mapping_init() users? -- Kiryl Shutsemau

Re: [PATCHv4 05/14] x86/kvm: Do not try to disable kvmclock if it was not enabled

2023-12-11 Thread Kirill A. Shutemov
On Tue, Dec 05, 2023 at 03:45:01AM +0300, Kirill A. Shutemov wrote: > kvm_guest_cpu_offline() tries to disable kvmclock regardless if it is > present in the VM. It leads to write to a MSR that doesn't exist on some > configurations, namely in TDX guest: > > unchecked MSR acce

[PATCHv4 11/14] x86/mm: Make e820_end_ram_pfn() cover E820_TYPE_ACPI ranges

2023-12-04 Thread Kirill A. Shutemov
guest. TDX guest uses E820_TYPE_ACPI to store the unaccepted memory bitmap and pass it between the kernels on kexec. Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/e820.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820

[PATCHv4 03/14] cpu/hotplug: Add support for declaring CPU offlining not supported

2023-12-04 Thread Kirill A. Shutemov
CC_ATTR_HOTPLUG_DISABLED for ACPI MADT wakeup method. Signed-off-by: Kirill A. Shutemov --- include/linux/cpu.h | 2 ++ kernel/cpu.c| 13 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index fc8094419084..46f2e34a0c5e 100644

[PATCHv4 07/14] x86/mm: Make x86_platform.guest.enc_status_change_*() return errno

2023-12-04 Thread Kirill A. Shutemov
TDX is going to have more than one reason to fail enc_status_change_prepare(). Change the callback to return errno instead of assuming -EIO; enc_status_change_finish() changed too to keep the interface symmetric. Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdx.c | 20

[PATCHv4 08/14] x86/mm: Return correct level from lookup_address() if pte is none

2023-12-04 Thread Kirill A. Shutemov
by one PGD entry in 5-level paging mode. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe --- arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/pat/set_memory.c | 8 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm

[PATCHv4 01/14] x86/acpi: Extract ACPI MADT wakeup code into a separate file

2023-12-04 Thread Kirill A. Shutemov
In order to prepare for the expansion of support for the ACPI MADT wakeup method, move the relevant code into a separate file. Introduce a new configuration option to clearly indicate dependencies without the use of ifdefs. There have been no functional changes. Signed-off-by: Kirill

[PATCHv4 14/14] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2023-12-04 Thread Kirill A. Shutemov
-off-by: Kirill A. Shutemov Link: https://lore.kernel.org/all/13356251.uLZWGnKmhe@kreacher --- arch/x86/include/asm/smp.h | 1 + arch/x86/kernel/acpi/Makefile| 2 +- arch/x86/kernel/acpi/madt_playdead.S | 21 ++ arch/x86/kernel/acpi/madt_wakeup.c | 295

[PATCHv4 05/14] x86/kvm: Do not try to disable kvmclock if it was not enabled

2023-12-04 Thread Kirill A. Shutemov
: 0x8110687c (kvmclock_disable+0x1c/0x30) kvmclock enabling is gated by CLOCKSOURCE and CLOCKSOURCE2 KVM paravirt features. Do not disable kvmclock if it was not enabled. Signed-off-by: Kirill A. Shutemov Fixes: c02027b5742b ("x86/kvm: Disable kvmclock on all CPUs on shutdown") Reviewe

[PATCHv4 04/14] cpu/hotplug, x86/acpi: Disable CPU offlining for ACPI MADT wakeup

2023-12-04 Thread Kirill A. Shutemov
-by: Kirill A. Shutemov --- arch/x86/coco/core.c | 1 - arch/x86/kernel/acpi/madt_wakeup.c | 3 +++ include/linux/cc_platform.h| 10 -- kernel/cpu.c | 3 +-- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/arch/x86/coco/core.c b/arch

[PATCHv4 12/14] x86/acpi: Rename fields in acpi_madt_multiproc_wakeup structure

2023-12-04 Thread Kirill A. Shutemov
confusion. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang Reviewed-by: Kuppuswamy Sathyanarayanan --- arch/x86/kernel/acpi/madt_wakeup.c | 2 +- include/acpi/actbl2.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c

[PATCHv4 10/14] x86/tdx: Convert shared memory back to private on kexec

2023-12-04 Thread Kirill A. Shutemov
private mapping is fatal. It leads to unrecoverable TD exit. On kexec walk direct mapping and convert all shared memory back to private. It makes all RAM private again and second kernel may use it normally. Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/kexec.c | 0 arch/x86

[PATCHv4 06/14] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2023-12-04 Thread Kirill A. Shutemov
TDX guests are not allowed to clear CR4.MCE. Attempt to clear it leads to #VE. Use alternatives to keep the flag during kexec for TDX guests. The change doesn't affect non-TDX-guest environments. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang --- arch/x86/kernel/relocate_kernel_64

[PATCHv4 00/14] x86/tdx: Add kexec support

2023-12-04 Thread Kirill A. Shutemov
org/all/13356251.uLZWGnKmhe@kreacher Kirill A. Shutemov (14): x86/acpi: Extract ACPI MADT wakeup code into a separate file x86/apic: Mark acpi_mp_wake_* variables as __ro_after_init cpu/hotplug: Add support for declaring CPU offlining not supported cpu/hotplug, x86/acpi: Disable CPU offlin

[PATCHv4 02/14] x86/apic: Mark acpi_mp_wake_* variables as __ro_after_init

2023-12-04 Thread Kirill A. Shutemov
acpi_mp_wake_mailbox_paddr and acpi_mp_wake_mailbox initialized once during ACPI MADT init and never changed. Signed-off-by: Kirill A. Shutemov Acked-by: Kai Huang --- arch/x86/kernel/acpi/madt_wakeup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel

[PATCHv4 13/14] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case

2023-12-04 Thread Kirill A. Shutemov
kernel with signle CPU is enough to cover the most common case for kexec -- kdump. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang Reviewed-by: Kuppuswamy Sathyanarayanan --- arch/x86/kernel/acpi/madt_wakeup.c | 22 ++ 1 file changed, 22 insertions(+) diff --git

[PATCHv4 09/14] x86/tdx: Account shared memory

2023-12-04 Thread Kirill A. Shutemov
it. Keep track of the number of shared pages. This will allow for cross-checking against the shared information in the direct mapping and reporting if the shared bit is lost. Include a debugfs interface that allows for the check to be performed at any point. Signed-off-by: Kirill A. Shutemov --- arch

Re: [PATCHv3 00/14] x86/tdx: Add kexec support

2023-11-21 Thread Kirill A. Shutemov
cause > cpus are not resettable like kexec reboot does. Not sure if this is seen > in your test. Yes. It is the same reboot limitation I've mentioned before. -- Kiryl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv3 00/14] x86/tdx: Add kexec support

2023-11-21 Thread Kirill A. Shutemov
t.github.com/kiryl/e1dc1719e0c990b3ceee5d8de8dbf332 > > > Thanks a lot for providing the BIOS patch. One more question, is the > patched BIOS image for the host physical machine or for the tdx guest > vm? For the guest. -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCHv3 00/14] x86/tdx: Add kexec support

2023-11-21 Thread Kirill A. Shutemov
d you to tested before, right? If not, failure is expected. > 3) not sure if this is particular case on the system we tested on. -- Kiryl Shutsemau / Kirill A. Shutemov ___ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec

Re: [PATCHv3 00/14] x86/tdx: Add kexec support

2023-11-17 Thread Kirill A. Shutemov
On Thu, Nov 16, 2023 at 10:45:23PM +0800, Baoquan He wrote: > On 11/16/23 at 10:17pm, Baoquan He wrote: > > On 11/16/23 at 03:56pm, Kirill A. Shutemov wrote: > > > On Thu, Nov 16, 2023 at 08:10:47PM +0800, Baoquan He wrote: > > > > On 11/15/23 at 03:

Re: [PATCHv3 00/14] x86/tdx: Add kexec support

2023-11-16 Thread Kirill A. Shutemov
On Thu, Nov 16, 2023 at 08:10:47PM +0800, Baoquan He wrote: > On 11/15/23 at 03:00pm, Kirill A. Shutemov wrote: > > The patchset adds bits and pieces to get kexec (and crashkernel) work on > > TDX guest. > > I finally got a machine of intel-eaglestream-spr as host and built

[PATCHv3 05/14] x86/kvm: Do not try to disable kvmclock if it was not enabled

2023-11-15 Thread Kirill A. Shutemov
: 0x8110687c (kvmclock_disable+0x1c/0x30) kvmclock enabling is gated by CLOCKSOURCE and CLOCKSOURCE2 KVM paravirt features. Do not disable kvmclock if it was not enabled. Signed-off-by: Kirill A. Shutemov Fixes: c02027b5742b ("x86/kvm: Disable kvmclock on all CPUs on shutdown") Reviewe

Re: [PATCHv3 06/14] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2023-11-15 Thread Kirill A. Shutemov
On Wed, Nov 15, 2023 at 01:23:43PM +0100, Peter Zijlstra wrote: > On Wed, Nov 15, 2023 at 03:00:36PM +0300, Kirill A. Shutemov wrote: > > TDX guests are not allowed to clear CR4.MCE. Attempt to clear it leads > > to #VE. > > > > Use alternatives to keep the flag

[PATCHv3 08/14] x86/mm: Return correct level from lookup_address() if pte is none

2023-11-15 Thread Kirill A. Shutemov
by one PGD entry in 5-level paging mode. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe --- arch/x86/include/asm/pgtable_types.h | 1 + arch/x86/mm/pat/set_memory.c | 8 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm

[PATCHv3 10/14] x86/tdx: Convert shared memory back to private on kexec

2023-11-15 Thread Kirill A. Shutemov
private mapping is fatal. It leads to unrecoverable TD exit. On kexec walk direct mapping and convert all shared memory back to private. It makes all RAM private again and second kernel may use it normally. Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/kexec.c | 0 arch/x86

[PATCHv3 14/14] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2023-11-15 Thread Kirill A. Shutemov
-off-by: Kirill A. Shutemov Link: https://lore.kernel.org/all/13356251.uLZWGnKmhe@kreacher --- arch/x86/kernel/acpi/Makefile| 2 +- arch/x86/kernel/acpi/boot.c | 2 + arch/x86/kernel/acpi/madt_playdead.S | 21 ++ arch/x86/kernel/acpi/madt_wakeup.c | 332

[PATCHv3 09/14] x86/tdx: Account shared memory

2023-11-15 Thread Kirill A. Shutemov
it. Keep track of the number of shared pages. This will allow for cross-checking against the shared information in the direct mapping and reporting if the shared bit is lost. Include a debugfs interface that allows for the check to be performed at any point. Signed-off-by: Kirill A. Shutemov --- arch

[PATCHv3 13/14] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case

2023-11-15 Thread Kirill A. Shutemov
kernel with signle CPU is enough to cover the most common case for kexec -- kdump. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang --- arch/x86/kernel/acpi/madt_wakeup.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch

[PATCHv3 12/14] x86/acpi: Rename fields in acpi_madt_multiproc_wakeup structure

2023-11-15 Thread Kirill A. Shutemov
confusion. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang Reviewed-by: Kuppuswamy Sathyanarayanan --- arch/x86/kernel/acpi/madt_wakeup.c | 2 +- include/acpi/actbl2.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c

[PATCHv3 04/14] cpu/hotplug, x86/acpi: Disable CPU offlining for ACPI MADT wakeup

2023-11-15 Thread Kirill A. Shutemov
-by: Kirill A. Shutemov --- arch/x86/coco/core.c | 1 - arch/x86/kernel/acpi/madt_wakeup.c | 3 +++ include/linux/cc_platform.h| 10 -- kernel/cpu.c | 3 +-- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/arch/x86/coco/core.c b/arch

[PATCHv3 11/14] x86/mm: Make e820_end_ram_pfn() cover E820_TYPE_ACPI ranges

2023-11-15 Thread Kirill A. Shutemov
guest. TDX guest uses E820_TYPE_ACPI to store the unaccepted memory bitmap and pass it between the kernels on kexec. Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/e820.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820

[PATCHv3 02/14] x86/apic: Mark acpi_mp_wake_* variables as __ro_after_init

2023-11-15 Thread Kirill A. Shutemov
acpi_mp_wake_mailbox_paddr and acpi_mp_wake_mailbox initialized once during ACPI MADT init and never changed. Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/acpi/madt_wakeup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b

[PATCHv3 03/14] cpu/hotplug: Add support for declaring CPU offlining not supported

2023-11-15 Thread Kirill A. Shutemov
for ACPI MADT. Signed-off-by: Kirill A. Shutemov --- include/linux/cpu.h | 2 ++ kernel/cpu.c| 13 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index fc8094419084..46f2e34a0c5e 100644 --- a/include/linux/cpu.h

[PATCHv3 07/14] x86/mm: Make x86_platform.guest.enc_status_change_*() return errno

2023-11-15 Thread Kirill A. Shutemov
TDX is going to have more than one reason to fail enc_status_change_prepare(). Change the callback to return errno instead of assuming -EIO; enc_status_change_finish() changed too to keep the interface symmetric. Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdx.c | 20

[PATCHv3 01/14] x86/acpi: Extract ACPI MADT wakeup code into a separate file

2023-11-15 Thread Kirill A. Shutemov
In order to prepare for the expansion of support for the ACPI MADT wakeup method, move the relevant code into a separate file. Introduce a new configuration option to clearly indicate dependencies without the use of ifdefs. There have been no functional changes. Signed-off-by: Kirill

[PATCHv3 00/14] x86/tdx: Add kexec support

2023-11-15 Thread Kirill A. Shutemov
ent acpi_mp_play_dead(); - cond_resched() in tdx_shared_memory_show(); - s/target kernel/second kernel/; - Update commit messages and comments; [1] https://lore.kernel.org/all/13356251.uLZWGnKmhe@kreacher Kirill A. Shutemov (14): x86/acpi: Extract ACPI MADT wakeup code into a separate file

[PATCHv3 06/14] x86/kexec: Keep CR4.MCE set during kexec for TDX guest

2023-11-15 Thread Kirill A. Shutemov
TDX guests are not allowed to clear CR4.MCE. Attempt to clear it leads to #VE. Use alternatives to keep the flag during kexec for TDX guests. The change doesn't affect non-TDX-guest environments. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang --- arch/x86/kernel/relocate_kernel_64

Re: [PATCHv2 13/13] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2023-11-01 Thread Kirill A. Shutemov
On Sun, Oct 29, 2023 at 06:31:36PM +0100, Thomas Gleixner wrote: > On Fri, Oct 20 2023 at 18:12, 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

Re: [PATCHv2 02/13] kernel/cpu: Add support for declaring CPU offlining not supported

2023-10-29 Thread Kirill A. Shutemov
On Sat, Oct 28, 2023 at 04:12:10PM +0200, Thomas Gleixner wrote: > On Fri, Oct 20 2023 at 18:12, Kirill A. Shutemov wrote: > > Subject: cpu/hotplug: ... > > > ACPI MADT doesn't allow to offline CPU after it got woke up. > > ACPI MADT is a table ... > > This is

Re: [PATCHv2 11/13] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case

2023-10-27 Thread Kirill A. Shutemov
On Tue, Oct 24, 2023 at 06:59:58AM -0700, Kuppuswamy Sathyanarayanan wrote: > > > On 10/20/2023 8:12 AM, Kirill A. Shutemov wrote: > > ACPI MADT doesn't allow to offline CPU after it got woke up. It limits > > kexec: the second kernel won't be able to use more than

[PATCHv2 00/13] x86/tdx: Add kexec support

2023-10-20 Thread Kirill A. Shutemov
() to implement acpi_mp_play_dead(); - cond_resched() in tdx_shared_memory_show(); - s/target kernel/second kernel/; - Update commit messages and comments; [1] https://lore.kernel.org/all/13356251.uLZWGnKmhe@kreacher Kirill A. Shutemov (13): x86/acpi: Extract ACPI MADT wakeup code into a separate

  1   2   >