[RFC PATCH v1 13/15] x86/msr: Use the alternatives mechanism to read MSR

2025-04-05 Thread Xin Li (Intel)
Also add support for the immediate form MSR read support. Suggested-by: H. Peter Anvin (Intel) Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/msr.h| 274 -- arch/x86/include/asm/paravirt.h | 40 arch/x86/include/asm/paravirt_types.h | 9

[RFC PATCH v1 06/15] x86/msr: Remove MSR write APIs that take the MSR value in two u32 arguments

2025-04-05 Thread Xin Li (Intel)
Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/msr.h | 18 ++ 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h index 121597fc5d41..da4f2f6d127f 100644 --- a/arch/x86/include/asm/msr.h +++ b/arch/x86

[RFC PATCH v1 12/15] x86/msr: Use the alternatives mechanism to write MSR

2025-03-31 Thread Xin Li (Intel)
Also add support for the immediate form MSR write support. Originally-by: H. Peter Anvin (Intel) Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/fred.h | 2 +- arch/x86/include/asm/msr.h| 340 ++ arch/x86/include/asm/paravirt.h | 22

[RFC PATCH v1 05/15] x86/msr: Replace wrmsr(msr, low, 0) with wrmsrl(msr, value)

2025-03-31 Thread Xin Li (Intel)
Signed-off-by: Xin Li (Intel) --- arch/x86/hyperv/hv_apic.c | 6 +++--- arch/x86/include/asm/apic.h | 2 +- arch/x86/include/asm/switch_to.h | 2 +- arch/x86/kernel/cpu/amd.c | 2 +- arch/x86/kernel/cpu/common.c | 8

[RFC PATCH v1 07/15] x86/msr: Remove pmu_msr_{read,write}()

2025-03-31 Thread Xin Li (Intel)
Now pmu_msr_{read,write}() just do pmu_msr_chk_emulated(), so remove them and call pmu_msr_chk_emulated() directly. Suggested-by: H. Peter Anvin (Intel) Signed-off-by: Xin Li (Intel) --- arch/x86/xen/enlighten_pv.c | 17 ++--- arch/x86/xen/pmu.c | 24

[RFC PATCH v1 11/15] x86/extable: Implement EX_TYPE_FUNC_REWIND

2025-03-31 Thread Xin Li (Intel)
alternatives pattern, possibly invoking a different exception handling pattern there, or at least indicating the "real" location of the fault. Signed-off-by: H. Peter Anvin (Intel) Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/asm.h | 6 + arch/x86/include/a

[RFC PATCH v1 00/15] MSR refactor with new MSR instructions support

2025-03-31 Thread Xin Li (Intel)
EX_TYPE_FUNC_REWIND Xin Li (Intel) (14): x86/msr: Replace __wrmsr() with native_wrmsrl() x86/msr: Replace __rdmsr() with native_rdmsrl() x86/msr: Simplify pmu_msr_{read,write}() x86/msr: Let pv_cpu_ops.write_msr{_safe}() take an u64 instead of two u32 x86/msr: Replace wrmsr(msr, low, 0

[RFC PATCH v1 04/15] x86/msr: Let pv_cpu_ops.write_msr{_safe}() take an u64 instead of two u32

2025-03-31 Thread Xin Li (Intel)
Refactor pv_cpu_ops.write_msr{_safe}() to take the input MSR value in a single u64 argument, replacing the current dual u32 arguments. No functional change intended. Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/msr.h| 33 --- arch/x86/include/asm

[RFC PATCH v1 01/15] x86/msr: Replace __wrmsr() with native_wrmsrl()

2025-03-31 Thread Xin Li (Intel)
__wrmsr() is the lowest level primitive MSR write API, and its direct use is NOT preferred. Use its wrapper function native_wrmsrl() instead. No functional change intended. Signed-off-by: Xin Li (Intel) --- arch/x86/events/amd/brs.c | 2 +- arch/x86/include/asm/apic.h

[RFC PATCH v1 14/15] x86/extable: Add support for the immediate form MSR instructions

2025-03-31 Thread Xin Li (Intel)
Signed-off-by: Xin Li (Intel) --- arch/x86/mm/extable.c | 59 ++- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c index eb9331240a88..56138c0762b7 100644 --- a/arch/x86/mm/extable.c +++ b/arch

[RFC PATCH v1 10/15] KVM: VMX: Use WRMSRNS or its immediate form when available

2025-03-31 Thread Xin Li (Intel)
Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/msr-index.h | 6 ++ arch/x86/kvm/vmx/vmenter.S | 28 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index

[RFC PATCH v1 08/15] x86/cpufeatures: Add a CPU feature bit for MSR immediate form instructions

2025-03-31 Thread Xin Li (Intel)
feature bit for MSR immediate form instructions. Suggested-by: Borislav Petkov Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/cpufeatures.h | 19 ++- arch/x86/kernel/cpu/scattered.c| 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/x86/include

[RFC PATCH v1 03/15] x86/msr: Simplify pmu_msr_{read,write}()

2025-03-31 Thread Xin Li (Intel)
) Sign-off-by: Xin Li (Intel) --- arch/x86/xen/enlighten_pv.c | 6 +- arch/x86/xen/pmu.c | 27 --- arch/x86/xen/xen-ops.h | 4 ++-- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c

[RFC PATCH v1 02/15] x86/msr: Replace __rdmsr() with native_rdmsrl()

2025-03-31 Thread Xin Li (Intel)
__rdmsr() is the lowest level primitive MSR read API, and its direct use is NOT preferred. Use its wrapper function native_rdmsrl() instead. No functional change intended. Signed-off-by: Xin Li (Intel) --- arch/x86/coco/sev/core.c | 2 +- arch/x86/events/amd/brs.c

[RFC PATCH v1 09/15] x86/opcode: Add immediate form MSR instructions to x86-opcode-map

2025-03-31 Thread Xin Li (Intel)
Add the instruction opcodes used by the immediate form WRMSRNS/RDMSR to x86-opcode-map. Signed-off-by: Xin Li (Intel) --- arch/x86/lib/x86-opcode-map.txt | 5 +++-- tools/arch/x86/lib/x86-opcode-map.txt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/lib

[RFC PATCH v1 15/15] x86/msr: Move the ARGS macros after the MSR read/write APIs

2025-04-04 Thread Xin Li (Intel)
Since the ARGS macros are no longer used in the MSR read/write API implementation, move them after their definitions. Signed-off-by: Xin Li (Intel) --- arch/x86/include/asm/msr.h | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/x86