lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c822cc63-3ff4-4edd-9416-015c52f9fb5b@amd.com>
Date:   Mon, 27 Nov 2023 09:52:35 -0500
From:   Yazen Ghannam <yazen.ghannam@....com>
To:     Borislav Petkov <bp@...en8.de>
Cc:     yazen.ghannam@....com, linux-edac@...r.kernel.org,
        linux-kernel@...r.kernel.org, tony.luck@...el.com, x86@...nel.org,
        Avadhut.Naik@....com, Smita.KoralahalliChannabasappa@....com,
        amd-gfx@...ts.freedesktop.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH 02/20] x86/mce: Define mce_setup() helpers for global and
 per-CPU fields

On 11/22/2023 1:24 PM, Borislav Petkov wrote:
> On Sat, Nov 18, 2023 at 01:32:30PM -0600, Yazen Ghannam wrote:
>> +void mce_setup_global(struct mce *m)
> 
> We usually call those things "common":
> 
> mce_setup_common().
> 
>> +{
>> +	memset(m, 0, sizeof(struct mce));
>> +
>> +	m->cpuid	= cpuid_eax(1);
>> +	m->cpuvendor	= boot_cpu_data.x86_vendor;
>> +	m->mcgcap	= __rdmsr(MSR_IA32_MCG_CAP);
>> +	/* need the internal __ version to avoid deadlocks */
>> +	m->time		= __ktime_get_real_seconds();
>> +}
>> +
>> +void mce_setup_per_cpu(struct mce *m)
> 
> And call this
> 
> 	mce_setup_for_cpu(unsigned int cpu, struct mce *m);
> 
> so that it doesn't look like some per_cpu helper.
> 
> And yes, you should supply the CPU number as an argument. Because
> otherwise, when you look at your next change:
> 
> 
> +       mce_setup_global(&m);
> +       m.cpu = m.extcpu = cpu;
> +       mce_setup_per_cpu(&m);
> 
> This contains the "hidden" requirement that m.extcpu happens *always*
> *before* the mce_setup_per_cpu() call and that is flaky and error prone.
> 
> So make that:
> 
> 	mce_setup_common(&m);
> 	mce_setup_for_cpu(m.extcpu, &m);
> 
> and do m.cpu = m.extcpu = cpu inside the second function.
> 
> And then it JustWorks(tm) and you can't "forget" assigning m.extcpu and
> there's no subtlety.
> 
> Ok?
> 

Yep, understood. Thanks!

-Yazen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ