[PATCH v2 02/16] x86: Mark CPU state helpers used by resume and kexec notrace
flat view
WARM1d
From: Song Liu <song@kernel.org>
Date: 2026-10-23 01:11:07
Also in:
live-patching, lkml
Subsystem:
paravirt_ops interface, the rest, x86 architecture (32-bit and 64-bit) · Maintainers:
Juergen Gross, Linus Torvalds, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen
__restore_processor_state() is notrace because it starts running before %gs and the IDT are restored, when the function tracer cannot run yet. Before it restores MSR_GS_BASE, it calls wrmsrq(), __write_cr4(), write_cr3(), write_cr0(), load_idt() and loadsegment(), and after that it calls load_gs_index(). With CONFIG_PARAVIRT_XXL, wrmsrq() calls paravirt_write_msr(). machine_kexec() calls virt_to_phys() after load_segments() has reset %gs. All of these are plain inline functions. If the compiler emits one of them out of line, that copy is untraced only because inline implies notrace. Mark them notrace explicitly, together with the other paravirt MSR accessors, so they stay consistent with paravirt_write_msr(). No functional change. Assisted-by: Claude:claude-opus-5 Signed-off-by: Song Liu <song@kernel.org> --- arch/x86/include/asm/gsseg.h | 2 +- arch/x86/include/asm/io.h | 2 +- arch/x86/include/asm/msr.h | 2 +- arch/x86/include/asm/paravirt.h | 20 ++++++++++---------- arch/x86/include/asm/segment.h | 4 ++-- arch/x86/include/asm/special_insns.h | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/arch/x86/include/asm/gsseg.h b/arch/x86/include/asm/gsseg.h
index 14596425f36a..d46d6effb631 100644
--- a/arch/x86/include/asm/gsseg.h
+++ b/arch/x86/include/asm/gsseg.h@@ -52,7 +52,7 @@ static inline void __init lkgs_init(void) #ifndef CONFIG_PARAVIRT_XXL -static inline void load_gs_index(unsigned int selector) +static inline void notrace load_gs_index(unsigned int selector) { #ifdef CONFIG_X86_64 native_load_gs_index(selector);
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 7f4847b2b904..721ce7878966 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h@@ -126,7 +126,7 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size); * this function */ -static inline phys_addr_t virt_to_phys(volatile void *address) +static inline phys_addr_t notrace virt_to_phys(volatile void *address) { return __pa(address); }
diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
index ca138498a00b..7c311dbcd0bf 100644
--- a/arch/x86/include/asm/msr.h
+++ b/arch/x86/include/asm/msr.h@@ -194,7 +194,7 @@ static inline void wrmsr(u32 msr, u32 low, u32 high) #define rdmsrq(msr, val) \ ((val) = native_read_msr((msr))) -static inline void wrmsrq(u32 msr, u64 val) +static inline void notrace wrmsrq(u32 msr, u64 val) { native_write_msr(msr, val); }
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 0591aa38fd85..c30af937103b 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h@@ -98,7 +98,7 @@ static inline unsigned long read_cr0(void) return PVOP_CALL0(unsigned long, pv_ops, cpu.read_cr0); } -static inline void write_cr0(unsigned long x) +static inline void notrace write_cr0(unsigned long x) { PVOP_VCALL1(pv_ops, cpu.write_cr0, x); }
@@ -120,32 +120,32 @@ static inline unsigned long __read_cr3(void) "mov %%cr3, %%rax", ALT_NOT_XEN); } -static inline void write_cr3(unsigned long x) +static inline void notrace write_cr3(unsigned long x) { PVOP_ALT_VCALL1(pv_ops, mmu.write_cr3, x, "mov %%rdi, %%cr3", ALT_NOT_XEN); } -static inline void __write_cr4(unsigned long x) +static inline void notrace __write_cr4(unsigned long x) { PVOP_VCALL1(pv_ops, cpu.write_cr4, x); } -static inline u64 paravirt_read_msr(u32 msr) +static inline u64 notrace paravirt_read_msr(u32 msr) { return PVOP_CALL1(u64, pv_ops, cpu.read_msr, msr); } -static inline void paravirt_write_msr(u32 msr, u64 val) +static inline void notrace paravirt_write_msr(u32 msr, u64 val) { PVOP_VCALL2(pv_ops, cpu.write_msr, msr, val); } -static inline int paravirt_read_msr_safe(u32 msr, u64 *val) +static inline int notrace paravirt_read_msr_safe(u32 msr, u64 *val) { return PVOP_CALL2(int, pv_ops, cpu.read_msr_safe, msr, val); } -static inline int paravirt_write_msr_safe(u32 msr, u64 val) +static inline int notrace paravirt_write_msr_safe(u32 msr, u64 val) { return PVOP_CALL2(int, pv_ops, cpu.write_msr_safe, msr, val); }
@@ -167,7 +167,7 @@ do { \ val = paravirt_read_msr(msr); \ } while (0) -static inline void wrmsrq(u32 msr, u64 val) +static inline void notrace wrmsrq(u32 msr, u64 val) { paravirt_write_msr(msr, val); }
@@ -215,7 +215,7 @@ static inline void load_gdt(const struct desc_ptr *dtr) { PVOP_VCALL1(pv_ops, cpu.load_gdt, dtr); } -static inline void load_idt(const struct desc_ptr *dtr) +static inline void notrace load_idt(const struct desc_ptr *dtr) { PVOP_VCALL1(pv_ops, cpu.load_idt, dtr); }
@@ -234,7 +234,7 @@ static inline void load_TLS(struct thread_struct *t, unsigned cpu) PVOP_VCALL2(pv_ops, cpu.load_tls, t, cpu); } -static inline void load_gs_index(unsigned int gs) +static inline void notrace load_gs_index(unsigned int gs) { PVOP_VCALL1(pv_ops, cpu.load_gs_index, gs); }
diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index dbd90fede5e7..01ed6f1f7952 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h@@ -303,7 +303,7 @@ extern const char xen_early_idt_handler_array[NUM_EXCEPTION_VECTORS][XEN_EARLY_I * FS and GS. */ #define LOAD_SEGMENT(seg) \ -static inline void __loadsegment_##seg(u16 value) \ +static inline void notrace __loadsegment_##seg(u16 value) \ { \ asm volatile("1: movl %k0,%%" #seg "\n" \ _ASM_EXTABLE_TYPE_REG(1b, 1b, EX_TYPE_ZERO_REG, %k0)\
@@ -325,7 +325,7 @@ LOAD_SEGMENT(gs) #else -static inline void __loadsegment_fs(u16 value) +static inline void notrace __loadsegment_fs(u16 value) { asm volatile("1: movw %0, %%fs\n" "2:\n"
diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h
index 810c992f3a0d..f854eb3333d0 100644
--- a/arch/x86/include/asm/special_insns.h
+++ b/arch/x86/include/asm/special_insns.h@@ -147,7 +147,7 @@ static inline unsigned long read_cr0(void) return native_read_cr0(); } -static inline void write_cr0(unsigned long x) +static inline void notrace write_cr0(unsigned long x) { native_write_cr0(x); }
@@ -171,12 +171,12 @@ static inline unsigned long __read_cr3(void) return __native_read_cr3(); } -static inline void write_cr3(unsigned long x) +static inline void notrace write_cr3(unsigned long x) { native_write_cr3(x); } -static inline void __write_cr4(unsigned long x) +static inline void notrace __write_cr4(unsigned long x) { native_write_cr4(x); }
--
2.53.0-Meta