Re: [PATCH 05/32] x86/mtrr: Stop using 32-bit MSR interfaces

From: Jürgen Groß

Date: Mon Jun 29 2026 - 07:53:43 EST


On 29.06.26 13:33, Ingo Molnar wrote:

* Juergen Gross <jgross@xxxxxxxx> wrote:

amd_get_mtrr(unsigned int reg, unsigned long *base,
unsigned long *size, mtrr_type *type)
{
- unsigned long low, high;
+ unsigned long val;
+ struct msr msr;

So, 'struct msr' is defined in <asm/msr.h>, but:

static void
amd_set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type type)
{
- u32 regs[2];
+ union {
+ u32 regs[2];
+ u64 val;
+ } msr;

Why do we use a local anonymous union here with overlapping
nomenclature and a confusingly different but (AFAICS) functionally
equivalent definition to 'struct msr'?

This is done in order to avoid having to change the code too much. As an
alternative I could use struct msr by doing:

rdmsrq(MSR_K6_UWCCR, msr.q);
regs[0] = msr.l;
regs[1] = msr.h;

...

msr.l = regs[0];
msr.h = regs[1];
wrmsrq(MSR_K6_UWCCR, msr.q);


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature