Re: [PATCH RFC v2 0/4] mm: Introduce MAP_BELOW_HINT

2024-09-09 Thread Kirill A. Shutemov
On Thu, Sep 05, 2024 at 10:26:52AM -0700, Charlie Jenkins wrote: > On Thu, Sep 05, 2024 at 09:47:47AM +0300, Kirill A. Shutemov wrote: > > On Thu, Aug 29, 2024 at 12:15:57AM -0700, Charlie Jenkins wrote: > > > Some applications rely on placing data in free bits addresses alloc

Re: [PATCH RFC v2 0/4] mm: Introduce MAP_BELOW_HINT

2024-09-09 Thread Kirill A. Shutemov
On Thu, Sep 05, 2024 at 10:26:52AM -0700, Charlie Jenkins wrote: > On Thu, Sep 05, 2024 at 09:47:47AM +0300, Kirill A. Shutemov wrote: > > On Thu, Aug 29, 2024 at 12:15:57AM -0700, Charlie Jenkins wrote: > > > Some applications rely on placing data in free bits addresses alloc

Re: [PATCH RFC v2 0/4] mm: Introduce MAP_BELOW_HINT

2024-09-09 Thread Kirill A. Shutemov
On Thu, Sep 05, 2024 at 10:26:52AM -0700, Charlie Jenkins wrote: > On Thu, Sep 05, 2024 at 09:47:47AM +0300, Kirill A. Shutemov wrote: > > On Thu, Aug 29, 2024 at 12:15:57AM -0700, Charlie Jenkins wrote: > > > Some applications rely on placing data in free bits addresses alloc

Re: [PATCH RFC v2 0/4] mm: Introduce MAP_BELOW_HINT

2024-09-05 Thread Kirill A. Shutemov
e got tested on x86 with 47bit VA. We can consider more options to opt-in into wider address space like personality or prctl() handle. But opt-out is no-go from what I see. -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCH RFC v2 0/4] mm: Introduce MAP_BELOW_HINT

2024-09-04 Thread Kirill A. Shutemov
e got tested on x86 with 47bit VA. We can consider more options to opt-in into wider address space like personality or prctl() handle. But opt-out is no-go from what I see. -- Kiryl Shutsemau / Kirill A. Shutemov ___ linux-snps-arc mailing list linux

Re: [PATCH RFC v2 0/4] mm: Introduce MAP_BELOW_HINT

2024-09-04 Thread Kirill A. Shutemov
e got tested on x86 with 47bit VA. We can consider more options to opt-in into wider address space like personality or prctl() handle. But opt-out is no-go from what I see. -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCHv2 3/4] x86/64/kexec: Map original relocate_kernel() in init_transition_pgtable()

2024-08-15 Thread Kirill A. Shutemov
On Thu, Aug 15, 2024 at 02:15:40PM +0800, Baoquan He wrote: > Cc Eric and kexec mailing list. > > On 08/14/24 at 03:46pm, Kirill A. Shutemov wrote: > > The init_transition_pgtable() function sets up transitional page tables. > > It ensures that the relocate_kernel() funct

Re: [PATCH] virtio: Remove virtio devices on device_shutdown()

2024-08-08 Thread Kirill A. Shutemov
On Thu, Aug 08, 2024 at 11:03:30AM -0400, Michael S. Tsirkin wrote: > On Thu, Aug 08, 2024 at 04:15:25PM +0300, Kirill A. Shutemov wrote: > > On Thu, Aug 08, 2024 at 08:10:34AM -0400, Michael S. Tsirkin wrote: > > > On Thu, Aug 08, 2024 at 10:51:41AM +0300, Kirill A. Shutemov wro

Re: [PATCH] virtio: Remove virtio devices on device_shutdown()

2024-08-08 Thread Kirill A. Shutemov
On Thu, Aug 08, 2024 at 08:10:34AM -0400, Michael S. Tsirkin wrote: > On Thu, Aug 08, 2024 at 10:51:41AM +0300, Kirill A. Shutemov wrote: > > Hongyu reported a hang on kexec in a VM. QEMU reported invalid memory > > accesses during the hang. > > > > Invalid read

Re: [PATCH] virtio: Remove virtio devices on device_shutdown()

2024-08-08 Thread Kirill A. Shutemov
e > >is not in use. > > > >Looks like virtio-console continues to write to the MMIO even after > >underlying virtio-pci device is removed. > > > >The problem can be mitigated by removing all virtio devices on virtio > >bus shutdown. > > > >Sig

[PATCH] virtio: Remove virtio devices on device_shutdown()

2024-08-08 Thread Kirill A. Shutemov
... It was traced down to virtio-console. Kexec works fine if virtio-console is not in use. Looks like virtio-console continues to write to the MMIO even after underlying virtio-pci device is removed. The problem can be mitigated by removing all virtio devices on virtio bus shutdown. Signed-off-by

Re: [PATCH v2 1/2] Add prctl to allow userlevel TDX hypercalls

2024-08-02 Thread Kirill A . Shutemov
ned long __get_wchan(struct task_struct *p) > return addr; > } > > +static int get_coco_user_hcall_mode(void) > +{ > + return !test_bit(MM_CONTEXT_COCO_USER_HCALL, > + ¤t->mm->context.flags); Hm. Why "!"? -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCH 1/2] x86/tdx: Add prctl to allow userlevel TDX hypercalls

2024-07-23 Thread Kirill A . Shutemov
On Mon, Jul 22, 2024 at 10:04:40PM -0700, Tim Merrifield wrote: > > Thanks for the review, Kirill. > > On Mon, Jul 08, 2024 at 03:19:54PM +0300, Kirill A . Shutemov wrote: > > Hm. Per-thread flag is odd. I think it should be per-process. > > This is the only

Re: [PATCH 2/2] x86/vmware: VMware support for TDX userspace hypercalls

2024-07-08 Thread Kirill A . Shutemov
ifdef CONFIG_INTEL_TDX_GUEST > + .runtime.tdx_hcall = vmware_tdx_user_hcall, > +#endif > }; > -- > 2.40.1 > -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCH 1/2] x86/tdx: Add prctl to allow userlevel TDX hypercalls

2024-07-08 Thread Kirill A . Shutemov
long do_arch_prctl_common(int option, unsigned long arg2) > { > switch (option) { > @@ -1052,6 +1067,11 @@ long do_arch_prctl_common(int option, unsigned long > arg2) > case ARCH_GET_XCOMP_GUEST_PERM: > case ARCH_REQ_XCOMP_GUEST_PERM: > return fpu_xstate_prctl(option, arg2); > + case ARCH_GET_COCO_USER_HCALL: > + return get_coco_user_hcall_mode(); > + case ARCH_SET_COCO_USER_HCALL: > + return set_coco_user_hcall_mode(arg2); > + > } > > return -EINVAL; > -- > 2.40.1 > -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCH] x86/tdx: Support vmalloc() for tdx_enc_status_changed()

2024-06-28 Thread Kirill A. Shutemov
us_changed_phys(start_pa, end_pa, enc)) return false; -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCHv11 18/19] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-06-18 Thread Kirill A. Shutemov
On Fri, Jun 14, 2024 at 09:06:30AM -0500, Tom Lendacky wrote: > On 6/13/24 09:56, Borislav Petkov wrote: > > On Thu, Jun 13, 2024 at 04:41:00PM +0300, Kirill A. Shutemov wrote: > > > It is easy enough to do. See the patch below. > > > > Thanks, will have a look. >

[PATCHv12 18/19] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-06-14 Thread Kirill A. Shutemov
single 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 Acked-by: Kai Huang Acked-by: Rafael J. Wysocki Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Thomas

[PATCHv12 19/19] ACPI: tables: Print MULTIPROC_WAKEUP when MADT is parsed

2024-06-14 Thread Kirill A. Shutemov
When MADT is parsed, print MULTIPROC_WAKEUP information: ACPI: MP Wakeup (version[1], mailbox[0x7fffd000], reset[0x7fffe068]) This debug information will be very helpful during bring up. Signed-off-by: Kirill A. Shutemov Acked-by: Kai Huang Acked-by: Rafael J. Wysocki Reviewed-by: Baoquan He

[PATCHv12 17/19] x86/mm: Introduce kernel_ident_mapping_free()

2024-06-14 Thread Kirill A. Shutemov
() callback hooked up and the pgd_t to free. Signed-off-by: Kirill A. Shutemov Acked-by: Kai Huang Tested-by: Tao Liu --- 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

[PATCHv12 16/19] x86/smp: Add smp_ops.stop_this_cpu() callback

2024-06-14 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 Acked-by: Kai Huang

[PATCHv12 15/19] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case

2024-06-14 Thread Kirill A. Shutemov
nel to use 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 Acked-

[PATCHv12 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-06-14 Thread Kirill A. Shutemov
conflicts with code that may access shared memory. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe Reviewed-by: Kai Huang Tested-by: Tao Liu --- arch/x86/coco/tdx/tdx.c | 94 +++ arch/x86/include/asm/pgtable.h| 5 ++ arch/x86/include/asm

[PATCHv12 14/19] x86/acpi: Rename fields in acpi_madt_multiproc_wakeup structure

2024-06-14 Thread Kirill A. Shutemov
s field has not been utilized in the code thus far. Rename 'base_address' to 'mailbox_address' to clarify the kind of address it represents. In version 1, the structure includes the reset vector address. Clear and distinct naming helps to prevent any confusion. Signed-off-by

[PATCHv12 13/19] x86/mm: Do not zap page table entries mapping unaccepted memory table during kdump.

2024-06-14 Thread Kirill A. Shutemov
stored with E820_TYPE_ACPI and passed between the kernels on kdump was getting zapped as the PMD entry mapping this is above the E820_TYPE_RAM range for the reserved crashkernel memory. Signed-off-by: Ashish Kalra Signed-off-by: Kirill A. Shutemov --- arch/x86/mm/init_64.c | 16 1

[PATCHv12 12/19] x86/mm: Make e820__end_ram_pfn() cover E820_TYPE_ACPI ranges

2024-06-14 Thread Kirill A. Shutemov
r TDX 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 Reviewed-by: Dave Hansen Tested-by: Tao Liu --- arch/x86/kernel/e820.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --

[PATCHv12 09/19] x86/tdx: Account shared memory

2024-06-14 Thread Kirill A. Shutemov
. 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. Memory conversion is slow and does not happen often. Global atomic is not going to be a bottleneck. Signed-off-by: Kirill A

[PATCHv12 10/19] x86/mm: Add callbacks to prepare encrypted memory for kexec

2024-06-14 Thread Kirill A. Shutemov
. - enc_kexec_finish() unshares all existing shared memory, reverting it back to private. Signed-off-by: Kirill A. Shutemov Reviewed-by: Nikolay Borisov Reviewed-by: Kai Huang Tested-by: Tao Liu Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/x86_init.h | 10 ++ arch/x86

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

2024-06-14 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 Reviewed-by: Dave Hansen Reviewed-by: Kai Huang

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

2024-06-14 Thread Kirill A. Shutemov
to indicate the size of the VA covered by one PGD entry in 5-level paging mode. Update comments for lookup_address() and lookup_address_in_pgd() to reflect changes in the interface. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe Reviewed-by: Baoquan He Reviewed-by: Dave Hansen T

[PATCHv12 05/19] x86/relocate_kernel: Use named labels for less confusion

2024-06-14 Thread Kirill A. Shutemov
From: Borislav Petkov That identity_mapped() functions was loving that "1" label to the point of completely confusing its readers. Use named labels in each place for clarity. No functional changes. Signed-off-by: Borislav Petkov (AMD) Signed-off-by: Kirill A. Shutemov --- arch/

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

2024-06-14 Thread Kirill A. Shutemov
avoid raising any #VEs. The change doesn't affect non-TDX-guest environments. Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/relocate_kernel_64.S | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/k

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

2024-06-14 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 A

[PATCHv12 02/19] x86/apic: Mark acpi_mp_wake_* variables as __ro_after_init

2024-06-14 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 Acked-by: Rafael J. Wysocki Reviewed-by: Baoquan He Reviewed-by: Thomas Gleixner Tested-by: Tao Liu --- arch/x86/kernel/acpi

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

2024-06-14 Thread Kirill A. Shutemov
e CPU. Disable CPU offlining on ACPI MADT wakeup enumeration. The change has no visible effects for users: currently, TDX guest is the only platform that uses the ACPI MADT wakeup method. Signed-off-by: Kirill A. Shutemov Acked-by: Rafael J. Wysocki Reviewed-by: Thomas Gleixner Tested-by: Ta

[PATCHv12 03/19] cpu/hotplug: Add support for declaring CPU offlining not supported

2024-06-14 Thread Kirill A. Shutemov
place CC_ATTR_HOTPLUG_DISABLED for ACPI MADT wakeup method. Signed-off-by: Kirill A. Shutemov Reviewed-by: Thomas Gleixner Tested-by: Tao Liu --- include/linux/cpuhplock.h | 2 ++ kernel/cpu.c | 13 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/cpuhploc

[PATCHv12 00/19] x86/tdx: Add kexec support

2024-06-14 Thread Kirill A. Shutemov
ries mapping unaccepted memory table during kdump. Borislav Petkov (1): x86/relocate_kernel: Use named labels for less confusion Kirill A. Shutemov (17): x86/acpi: Extract ACPI MADT wakeup code into a separate file x86/apic: Mark acpi_mp_wake_* variables as __ro_after_init cpu/h

Re: [PATCHv11 18/19] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-06-13 Thread Kirill A. Shutemov
PKE|DISABLE_LA57|DISABLE_UMIP| \ -DISABLE_ENQCMD) +#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_UMIP|DISABLE_ENQCMD) #define DISABLED_MASK170 #define DISABLED_MASK18(DISABLE_IBT) #define DISABLED_MASK19(DISABLE_SEV_SNP) -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCHv11 18/19] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-06-12 Thread Kirill A. Shutemov
On Tue, Jun 11, 2024 at 09:46:53PM +0200, Borislav Petkov wrote: > On Tue, Jun 11, 2024 at 06:47:05PM +0300, Kirill A. Shutemov wrote: > > Borislav, given this code deduplication effort is not trivial, maybe we > > can do it as a separate patchset on top of this one? > > Sur

Re: [PATCHv11 05/19] x86/relocate_kernel: Use named labels for less confusion

2024-06-12 Thread Kirill A. Shutemov
On Tue, Jun 11, 2024 at 11:26:17AM -0700, H. Peter Anvin wrote: > On 6/4/24 08:21, Kirill A. Shutemov wrote: > > > > From b45fe48092abad2612c2bafbb199e4de80c99545 Mon Sep 17 00:00:00 2001 > > From: "Kirill A. Shutemov" > > Date: Fri, 10 Feb 2023 12:53:11

Re: [PATCHv11 18/19] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-06-11 Thread Kirill A. Shutemov
On Mon, Jun 10, 2024 at 05:01:55PM +0300, Kirill A. Shutemov wrote: > On Mon, Jun 10, 2024 at 03:40:20PM +0200, Borislav Petkov wrote: > > On Fri, Jun 07, 2024 at 06:14:28PM +0300, Kirill A. Shutemov wrote: > > > I was able to address this issue by switching cpa_lock to a mute

Re: [PATCH] x86/uaccess: Fix missed zeroing of ia32 u64 get_user() range checking

2024-06-11 Thread Kirill A. Shutemov
ation (and rename the jump to using the expected ".L" prefix). Oh. My bad. Reviewed-by: Kirill A. Shutemov -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCHv11 18/19] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-06-10 Thread Kirill A. Shutemov
On Mon, Jun 10, 2024 at 03:40:20PM +0200, Borislav Petkov wrote: > On Fri, Jun 07, 2024 at 06:14:28PM +0300, Kirill A. Shutemov wrote: > > I was able to address this issue by switching cpa_lock to a mutex. > > However, this solution will only work if the callers for set_memory &

Re: [PATCHv11 18/19] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-06-07 Thread Kirill A. Shutemov
nsigned long address, WARN_ONCE(num_online_cpus() > 1, "Don't call after initializing SMP"); retval = __change_page_attr_set_clr(&cpa, 1); + preempt_disable(); __flush_tlb_all(); + preempt_enable(); return retval; } -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCHv11.1 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-06-06 Thread Kirill A. Shutemov
On Wed, Jun 05, 2024 at 06:24:19PM +0200, Borislav Petkov wrote: > On Wed, Jun 05, 2024 at 03:21:42PM +0300, Kirill A. Shutemov wrote: > > If a page can be accessed via private mapping is determined by the > > presence in Secure EPT. This state persist across kexec. > >

Re: [PATCHv11 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-06-05 Thread Kirill A. Shutemov
On Tue, Jun 04, 2024 at 09:27:59AM -0700, Dave Hansen wrote: > On 5/28/24 02:55, Kirill A. Shutemov wrote: > > +/* Stop new private<->shared conversions */ > > +static void tdx_kexec_begin(bool crash) > > +{ > > + /* > > +* Crash kernel reaches here w

Re: [PATCHv11.1 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-06-05 Thread Kirill A. Shutemov
On Tue, Jun 04, 2024 at 08:05:54PM +0200, Borislav Petkov wrote: > On Tue, Jun 04, 2024 at 07:14:00PM +0300, Kirill A. Shutemov wrote: > > /* > > * If tdx_enc_status_changed() fails, it leaves memory > > * in an

Re: [PATCHv11 09/19] x86/tdx: Account shared memory

2024-06-04 Thread Kirill A. Shutemov
On Tue, Jun 04, 2024 at 09:08:25AM -0700, Dave Hansen wrote: > On 5/28/24 02:55, Kirill A. Shutemov wrote: > > 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 t

Re: [PATCHv11.1 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-06-04 Thread Kirill A. Shutemov
On Tue, Jun 04, 2024 at 08:47:22AM -0700, Dave Hansen wrote: > On 6/4/24 08:32, Kirill A. Shutemov wrote: > > What about the comment below? > > > > /* > > * One possible reason for the failure is if kexec raced > >

Re: [PATCHv11.1 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-06-04 Thread Kirill A. Shutemov
On Mon, Jun 03, 2024 at 10:37:54AM +0200, Borislav Petkov wrote: > On Sun, Jun 02, 2024 at 05:23:03PM +0300, Kirill A. Shutemov wrote: > > + /* > > +* The only thing one can do at this point on failure > > +* is panic

Re: [PATCHv11 05/19] x86/relocate_kernel: Use named labels for less confusion

2024-06-04 Thread Kirill A. Shutemov
ove can simply be: > > > > andl $(X86_CR4_PAE | X86_CR4_LA54), %r13 > > movq %r13, %cr4 > > > > %r13 is dead afterwards, and the PAE bit *will* be set in %r13 anyway. > > Yeah, with a proper comment. The testing of bits is not really needed. I think

Re: [PATCH] x86/tdx: Enhance code generation for TDCALL and SEAMCALL wrappers

2024-06-04 Thread Kirill A. Shutemov
On Mon, Jun 03, 2024 at 06:37:45AM -0700, Dave Hansen wrote: > On 6/2/24 04:54, Kirill A. Shutemov wrote: > > Sean observed that the compiler is generating inefficient code to clear > > the tdx_module_args struct for TDCALL and SEAMCALL wrappers. The > > compiler i

[PATCHv11.1 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-06-02 Thread Kirill A. Shutemov
conflicts with code that may access shared memory. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe Reviewed-by: Kai Huang Tested-by: Tao Liu --- arch/x86/coco/tdx/tdx.c | 90 +++ arch/x86/include/asm/pgtable.h| 5 ++ arch/x86/include/asm

Re: [PATCHv11 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-06-02 Thread Kirill A. Shutemov
On Fri, May 31, 2024 at 05:14:42PM +0200, Borislav Petkov wrote: > On Tue, May 28, 2024 at 12:55:14PM +0300, Kirill A. Shutemov wrote: > > +static void tdx_kexec_finish(void) > > +{ > > + unsigned long addr, end; > > + long found = 0, shared; > > + >

[PATCHv11.2 10/19] x86/mm: Add callbacks to prepare encrypted memory for kexec

2024-06-02 Thread Kirill A. Shutemov
. - enc_kexec_finish() unshares all existing shared memory, reverting it back to private. Signed-off-by: Kirill A. Shutemov Reviewed-by: Nikolay Borisov Reviewed-by: Kai Huang Tested-by: Tao Liu Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/x86_init.h | 12 arch

Re: [PATCHv11.1 10/19] x86/mm: Add callbacks to prepare encrypted memory for kexec

2024-06-02 Thread Kirill A. Shutemov
Please disregard this. I failed to fold changes :/ -- Kiryl Shutsemau / Kirill A. Shutemov

[PATCHv11.1 10/19] x86/mm: Add callbacks to prepare encrypted memory for kexec

2024-06-02 Thread Kirill A. Shutemov
. - enc_kexec_finish() unshares all existing shared memory, reverting it back to private. Signed-off-by: Kirill A. Shutemov Reviewed-by: Nikolay Borisov Reviewed-by: Kai Huang Tested-by: Tao Liu --- arch/x86/include/asm/x86_init.h | 9 + arch/x86/kernel/crash.c | 12

[PATCH] x86/tdx: Enhance code generation for TDCALL and SEAMCALL wrappers

2024-06-02 Thread Kirill A. Shutemov
grow/shrink: 3/22 up/down: 17/-313 (-296) GCC tends to generate string instructions more frequently to clear the struct. Signed-off-by: Kirill A. Shutemov Suggested-by: Dave Hansen Cc: Sean Christopherson --- arch/x86/boot/compressed/tdx.c| 32 --- arch/x86/coco/tdx/tdx-shared.c

Re: [PATCHv11 05/19] x86/relocate_kernel: Use named labels for less confusion

2024-05-29 Thread Kirill A. Shutemov
On Wed, May 29, 2024 at 01:47:50PM +0300, Nikolay Borisov wrote: > > > On 28.05.24 г. 12:55 ч., Kirill A. Shutemov wrote: > > From: Borislav Petkov > > > > That identity_mapped() functions was loving that "1" label to the point > > of completely confu

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

2024-05-28 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 Reviewed-by: Dave Hansen Reviewed-by: Kai Huang

[PATCHv11 14/19] x86/acpi: Rename fields in acpi_madt_multiproc_wakeup structure

2024-05-28 Thread Kirill A. Shutemov
s field has not been utilized in the code thus far. Rename 'base_address' to 'mailbox_address' to clarify the kind of address it represents. In version 1, the structure includes the reset vector address. Clear and distinct naming helps to prevent any confusion. Signed-off-by: Ki

[PATCHv11 12/19] x86/mm: Make e820__end_ram_pfn() cover E820_TYPE_ACPI ranges

2024-05-28 Thread Kirill A. Shutemov
r TDX 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 Reviewed-by: Dave Hansen Tested-by: Tao Liu --- arch/x86/kernel/e820.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --

[PATCHv11 17/19] x86/mm: Introduce kernel_ident_mapping_free()

2024-05-28 Thread Kirill A. Shutemov
() callback hooked up and the pgd_t to free. Signed-off-by: Kirill A. Shutemov Acked-by: Kai Huang Tested-by: Tao Liu --- 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

[PATCHv11 10/19] x86/mm: Add callbacks to prepare encrypted memory for kexec

2024-05-28 Thread Kirill A. Shutemov
. - enc_kexec_finish() unshares all existing shared memory, reverting it back to private. Signed-off-by: Kirill A. Shutemov Reviewed-by: Nikolay Borisov Reviewed-by: Kai Huang Tested-by: Tao Liu --- arch/x86/include/asm/x86_init.h | 9 + arch/x86/kernel/crash.c | 12

[PATCHv11 09/19] x86/tdx: Account shared memory

2024-05-28 Thread Kirill A. Shutemov
. 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. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kai Huang Tested-by: Tao Liu --- arch/x86/coco/tdx/tdx.c | 7 +++ 1 file

[PATCHv11 19/19] ACPI: tables: Print MULTIPROC_WAKEUP when MADT is parsed

2024-05-28 Thread Kirill A. Shutemov
When MADT is parsed, print MULTIPROC_WAKEUP information: ACPI: MP Wakeup (version[1], mailbox[0x7fffd000], reset[0x7fffe068]) This debug information will be very helpful during bring up. Signed-off-by: Kirill A. Shutemov Reviewed-by: Baoquan He Reviewed-by: Kuppuswamy Sathyanarayanan Acked

[PATCHv11 18/19] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method

2024-05-28 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 Acked-by: Kai Huang Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Thomas Gleixner Tested-by: Tao Liu

[PATCHv11 16/19] x86/smp: Add smp_ops.stop_this_cpu() callback

2024-05-28 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 Acked-by: Kai Huang

[PATCHv11 15/19] x86/acpi: Do not attempt to bring up secondary CPUs in kexec case

2024-05-28 Thread Kirill A. Shutemov
nel to use 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 Review

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

2024-05-28 Thread Kirill A. Shutemov
e CPU. Disable CPU offlining on ACPI MADT wakeup enumeration. The change has no visible effects for users: currently, TDX guest is the only platform that uses the ACPI MADT wakeup method. Signed-off-by: Kirill A. Shutemov Reviewed-by: Thomas Gleixner Tested-by: Tao Liu --- arch/x86/coco/c

[PATCHv11 02/19] x86/apic: Mark acpi_mp_wake_* variables as __ro_after_init

2024-05-28 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 Reviewed-by: Baoquan He Reviewed-by: Thomas Gleixner Tested-by: Tao Liu --- arch/x86/kernel/acpi/madt_wakeup.c | 4 ++-- 1 file

[PATCHv11 13/19] x86/mm: Do not zap page table entries mapping unaccepted memory table during kdump.

2024-05-28 Thread Kirill A. Shutemov
stored with E820_TYPE_ACPI and passed between the kernels on kdump was getting zapped as the PMD entry mapping this is above the E820_TYPE_RAM range for the reserved crashkernel memory. Signed-off-by: Ashish Kalra Signed-off-by: Kirill A. Shutemov --- arch/x86/mm/init_64.c | 16 1

[PATCHv11 11/19] x86/tdx: Convert shared memory back to private on kexec

2024-05-28 Thread Kirill A. Shutemov
conflicts with code that may access shared memory. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe Reviewed-by: Kai Huang Tested-by: Tao Liu --- arch/x86/coco/tdx/tdx.c | 69 +++ arch/x86/include/asm/pgtable.h| 5 +++ arch/x86/include/asm

[PATCHv11 05/19] x86/relocate_kernel: Use named labels for less confusion

2024-05-28 Thread Kirill A. Shutemov
From: Borislav Petkov That identity_mapped() functions was loving that "1" label to the point of completely confusing its readers. Use named labels in each place for clarity. No functional changes. Signed-off-by: Borislav Petkov (AMD) Signed-off-by: Kirill A. Shutemov --- arch/

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

2024-05-28 Thread Kirill A. Shutemov
to indicate the size of the VA covered by one PGD entry in 5-level paging mode. Update comments for lookup_address() and lookup_address_in_pgd() to reflect changes in the interface. Signed-off-by: Kirill A. Shutemov Reviewed-by: Rick Edgecombe Reviewed-by: Baoquan He Reviewed-by: Dave Hansen T

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

2024-05-28 Thread Kirill A. Shutemov
avoid raising any #VEs. The change doesn't affect non-TDX-guest environments. Signed-off-by: Kirill A. Shutemov --- arch/x86/kernel/relocate_kernel_64.S | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/k

[PATCHv11 03/19] cpu/hotplug: Add support for declaring CPU offlining not supported

2024-05-28 Thread Kirill A. Shutemov
place CC_ATTR_HOTPLUG_DISABLED for ACPI MADT wakeup method. Signed-off-by: Kirill A. Shutemov Reviewed-by: Thomas Gleixner Tested-by: Tao Liu --- 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/

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

2024-05-28 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 A

[PATCHv11 00/19] x86/tdx: Add kexec support

2024-05-28 Thread Kirill A. Shutemov
target kernel/second kernel/; - Update commit messages and comments; Ashish Kalra (1): x86/mm: Do not zap page table entries mapping unaccepted memory table during kdump. Borislav Petkov (1): x86/relocate_kernel: Use named labels for less confusion Kirill A. Shutemov (17): x86/acpi: Extr

Re: [RFC PATCH] clocksource: hyper-v: Enable the tsc_page for a TDX VM in TD mode

2024-05-23 Thread Kirill A. Shutemov
lock_tsc(); when > Hyper-V TSC page is not enabled, hv_read_reference_counter defaults to > be drivers/hv/hv_common.c: __hv_read_ref_counter(), which is suboptimal > as it uses the slow MSR interface to get the time info. Why can't the guest just read the TSC directly? Why do we need the page? I am confused. -- Kiryl Shutsemau / Kirill A. Shutemov

Re: [PATCH 16/20] x86/tdx: Convert VP_INFO tdcall to use new TDCALL_5() macro

2024-05-20 Thread Kirill A. Shutemov
On Fri, May 17, 2024 at 08:57:10AM -0700, Dave Hansen wrote: > On 5/17/24 07:19, Kirill A. Shutemov wrote: > > - /* > > -* TDINFO TDX module call is used to get the TD execution environment > > -* information like GPA width, number of available vcpus, debug mode &

Re: [PATCH 02/20] x86/tdx: Add macros to generate TDVMCALL wrappers

2024-05-20 Thread Kirill A. Shutemov
On Fri, May 17, 2024 at 06:54:15PM +0200, Paolo Bonzini wrote: > On 5/17/24 16:19, Kirill A. Shutemov wrote: > > Introduce a set of macros that allow to generate wrappers for TDVMCALL > > leafs. The macros uses tdvmcall_trmapoline() and provides SYSV-complaint > > ABI on top o

Re: [PATCH 01/20] x86/tdx: Introduce tdvmcall_trampoline()

2024-05-20 Thread Kirill A. Shutemov
On Fri, May 17, 2024 at 07:02:25PM +0200, Paolo Bonzini wrote: > On 5/17/24 16:19, Kirill A. Shutemov wrote: > > The function will be used from inline assembly to handle most TDVMCALL > > cases. > > Perhaps add that the calling convention is designed to allow using the asm &g

Re: [PATCH 01/20] x86/tdx: Introduce tdvmcall_trampoline()

2024-05-20 Thread Kirill A. Shutemov
On Fri, May 17, 2024 at 08:21:37AM -0700, Dave Hansen wrote: > On 5/17/24 07:19, Kirill A. Shutemov wrote: > > TDCALL calls are centralized into a few megawrappers that take the > > struct tdx_module_args as input. Most of the call sites only use a few > > arguments, but

[PATCH 20/20] x86/tdx: Remove old TDCALL wrappers

2024-05-17 Thread Kirill A. Shutemov
All code has been converted to new TDCALL wrappers. Drop the old wrappers. Signed-off-by: Kirill A. Shutemov --- arch/x86/boot/compressed/tdx.c| 6 arch/x86/coco/tdx/tdcall.S| 60 ++- arch/x86/coco/tdx/tdx-shared.c| 20 --- arch/x86

[PATCH 17/20] x86/tdx: Convert VM_RD/VM_WR tdcalls to use new TDCALL macros

2024-05-17 Thread Kirill A. Shutemov
tdx_early_init() is code reduction. Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdx.c | 18 ++ 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index e1849878f3bc..6559f3842f67 100644 --- a/arch/x86/coco/tdx

[PATCH 19/20] x86/tdx: Convert MR_REPORT tdcall to use new TDCALL_0() macro

2024-05-17 Thread Kirill A. Shutemov
Use newly introduced TDCALL_0() instead of tdcall() to issue MR_REPORT tdcall. It cuts code bloat substantially: Function old new delta tdx_mcall_get_report0229 111-118 Signed-off-by: Kirill A. Shutemov --- arch/x86

[PATCH 18/20] x86/tdx: Convert VP_VEINFO_GET tdcall to use new TDCALL_5() macro

2024-05-17 Thread Kirill A. Shutemov
Use newly introduced TDCALL_5() instead of tdcall() to issue VP_VEINFO_GET tdcall. It cuts code bloat substantially: Function old new delta tdx_get_ve_info 253 116-137 Signed-off-by: Kirill A. Shutemov --- arch/x86

[PATCH 16/20] x86/tdx: Convert VP_INFO tdcall to use new TDCALL_5() macro

2024-05-17 Thread Kirill A. Shutemov
Use newly introduced TDCALL_5() instead of tdcall() to issue VP_INFO tdcall. It cuts code bloat slightly: Function old new delta tdx_early_init 780 744 -36 Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx

[PATCH 15/20] x86/tdx: Convert PAGE_ACCEPT tdcall to use new TDCALL_0() macro

2024-05-17 Thread Kirill A. Shutemov
Use newly introduced TDCALL_0() instead of __tdcall() to issue PAGE_ACCEPT tdcall. It cuts code bloat substantially: Function old new delta tdx_accept_memory592 233-359 Signed-off-by: Kirill A. Shutemov --- arch/x86

[PATCH 08/20] x86/tdx: Convert MMIO handling to use new TDVMCALL macros

2024-05-17 Thread Kirill A. Shutemov
Use newly introduced TDVMCALL_0() and TDVMCALL_1() instead of __tdx_hypercall() to handle MMIO emulation. It cuts code bloat substantially: Function old new delta tdx_handle_virt_exception 17471383-364 Signed-off-by: Kirill A

[PATCH 12/20] x86/tdx: Rewrite tdx_kvm_hypercall() without __tdx_hypercall()

2024-05-17 Thread Kirill A. Shutemov
-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdx.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index b7299e668564..e7ffe1cd6d32 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -49,15

[PATCH 11/20] x86/tdx: Rewrite tdx_panic() without __tdx_hypercall()

2024-05-17 Thread Kirill A. Shutemov
hypercall directly in assembly. It cuts code bloat substantially: Function old new delta tdx_panic222 59-163 Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdcall.S | 28

[PATCH 14/20] x86/tdx: Add macros to generate TDCALL wrappers

2024-05-17 Thread Kirill A. Shutemov
Introduce a set of macros that allow to generate wrappers for TDCALL leafs. There are three macros differentiated by number of return parameters. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/shared/tdx.h | 58 +++ 1 file changed, 58 insertions(+) diff

[PATCH 09/20] x86/tdx: Convert MAP_GPA hypercall to use new TDVMCALL macros

2024-05-17 Thread Kirill A. Shutemov
645 530-115 tdx_enc_status_change_prepare326 181-145 Total: Before=5553, After=5183, chg -6.66% Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdx.c | 12 +++- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/x86/coco/tdx

[PATCH 07/20] x86/tdx: Convert CPUID handling to use new TDVMCALL_4()

2024-05-17 Thread Kirill A. Shutemov
Use newly introduced TDVMCALL_4() instead of __tdx_hypercall() to handle CPUID instruction emulation. It cuts code bloat substantially: Function old new delta tdx_handle_virt_exception 18191747 -72 Signed-off-by: Kirill A

[PATCH 13/20] x86/tdx: Rewrite hv_tdx_hypercall() without __tdx_hypercall()

2024-05-17 Thread Kirill A. Shutemov
old new delta hv_tdx_hypercall 171 42-129 Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdcall.S | 30 ++ arch/x86/hyperv/ivm.c | 14 -- 2 files changed, 30 insertions(+), 14

[PATCH 10/20] x86/tdx: Convert GET_QUOTE hypercall to use new TDVMCALL macros

2024-05-17 Thread Kirill A. Shutemov
Use newly introduced TDVMCALL_0() instead of __tdx_hypercall() to issue GET_QUOTE hypercall. It cuts code bloat substantially: Function old new delta tdx_hcall_get_quote 188 76-112 Signed-off-by: Kirill A. Shutemov

[PATCH 05/20] x86/tdx: Convert MSR read handling to use new TDVMCALL_1()

2024-05-17 Thread Kirill A. Shutemov
Use newly introduced TDVMCALL_1() instead of __tdx_hypercall() to handle MSR read emulation. It cuts code bloat substantially: Function old new delta tdx_handle_virt_exception 20521947-105 Signed-off-by: Kirill A. Shutemov

[PATCH 01/20] x86/tdx: Introduce tdvmcall_trampoline()

2024-05-17 Thread Kirill A. Shutemov
: dozens of instructions per call site to clear unused fields of the structure. This issue can be avoided by using more targeted wrappers. tdvmcall_trampoline() provides a common base for them. The function will be used from inline assembly to handle most TDVMCALL cases. Signed-off-by: Kirill A

  1   2   3   4   5   6   7   8   9   10   >