x86/microcode/intel: Ensure new microcode processor flags match with cpu's pf
Subsystems (2)
PATCH 1/1 x86/microcode/intel: Ensure new microcode processor flags match with cpu's pf
Intel spec says: 'The processor flags in the 48-byte header and the processor flags field associated with the extended processor signature structures may have multiple bits set.'
Make sure processor flags of the new microcode intersect with current cpu's. Comparing with old microcode's pf can't guarantee this.
--- arch/x86/kernel/cpu/microcode/intel.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/microcode/intel.c +3 -5
@@ -371,12 +371,10 @@ static int microcode_sanity_check(void *mc, int print_err) goto next; }else { -struct microcode_header_intel *phdr = &patch->hdr; -if (!has_newer_microcode (data, - phdr->sig, - phdr->pf, - phdr->rev)) + uci->cpu_sig.sig, + uci->cpu_sig.pf, + patch->hdr.rev)) goto next; }
Signature · 1 line
1.7.3
Borislav Petkov
maintainerQuoted 23 lines · Zhenzhong Duan
Intel spec says: 'The processor flags in the 48-byte header and the processor flags field associated with the extended processor signature structures may have multiple bits set.'
Make sure processor flags of the new microcode intersect with current cpu's. Comparing with old microcode's pf can't guarantee this.
Signed-off-by Zhenzhong Duan <[email protected]>--- arch/x86/kernel/cpu/microcode/intel.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)arch/x86/kernel/cpu/microcode/intel.c +0
-2@@ -371,12 +371,10 @@ static int microcode_sanity_check(void *mc, int print_err) goto next; }else { -struct microcode_header_intel *phdr = &patch->hdr; -
arch/x86/kernel/cpu/microcode/intel.c static int microcode_sanity_check(void *mc, int print_err) · line 380
Quoted 10 lines
arch/x86/kernel/cpu/microcode/intel.c +3
-3if (!has_newer_microcode (data, - phdr->sig, - phdr->pf, - phdr->rev)) + uci->cpu_sig.sig, + uci->cpu_sig.pf, + patch->hdr.rev)) goto next; }
So I'm scratching my head over this and have no clue what you're trying to achieve. Is this a fix for a bug you're seeing or what? You'd need to be a lot more verbose when explaining what this patch is trying to do...
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 33 lines · Borislav Petkov
Quoted 32 lines · Zhenzhong Duan
Intel spec says: 'The processor flags in the 48-byte header and the processor flags field associated with the extended processor signature structures may have multiple bits set.'
Make sure processor flags of the new microcode intersect with current cpu's. Comparing with old microcode's pf can't guarantee this.
Signed-off-by Zhenzhong Duan <[email protected]>--- arch/x86/kernel/cpu/microcode/intel.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-)arch/x86/kernel/cpu/microcode/intel.c +3
-5@@ -371,12 +371,10 @@ static int microcode_sanity_check(void *mc, int print_err) goto next; }else { -struct microcode_header_intel *phdr = &patch->hdr; -if (!has_newer_microcode (data, - phdr->sig, - phdr->pf, - phdr->rev)) + uci->cpu_sig.sig, + uci->cpu_sig.pf, + patch->hdr.rev)) goto next; }
Quoted 5 lines
Quoted 1 line
So I'm scratching my head over this and have no clue what you're trying to achieve. Is this a fix for a bug you're seeing or what? You'd need to be a lot more verbose when explaining what this patch is trying to do...
Imagine kernel already found a microcode blob A with extended sig/pf matching current cpu, then another microcode B is checked which doesn't match current cpu but matches the sig/pf of microcode A, then microcode B will replaced A, but it's not suitable for current cpu.
I didn't see same issue in our system. When fixing another bug and reading upstream microcode code, I found this potential issue, feel free to correct me if it's never possible in reality.
Thanks
Zhenzhong
Borislav Petkov
maintainerQuoted 3 lines · Zhenzhong Duan
Imagine kernel already found a microcode blob A with extended sig/pf matching current cpu, then another microcode B is checked which doesn't match current cpu...
Do you see the
if (!microcode_matches(mc_header, uci->cpu_sig.sig)) {call a couple of lines earlier?
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 9 lines · Borislav Petkov
Quoted 3 lines · Zhenzhong Duan
Imagine kernel already found a microcode blob A with extended sig/pf matching current cpu, then another microcode B is checked which doesn't match current cpu...
Do you see the
if (!microcode_matches(mc_header, uci->cpu_sig.sig)) {call a couple of lines earlier?
Sure, but it didn't ensure a match in stepping and pf, is that expected?
Thanks
Zhenzhong
Borislav Petkov
maintainerQuoted 11 lines · Zhenzhong Duan
Quoted 9 lines · Borislav Petkov
Quoted 3 lines · Zhenzhong Duan
Imagine kernel already found a microcode blob A with extended sig/pf matching current cpu, then another microcode B is checked which doesn't match current cpu...
Do you see the
if (!microcode_matches(mc_header, uci->cpu_sig.sig)) {call a couple of lines earlier?
Sure, but it didn't ensure a match in stepping and pf, is that expected?
Do you see the
if (!has_newer_microcode(data,
uci->cpu_sig.sig,
uci->cpu_sig.pf,
uci->cpu_sig.rev))a couple lines later?
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.