From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E22B38553E for ; Mon, 20 Apr 2026 09:17:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776676630; cv=none; b=IUSWR3RmvZS6g4SxQLGZBfySKf8NqKr+HPV7pI8tI5WfFKCUHXNIYBpGPjEt6owFLQ4RBTHGr5wz99FyF0iLBAFuzMEpyZvC4kDWPTxxHa2thEpfYm34WnHbj3aYc4ykAxIia2OOYUkIrpMPnQbx9zuKttcvr1q3FiozK0Bf0wQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776676630; c=relaxed/simple; bh=6zpe/dsMyNJA+SQ7zamr61zllof60DPgKrLwdDzcFMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YZiA41RHFAmykt4PiZm1IVbb86Uj5Esj4qXTnRgUWFhCrIKqU/Gffh4mSWwZvcztgAehQXJo1qEnGOTmyk48SP/lkzyMW9P4HMX1Vv1e0RUZLtexbxoDTHMw1KcSmV5Hlmd6qi4pekCsfeRlrik7B7+A+gaTLGqqRn+Yevo75aQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=blhKER2E; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=blhKER2E; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="blhKER2E"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="blhKER2E" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 52B646A8E3; Mon, 20 Apr 2026 09:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1776676626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gs2/tyfQansJGWsPeB/X7grYSFW1Cp0LNMKe3Zz00IE=; b=blhKER2EwV6aV9iU3uHUfPB0wSx6aJr9+uxQxzixWnrIs0l/xpZzQ7E18xY0FHbwO8fLZR YUEjcPZUjPMXbrB7S+IJVUW/lVycm3Yhl9F2RH22UEZ4Nir2m+EBfJEKbShbHoGbBzNY+S zmw1NZNWTxwGQcYaF1YyYht+40uFT2c= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=blhKER2E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1776676626; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gs2/tyfQansJGWsPeB/X7grYSFW1Cp0LNMKe3Zz00IE=; b=blhKER2EwV6aV9iU3uHUfPB0wSx6aJr9+uxQxzixWnrIs0l/xpZzQ7E18xY0FHbwO8fLZR YUEjcPZUjPMXbrB7S+IJVUW/lVycm3Yhl9F2RH22UEZ4Nir2m+EBfJEKbShbHoGbBzNY+S zmw1NZNWTxwGQcYaF1YyYht+40uFT2c= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2021E593AE; Mon, 20 Apr 2026 09:17:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Es/FBhLv5WnQPQAAD6G6ig (envelope-from ); Mon, 20 Apr 2026 09:17:06 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH RFC 4/6] x86/msr: Rename the *_safe_regs[_on_cpu]() MSR functions Date: Mon, 20 Apr 2026 11:16:32 +0200 Message-ID: <20260420091634.128787-5-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420091634.128787-1-jgross@suse.com> References: <20260420091634.128787-1-jgross@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; URIBL_BLOCKED(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[8]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Queue-Id: 52B646A8E3 X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: Move the functions rdmsr_safe_regs[_on_cpu]() and wrmsr_safe_regs[_on_cpu]() into the "msr_" name space and change all callers accordingly. Signed-off-by: Juergen Gross --- arch/x86/include/asm/msr.h | 17 ++++++++--------- arch/x86/kernel/cpu/amd.c | 4 ++-- arch/x86/kernel/msr.c | 4 ++-- arch/x86/lib/msr-reg-export.c | 4 ++-- arch/x86/lib/msr-reg.S | 16 ++++++++-------- arch/x86/lib/msr-smp.c | 20 ++++++++++---------- 6 files changed, 32 insertions(+), 33 deletions(-) diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h index 74e87b2b39fd..9b3d16b2eb61 100644 --- a/arch/x86/include/asm/msr.h +++ b/arch/x86/include/asm/msr.h @@ -156,9 +156,6 @@ static inline int notrace native_write_msr_safe(u32 msr, u64 val) return err; } -extern int rdmsr_safe_regs(u32 regs[8]); -extern int wrmsr_safe_regs(u32 regs[8]); - static inline u64 native_read_pmc(int counter) { EAX_EDX_DECLARE_ARGS(val, low, high); @@ -292,6 +289,8 @@ struct msr __percpu *msrs_alloc(void); void msrs_free(struct msr __percpu *msrs); int msr_set_bit(u32 msr, u8 bit); int msr_clear_bit(u32 msr, u8 bit); +int msr_read_safe_regs(u32 regs[8]); +int msr_write_safe_regs(u32 regs[8]); #ifdef CONFIG_SMP int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); @@ -304,8 +303,8 @@ int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); int rdmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 *q); int wrmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 q); -int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]); -int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]); +int msr_read_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]); +int msr_write_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]); #else /* CONFIG_SMP */ static inline int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h) { @@ -354,13 +353,13 @@ static inline int wrmsrq_safe_on_cpu(unsigned int cpu, u32 msr_no, u64 q) { return wrmsrq_safe(msr_no, q); } -static inline int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) +static inline int msr_read_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) { - return rdmsr_safe_regs(regs); + return msr_read_safe_regs(regs); } -static inline int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) +static inline int msr_write_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) { - return wrmsr_safe_regs(regs); + return msr_write_safe_regs(regs); } #endif /* CONFIG_SMP */ diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 2d9ae6ab1701..7266fcfcf448 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -45,7 +45,7 @@ static inline int rdmsrq_amd_safe(unsigned msr, u64 *p) gprs[1] = msr; gprs[7] = 0x9c5a203a; - err = rdmsr_safe_regs(gprs); + err = msr_read_safe_regs(gprs); *p = gprs[0] | ((u64)gprs[2] << 32); @@ -64,7 +64,7 @@ static inline int wrmsrq_amd_safe(unsigned msr, u64 val) gprs[2] = val >> 32; gprs[7] = 0x9c5a203a; - return wrmsr_safe_regs(gprs); + return msr_write_safe_regs(gprs); } /* diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index 43791746103c..e3e71e3ba59f 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -162,7 +162,7 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) err = -EFAULT; break; } - err = rdmsr_safe_regs_on_cpu(cpu, regs); + err = msr_read_safe_regs_on_cpu(cpu, regs); if (err) break; if (copy_to_user(uregs, ®s, sizeof(regs))) @@ -188,7 +188,7 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); - err = wrmsr_safe_regs_on_cpu(cpu, regs); + err = msr_write_safe_regs_on_cpu(cpu, regs); if (err) break; if (copy_to_user(uregs, ®s, sizeof(regs))) diff --git a/arch/x86/lib/msr-reg-export.c b/arch/x86/lib/msr-reg-export.c index 876b4168ab0a..c3da46f0581b 100644 --- a/arch/x86/lib/msr-reg-export.c +++ b/arch/x86/lib/msr-reg-export.c @@ -2,5 +2,5 @@ #include #include -EXPORT_SYMBOL(rdmsr_safe_regs); -EXPORT_SYMBOL(wrmsr_safe_regs); +EXPORT_SYMBOL(msr_read_safe_regs); +EXPORT_SYMBOL(msr_write_safe_regs); diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S index 5ef8494896e8..ccb9e3a962f4 100644 --- a/arch/x86/lib/msr-reg.S +++ b/arch/x86/lib/msr-reg.S @@ -12,8 +12,8 @@ * reg layout: u32 gprs[eax, ecx, edx, ebx, esp, ebp, esi, edi] * */ -.macro op_safe_regs op -SYM_TYPED_FUNC_START(\op\()_safe_regs) +.macro op_safe_regs name op +SYM_TYPED_FUNC_START(\name) pushq %rbx pushq %r12 movq %rdi, %r10 /* Save pointer */ @@ -42,13 +42,13 @@ SYM_TYPED_FUNC_START(\op\()_safe_regs) jmp 2b _ASM_EXTABLE(1b, 3b) -SYM_FUNC_END(\op\()_safe_regs) +SYM_FUNC_END(\name) .endm #else /* X86_32 */ -.macro op_safe_regs op -SYM_FUNC_START(\op\()_safe_regs) +.macro op_safe_regs name op +SYM_FUNC_START(\name) pushl %ebx pushl %ebp pushl %esi @@ -84,11 +84,11 @@ SYM_FUNC_START(\op\()_safe_regs) jmp 2b _ASM_EXTABLE(1b, 3b) -SYM_FUNC_END(\op\()_safe_regs) +SYM_FUNC_END(\name) .endm #endif -op_safe_regs rdmsr -op_safe_regs wrmsr +op_safe_regs msr_read_safe_regs rdmsr +op_safe_regs msr_write_safe_regs wrmsr diff --git a/arch/x86/lib/msr-smp.c b/arch/x86/lib/msr-smp.c index b8f63419e6ae..21bb1aee2af7 100644 --- a/arch/x86/lib/msr-smp.c +++ b/arch/x86/lib/msr-smp.c @@ -236,42 +236,42 @@ EXPORT_SYMBOL(rdmsrq_safe_on_cpu); * These variants are significantly slower, but allows control over * the entire 32-bit GPR set. */ -static void __rdmsr_safe_regs_on_cpu(void *info) +static void __msr_read_safe_regs(void *info) { struct msr_regs_info *rv = info; - rv->err = rdmsr_safe_regs(rv->regs); + rv->err = msr_read_safe_regs(rv->regs); } -static void __wrmsr_safe_regs_on_cpu(void *info) +static void __msr_write_safe_regs(void *info) { struct msr_regs_info *rv = info; - rv->err = wrmsr_safe_regs(rv->regs); + rv->err = msr_write_safe_regs(rv->regs); } -int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) +int msr_read_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) { int err; struct msr_regs_info rv; rv.regs = regs; rv.err = -EIO; - err = smp_call_function_single(cpu, __rdmsr_safe_regs_on_cpu, &rv, 1); + err = smp_call_function_single(cpu, __msr_read_safe_regs, &rv, 1); return err ? err : rv.err; } -EXPORT_SYMBOL(rdmsr_safe_regs_on_cpu); +EXPORT_SYMBOL(msr_read_safe_regs_on_cpu); -int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) +int msr_write_safe_regs_on_cpu(unsigned int cpu, u32 regs[8]) { int err; struct msr_regs_info rv; rv.regs = regs; rv.err = -EIO; - err = smp_call_function_single(cpu, __wrmsr_safe_regs_on_cpu, &rv, 1); + err = smp_call_function_single(cpu, __msr_write_safe_regs, &rv, 1); return err ? err : rv.err; } -EXPORT_SYMBOL(wrmsr_safe_regs_on_cpu); +EXPORT_SYMBOL(msr_write_safe_regs_on_cpu); -- 2.53.0