public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sohil Mehta <sohil.mehta@intel.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	"H . Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Nikolay Borisov <nik.borisov@suse.com>,
	<linux-kernel@vger.kernel.org>, Borislav Petkov <bp@alien8.de>,
	<x86@kernel.org>
Subject: Re: [PATCH v4] scripts/x86/intel: Add a script to update the old microcode list
Date: Fri, 30 Jan 2026 15:09:35 -0800	[thread overview]
Message-ID: <d0835c59-7989-4d41-b63f-82f7da0e6fab@intel.com> (raw)
In-Reply-To: <98b13199-f427-4054-8f37-15b2219c1fa3@citrix.com>

On 1/30/2026 2:00 PM, Andrew Cooper wrote:
> On 30/01/2026 7:47 pm, Sohil Mehta wrote:
>> +# Functions to extract family, model, and stepping
>> +def bits(val, bottom, top):
>> +    mask = (1 << (top + 1 - bottom)) - 1
>> +    mask = mask << bottom
>> +    return (val & mask) >> bottom
> 
> return (val >> bottom) & mask
> 

Yup, that is better. Saves an extra step/line.


>> +# Prepare the microcode entries
>> +ucode_entries = []
>> +for ucode_key in ucode_dict:
>> +    rev = ucode_dict[ucode_key]
>> +    sig = rev['sig']
>> +    ucode_entries.append({
>> +        'family': family(sig),
>> +        'model': model(sig),
>> +        'steppings': 1 << step(sig),
>> +        'platforms': rev['platforms'],
>> +        'rev': rev['rev'],
>> +        'sig': sig
>> +    })
> 
> This is crying out for a small class, and for the use of set()
> 

> Try the attached version, which is rather more pythonic.

Thank you for improving the script. It looks cleaner and "pythonic". It
works for my usage with unique ucode files in a single directory.

Dave probably has a use case where he passes multiple directories to the
script. IIUC, the new version just inserts a unique entry for every FMS
+ pf_mask and skips the repeats. But it doesn't necessarily use the
latest revision for the duplicates. We probably need an equivalent logic
for this:

    if existing is not None:
        # If the existing one is newer, just move on:
        if existing['rev'] > rev['rev']:
            continue

Dave, opinion?

  reply	other threads:[~2026-01-30 23:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 19:47 [PATCH v4] scripts/x86/intel: Add a script to update the old microcode list Sohil Mehta
2026-01-30 22:00 ` Andrew Cooper
2026-01-30 23:09   ` Sohil Mehta [this message]
2026-02-02 18:01     ` Dave Hansen
2026-02-03 19:09       ` Sohil Mehta
2026-02-10 18:54 ` Luck, Tony

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d0835c59-7989-4d41-b63f-82f7da0e6fab@intel.com \
    --to=sohil.mehta@intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nik.borisov@suse.com \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox