mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	live-patching@vger.kernel.org
Cc: rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com,
	kernel-team@meta.com, Song Liu <song@kernel.org>
Subject: [PATCH v2 02/16] x86: Mark CPU state helpers used by resume and kexec notrace
Date: Thu, 22 Oct 2026 18:10:35 -0700	[thread overview]
Message-ID: <20261023011049.1164625-3-song@kernel.org> (raw)
In-Reply-To: <20261023011049.1164625-1-song@kernel.org>

__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


  parent reply	other threads:[~2026-10-23  1:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  1:10 [PATCH v2 00/16] Move notrace from inline to __always_inline Song Liu
2026-10-23  1:10 ` [PATCH v2 01/16] x86/paravirt: Mark native pv_ops helpers notrace Song Liu
2026-10-23  1:10 ` Song Liu [this message]
2026-10-23  1:10 ` [PATCH v2 03/16] bpf: Mark bpf_spin_lock " Song Liu
2026-10-23  1:10 ` [PATCH v2 04/16] bpf: Mark the BPF trampoline " Song Liu
2026-10-23  1:10 ` [PATCH v2 05/16] bpf: Mark the bpf_mem_alloc fast path " Song Liu
2026-10-23  1:10 ` [PATCH v2 06/16] u64_stats: Mark the update helpers used by BPF notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 07/16] tracepoint: Mark __do_trace_##name() notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 08/16] srcu: Mark the fast notrace read-side helpers notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 09/16] arm64: Mark the preempt count " Song Liu
2026-10-23  1:10 ` [PATCH v2 10/16] powerpc, csky, mips, sh: Mark the accessors behind current notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 11/16] rcu: Mark the Tiny RCU rcu_is_watching() notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 12/16] tracing: Mark the tracing_gen_ctx helpers notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 13/16] ktime: Mark ktime_to_ns() notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 14/16] kallsyms: Mark the kernel text address checks notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 15/16] uaccess: Mark pagefault_disable() and pagefault_enable() notrace Song Liu
2026-10-23  1:10 ` [PATCH v2 16/16] compiler_types: Move notrace from inline to __always_inline Song Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261023011049.1164625-3-song@kernel.org \
    --to=song@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®