From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796098978; b=sMlcOo3zNPRRJ+Rhg2C0YChsXIpSlBVl6w3hPO4pcsyOXDPbfErwCtKMTbJ10vmK6oah lFIuT1TkDwE2tf8buLcd7Ax9LYpGjkLv/rHVMVsTA68NWiwQLy7uAEe5d+KT7LjDRRhVc V5XlylR4HbZpnOgaL7VCqq1yqwpPI2YmpFaDtxdfP5Xzk3pQh+VLji54WqxhLcZni0nXV OavEUl5+Cq0mjZiu1TkeSW2gv5z0GihBsUPiFtfmfu9z9UwcRAbUULPsVuf4ZUnx6ZTqI ILvUBUW8gB1cQ5j2WPpC2s6QuvsY+TNYnuyAtiSua31z2O0M87mIim1JUNMdBH1ufwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796098978; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=k5Z8b2Zo3lDccwCgvLU5ZEALrOI8k28M68WCJC2y5fU=; b=Fs649BZiCNDk2gYgXpfebRSYb1KXi9PFLFy2oYwEsA7IlQYCQjWoyDzo+KUcTi29o7NL jG7KY+YIF8H4dfN7R/VCiuViskjw13MBzHUu20in8wMVp6AXCcHPGaDTC1+B1SvWM9vKt PNaObpkuOKbOIe82nNiMXAXVAVsDm5HUWtJ9AtOy5yVWwljdbhMFNGKC3Ck0inkPE8qOI rrARakitLI3TSuLDDK88dO4JmROxpdHh6cvS2C8ra61MJDgWXbjJTDF2JXBsUIAaODD4n ZXWlt457p9AOenpnTWuEGBVc2MP9rRb9mQFLrX4OhUo1th1HKg7EAZ2R6xpzZ/8BbSA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hwzlzvoR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A222B606A31A; Tue, 1 Dec 2026 04:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hwzlzvoR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E9051F00927; Tue, 1 Dec 2026 04:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796098978; bh=k5Z8b2Zo3lDccwCgvLU5ZEALrOI8k28M68WCJC2y5fU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hwzlzvoRU9g6Ic5soWTDYXz1UjHP/BvSeyRhEIUISi5m0FLPjk4HSsJPJGAncuHz0 PH08SDIs6yDNegZZqb0IohVlInRHEelkt9wJKEsoNzEhHi0yZk2YSx45cSCv2I9qiU XA68qHyIqi1AD9ZiA6iLK56JTqK2F/BSaW2nLiQyahPXCTxBE2NUBhSBsiF516BfcM PbauJqOkHuaL+FowOpsG0l6FMhVzVrHvMZ1NN2B/ghSdxj4JxkhCkI3IGaxaRffU2O uC6O3/w5VL2HiZ+7ZrrYB8x+Le3neh4CjMrFsAQxa6jg5+JoMYSHCddExhIYc4d7gS CEPR6W2BmHBaA== From: Song Liu To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, live-patching@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, bpf@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, peterz@infradead.org, tglx@kernel.org, frederic@kernel.org, paulmck@kernel.org, catalin.marinas@arm.com, will@kernel.org, maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, ojeda@kernel.org, kernel-team@meta.com, Song Liu Subject: [PATCH v3 02/22] x86: Mark CPU state helpers used by resume and kexec notrace Date: Mon, 30 Nov 2026 20:21:41 -0800 Message-ID: <20261201042201.3199928-3-song@kernel.org> X-Mailer: git-send-email 2.53.1 In-Reply-To: <20261201042201.3199928-1-song@kernel.org> References: <20261201042201.3199928-1-song@kernel.org> X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit __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 --- 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 f39891c94e7b..10c30ae70798 100644 --- a/arch/x86/include/asm/special_insns.h +++ b/arch/x86/include/asm/special_insns.h @@ -134,7 +134,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); } @@ -158,12 +158,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.1-Meta