[PATCH v3 1/1] x86: Rename __{start,end}_init_task to __{start,end}_init_stack

2024-03-22 Thread Xin Li (Intel)
architectures are not affected because __{start,end}_init_task are used on x86 only. Reviewed-by: Juergen Gross Signed-off-by: Xin Li (Intel) --- Change since v2: * Rebase to the latest tip master branch. Change since v1: * Revert an accident insane change, init_task to init_stack (Jürgen Groß

Re: [PATCH v2 1/1] x86: Rename __{start,end}_init_task to __{start,end}_init_stack

2024-03-21 Thread Xin Li
On 3/21/2024 12:54 PM, Ingo Molnar wrote: * Xin Li (Intel) wrote: The stack of a task has been separated from the memory of a task_struct struture for a long time on x86, as a result __{start,end}_init_task no longer mark the start and end of the init_task structure, but its stack only

[PATCH v2 1/1] x86: Rename __{start,end}_init_task to __{start,end}_init_stack

2024-03-18 Thread Xin Li (Intel)
architectures are not affected because __{start,end}_init_task are used on x86 only. Signed-off-by: Xin Li (Intel) --- Change since v1: * Revert an accident insane change, init_task to init_stack (Jürgen Groß). --- arch/x86/include/asm/processor.h | 4 ++-- arch/x86/kernel/head_64.S | 2

Re: [PATCH v1 1/1] x86: Rename __{start,end}_init_task to __{start,end}_init_stack

2024-03-13 Thread Xin Li
On 3/13/2024 12:09 AM, Jürgen Groß wrote: On 13.03.24 07:05, Xin Li (Intel) wrote: The stack of a task has been separated from the memory of a task_struct struture for a long time on x86, as a result __{start,end}_init_task no longer mark the start and end of the init_task structure, but its

[PATCH v1 1/1] x86: Rename __{start,end}_init_task to __{start,end}_init_stack

2024-03-13 Thread Xin Li (Intel)
architectures are not affected because __{start,end}_init_task are used on x86 only. Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/processor.h | 4 ++-- arch/x86/kernel/head_64.S | 2 +- arch/x86/xen/xen-head.S | 2 +- include/asm-generic/vmlinux.lds.h | 8 4

Re: [PATCH v2 1/1] x86/fred: Fix init_task thread stack pointer initialization

2024-03-06 Thread Xin Li
On 3/4/2024 12:33 AM, Xin Li (Intel) wrote: As TOP_OF_KERNEL_STACK_PADDING is defined as 0 on x86_64, no one noticed it's missing in the calculation of the .sp field in INIT_THREAD until it is defined to 16 with CONFIG_X86_FRED=y. Subtract TOP_OF_KERNEL_STACK_PADDING from the .sp field

[PATCH v2 1/1] x86/fred: Fix init_task thread stack pointer initialization

2024-03-04 Thread Xin Li (Intel)
/fred: Reserve space for the FRED stack frame") Fixes: 3adee777ad0d ("x86/smpboot: Remove initial_stack on 64-bit") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202402262159.183c2a37-...@intel.com Signed-off-by: Xin Li (Intel) --- Change Sinc

[PATCH v13A 24/35] x86/fred: Add a NMI entry stub for FRED

2023-12-15 Thread Xin Li
uite small... Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v13: * Save and restore %cr2 upon entering and leaving the FRED NMI handler (H. Peter Anvin). * Remove an unnecessary check "IS_ENABLED(CONFIG_SMP)" (H. Peter Anvin). * Syn

[PATCH v13A 26/35] x86/fred: FRED entry/exit and dispatch code

2023-12-09 Thread Xin Li
patch code for FRED. The first-level dispatch is on the event type, and the second-level is on the event vector. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Suggested-by: Thomas Gleixner Tested-by: Shan Kang Co-developed-by: Xin Li Signed-off-by: Xin Li --- Changes

[PATCH v13 34/35] x86/fred: Add FRED initialization functions

2023-12-05 Thread Xin Li
rce 32-bit system calls to use "int $0x80" only. Add fred_complete_exception_setup() to: - Initialize system_vectors as done for IDT systems. - Set unused sysvec_table entries to fred_handle_spurious_interrupt(). Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Co-develope

[PATCH v13 22/35] x86/idtentry: Incorporate definitions/declarations of the FRED entries

2023-12-05 Thread Xin Li
irqentry/exit() in the dispatcher instead of having it in each handler. Also add stub defines for vectors which are not used due to Kconfig decisions to spare the ifdeffery in the actual FRED dispatch code. Suggested-by: Thomas Gleixner Tested-by: Shan Kang Signed-off-by: Xin Li --- Change since v9

[PATCH v13 16/35] x86/fred: Reserve space for the FRED stack frame

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" When using FRED, reserve space at the top of the stack frame, just like i386 does. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/thread_info.h | 12 +--- 1 file changed, 9 insert

[PATCH v13 14/35] x86/ptrace: Add FRED additional information to the pt_regs structure

2023-12-05 Thread Xin Li
and easier to read. Originally-by: H. Peter Anvin (Intel) Suggested-by: Thomas Gleixner Tested-by: Shan Kang Signed-off-by: Xin Li --- Change since v11: * Add a new structure fred_cs to denote the FRED flags above CS selector as what is done for SS (H. Peter Anvin). Changes since v9: * Introduce

[PATCH v13 25/35] x86/fred: Add a machine check entry stub for FRED

2023-12-05 Thread Xin Li
stack, i.e., current task stack; ring 0 event on the #MCE dedicated stack specified in the IA32_FRED_STKLVLS MSR. So unlike IDT, the FRED machine check entry stub doesn't do stack switch. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v5: * Disallow #DB inside #MCE for robustness

[PATCH v13 31/35] x86/entry: Add fred_entry_from_kvm() for VMX to handle IRQ/NMI

2023-12-05 Thread Xin Li
-by: Sean Christopherson Suggested-by: Thomas Gleixner Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v10: * Better explain the reason why no need to check current stack level (Paolo Bonzini). Changes since v9: * Shove the whole thing into arch/x86/entry/entry_64_fred.S

[PATCH v13 20/35] x86/fred: Allow single-step trap and NMI when starting a new task

2023-12-05 Thread Xin Li
vin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v8: * Use high-order 48 bits above the lowest 16 bit SS only when FRED is enabled (Thomas Gleixner). --- arch/x86/kernel/process_64.c | 38 ++-- 1 file changed, 32 insertions(+), 6 deletions(-)

[PATCH v13 28/35] x86/fred: Let ret_from_fork_asm() jmp to asm_fred_exit_user when FRED is enabled

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" Let ret_from_fork_asm() jmp to asm_fred_exit_user when FRED is enabled, otherwise the existing IDT code is chosen. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/entry/entry_64.S | 6 ++ arch

[PATCH v13 15/35] x86/fred: Add a new header file for FRED definitions

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add a header file for FRED prototypes and definitions. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v6: * Replace pt_regs csx flags prefix FRED_CSL_ with FRED_CSX_. --- arch/x86/include/asm/f

[PATCH v13 26/35] x86/fred: FRED entry/exit and dispatch code

2023-12-05 Thread Xin Li
patch code for FRED. The first-level dispatch is on the event type, and the second-level is on the event vector. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Suggested-by: Thomas Gleixner Tested-by: Shan Kang Co-developed-by: Xin Li Signed-off-by: Xin Li --- Changes

[PATCH v13 18/35] x86/fred: Disallow the swapgs instruction when FRED is enabled

2023-12-05 Thread Xin Li
se address into the IA32_KERNEL_GS_BASE MSR instead of the GS segment's descriptor cache. As such, the operating system never changes its runtime GS base address. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Change since v12: * Use the ASCII char ' (char number 0x27

[PATCH v13 32/35] KVM: VMX: Call fred_entry_from_kvm() for IRQ/NMI handling

2023-12-05 Thread Xin Li
When FRED is enabled, call fred_entry_from_kvm() to handle IRQ/NMI in IRQ/NMI induced VM exits. Tested-by: Shan Kang Signed-off-by: Xin Li Acked-by: Paolo Bonzini --- arch/x86/kvm/vmx/vmx.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c

[PATCH v13 10/35] x86/objtool: Teach objtool about ERET[US]

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" Update the objtool decoder to know about the ERET[US] instructions (type INSN_CONTEXT_SWITCH). Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- tools/objtool/arch/x86/decode.c | 19 ++- 1 file c

[PATCH v13 33/35] x86/syscall: Split IDT syscall setup code into idt_syscall_init()

2023-12-05 Thread Xin Li
syscall setup code when FRED is enabled. Suggested-by: Thomas Gleixner Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/cpu/common.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index

[PATCH v13 23/35] x86/fred: Add a debug fault entry stub for FRED

2023-12-05 Thread Xin Li
rmat which debug_read_clear_dr6() returns for the IDT entry points. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v9: * Disable #DB to avoid endless recursion and stack overflow when a watchpoint/breakpoint is set in the code path which is execute

[PATCH v13 12/35] x86/cpu: Add MSR numbers for FRED configuration

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add MSR numbers for the FRED configuration registers per FRED spec 5.0. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/msr-index.h | 13 - tool

[PATCH v13 19/35] x86/fred: No ESPFIX needed when FRED is enabled

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" Because FRED always restores the full value of %rsp, ESPFIX is no longer needed when it's enabled. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/espfix_64.c | 8 1 file changed, 8

[PATCH v13 11/35] x86/cpu: Add X86_CR4_FRED macro

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add X86_CR4_FRED macro for the FRED bit in %cr4. This bit must not be changed after initialization, so add it to the pinned CR4 bits. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v9: * Avoid a

[PATCH v13 27/35] x86/traps: Add sysvec_install() to install a system interrupt handler

2023-12-05 Thread Xin Li
Add sysvec_install() to install a system interrupt handler into the IDT or the FRED system interrupt handler table. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v8: * Introduce a macro sysvec_install() to derive the asm handler name from a C handler, which simplifies the code

[PATCH v13 30/35] x86/entry/calling: Allow PUSH_AND_CLEAR_REGS being used beyond actual entry code

2023-12-05 Thread Xin Li
From: "Peter Zijlstra (Intel)" PUSH_AND_CLEAR_REGS could be used besides actual entry code; in that case %rbp shouldn't be cleared (otherwise the frame pointer is destroyed) and UNWIND_HINT shouldn't be added. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Shan Kang Signed-off-

[PATCH v13 24/35] x86/fred: Add a NMI entry stub for FRED

2023-12-05 Thread Xin Li
uite small... Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/nmi.c | 28 1 file changed, 28 insertions(+) diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 17e955ab69fe..56350d839e44 100644 --- a/arch/

[PATCH v13 08/35] x86/fred: Disable FRED by default in its early stage

2023-12-05 Thread Xin Li
To enable FRED, a new kernel command line option "fred" needs to be added. Tested-by: Shan Kang Signed-off-by: Xin Li --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/x86/kernel/cpu/common.c| 3 +++ 2 files changed, 6 insertions(+)

[PATCH v13 03/35] x86/trapnr: Add event type macros to

2023-12-05 Thread Xin Li
-by: Shan Kang Signed-off-by: Xin Li --- Changes since v10: * A few comment fixes and improvements (Andrew Cooper). --- arch/x86/include/asm/trapnr.h | 12 arch/x86/include/asm/vmx.h| 17 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/x86

[PATCH v13 06/35] x86/cpufeatures: Add the CPU feature bit for FRED

2023-12-05 Thread Xin Li
zing WRMSR for faster MSR writes. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Change since v12: * s/cpu/CPU/g (Borislav Petkov). --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 2 ++ tools/arch/x86/i

[PATCH v13 13/35] x86/ptrace: Cleanup the definition of the pt_regs structure

2023-12-05 Thread Xin Li
Signed-off-by: Xin Li --- Change since v12: * Put comments ontop, not on the side (Borislav Petkov). --- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- arch/x86/include/asm/ptrace.h | 48 +++ arch/x86/kernel/process_64.c | 2 +- 3 files changed, 37

[PATCH v13 17/35] x86/fred: Update MSR_IA32_FRED_RSP0 during task switch

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" MSR_IA32_FRED_RSP0 is used during ring 3 event delivery, and needs to be updated to point to the top of next task stack during task switch. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/s

[PATCH v13 35/35] x86/fred: Invoke FRED initialization code to enable FRED

2023-12-05 Thread Xin Li
ed-by: Xin Li Signed-off-by: Xin Li --- Changes since v10: * No need to invalidate SYSCALL and SYSENTER MSRs (Thomas Gleixner). Changes since v8: * Move this patch after all required changes are in place (Thomas Gleixner). --- arch/x86/kernel/cpu/common.c | 22 +- arch/

[PATCH v13 01/35] x86/cpufeatures,opcode,msr: Add the WRMSRNS instruction support

2023-12-05 Thread Xin Li
API __wrmsrns() to embed WRMSRNS into the code. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v12: * Merge the 3 WRMSRNS patches into one (Borislav Petkov). * s/cpu/CPU/g (Borislav Petkov). * Shorten the WRMSRNS description (Borislav Petkov). --- arch/x86/include/asm/cpufeatures.h

[PATCH v13 29/35] x86/fred: Fixup fault on ERETU by jumping to fred_entrypoint_user

2023-12-05 Thread Xin Li
ept the fault, fix up the exception frame, and redirect execution to fred_entrypoint_user. The end result is that it appears just as if the hardware had taken the exception immediately after completing the transition to user space. Suggested-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by:

[PATCH v13 09/35] x86/opcode: Add ERET[US] instructions to the x86 opcode map

2023-12-05 Thread Xin Li
-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Xin Li --- arch/x86/lib/x86-opcode-map.txt | 2 +- tools/arch/x86/lib/x86-opcode-map.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/lib/x86-opcode-map.

[PATCH v13 05/35] x86/fred: Add Kconfig option for FRED (CONFIG_X86_FRED)

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add the configuration option CONFIG_X86_FRED to enable FRED. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/Kconfig | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x

[PATCH v13 21/35] x86/fred: Make exc_page_fault() work for FRED

2023-12-05 Thread Xin Li
d-by: Shan Kang Signed-off-by: Xin Li --- Change since v12: * No "we" in a commit message, use passive voice (Borislav Petkov). --- arch/x86/mm/fault.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index ab778eac1952.

[PATCH v13 04/35] Documentation/x86/64: Add a documentation for FRED

2023-12-05 Thread Xin Li
Briefly introduce FRED, and its advantages compared to IDT. Reviewed-by: Bagas Sanjaya Signed-off-by: Xin Li --- Changes since v10: * Reword a sentence to improve readability (Nikolay Borisov). --- Documentation/arch/x86/x86_64/fred.rst | 96 + Documentation/arch/x86

[PATCH v13 00/35] x86: enable FRED for x86-64

2023-12-05 Thread Xin Li
ns x86/fred: Invoke FRED initialization code to enable FRED Peter Zijlstra (Intel) (1): x86/entry/calling: Allow PUSH_AND_CLEAR_REGS being used beyond actual entry code Xin Li (14): x86/cpufeatures,opcode,msr: Add the WRMSRNS instruction support x86/entry: Remove idtentry_sysvec from entr

[PATCH v13 07/35] x86/fred: Disable FRED support if CONFIG_X86_FRED is disabled

2023-12-05 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add CONFIG_X86_FRED to to make cpu_feature_enabled() work correctly with FRED. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v10: * FRED feature is defined in cpuid word

[PATCH v13 02/35] x86/entry: Remove idtentry_sysvec from entry_{32,64}.S

2023-12-05 Thread Xin Li
idtentry_sysvec is really just DECLARE_IDTENTRY defined in , no need to define it separately. Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/entry/entry_32.S | 4 arch/x86/entry/entry_64.S | 8 arch/x86/include/asm/idtentry.h | 2 +- 3 files changed, 1

[PATCH v12 32/37] x86/entry/calling: Allow PUSH_AND_CLEAR_REGS being used beyond actual entry code

2023-10-03 Thread Xin Li
From: "Peter Zijlstra (Intel)" PUSH_AND_CLEAR_REGS could be used besides actual entry code; in that case %rbp shouldn't be cleared (otherwise the frame pointer is destroyed) and UNWIND_HINT shouldn't be added. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Shan Kang Signed-off-

[PATCH v12 33/37] x86/entry: Add fred_entry_from_kvm() for VMX to handle IRQ/NMI

2023-10-03 Thread Xin Li
-by: Sean Christopherson Tested-by: Shan Kang Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li --- Changes since v10: * Better explain the reason why no need to check current stack level (Paolo Bonzini). Changes since v9: * Shove the whole thing into arch/x86/entry/entry_64_fred.S

[PATCH v12 26/37] x86/fred: Add a NMI entry stub for FRED

2023-10-03 Thread Xin Li
uite small... Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/nmi.c | 28 1 file changed, 28 insertions(+) diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index a0c551846b35..58843fdf5cd0 100644 --- a/arch/

[PATCH v12 21/37] x86/fred: No ESPFIX needed when FRED is enabled

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Because FRED always restores the full value of %rsp, ESPFIX is no longer needed when it's enabled. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/espfix_64.c | 8 1 file changed, 8

[PATCH v12 36/37] x86/fred: Add FRED initialization functions

2023-10-03 Thread Xin Li
rce 32-bit system calls to use "int $0x80" only. Add fred_complete_exception_setup() to: - Initialize system_vectors as done for IDT systems. - Set unused sysvec_table entries to fred_handle_spurious_interrupt(). Signed-off-by: H. Peter Anvin (Intel) Co-developed-by: Xin Li Tested-b

[PATCH v12 37/37] x86/fred: Invoke FRED initialization code to enable FRED

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Let cpu_init_exception_handling() call cpu_init_fred_exceptions() to initialize FRED. However if FRED is unavailable or disabled, it falls back to set up TSS IST and initialize IDT. Signed-off-by: H. Peter Anvin (Intel) Co-developed-by: Xin Li Teste

[PATCH v12 25/37] x86/fred: Add a debug fault entry stub for FRED

2023-10-03 Thread Xin Li
rmat which debug_read_clear_dr6() returns for the IDT entry points. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v9: * Disable #DB to avoid endless recursion and stack overflow when a watchpoint/breakpoint is set in the code path which is execute

[PATCH v12 23/37] x86/fred: Make exc_page_fault() work for FRED

2023-10-03 Thread Xin Li
by: Thomas Gleixner Signed-off-by: Xin Li --- arch/x86/mm/fault.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index ab778eac1952..7675bc067153 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -34,6 +34,7 @@

[PATCH v12 27/37] x86/fred: Add a machine check entry stub for FRED

2023-10-03 Thread Xin Li
stack, i.e., current task stack; ring 0 event on the #MCE dedicated stack specified in the IA32_FRED_STKLVLS MSR. So unlike IDT, the FRED machine check entry stub doesn't do stack switch. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v5: * Disallow #DB inside #MCE for robustness

[PATCH v12 22/37] x86/fred: Allow single-step trap and NMI when starting a new task

2023-10-03 Thread Xin Li
vin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v8: * Use high-order 48 bits above the lowest 16 bit SS only when FRED is enabled (Thomas Gleixner). --- arch/x86/kernel/process_64.c | 38 ++-- 1 file changed, 32 insertions(+), 6 deletions(-)

[PATCH v12 31/37] x86/fred: Fixup fault on ERETU by jumping to fred_entrypoint_user

2023-10-03 Thread Xin Li
ept the fault, fix up the exception frame, and redirect execution to fred_entrypoint_user. The end result is that it appears just as if the hardware had taken the exception immediately after completing the transition to user space. Suggested-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by:

[PATCH v12 29/37] x86/traps: Add sysvec_install() to install a system interrupt handler

2023-10-03 Thread Xin Li
Add sysvec_install() to install a system interrupt handler into the IDT or the FRED system interrupt handler table. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v8: * Introduce a macro sysvec_install() to derive the asm handler name from a C handler, which simplifies the code

[PATCH v12 28/37] x86/fred: FRED entry/exit and dispatch code

2023-10-03 Thread Xin Li
patch code for FRED. The first-level dispatch is on the event type, and the second-level is on the event vector. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Co-developed-by: Xin Li Tested-by: Shan Kang Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li --- Changes

[PATCH v12 20/37] x86/fred: Disallow the swapgs instruction when FRED is enabled

2023-10-03 Thread Xin Li
se address into the IA32_KERNEL_GS_BASE MSR instead of the GS segment’s descriptor cache. As such, the operating system never changes its runtime GS base address. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v8: * Explain why writin

[PATCH v12 30/37] x86/fred: Let ret_from_fork_asm() jmp to asm_fred_exit_user when FRED is enabled

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Let ret_from_fork_asm() jmp to asm_fred_exit_user when FRED is enabled, otherwise the existing IDT code is chosen. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/entry/entry_64.S | 6 ++ arch

[PATCH v12 34/37] KVM: VMX: Call fred_entry_from_kvm() for IRQ/NMI handling

2023-10-03 Thread Xin Li
When FRED is enabled, call fred_entry_from_kvm() to handle IRQ/NMI in IRQ/NMI induced VM exits. Tested-by: Shan Kang Signed-off-by: Xin Li Acked-by: Paolo Bonzini --- arch/x86/kvm/vmx/vmx.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c

[PATCH v12 24/37] x86/idtentry: Incorporate definitions/declarations of the FRED entries

2023-10-03 Thread Xin Li
irqentry/exit() in the dispatcher instead of having it in each handler. Also add stub defines for vectors which are not used due to Kconfig decisions to spare the ifdeffery in the actual FRED dispatch code. Tested-by: Shan Kang Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li --- Changes since v9

[PATCH v12 35/37] x86/syscall: Split IDT syscall setup code into idt_syscall_init()

2023-10-03 Thread Xin Li
syscall setup code when FRED is enabled. Suggested-by: Thomas Gleixner Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/cpu/common.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index

[PATCH v12 16/37] x86/ptrace: Add FRED additional information to the pt_regs structure

2023-10-03 Thread Xin Li
and easier to read. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li --- Changes since v11: * Add a new structure fred_cs to denote the FRED flags above CS selector as what is done for SS (H. Peter Anvin). Changes since v9: * Introduce

[PATCH v12 17/37] x86/fred: Add a new header file for FRED definitions

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add a header file for FRED prototypes and definitions. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v6: * Replace pt_regs csx flags prefix FRED_CSL_ with FRED_CSX_. --- arch/x86/include/asm/f

[PATCH v12 19/37] x86/fred: Update MSR_IA32_FRED_RSP0 during task switch

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" MSR_IA32_FRED_RSP0 is used during ring 3 event delivery, and needs to be updated to point to the top of next task stack during task switch. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/s

[PATCH v12 06/37] Documentation/x86/64: Add a documentation for FRED

2023-10-03 Thread Xin Li
Briefly introduce FRED, and its advantages compared to IDT. Signed-off-by: Xin Li --- Changes since v10: * Reword a sentence to improve readability (Nikolay Borisov). --- Documentation/arch/x86/x86_64/fred.rst | 96 + Documentation/arch/x86/x86_64/index.rst | 1 + 2

[PATCH v12 13/37] x86/cpu: Add X86_CR4_FRED macro

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add X86_CR4_FRED macro for the FRED bit in %cr4. This bit must not be changed after initialization, so add it to the pinned CR4 bits. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v9: * Avoid a

[PATCH v12 11/37] x86/opcode: Add ERET[US] instructions to the x86 opcode map

2023-10-03 Thread Xin Li
-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li Reviewed-by: Masami Hiramatsu (Google) --- arch/x86/lib/x86-opcode-map.txt | 2 +- tools/arch/x86/lib/x86-opcode-map.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/lib/x86-opcode-map.

[PATCH v12 07/37] x86/fred: Add Kconfig option for FRED (CONFIG_X86_FRED)

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add the configuration option CONFIG_X86_FRED to enable FRED. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/Kconfig | 9 + 1 file changed, 9 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x

[PATCH v12 02/37] x86/opcode: Add the WRMSRNS instruction to the x86 opcode map

2023-10-03 Thread Xin Li
Add the opcode used by WRMSRNS, which is the non-serializing version of WRMSR and may replace it to improve performance, to the x86 opcode map. Tested-by: Shan Kang Signed-off-by: Xin Li Acked-by: Masami Hiramatsu (Google) --- arch/x86/lib/x86-opcode-map.txt | 2 +- tools/arch/x86/lib

[PATCH v12 01/37] x86/cpufeatures: Add the cpu feature bit for WRMSRNS

2023-10-03 Thread Xin Li
WRMSRNS is an instruction that behaves exactly like WRMSR, with the only difference being that it is not a serializing instruction by default. Under certain conditions, WRMSRNS may replace WRMSR to improve performance. Add the CPU feature bit for WRMSRNS. Tested-by: Shan Kang Signed-off-by: Xin

[PATCH v12 03/37] x86/msr: Add the WRMSRNS instruction support

2023-10-03 Thread Xin Li
Add an always inline API __wrmsrns() to embed the WRMSRNS instruction into the code. Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/msr.h | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h index

[PATCH v12 18/37] x86/fred: Reserve space for the FRED stack frame

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" When using FRED, reserve space at the top of the stack frame, just like i386 does. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/thread_info.h | 12 +--- 1 file changed, 9 insert

[PATCH v12 15/37] x86/ptrace: Cleanup the definition of the pt_regs structure

2023-10-03 Thread Xin Li
Signed-off-by: Xin Li --- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- arch/x86/include/asm/ptrace.h | 44 +++ arch/x86/kernel/process_64.c | 2 +- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b

[PATCH v12 14/37] x86/cpu: Add MSR numbers for FRED configuration

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add MSR numbers for the FRED configuration registers per FRED spec 5.0. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/msr-index.h | 13 - tool

[PATCH v12 12/37] x86/objtool: Teach objtool about ERET[US]

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Update the objtool decoder to know about the ERET[US] instructions (type INSN_CONTEXT_SWITCH). Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- tools/objtool/arch/x86/decode.c | 19 ++- 1 file c

[PATCH v12 05/37] x86/trapnr: Add event type macros to

2023-10-03 Thread Xin Li
-by: Shan Kang Signed-off-by: Xin Li --- Changes since v10: * A few comment fixes and improvements (Andrew Cooper). --- arch/x86/include/asm/trapnr.h | 12 arch/x86/include/asm/vmx.h| 17 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/x86

[PATCH v12 10/37] x86/fred: Disable FRED by default in its early stage

2023-10-03 Thread Xin Li
To enable FRED, a new kernel command line option "fred" needs to be added. Tested-by: Shan Kang Signed-off-by: Xin Li --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/x86/kernel/cpu/common.c| 3 +++ 2 files changed, 6 insertions(+)

[PATCH v12 09/37] x86/fred: Disable FRED support if CONFIG_X86_FRED is disabled

2023-10-03 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add CONFIG_X86_FRED to to make cpu_feature_enabled() work correctly with FRED. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v10: * FRED feature is defined in cpuid word

[PATCH v12 04/37] x86/entry: Remove idtentry_sysvec from entry_{32,64}.S

2023-10-03 Thread Xin Li
idtentry_sysvec is really just DECLARE_IDTENTRY defined in , no need to define it separately. Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/entry/entry_32.S | 4 arch/x86/entry/entry_64.S | 8 arch/x86/include/asm/idtentry.h | 2 +- 3 files changed, 1

[PATCH v12 00/37] x86: enable FRED for x86-64

2023-10-03 Thread Xin Li
entry/exit and dispatch code x86/fred: Let ret_from_fork_asm() jmp to asm_fred_exit_user when FRED is enabled x86/fred: Add FRED initialization functions x86/fred: Invoke FRED initialization code to enable FRED Peter Zijlstra (Intel) (1): x86/entry/calling: Allow PUSH_AND_CLEAR_REGS being us

[PATCH v12 08/37] x86/cpufeatures: Add the cpu feature bit for FRED

2023-10-03 Thread Xin Li
zing WRMSR for faster MSR writes. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/cpuid-deps.c | 2 ++ tools/arch/x86/include/asm/cpufeatures.h | 1 + 3 files changed, 4 insertions(+)

[PATCH v11 19/37] x86/fred: Update MSR_IA32_FRED_RSP0 during task switch

2023-09-23 Thread Xin Li
From: "H. Peter Anvin (Intel)" MSR_IA32_FRED_RSP0 is used during ring 3 event delivery, and needs to be updated to point to the top of next task stack during task switch. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/s

[PATCH v11 17/37] x86/fred: Add a new header file for FRED definitions

2023-09-23 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add a header file for FRED prototypes and definitions. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v6: * Replace pt_regs csx flags prefix FRED_CSL_ with FRED_CSX_. --- arch/x86/include/asm/f

[PATCH v11 35/37] x86/syscall: Split IDT syscall setup code into idt_syscall_init()

2023-09-23 Thread Xin Li
syscall setup code when FRED is enabled. Suggested-by: Thomas Gleixner Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/cpu/common.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index

[PATCH v11 27/37] x86/fred: Add a machine check entry stub for FRED

2023-09-23 Thread Xin Li
stack, i.e., current task stack; ring 0 event on the #MCE dedicated stack specified in the IA32_FRED_STKLVLS MSR. So unlike IDT, the FRED machine check entry stub doesn't do stack switch. Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v5: * Disallow #DB inside #MCE for robustness

[PATCH v11 34/37] KVM: VMX: Call fred_entry_from_kvm() for IRQ/NMI handling

2023-09-23 Thread Xin Li
When FRED is enabled, call fred_entry_from_kvm() to handle IRQ/NMI in IRQ/NMI induced VM exits. Tested-by: Shan Kang Signed-off-by: Xin Li Acked-by: Paolo Bonzini --- arch/x86/kvm/vmx/vmx.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c

[PATCH v11 32/37] x86/entry/calling: Allow PUSH_AND_CLEAR_REGS being used beyond actual entry code

2023-09-23 Thread Xin Li
From: "Peter Zijlstra (Intel)" PUSH_AND_CLEAR_REGS could be used besides actual entry code; in that case %rbp shouldn't be cleared (otherwise the frame pointer is destroyed) and UNWIND_HINT shouldn't be added. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Shan Kang Signed-off-

[PATCH v11 37/37] x86/fred: Invoke FRED initialization code to enable FRED

2023-09-23 Thread Xin Li
From: "H. Peter Anvin (Intel)" Let cpu_init_exception_handling() call cpu_init_fred_exceptions() to initialize FRED. However if FRED is unavailable or disabled, it falls back to set up TSS IST and initialize IDT. Signed-off-by: H. Peter Anvin (Intel) Co-developed-by: Xin Li Teste

[PATCH v11 36/37] x86/fred: Add FRED initialization functions

2023-09-23 Thread Xin Li
rce 32-bit system calls to use "int $0x80" only. Add fred_complete_exception_setup() to: - Initialize system_vectors as done for IDT systems. - Set unused sysvec_table entries to fred_handle_spurious_interrupt(). Signed-off-by: H. Peter Anvin (Intel) Co-developed-by: Xin Li Tested-b

[PATCH v11 28/37] x86/fred: FRED entry/exit and dispatch code

2023-09-23 Thread Xin Li
patch code for FRED. The first-level dispatch is on the event type, and the second-level is on the event vector. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Co-developed-by: Xin Li Tested-by: Shan Kang Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li --- Changes

[PATCH v11 31/37] x86/fred: Fixup fault on ERETU by jumping to fred_entrypoint_user

2023-09-23 Thread Xin Li
ept the fault, fix up the exception frame, and redirect execution to fred_entrypoint_user. The end result is that it appears just as if the hardware had taken the exception immediately after completing the transition to user space. Suggested-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by:

[PATCH v11 13/37] x86/cpu: Add X86_CR4_FRED macro

2023-09-23 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add X86_CR4_FRED macro for the FRED bit in %cr4. This bit must not be changed after initialization, so add it to the pinned CR4 bits. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v9: * Avoid a

[PATCH v11 26/37] x86/fred: Add a NMI entry stub for FRED

2023-09-23 Thread Xin Li
uite small... Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/kernel/nmi.c | 28 1 file changed, 28 insertions(+) diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index a0c551846b35..58843fdf5cd0 100644 --- a/arch/

[PATCH v11 15/37] x86/ptrace: Cleanup the definition of the pt_regs structure

2023-09-23 Thread Xin Li
Signed-off-by: Xin Li --- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- arch/x86/include/asm/ptrace.h | 44 +++ arch/x86/kernel/process_64.c | 2 +- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b

[PATCH v11 33/37] x86/entry: Add fred_entry_from_kvm() for VMX to handle IRQ/NMI

2023-09-23 Thread Xin Li
-by: Sean Christopherson Tested-by: Shan Kang Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li --- Changes since v10: * Better explain the reason why no need to check current stack level (Paolo Bonzini). Changes since v9: * Shove the whole thing into arch/x86/entry/entry_64_fred.S

[PATCH v11 18/37] x86/fred: Reserve space for the FRED stack frame

2023-09-23 Thread Xin Li
From: "H. Peter Anvin (Intel)" When using FRED, reserve space at the top of the stack frame, just like i386 does. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- arch/x86/include/asm/thread_info.h | 12 +--- 1 file changed, 9 insert

[PATCH v11 09/37] x86/fred: Disable FRED support if CONFIG_X86_FRED is disabled

2023-09-23 Thread Xin Li
From: "H. Peter Anvin (Intel)" Add CONFIG_X86_FRED to to make cpu_feature_enabled() work correctly with FRED. Originally-by: Megha Dey Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Changes since v10: * FRED feature is defined in cpuid word

[PATCH v11 16/37] x86/ptrace: Add FRED additional information to the pt_regs structure

2023-09-23 Thread Xin Li
and easier to read. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li --- Changes since v9: * Introduce a new structure fred_ss to denote the FRED flags above SS selector, which avoids FRED_SSX_ macros and makes the code simpler

  1   2   3   >