From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EC2347ECFA; Thu, 2 Jul 2026 10:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782987369; cv=none; b=DHBQ4e39sHBQqAn7QN7ceXL3cgPF9LFiFH9qcQEABTmJAEHMAWxF9JzJDLochNp9DsP8pljYCuN0wgfSeglesxrB84Ho4RLhvUs5c8EUTv2Dzsiz/DERWVGshL5x34StmvKvyOQJ7uS7mLMfMNU4bMLfaQntvh2OEBBT0FHwQQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782987369; c=relaxed/simple; bh=gBoUyjh/zlHz9/lSbQjpvcTOGOg8SQE9VKh6zB/Kvrk=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=LwLBtx4q9yS15uQVBBWxR/vCD4DtTzGpHmNiJSaUANFt1j85qQ14eGgvL1LeNFvs40jPWQIEtE6g5r/ehoWlS1EEBbBZteh2xMBgzd6gFz8fqBraQ69IAnT99N7PWSqQojfygIQqHkmAMGBXYCKlanwQGdGr6P5faTWsr7g94dk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=S9K/4vtu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=l6DqT45M; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="S9K/4vtu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="l6DqT45M" Date: Thu, 02 Jul 2026 10:16:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782987366; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Z5po5aCvYpDcEzU2IA1IFDQK1QmaD2lYZa+7lEsKN4=; b=S9K/4vtucMNfVQsuDcIBm7DppOxuW7ny0edTRfJgXTMArb6WHoW/wr4B1BNc/gejnav31P YHmRB1AkJ+W2hlpw1AfQmIzWNbfQjwcmHGm7gb8tzKdvheHcKVGpTCDKpVZFCK/JicRGYI YBfsYc6CI87PVLKBzZn98QW31vQpkrmMMXuQumXx0l4ZGPwpye8fPWlIVN2UYl+nrbK1SS 4krJoJns8BWyYg4h+xmjiGUjQOm5e5RNkq/3gYHd66L62mpjb1kHlctgoI0sszms65H35t NOkGWc8JBRAKo1xvdOYlsEc1jfOVnO4bhNnPoFIPe2elId9X4Wn7XHB90a0Dcw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782987366; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Z5po5aCvYpDcEzU2IA1IFDQK1QmaD2lYZa+7lEsKN4=; b=l6DqT45MSnAnlLoUa/q6lPRMVzuJ2fnhr/4522r4vxrbOs3YRgINmA6LpAiiN/CPJIigOB IexcVBr+2GG7ZjCw== From: "tip-bot2 for Juergen Gross" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/msr] x86/mce: Stop using 32-bit MSR interfaces Cc: Juergen Gross , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260629060526.3638272-9-jgross@suse.com> References: <20260629060526.3638272-9-jgross@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178298736498.3843924.8223709477114108058.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/msr branch of tip: Commit-ID: cff219368bd066d67cc66e8fcdd2c4b13f5101ce Gitweb: https://git.kernel.org/tip/cff219368bd066d67cc66e8fcdd2c4b13f5= 101ce Author: Juergen Gross AuthorDate: Mon, 29 Jun 2026 08:04:59 +02:00 Committer: Ingo Molnar CommitterDate: Thu, 02 Jul 2026 11:54:51 +02:00 x86/mce: Stop using 32-bit MSR interfaces The 32-bit MSR interfaces rdmsr(), wrmsr() and rdmsr_safe() are planned to be removed. Use the related 64-bit variants instead. Signed-off-by: Juergen Gross Signed-off-by: Ingo Molnar Link: https://patch.msgid.link/20260629060526.3638272-9-jgross@suse.com --- arch/x86/kernel/cpu/mce/amd.c | 87 +++++++++++++++--------------- arch/x86/kernel/cpu/mce/core.c | 2 +- arch/x86/kernel/cpu/mce/p5.c | 16 +++--- arch/x86/kernel/cpu/mce/winchip.c | 10 +-- 4 files changed, 58 insertions(+), 57 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 36e0df4..f916fb4 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -280,11 +280,11 @@ static void smca_configure(unsigned int bank, unsigned = int cpu) u8 *bank_counts =3D this_cpu_ptr(smca_bank_counts); const struct smca_hwid *s_hwid; unsigned int i, hwid_mcatype; - u32 high, low; + struct msr val; u32 smca_config =3D MSR_AMD64_SMCA_MCx_CONFIG(bank); =20 /* Set appropriate bits in MCA_CONFIG */ - if (!rdmsr_safe(smca_config, &low, &high)) { + if (!rdmsrq_safe(smca_config, &val.q)) { /* * OS is required to set the MCAX bit to acknowledge that it is * now using the new MSR ranges and new registers under each @@ -294,7 +294,7 @@ static void smca_configure(unsigned int bank, unsigned in= t cpu) * * MCA_CONFIG[MCAX] is bit 32 (0 in the high portion of the MSR.) */ - high |=3D BIT(0); + val.h |=3D BIT(0); =20 /* * SMCA sets the Deferred Error Interrupt type per bank. @@ -307,9 +307,9 @@ static void smca_configure(unsigned int bank, unsigned in= t cpu) * APIC based interrupt. First, check that no interrupt has been * set. */ - if ((low & BIT(5)) && !((high >> 5) & 0x3) && data->dfr_intr_en) { + if ((val.l & BIT(5)) && !((val.h >> 5) & 0x3) && data->dfr_intr_en) { __set_bit(bank, data->dfr_intr_banks); - high |=3D BIT(5); + val.h |=3D BIT(5); } =20 /* @@ -324,33 +324,33 @@ static void smca_configure(unsigned int bank, unsigned = int cpu) * The OS should set this to inform the platform that the OS is ready * to handle the MCA Thresholding interrupt. */ - if ((low & BIT(10)) && data->thr_intr_en) { + if ((val.l & BIT(10)) && data->thr_intr_en) { __set_bit(bank, data->thr_intr_banks); - high |=3D BIT(8); + val.h |=3D BIT(8); } =20 - this_cpu_ptr(mce_banks_array)[bank].lsb_in_status =3D !!(low & BIT(8)); + this_cpu_ptr(mce_banks_array)[bank].lsb_in_status =3D !!(val.l & BIT(8)); =20 - if (low & MCI_CONFIG_PADDRV) + if (val.l & MCI_CONFIG_PADDRV) this_cpu_ptr(smca_banks)[bank].paddrv =3D 1; =20 - wrmsr(smca_config, low, high); + wrmsrq(smca_config, val.q); } =20 - if (rdmsr_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &low, &high)) { + if (rdmsrq_safe(MSR_AMD64_SMCA_MCx_IPID(bank), &val.q)) { pr_warn("Failed to read MCA_IPID for bank %d\n", bank); return; } =20 - hwid_mcatype =3D HWID_MCATYPE(high & MCI_IPID_HWID, - (high & MCI_IPID_MCATYPE) >> 16); + hwid_mcatype =3D HWID_MCATYPE(val.h & MCI_IPID_HWID, + (val.h & MCI_IPID_MCATYPE) >> 16); =20 for (i =3D 0; i < ARRAY_SIZE(smca_hwid_mcatypes); i++) { s_hwid =3D &smca_hwid_mcatypes[i]; =20 if (hwid_mcatype =3D=3D s_hwid->hwid_mcatype) { this_cpu_ptr(smca_banks)[bank].hwid =3D s_hwid; - this_cpu_ptr(smca_banks)[bank].id =3D low; + this_cpu_ptr(smca_banks)[bank].id =3D val.l; this_cpu_ptr(smca_banks)[bank].sysfs_id =3D bank_counts[s_hwid->bank_type= ]++; break; } @@ -432,50 +432,50 @@ static bool lvt_off_valid(struct threshold_block *b, in= t apic, u32 lo, u32 hi) static void threshold_restart_block(void *_tr) { struct thresh_restart *tr =3D _tr; - u32 hi, lo; + struct msr val; =20 /* sysfs write might race against an offline operation */ if (!this_cpu_read(threshold_banks) && !tr->set_lvt_off) return; =20 - rdmsr(tr->b->address, lo, hi); + rdmsrq(tr->b->address, val.q); =20 /* * Reset error count and overflow bit. * This is done during init or after handling an interrupt. */ - if (hi & MASK_OVERFLOW_HI || tr->set_lvt_off) { - hi &=3D ~(MASK_ERR_COUNT_HI | MASK_OVERFLOW_HI); - hi |=3D THRESHOLD_MAX - tr->b->threshold_limit; + if (val.h & MASK_OVERFLOW_HI || tr->set_lvt_off) { + val.h &=3D ~(MASK_ERR_COUNT_HI | MASK_OVERFLOW_HI); + val.h |=3D THRESHOLD_MAX - tr->b->threshold_limit; } else if (tr->old_limit) { /* change limit w/o reset */ - int new_count =3D (hi & THRESHOLD_MAX) + + int new_count =3D (val.h & THRESHOLD_MAX) + (tr->old_limit - tr->b->threshold_limit); =20 - hi =3D (hi & ~MASK_ERR_COUNT_HI) | + val.h =3D (val.h & ~MASK_ERR_COUNT_HI) | (new_count & THRESHOLD_MAX); } =20 /* clear IntType */ - hi &=3D ~MASK_INT_TYPE_HI; + val.h &=3D ~MASK_INT_TYPE_HI; =20 if (!tr->b->interrupt_capable) goto done; =20 if (tr->set_lvt_off) { - if (lvt_off_valid(tr->b, tr->lvt_off, lo, hi)) { + if (lvt_off_valid(tr->b, tr->lvt_off, val.l, val.h)) { /* set new lvt offset */ - hi &=3D ~MASK_LVTOFF_HI; - hi |=3D tr->lvt_off << 20; + val.h &=3D ~MASK_LVTOFF_HI; + val.h |=3D tr->lvt_off << 20; } } =20 if (tr->b->interrupt_enable) - hi |=3D INT_TYPE_APIC; + val.h |=3D INT_TYPE_APIC; =20 done: =20 - hi |=3D MASK_COUNT_EN_HI; - wrmsr(tr->b->address, lo, hi); + val.h |=3D MASK_COUNT_EN_HI; + wrmsrq(tr->b->address, val.q); } =20 static void threshold_restart_bank(unsigned int bank, bool intr_en) @@ -726,7 +726,8 @@ static void smca_enable_interrupt_vectors(void) void mce_amd_feature_init(struct cpuinfo_x86 *c) { unsigned int bank, block, cpu =3D smp_processor_id(); - u32 low =3D 0, high =3D 0, address =3D 0; + struct msr val =3D { .q =3D 0 }; + u32 address =3D 0; int offset =3D -1; =20 amd_apply_cpu_quirks(c); @@ -746,21 +747,21 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) disable_err_thresholding(c, bank); =20 for (block =3D 0; block < NR_BLOCKS; ++block) { - address =3D get_block_address(address, low, high, bank, block, cpu); + address =3D get_block_address(address, val.l, val.h, bank, block, cpu); if (!address) break; =20 - if (rdmsr_safe(address, &low, &high)) + if (rdmsrq_safe(address, &val.q)) break; =20 - if (!(high & MASK_VALID_HI)) + if (!(val.h & MASK_VALID_HI)) continue; =20 - if (!(high & MASK_CNTP_HI) || - (high & MASK_LOCKED_HI)) + if (!(val.h & MASK_CNTP_HI) || + (val.h & MASK_LOCKED_HI)) continue; =20 - offset =3D prepare_threshold_block(bank, block, address, offset, high); + offset =3D prepare_threshold_block(bank, block, address, offset, val.h); } } } @@ -1083,24 +1084,24 @@ static int allocate_threshold_blocks(unsigned int cpu= , struct threshold_bank *tb u32 address) { struct threshold_block *b =3D NULL; - u32 low, high; + struct msr val; int err; =20 if ((bank >=3D this_cpu_read(mce_num_banks)) || (block >=3D NR_BLOCKS)) return 0; =20 - if (rdmsr_safe(address, &low, &high)) + if (rdmsrq_safe(address, &val.q)) return 0; =20 - if (!(high & MASK_VALID_HI)) { + if (!(val.h & MASK_VALID_HI)) { if (block) goto recurse; else return 0; } =20 - if (!(high & MASK_CNTP_HI) || - (high & MASK_LOCKED_HI)) + if (!(val.h & MASK_CNTP_HI) || + (val.h & MASK_LOCKED_HI)) goto recurse; =20 b =3D kzalloc_obj(struct threshold_block); @@ -1112,7 +1113,7 @@ static int allocate_threshold_blocks(unsigned int cpu, = struct threshold_bank *tb b->cpu =3D cpu; b->address =3D address; b->interrupt_enable =3D 0; - b->interrupt_capable =3D lvt_interrupt_supported(bank, high); + b->interrupt_capable =3D lvt_interrupt_supported(bank, val.h); b->threshold_limit =3D get_thr_limit(); =20 if (b->interrupt_capable) { @@ -1124,13 +1125,13 @@ static int allocate_threshold_blocks(unsigned int cpu= , struct threshold_bank *tb =20 list_add(&b->miscj, &tb->miscj); =20 - mce_threshold_block_init(b, (high & MASK_LVTOFF_HI) >> 20); + mce_threshold_block_init(b, (val.h & MASK_LVTOFF_HI) >> 20); =20 err =3D kobject_init_and_add(&b->kobj, &threshold_ktype, tb->kobj, get_name= (cpu, bank, b)); if (err) goto out_free; recurse: - address =3D get_block_address(address, low, high, bank, ++block, cpu); + address =3D get_block_address(address, val.l, val.h, bank, ++block, cpu); if (!address) return 0; =20 diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 9bba1e2..017aaf5 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1866,7 +1866,7 @@ static void __mcheck_cpu_init_generic(void) =20 rdmsrq(MSR_IA32_MCG_CAP, cap); if (cap & MCG_CTL_P) - wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff); + wrmsrq(MSR_IA32_MCG_CTL, ~0ULL); } =20 static void __mcheck_cpu_init_prepare_banks(void) diff --git a/arch/x86/kernel/cpu/mce/p5.c b/arch/x86/kernel/cpu/mce/p5.c index 2272ad5..eb99f38 100644 --- a/arch/x86/kernel/cpu/mce/p5.c +++ b/arch/x86/kernel/cpu/mce/p5.c @@ -23,16 +23,16 @@ int mce_p5_enabled __read_mostly; /* Machine check handler for Pentium class Intel CPUs: */ noinstr void pentium_machine_check(struct pt_regs *regs) { - u32 loaddr, hi, lotype; + u64 addr, type; =20 instrumentation_begin(); - rdmsr(MSR_IA32_P5_MC_ADDR, loaddr, hi); - rdmsr(MSR_IA32_P5_MC_TYPE, lotype, hi); + rdmsrq(MSR_IA32_P5_MC_ADDR, addr); + rdmsrq(MSR_IA32_P5_MC_TYPE, type); =20 pr_emerg("CPU#%d: Machine Check Exception: 0x%8X (type 0x%8X).\n", - smp_processor_id(), loaddr, lotype); + smp_processor_id(), (u32)addr, (u32)type); =20 - if (lotype & (1<<5)) { + if (type & (1<<5)) { pr_emerg("CPU#%d: Possible thermal failure (CPU on fire ?).\n", smp_processor_id()); } @@ -44,7 +44,7 @@ noinstr void pentium_machine_check(struct pt_regs *regs) /* Set up machine check reporting for processors with Intel style MCE: */ void intel_p5_mcheck_init(struct cpuinfo_x86 *c) { - u32 l, h; + u64 q; =20 /* Default P5 to off as its often misconnected: */ if (!mce_p5_enabled) @@ -55,8 +55,8 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c) return; =20 /* Read registers before enabling: */ - rdmsr(MSR_IA32_P5_MC_ADDR, l, h); - rdmsr(MSR_IA32_P5_MC_TYPE, l, h); + rdmsrq(MSR_IA32_P5_MC_ADDR, q); + rdmsrq(MSR_IA32_P5_MC_TYPE, q); pr_info("Intel old style machine check architecture supported.\n"); =20 /* Enable MCE: */ diff --git a/arch/x86/kernel/cpu/mce/winchip.c b/arch/x86/kernel/cpu/mce/winc= hip.c index 6c99f29..7040243 100644 --- a/arch/x86/kernel/cpu/mce/winchip.c +++ b/arch/x86/kernel/cpu/mce/winchip.c @@ -28,12 +28,12 @@ noinstr void winchip_machine_check(struct pt_regs *regs) /* Set up machine check reporting on the Winchip C6 series */ void winchip_mcheck_init(struct cpuinfo_x86 *c) { - u32 lo, hi; + struct msr val; =20 - rdmsr(MSR_IDT_FCR1, lo, hi); - lo |=3D (1<<2); /* Enable EIERRINT (int 18 MCE) */ - lo &=3D ~(1<<4); /* Enable MCE */ - wrmsr(MSR_IDT_FCR1, lo, hi); + rdmsrq(MSR_IDT_FCR1, val.q); + val.l |=3D (1<<2); /* Enable EIERRINT (int 18 MCE) */ + val.l &=3D ~(1<<4); /* Enable MCE */ + wrmsrq(MSR_IDT_FCR1, val.q); =20 cr4_set_bits(X86_CR4_MCE); =20