x86/cpu: Cleanup for NX adjustments
cover x86/cpu: Cleanup for NX adjustments
I was hoping this to be a patch or two, but it got out of hand...
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287078891
https://gitlab.com/xen-project/hardware/xen-staging/-/commits/andrew/nx
The branch has one extra patch to fake up the firmware settings being set to Gitlab CI, not included in this series.
Julien: This ought to suitable to rebase your cleanup on to. In the end, I did the AMD adjustment mostly because I needed it to test the correctness of the prior cleanup.
The final 4 patches are tangential cleanup which I've kept out of the prior work in case we wish to backport it. Everything prior is relevant to untangling, and mostly for the benefit of the AMD side.
The early patches are hopefully non-controvertial. Later patches are a little more RFC, and in need of further testing.
Andrew Cooper (16):
x86/cpu: Fix boot time cache flushing
x86/cpu: Drop cpuid_level adjustment from generic_identify() x86/intel: Drop the paddr_bits workaround for P4 Nocona/Prescott CPUs x86/cpu: Fold generic_identify() into its single caller x86/cpu: Move per-CPU actions out of the vendor early_init() hook x86/cpu: Rework the vendor early_init() hooks to be __init x86/cpu: Call the vendor early_init() hook in early_cpu_init() xen/sysctl: Drop XEN_SYSCTL_get_cpu_levelling_caps x86/intel: Always check MSR_MISC_ENABLE on all CPUs x86/amd: Always probe and configure the masking MSRs x86/amd: Fix re-activation of TopoExt on Fam15h CPUs x86/amd: Probe for NX support and re-activate if possible x86/cpu: Drop NOISY_CAPS
x86/cpu: Drop default_init() and default_cpu
x86/cpu: Clean up use of LCAP_* constants
x86/cpuid: Drop the include of public/sysctl.h
CHANGELOG.md | 2 + tools/flask/policy/modules/dom0.te | 1 - tools/include/xenguest.h | 1 - tools/libs/guest/xg_cpuid_x86.c | 14 --- xen/arch/x86/boot/head.S | 1 - xen/arch/x86/boot/trampoline.S | 29 +++--- xen/arch/x86/boot/wakeup.S | 27 +++--- xen/arch/x86/cpu/amd.c | 107 ++++++++++++++------ xen/arch/x86/cpu/common.c | 135 +++++++++++++------------- xen/arch/x86/cpu/cpu.h | 7 +- xen/arch/x86/cpu/hygon.c | 2 + xen/arch/x86/cpu/intel.c | 74 ++++---------- xen/arch/x86/domain.c | 10 +- xen/arch/x86/flushtlb.c | 19 ++-- xen/arch/x86/include/asm/cpuid.h | 17 ++-- xen/arch/x86/include/asm/hvm/hvm.h | 2 + xen/arch/x86/include/asm/hvm/vlapic.h | 2 + xen/arch/x86/include/asm/hvm/vpt.h | 2 + xen/arch/x86/include/asm/trampoline.h | 7 +- xen/arch/x86/sysctl.c | 6 -- xen/include/public/sysctl.h | 22 +---- xen/xsm/flask/hooks.c | 4 - xen/xsm/flask/policy/access_vectors | 2 - 23 files changed, 238 insertions(+), 255 deletions(-)
Signature · 1 line
2.39.5
PATCH 1/16 x86/cpu: Fix boot time cache flushing
All 64-bit CPUs have CLFLUSH. AMD introduced it in the K8, Intel in the P4 Willamette core prior to 64-bit support, and VIA/Centaur in the Isaiah. Furthermore, the reported cacheline size is 64 on all CPUs to date.
Arguably changeset 19435c10abf7 ("x86: consolidate/enhance TLB flushing interface", 2007) should have initialised c->x86_clflush_size earlier, but even at the time of changeset 3330013e6739 ("VT-d / x86: re-arrange cache syncing", 2022), early_cpu_init() had CLFLUSH-parsing logic but simply failed to record the size.
By removing get_cache_line_size() and assuming 16 bytes, the practical consequence for early IOMMU initialisation of SandyBridge era systems is to flush every cacheline 4 times (a pipeline stall too, as those CPUs could only have one flush in flight at a single time).
Record c->x86_clflush_size in early_cpu_init(), and panic() if CLFLUSH isn't found. Drop the redundant initialisation of c->x86_cache_alignment.
Remove the fallback to 16 bytes in cache_{flush,writeback}(), opting instead for an ASSERT() to confirm that the logic hasn't been re-arranged too early.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/common.c | 7 ++++--- xen/arch/x86/flushtlb.c | 19 +++++++------------ 2 files changed, 11 insertions(+), 15 deletions(-)
xen/arch/x86/cpu/common.c +4 -3
@@ -319,8 +319,6 @@ void __init early_cpu_init(bool verbose)uint64_t val;u32 eax, ebx, ecx, edx; - c->x86_cache_alignment =32 ; -/* Get vendor name */ cpuid (0x00000000 , &c->cpuid_level, &ebx, &ecx, &edx); *(u32 *)&c->x86_vendor_id[0 ] = ebx;
@@ -352,6 +350,7 @@ void __init early_cpu_init(bool verbose)if (edx &cpufeat_mask (X86_FEATURE_CLFLUSH )) {unsigned int size = ((ebx >>8 ) &0xff ) *8 ; + c->x86_clflush_size = size; c->x86_cache_alignment = size;/*
@@ -380,7 +379,9 @@ void __init early_cpu_init(bool verbose) }else setup_clear_cpu_cap (X86_FEATURE_CLZERO ); - } + }else +panic ("CLFLUSH information not available\n" ); +/* Leaf 0x1 capabilities filled in early for Xen. */ c->x86_capability[FEATURESET_1d] = edx; c->x86_capability[FEATURESET_1c] = ecx;
xen/arch/x86/flushtlb.c +7 -12
@@ -234,8 +234,7 @@ unsigned int flush_area_local(const void *va, unsigned int flags)if ( (!(flags & (FLUSH_TLB |FLUSH_TLB_GLOBAL )) || (flags &FLUSH_VA_VALID )) && - c->x86_clflush_size && c->x86_cache_size && sz && - ((sz >>10 ) < c->x86_cache_size) ) + c->x86_cache_size && sz && ((sz >>10 ) < c->x86_cache_size) ) {if ( flags &FLUSH_CACHE_EVICT )cache_flush (va, sz);
@@ -264,13 +263,11 @@ unsigned int flush_area_local(const void *va, unsigned int flags)*/ void cache_flush (const void *addr,unsigned int size) { -/* -* This function may be called before current_cpu_data is established. -* Hence a fallback is needed to prevent the loop below becoming infinite. -*/ -unsigned int clflush_size = current_cpu_data.x86_clflush_size ?:16 ; +unsigned int clflush_size = current_cpu_data.x86_clflush_size;const void *end = addr + size; +ASSERT (clflush_size); +alternative ("" ,"mfence" ,X86_BUG_CLFLUSH_MFENCE ); addr -= (unsigned long )addr & (clflush_size -1 );
@@ -301,11 +298,9 @@ void cache_writeback(const void *addr, unsigned int size)if ( !boot_cpu_has (X86_FEATURE_CLWB ) )return cache_flush (addr, size); -/* -* This function may be called before current_cpu_data is established. -* Hence a fallback is needed to prevent the loop below becoming infinite. -*/ - clflush_size = current_cpu_data.x86_clflush_size ?:16 ; + clflush_size = current_cpu_data.x86_clflush_size; +ASSERT (clflush_size); + addr -= (unsigned long )addr & (clflush_size -1 );for ( ; addr < end; addr += clflush_size )clwb (addr);
Signature · 1 line
2.39.5
Re: [PATCH 01/16] x86/cpu: Fix boot time cache flushing
Quoted 12 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +0
-2@@ -319,8 +319,6 @@ void __init early_cpu_init(bool verbose)uint64_t val;u32 eax, ebx, ecx, edx; - c->x86_cache_alignment =32 ; -/* Get vendor name */ cpuid (0x00000000 , &c->cpuid_level, &ebx, &ecx, &edx); *(u32 *)&c->x86_vendor_id[0 ] = ebx;
xen/arch/x86/cpu/common.c void __init early_cpu_init(bool verbose) · line 354
Quoted 5 lines
xen/arch/x86/cpu/common.c +1
-0@@ -352,6 +350,7 @@ void __init early_cpu_init(bool verbose)if (edx &cpufeat_mask (X86_FEATURE_CLFLUSH )) {unsigned int size = ((ebx >>8 ) &0xff ) *8 ; + c->x86_clflush_size = size; c->x86_cache_alignment = size;
With this change, can't the writing of the field in generic_identify() go away? CPU_DATA_INIT() in particular doesn't invalidate it. Perferably with that dropped (unless of course there is a reason not to):
Tangentially, "cpuid=no-clflush" didn't have any effect on any of this so far, and also isn't going to have with the changes you make.
Jan
Re: [PATCH 01/16] x86/cpu: Fix boot time cache flushing
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +0
-2@@ -319,8 +319,6 @@ void __init early_cpu_init(bool verbose)uint64_t val;u32 eax, ebx, ecx, edx; - c->x86_cache_alignment =32 ; -/* Get vendor name */ cpuid (0x00000000 , &c->cpuid_level, &ebx, &ecx, &edx); *(u32 *)&c->x86_vendor_id[0 ] = ebx;@@ -352,6 +350,7 @@ void __init early_cpu_init(bool verbose)if (edx &cpufeat_mask (X86_FEATURE_CLFLUSH )) {unsigned int size = ((ebx >>8 ) &0xff ) *8 ;
Quoted 4 lines
xen/arch/x86/cpu/common.c void __init early_cpu_init(bool verbose) · line 354
Quoted 2 lines
xen/arch/x86/cpu/common.c +1
-0+ c->x86_clflush_size = size; c->x86_cache_alignment = size;With this change, can't the writing of the field in
generic_identify()go away?CPU_DATA_INIT()in particular doesn't invalidate it.
No, it can't. The value needs setting up on every AP, right now at least.
Quoted 3 lines
Perferably
with that dropped (unless of course there is a reason not to):Reviewed-by Jan Beulich <[email protected]>
Hopefully this is a good enough reason. I know we agreed to make it a single global, but that's future work.
Quoted 3 lines
Tangentially, "cpuid=no-clflush" didn't have any effect on any of this so far, and also isn't going to have with the changes you make.
The line immediately out of context above will applies the clear cap mask, so will cause cpuid=no-clflush to take effect.
~Andrew
Re: [PATCH 01/16] x86/cpu: Fix boot time cache flushing
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +0
-2@@ -319,8 +319,6 @@ void __init early_cpu_init(bool verbose)uint64_t val;u32 eax, ebx, ecx, edx; - c->x86_cache_alignment =32 ; -/* Get vendor name */ cpuid (0x00000000 , &c->cpuid_level, &ebx, &ecx, &edx); *(u32 *)&c->x86_vendor_id[0 ] = ebx;@@ -352,6 +350,7 @@ void __init early_cpu_init(bool verbose)if (edx &cpufeat_mask (X86_FEATURE_CLFLUSH )) {unsigned int size = ((ebx >>8 ) &0xff ) *8 ;
Quoted 6 lines
Quoted 4 lines
xen/arch/x86/cpu/common.c void __init early_cpu_init(bool verbose) · line 354
Quoted 2 lines
xen/arch/x86/cpu/common.c +1
-0+ c->x86_clflush_size = size; c->x86_cache_alignment = size;With this change, can't the writing of the field in
generic_identify()go away?CPU_DATA_INIT()in particular doesn't invalidate it.No, it can't. The value needs setting up on every AP, right now at least.
Are you sure? APs inherit part of the BSP's data (initialize_cpu_data()), and reset_cpuinfo() doesn't clear ->x86_clflush_size afaics.
Quoted 5 lines
Quoted 2 lines
Tangentially, "cpuid=no-clflush" didn't have any effect on any of this so far, and also isn't going to have with the changes you make.
The line immediately out of context above will applies the clear cap mask, so will cause cpuid=no-clflush to take effect.
This concerns me. With your change, "cpuid=no-clflush" will lead to an unconditional panic() then. Whereas previously, with cleared_caps[] being applied by identify_cpu() only after generic_identify() has already evaluated the CLFLUSH bit, there was no effect at all.
I don't think this panic()ing is desirable, but as an absolute minimum this (drastic) change in behavior would want calling out in the description.
Further, if the panic() was to stay, there's no point having cpu_has_clflush evaluate to anything other than constant true anymore.
Again tangentially (and partly the reason why I overlooked that aspect originally): While early_cpu_init() respects cleared_caps[] for leaf 1, it doesn't for any of leaf 7's subleaves, nor for ARCH_CAPS.
Jan
Re: [PATCH 01/16] x86/cpu: Fix boot time cache flushing
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +0
-2@@ -319,8 +319,6 @@ void __init early_cpu_init(bool verbose)uint64_t val;u32 eax, ebx, ecx, edx; - c->x86_cache_alignment =32 ; -/* Get vendor name */ cpuid (0x00000000 , &c->cpuid_level, &ebx, &ecx, &edx); *(u32 *)&c->x86_vendor_id[0 ] = ebx;@@ -352,6 +350,7 @@ void __init early_cpu_init(bool verbose)if (edx &cpufeat_mask (X86_FEATURE_CLFLUSH )) {unsigned int size = ((ebx >>8 ) &0xff ) *8 ;
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
xen/arch/x86/cpu/common.c void __init early_cpu_init(bool verbose) · line 354
Quoted 2 lines
xen/arch/x86/cpu/common.c +1
-0+ c->x86_clflush_size = size; c->x86_cache_alignment = size;With this change, can't the writing of the field in
generic_identify()go away?CPU_DATA_INIT()in particular doesn't invalidate it.No, it can't. The value needs setting up on every AP, right now at least.
Are you sure? APs inherit part of the BSP's data (
initialize_cpu_data()), andreset_cpuinfo()doesn't clear ->x86_clflush_size afaics.
Every time I look at that, it gets more insane.
For every CPU, initialize_cpu_data() clobbers boot_cpu_data, *then* copies the result into cpu_data[] array.
This cannot possibly be correct. Why on earth did I ack it?
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Tangentially, "cpuid=no-clflush" didn't have any effect on any of this so far, and also isn't going to have with the changes you make.
The line immediately out of context above will applies the clear cap mask, so will cause cpuid=no-clflush to take effect.
This concerns me. With your change, "cpuid=no-clflush" will lead to an unconditional
panic()then.
So will no-cmpxchg8b. The only reason no-lm won't is because that's evaluated before parsing the cmdline.
Quoted 3 lines
Whereas previously, with cleared_caps[] being
applied byidentify_cpu()only aftergeneric_identify()has already evaluated the CLFLUSH bit, there was no effect at all.
That wasn't no effect. The effect (upon request of an impossible thing) would be that part of Xen would have ignored the request and functioned, but another part of Xen would have propagated that to guests, which will probably have equally rude things to say.
Quoted 5 lines
I don't think this panic()ing is desirable, but as an absolute minimum this (drastic) change in behavior would want calling out in the description.
Further, if the
panic()was to stay, there's no point havingcpu_has_clflushevaluate to anything other than constant true anymore.
I'm not overly interested in users complaining about a panic() if they ask for an impossible thing. Better that than the prior behaviour we had.
Talking of other impossible things, cpuid=no-$foo does nothing for FPU/DE/PSE/PGE or MMX which are the features hard wired to 1 already, and with 0 users in the tree.
Again, Xen will assume the safe thing, but pass the impossible request on to guests.
Quoted 3 lines
Again tangentially (and partly the reason why I overlooked that aspect originally): While
early_cpu_init()respects cleared_caps[] for leaf 1, it doesn't for any of leaf 7's subleaves, nor forARCH_CAPS.
No idea. I stopped doing archaeology on all the wrong-looking things I found, because there are just too many of them.
~Andrew
Re: [PATCH 01/16] x86/cpu: Fix boot time cache flushing
Quoted 27 lines · Andrew Cooper
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +0
-2@@ -319,8 +319,6 @@ void __init early_cpu_init(bool verbose)uint64_t val;u32 eax, ebx, ecx, edx; - c->x86_cache_alignment =32 ; -/* Get vendor name */ cpuid (0x00000000 , &c->cpuid_level, &ebx, &ecx, &edx); *(u32 *)&c->x86_vendor_id[0 ] = ebx;@@ -352,6 +350,7 @@ void __init early_cpu_init(bool verbose)if (edx &cpufeat_mask (X86_FEATURE_CLFLUSH )) {unsigned int size = ((ebx >>8 ) &0xff ) *8 ;Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
xen/arch/x86/cpu/common.c void __init early_cpu_init(bool verbose) · line 354
Quoted 2 lines
xen/arch/x86/cpu/common.c +1
-0+ c->x86_clflush_size = size; c->x86_cache_alignment = size;With this change, can't the writing of the field in
generic_identify()go away?CPU_DATA_INIT()in particular doesn't invalidate it.No, it can't. The value needs setting up on every AP, right now at least.
Are you sure? APs inherit part of the BSP's data (
initialize_cpu_data()), andreset_cpuinfo()doesn't clear ->x86_clflush_size afaics.
Quoted 6 lines
Every time I look at that, it gets more insane.
For every CPU,
initialize_cpu_data()clobbersboot_cpu_data, *then* copies the result into cpu_data[] array.This cannot possibly be correct. Why on earth did I ack it?
I wonder what you're looking at. My initialize_cpu_data() has
struct cpuinfo_x86 c = boot_cpu_data;
which means a copy is being made, the address of which is then handed to reset_cpuinfo().
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Tangentially, "cpuid=no-clflush" didn't have any effect on any of this so far, and also isn't going to have with the changes you make.
The line immediately out of context above will applies the clear cap mask, so will cause cpuid=no-clflush to take effect.
This concerns me. With your change, "cpuid=no-clflush" will lead to an unconditional
panic()then.So will no-cmpxchg8b.
Which doesn't make the situation any better. (I think you mean no-cmpxchg16b though?)
Quoted 8 lines
Quoted 3 lines
Whereas previously, with cleared_caps[] being
applied byidentify_cpu()only aftergeneric_identify()has already evaluated the CLFLUSH bit, there was no effect at all.That wasn't no effect. The effect (upon request of an impossible thing) would be that part of Xen would have ignored the request and functioned, but another part of Xen would have propagated that to guests, which will probably have equally rude things to say.
Well, I thought it was clear from context that I meant "no effect for Xen itself". As to guests - as long as they're properly checking CPUID bits and refrain from using insns which CPUID says aren't available, I don't see why they should get upset.
When knowing one may run virtualized, the concept of "I know one feature (e.g. LM) implies another (e.g. CLFLUSH)" is flawed. Any combination of features can be surfaced, so long as true dependencies between them are respected. IOW I disagree with "cpuid=no-clflush" requesting an impossible thing. "cpuid=no-lm", otoh, does for a 64-bit target environment.
Quoted 6 lines
Quoted 5 lines
I don't think this panic()ing is desirable, but as an absolute minimum this (drastic) change in behavior would want calling out in the description.
Further, if the
panic()was to stay, there's no point havingcpu_has_clflushevaluate to anything other than constant true anymore.
Quoted 6 lines
I'm not overly interested in users complaining about a
panic()if they ask for an impossible thing. Better that than the prior behaviour we had.Talking of other impossible things, cpuid=no-$foo does nothing for FPU/DE/PSE/PGE or MMX which are the features hard wired to 1 already, and with 0 users in the tree.
Indeed, and while there is that "Currently accepted:" section in the doc, I can't help thinking that even for the speculation control aspect that it explicitly names it has already gone stale. Yes, in the past we said we'd mean to not support use of arbitrary forms of this option, yet
"Unless otherwise noted, options only have any effect in their negative form,
to hide the named feature(s). Ignoring a feature using this mechanism will cause Xen not to use the feature, nor offer them as usable to guests."
to me really says otherwise. Even if intended to be thus restricted, it would then feel rather odd that we implement support for an option with hundreds of sub-options, out of which only a handful are supposed to be possibly used.
On concrete example where a presently not explicitly permitted form could be useful to people is "no-rdseed" on AMD hardware affected by one of the two known issues (patches sadly still only pending). This viable mitigation would be unsupported by your implied interpretation.
Jan
PATCH 2/16 x86/cpu: Drop cpuid_level adjustment from generic_identify()
In reply to Andrew Cooperearly_cpu_init() calls intel_unlock_cpuid_leaves(), which arranges for the boot trampoline to make the adjustment for all APs, meaning the call from early_init_intel() is a no-op. Drop it, allowing intel_unlock_cpuid_leaves() to become __init code.
In turn, the adjustments in generic_identify() were a no-op too. Nothing in the c_early_init() hooks modifies the 1c/1d features, so their values in c->x86_capability[] are still good from just above.
The ebx variable used to calculate c->x86_clflush_size is still good too, but move the logic earlier so it's more obviously correct.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/common.c | 10 +--------- xen/arch/x86/cpu/intel.c | 4 +--- 2 files changed, 2 insertions(+), 12 deletions(-)
xen/arch/x86/cpu/common.c +1 -9
@@ -479,6 +479,7 @@ static void generic_identify(struct cpuinfo_x86 *c)cpuid (1 , &eax, &ebx, &ecx, &edx); c->x86 =get_cpu_family (eax, &c->x86_model, &c->x86_mask); c->apicid =phys_pkg_id ((ebx >>24 ) &0xFF ,0 ); + c->x86_clflush_size = ((ebx >>8 ) &0xff ) *8 ; c->phys_proc_id = c->apicid;/*
@@ -502,15 +503,6 @@ static void generic_identify(struct cpuinfo_x86 *c)if (actual_cpu.c_early_init)alternative_vcall (actual_cpu.c_early_init, c); -/* c_early_init() may have adjusted cpuid levels/features. Reread. */ - c->cpuid_level =cpuid_eax (0 ); -cpuid (1 , &eax, &ebx, - &c->x86_capability[FEATURESET_1c], - &c->x86_capability[FEATURESET_1d]); - -if (cpu_has (c,X86_FEATURE_CLFLUSH ) ) - c->x86_clflush_size = ((ebx >>8 ) &0xff ) *8 ; -/* AMD-defined flags: level 0x80000001 */ if (c->extended_cpuid_level >=0x80000001 ) cpuid(0x80000001, &tmp, &tmp,
xen/arch/x86/cpu/intel.c +1 -3
@@ -310,7 +310,7 @@ static void __init noinline intel_init_levelling(void) }/* Unmask CPUID levels if masked. */ -void intel_unlock_cpuid_leaves (struct cpuinfo_x86 *c) +void __init intel_unlock_cpuid_leaves (struct cpuinfo_x86 *c) {uint64_t misc_enable, disable;
@@ -335,8 +335,6 @@ static void cf_check early_init_intel(struct cpuinfo_x86 *c) bootsym(trampoline_misc_enable_off) & MSR_IA32_MISC_ENABLE_XD_DISABLE)printk (KERN_INFO "re-enabled NX (Execute Disable) protection\n" ); -intel_unlock_cpuid_leaves (c); -/* CPUID workaround for Intel 0F33/0F34 CPU */ if (boot_cpu_data.x86 ==0xF && boot_cpu_data.x86_model ==3 && (boot_cpu_data.x86_mask ==3 || boot_cpu_data.x86_mask ==4 ))
Signature · 1 line
2.39.5
Re: [PATCH 02/16] x86/cpu: Drop cpuid_level adjustment from generic_identify()
Quoted 2 lines · Andrew Cooper
early_cpu_init()callsintel_unlock_cpuid_leaves(), which arranges for the boot trampoline
And, not to neglect, also the S3 wakeup entry point.
Quoted 10 lines
to make the adjustment for all APs, meaning the call from
early_init_intel()is a no-op. Drop it, allowingintel_unlock_cpuid_leaves()to become__initcode.In turn, the adjustments in
generic_identify()were a no-op too. Nothing in thec_early_init()hooks modifies the 1c/1d features, so their values in c->x86_capability[] are still good from just above.The ebx variable used to calculate
c->x86_clflush_sizeis still good too, but move the logic earlier so it's more obviously correct.
This part likely can be dropped when the pending adjustment to patch 1 is done.
Quoted 2 lines
Fixes fa4d026737a4 ("x86/Intel: unlock CPUID earlier for the BSP")Signed-off-by Andrew Cooper <[email protected]>
Suitably adjusted:
Jan
PATCH 3/16 x86/intel: Drop the paddr_bits workaround for P4 Nocona/Prescott CPUs
In reply to Andrew CooperThese are 32bit CPUs only. 64bit support started with model 4 (Prescott-256).
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
CC: Kevin Lampis <[email protected]>
This ideally wants backporting to 4.20 along with the rest of the VFM cleanup in order to support DMR/NVL, which ends with removing the x86_ prefixed names.
--- xen/arch/x86/cpu/intel.c | 5 ----- 1 file changed, 5 deletions(-)
xen/arch/x86/cpu/intel.c +0 -5
@@ -335,11 +335,6 @@ static void cf_check early_init_intel(struct cpuinfo_x86 *c) bootsym(trampoline_misc_enable_off) & MSR_IA32_MISC_ENABLE_XD_DISABLE)printk (KERN_INFO "re-enabled NX (Execute Disable) protection\n" ); -/* CPUID workaround for Intel 0F33/0F34 CPU */ -if (boot_cpu_data.x86 ==0xF && boot_cpu_data.x86_model ==3 && - (boot_cpu_data.x86_mask ==3 || boot_cpu_data.x86_mask ==4 )) - paddr_bits =36 ; -if (c == &boot_cpu_data) {uint64_t misc_enable;
Signature · 1 line
2.39.5
Re: [PATCH 03/16] x86/intel: Drop the paddr_bits workaround for P4 Nocona/Prescott CPUs
Quoted 1 line · Andrew Cooper
These are 32bit CPUs only. 64bit support started with model 4 (Prescott-256).
It turns out that this isn't true. These CPUs did have Long Mode.
I'll need to rework this patch into a later one.
~Andrew
PATCH 4/16 x86/cpu: Fold generic_identify() into its single caller
In reply to Andrew CooperThis makes the correctness of future changes more obvious.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/common.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
xen/arch/x86/cpu/common.c +4 -12
@@ -455,10 +455,13 @@ void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic)CPU_DATA_INIT ((*c)); } -static void generic_identify (struct cpuinfo_x86 *c) +void identify_cpu (struct cpuinfo_x86 *c) {uint64_t val;u32 eax, ebx, ecx, edx, tmp; +int i; + +reset_cpuinfo (c, false);/* Get vendor name */ cpuid (0 , &c->cpuid_level, &ebx, &ecx, &edx);
@@ -550,17 +553,6 @@ static void generic_identify(struct cpuinfo_x86 *c) c->x86_capability[FEATURESET_m10Al] = val; c->x86_capability[FEATURESET_m10Ah] = val >>32 ; } -} - -/* -* This does the hard work of actually picking apart the CPU stuff... -*/ -void identify_cpu (struct cpuinfo_x86 *c) -{ -int i; - -reset_cpuinfo (c, false); -generic_identify (c);#ifdef NOISY_CAPS printk (KERN_DEBUG "CPU: After vendor identify, caps:" );
Signature · 1 line
2.39.5
Re: [PATCH 04/16] x86/cpu: Fold generic_identify() into its single caller
Quoted 5 lines · Andrew Cooper
This makes the correctness of future changes more obvious.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Especially with the way the diff is presented, could I talk you into ...
xen/arch/x86/cpu/common.c void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic) · line 462
Quoted 12 lines
xen/arch/x86/cpu/common.c +2
-1@@ -455,10 +455,13 @@ void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic)CPU_DATA_INIT ((*c)); } -static void generic_identify (struct cpuinfo_x86 *c) +void identify_cpu (struct cpuinfo_x86 *c) {uint64_t val;u32 eax, ebx, ecx, edx, tmp; +int i;
... taking the opportunity and make this unsigned int?
Jan
Re: [PATCH 04/16] x86/cpu: Fold generic_identify() into its single caller
In reply to Andrew CooperQuoted 25 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +4
-5@@ -455,10 +455,13 @@ void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic)CPU_DATA_INIT ((*c)); } -static void generic_identify (struct cpuinfo_x86 *c) +void identify_cpu (struct cpuinfo_x86 *c) {uint64_t val;u32 eax, ebx, ecx, edx, tmp; +int i; + +reset_cpuinfo (c, false);/* Get vendor name */ cpuid (0 , &c->cpuid_level, &ebx, &ecx, &edx);@@ -550,17 +553,6 @@ static void generic_identify(struct cpuinfo_x86 *c) c->x86_capability[FEATURESET_m10Al] = val; c->x86_capability[FEATURESET_m10Ah] = val >>32 ; } -} - -/* -* This does the hard work of actually picking apart the CPU stuff...
xen/arch/x86/cpu/common.c static void generic_identify(struct cpuinfo_x86 *c) · line 558
Quoted 10 lines
xen/arch/x86/cpu/common.c +0
-7-*/ -void identify_cpu (struct cpuinfo_x86 *c) -{ -int i; - -reset_cpuinfo (c, false); -generic_identify (c);#ifdef NOISY_CAPS printk (KERN_DEBUG "CPU: After vendor identify, caps:" );
To aid reducing the gap between the calls of .c_early_init() and .c_init() (that the next patch's description talks about), wouldn't it make sense to also drop this NOISY_CAPS thingy right here? The log message saying "After vendor identify" isn't quite accurate anyway.
Jan
Re: [PATCH 04/16] x86/cpu: Fold generic_identify() into its single caller
Quoted 34 lines · Jan Beulich
Quoted 33 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +4
-12@@ -455,10 +455,13 @@ void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic)CPU_DATA_INIT ((*c)); } -static void generic_identify (struct cpuinfo_x86 *c) +void identify_cpu (struct cpuinfo_x86 *c) {uint64_t val;u32 eax, ebx, ecx, edx, tmp; +int i; + +reset_cpuinfo (c, false);/* Get vendor name */ cpuid (0 , &c->cpuid_level, &ebx, &ecx, &edx);@@ -550,17 +553,6 @@ static void generic_identify(struct cpuinfo_x86 *c) c->x86_capability[FEATURESET_m10Al] = val; c->x86_capability[FEATURESET_m10Ah] = val >>32 ; } -} - -/* -* This does the hard work of actually picking apart the CPU stuff... -*/ -void identify_cpu (struct cpuinfo_x86 *c) -{ -int i; - -reset_cpuinfo (c, false); -generic_identify (c);
Quoted 6 lines
xen/arch/x86/cpu/common.c static void generic_identify(struct cpuinfo_x86 *c) · line 558
Quoted 2 lines
xen/arch/x86/cpu/common.c +0
-0#ifdef NOISY_CAPS printk (KERN_DEBUG "CPU: After vendor identify, caps:" );To aid reducing the gap between the calls of .c_early_init() and .c_init() (that the next patch's description talks about), wouldn't it make sense to also drop this
NOISY_CAPSthingy right here? The log message saying "After vendor identify" isn't quite accurate anyway.
See patch 13.
I put it later because it probably doesn't want backporting, and this might.
~Andrew
PATCH 5/16 x86/cpu: Move per-CPU actions out of the vendor early_init() hook
In reply to Andrew Coopercpu_dev.c_early_init() and .c_init() is a spilt we inherited from Linux.
In Xen, these are called moments apart in identify_cpu(). The only logic between the two calls is filling part of c->x86_capability[] and collecting the the long model name.
We are going to want to repurpose .c_early_init() somewhat, so move the logic wanting running on all CPUs to the .c_init() hook, which is only marginally later.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/amd.c | 4 ++-- xen/arch/x86/cpu/hygon.c | 2 ++ xen/arch/x86/cpu/intel.c | 12 ++++++------ 3 files changed, 10 insertions(+), 8 deletions(-)
xen/arch/x86/cpu/amd.c +2 -2
@@ -621,8 +621,6 @@ void cf_check early_init_amd(struct cpuinfo_x86 *c) {if (c == &boot_cpu_data)amd_init_levelling (); - -ctxt_switch_levelling (NULL ); }void amd_log_freq (const struct cpuinfo_x86 *c)
@@ -1018,6 +1016,8 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)u32 l, h;uint64_t value; +ctxt_switch_levelling (NULL ); +amd_init_de_cfg (c);if (c == &boot_cpu_data)
xen/arch/x86/cpu/hygon.c +2 -0
@@ -32,6 +32,8 @@ static void cf_check init_hygon(struct cpuinfo_x86 *c) {unsigned long long value; +ctxt_switch_levelling (NULL ); +amd_init_de_cfg (c);if (c == &boot_cpu_data)
xen/arch/x86/cpu/intel.c +6 -6
@@ -327,10 +327,6 @@ void __init intel_unlock_cpuid_leaves(struct cpuinfo_x86 *c) static void cf_check early_init_intel(struct cpuinfo_x86 *c) { -/* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */ -if (c->x86 ==15 && c->x86_cache_alignment ==64 ) - c->x86_cache_alignment =128 ; -if (c == &boot_cpu_data &&bootsym (trampoline_misc_enable_off) &MSR_IA32_MISC_ENABLE_XD_DISABLE )printk (KERN_INFO "re-enabled NX (Execute Disable) protection\n" );
@@ -350,8 +346,6 @@ static void cf_check early_init_intel(struct cpuinfo_x86 *c)intel_init_levelling (); } - -ctxt_switch_levelling (NULL ); }/*
@@ -615,6 +609,12 @@ static void init_intel_perf(struct cpuinfo_x86 *c) static void cf_check init_intel(struct cpuinfo_x86 *c) { +/* Netburst reports 64 bytes clflush size, but does IO in 128 bytes */ +if (c->x86 ==15 && c->x86_cache_alignment ==64 ) + c->x86_cache_alignment =128 ; + +ctxt_switch_levelling (NULL ); +/* Detect the extended topology information if available */ detect_extended_topology (c);
Signature · 1 line
2.39.5
Re: [PATCH 05/16] x86/cpu: Move per-CPU actions out of the vendor early_init() hook
Quoted 6 lines · Andrew Cooper
cpu_dev.c_early_init()and .c_init() is a spilt we inherited from Linux.In Xen, these are called moments apart in
identify_cpu(). The only logic between the two calls is filling part of c->x86_capability[] and collecting the the long model name.
Quoted 7 lines
We are going to want to repurpose .c_early_init() somewhat, so move the logic wanting running on all CPUs to the .c_init() hook, which is only marginally later.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
PATCH 6/16 x86/cpu: Rework the vendor early_init() hooks to be __init
In reply to Andrew CooperAll interior actions are now conditional on c == &boot_cpu_data, so rearrange it to the caller in identify_cpu() and drop the hook parameter.
This allows early_init_$VENDOR() to become __init, which in turn allows $VENDOR_init_levelling() to cease being noinline.
Reposition the early_init_intel() function simply to make diff legible.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/amd.c | 7 +++---- xen/arch/x86/cpu/common.c | 4 ++-- xen/arch/x86/cpu/cpu.h | 4 ++-- xen/arch/x86/cpu/intel.c | 42 +++++++++++++++++---------------------- 4 files changed, 25 insertions(+), 32 deletions(-)
xen/arch/x86/cpu/amd.c +3 -4
@@ -224,7 +224,7 @@ static const typeof(ctxt_switch_masking) __initconst_cf_clobber __used csm =* avoid this, as the accidentally-advertised features will not actually * function. */ -static void __init noinline amd_init_levelling(void) +static void __init amd_init_levelling (void ) {/* * If there's support for CpuidUserDis or CPUID faulting then
@@ -617,10 +617,9 @@ void amd_process_freq(const struct cpuinfo_x86 *c, *low_mhz =amd_parse_freq (c->x86, lo); } -void cf_check early_init_amd(struct cpuinfo_x86 *c) +void __init cf_check early_init_amd(void) { -if (c == &boot_cpu_data) -amd_init_levelling (); +amd_init_levelling (); }void amd_log_freq (const struct cpuinfo_x86 *c)
xen/arch/x86/cpu/common.c +2 -2
@@ -503,8 +503,8 @@ void identify_cpu(struct cpuinfo_x86 *c)if (c->extended_cpuid_level >=0x80000021 ) c->x86_capability[FEATURESET_e21a] =cpuid_eax (0x80000021 ); -if (actual_cpu.c_early_init) -alternative_vcall (actual_cpu.c_early_init, c); +if (c == &boot_cpu_data && actual_cpu.c_early_init) +alternative_vcall (actual_cpu.c_early_init);/* AMD-defined flags: level 0x80000001 */ if (c->extended_cpuid_level >=0x80000001 )
xen/arch/x86/cpu/cpu.h +2 -2
@@ -4,7 +4,7 @@#define X86_CPU_H struct cpu_dev { -void (*c_early_init)(struct cpuinfo_x86 *c); +void (*c_early_init)(void );void (*c_init)(struct cpuinfo_x86 * c); };
@@ -19,7 +19,7 @@ extern void display_cacheinfo(struct cpuinfo_x86 *c);extern void detect_ht (struct cpuinfo_x86 *c);extern bool detect_extended_topology (struct cpuinfo_x86 *c); -void cf_check early_init_amd(struct cpuinfo_x86 *c); +void cf_check early_init_amd(void);void amd_log_freq (const struct cpuinfo_x86 *c);void amd_init_de_cfg (const struct cpuinfo_x86 *c);void amd_init_lfence_dispatch (void );
xen/arch/x86/cpu/intel.c +18 -24
60 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH 06/16] x86/cpu: Rework the vendor early_init() hooks to be __init
xen/arch/x86/cpu/common.c void identify_cpu(struct cpuinfo_x86 *c) · line 507
Quoted 10 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +2
-2@@ -503,8 +503,8 @@ void identify_cpu(struct cpuinfo_x86 *c)if (c->extended_cpuid_level >=0x80000021 ) c->x86_capability[FEATURESET_e21a] =cpuid_eax (0x80000021 ); -if (actual_cpu.c_early_init) -alternative_vcall (actual_cpu.c_early_init, c); +if (c == &boot_cpu_data && actual_cpu.c_early_init) +alternative_vcall (actual_cpu.c_early_init);
Using alternative_vcall() then doesn't make any sense anymore, does it? With it replaced by an ordinary call:
Jan
Re: [PATCH 06/16] x86/cpu: Rework the vendor early_init() hooks to be __init
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +0
-0@@ -503,8 +503,8 @@ void identify_cpu(struct cpuinfo_x86 *c)if (c->extended_cpuid_level >=0x80000021 ) c->x86_capability[FEATURESET_e21a] =cpuid_eax (0x80000021 );
Quoted 5 lines
xen/arch/x86/cpu/common.c void identify_cpu(struct cpuinfo_x86 *c) · line 507
Quoted 4 lines
xen/arch/x86/cpu/common.c +2
-2-if (actual_cpu.c_early_init) -alternative_vcall (actual_cpu.c_early_init, c); +if (c == &boot_cpu_data && actual_cpu.c_early_init) +alternative_vcall (actual_cpu.c_early_init);Using
alternative_vcall()then doesn't make any sense anymore, does it?
It is still needed here, because this is .text and is a Spectre v1 into v2 gadget otherwise.
I've dropped alternative_vcall() in patch 7 where it becomes safe to do so.
~Andrew
Quoted 4 lines
With it replaced by an ordinary call:
Reviewed-by Jan Beulich <[email protected]>Jan
Re: [PATCH 06/16] x86/cpu: Rework the vendor early_init() hooks to be __init
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +0
-0@@ -503,8 +503,8 @@ void identify_cpu(struct cpuinfo_x86 *c)if (c->extended_cpuid_level >=0x80000021 ) c->x86_capability[FEATURESET_e21a] =cpuid_eax (0x80000021 );
Quoted 8 lines
Quoted 5 lines
xen/arch/x86/cpu/common.c void identify_cpu(struct cpuinfo_x86 *c) · line 507
Quoted 4 lines
xen/arch/x86/cpu/common.c +2
-2-if (actual_cpu.c_early_init) -alternative_vcall (actual_cpu.c_early_init, c); +if (c == &boot_cpu_data && actual_cpu.c_early_init) +alternative_vcall (actual_cpu.c_early_init);Using
alternative_vcall()then doesn't make any sense anymore, does it?It is still needed here, because this is .text and is a Spectre v1 into v2 gadget otherwise.
Hmm, I may not fully understand this. Is this because after patching the direct call becomes unsuitable for such a use, especially after .init.text was unmapped?
Quoted 1 line
I've dropped
alternative_vcall()in patch 7 where it becomes safe to do so.
Yes, I've meanwhile seen that.
Jan
PATCH 7/16 x86/cpu: Call the vendor early_init() hook in early_cpu_init()
In reply to Andrew Cooper... which is in practice much earlier on boot.
Currently, beyond basic vendor family and model information, the Intel hook needs the SELF_SNOOP CPUID bit which is collected by early_cpu_init() already. The AMD hook needs CPUID_USER_DIS, so the collection of leaf e21a needs to move too. (identify_cpu() has a second collection of this leaf, which remains.)
In order to facilitate this, have early_cpu_init() calculate c->extended_cpuid_level in the usual way.
No practical change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/common.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
xen/arch/x86/cpu/common.c +19 -16
@@ -413,8 +413,12 @@ void __init early_cpu_init(bool verbose) } eax =cpuid_eax (0x80000000 ); -if ((eax >>16 ) ==0x8000 && eax >=0x80000008 ) { - ebx = eax >=0x8000001f ?cpuid_ebx (0x8000001f ) :0 ; +if ((eax >>16 ) ==0x8000 ) + c->extended_cpuid_level = eax; + +if (c->extended_cpuid_level >=0x80000008 ) { + ebx = c->extended_cpuid_level >=0x8000001f + ?cpuid_ebx (0x8000001f ) :0 ; eax =cpuid_eax (0x80000008 ); paddr_bits = eax &0xff ;
@@ -433,6 +437,19 @@ void __init early_cpu_init(bool verbose) paddr_bits -= (ebx >>6 ) &0x3f ; } +if (c->extended_cpuid_level >=0x80000021 ) + c->x86_capability[FEATURESET_e21a] =cpuid_eax (0x80000021 ); + +/* +* Abuse 'verbose' to signal the first pass thought this function. +* +* Besides basic vendor, family and model information, the hooks need +* certain words of x86_capability[] already scanned, as they may take +* action to cause features to reappear. +*/ +if (verbose && actual_cpu.c_early_init) + actual_cpu.c_early_init (); +if (!(c->x86_vendor & (X86_VENDOR_AMD |X86_VENDOR_HYGON ))) park_offline_cpus = opt_mce;
@@ -485,10 +502,6 @@ void identify_cpu(struct cpuinfo_x86 *c) c->x86_clflush_size = ((ebx >>8 ) &0xff ) *8 ; c->phys_proc_id = c->apicid; -/* -* Early init of Self Snoop support requires 0x1.edx, while there also -* set 0x1.ecx as the value is in context. -*/ c->x86_capability[FEATURESET_1c] = ecx; c->x86_capability[FEATURESET_1d] = edx;
@@ -496,16 +509,6 @@ void identify_cpu(struct cpuinfo_x86 *c)if ((eax >>16 ) ==0x8000 ) c->extended_cpuid_level = eax; -/* -* These AMD-defined flags are out of place, but we need -* them early for the CPUID faulting probe code -*/ -if (c->extended_cpuid_level >=0x80000021 ) - c->x86_capability[FEATURESET_e21a] =cpuid_eax (0x80000021 ); - -if (c == &boot_cpu_data && actual_cpu.c_early_init) -alternative_vcall (actual_cpu.c_early_init); -/* AMD-defined flags: level 0x80000001 */ if (c->extended_cpuid_level >=0x80000001 ) cpuid(0x80000001, &tmp, &tmp,
Signature · 1 line
2.39.5
Re: [PATCH 07/16] x86/cpu: Call the vendor early_init() hook in early_cpu_init()
Quoted 6 lines · Andrew Cooper
xen/arch/x86/cpu/common.c +2
-0@@ -433,6 +437,19 @@ void __init early_cpu_init(bool verbose) paddr_bits -= (ebx >>6 ) &0x3f ; } +if (c->extended_cpuid_level >=0x80000021 ) + c->x86_capability[FEATURESET_e21a] =cpuid_eax (0x80000021 );
xen/arch/x86/cpu/common.c void __init early_cpu_init(bool verbose) · line 451
Quoted 10 lines
xen/arch/x86/cpu/common.c +10
-0+ +/* +* Abuse 'verbose' to signal the first pass thought this function. +* +* Besides basic vendor, family and model information, the hooks need +* certain words of x86_capability[] already scanned, as they may take +* action to cause features to reappear. +*/ +if (verbose && actual_cpu.c_early_init) + actual_cpu.c_early_init ();
There's one slight issue with this tying to the "first pass" only:early_init_intel() right now calls check_memory_type_self_snoop_errata(), which in turn uses boot_cpu_has(X86_FEATURE_SS). The comment at the 2nd pass call site is
/* Rescan CPUID/MSR features, which may have changed after a load. */
That, in principle, can affect any features, i.e. also SS. While for the particular feature it may be pretty unlikely that microcode might make it change, the mere fact that such a feature check is okay to do there may later lead to more such getting added, not realizing that ucode loads then may break things.
At the same time I understand that everything else in the *_early_init() really doesn't want doing twice.
Jan
PATCH 8/16 xen/sysctl: Drop XEN_SYSCTL_get_cpu_levelling_caps
In reply to Andrew CooperThis hypercall is an addition of mine from commit 67528a3f0649 ("x86/cpu:
Sysctl and common infrastructure for levelling context switching", 2016), but it never got wired into any toolstacks. In the meantime, how we handle CPUID for guests has evolved substantially.
In order to reuse the AMD levelling infrasturcture for boot time quirks, levelling_caps is going to have to change. While it's probably safe to expose this difference, it's safer still to make it an internal detail.
When re-plummbing the LCAP_* constants, turn them all into single bits.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Daniel P. Smith <[email protected]>
--- CHANGELOG.md | 2 ++ tools/flask/policy/modules/dom0.te | 1 - tools/include/xenguest.h | 1 - tools/libs/guest/xg_cpuid_x86.c | 14 -------------- xen/arch/x86/include/asm/cpuid.h | 15 ++++++--------- xen/arch/x86/sysctl.c | 6 ------ xen/include/public/sysctl.h | 22 +--------------------- xen/xsm/flask/hooks.c | 4 ---- xen/xsm/flask/policy/access_vectors | 2 -- 9 files changed, 9 insertions(+), 58 deletions(-)
CHANGELOG.md +2 -0
@@ -19,6 +19,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - The cpuid_mask_* command line options for legacy CPUs. These were deprecated in Xen 4.7 and noted not to work correctly with AMD CPUs from 2011 onwards, nor work at all with Intel CPUs from 2012. + - The SYSCTL_get_cpu_levelling_caps sysctl. This is not known to have been + used by any toolstack. - Xenoprofile support. Oprofile themselves removed support for Xen in 2014 prior to the version 1.0 release, and there has been no development since before then in Xen.
tools/flask/policy/modules/dom0.te +0 -1
@@ -43,7 +43,6 @@ allow dom0_t xen_t:xen2 { psr_alloc pmu_ctrl get_symbol - get_cpu_levelling_caps get_cpu_featureset livepatch_op coverage_op
tools/include/xenguest.h +0 -1
@@ -822,7 +822,6 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy,bool xc_cpu_policy_is_compatible (xc_interface *xch,xc_cpu_policy_t *host,xc_cpu_policy_t *guest); -int xc_get_cpu_levelling_caps (xc_interface *xch,uint32_t *caps);int xc_get_cpu_featureset (xc_interface *xch,uint32_t index,uint32_t *nr_features,uint32_t *featureset);
tools/libs/guest/xg_cpuid_x86.c +0 -14
@@ -36,20 +36,6 @@ enum {#define bitmaskof (idx) (1u << ((idx) & 31))#define featureword_of (idx) ((idx) >> 5) -int xc_get_cpu_levelling_caps (xc_interface *xch,uint32_t *caps) -{ -struct xen_sysctl sysctl = {}; -int ret; - - sysctl.cmd = XEN_SYSCTL_get_cpu_levelling_caps; - ret =do_sysctl (xch, &sysctl); - -if ( !ret ) - *caps = sysctl.u.cpu_levelling_caps.caps; - -return ret; -} -int xc_get_cpu_featureset (xc_interface *xch,uint32_t index,uint32_t *nr_features,uint32_t *featureset) {
xen/arch/x86/include/asm/cpuid.h +6 -9
@@ -15,15 +15,12 @@ extern const uint32_t known_features[FSCAPINTS];* Expected levelling capabilities (given cpuid vendor/family information), * and levelling capabilities actually available (given MSR probing). */ -#define LCAP_faulting XEN_SYSCTL_CPU_LEVELCAP_faulting -#define LCAP_1cd (XEN_SYSCTL_CPU_LEVELCAP_ecx | \ - XEN_SYSCTL_CPU_LEVELCAP_edx) -#define LCAP_e1cd (XEN_SYSCTL_CPU_LEVELCAP_extd_ecx | \ - XEN_SYSCTL_CPU_LEVELCAP_extd_edx) -#define LCAP_Da1 XEN_SYSCTL_CPU_LEVELCAP_xsave_eax -#define LCAP_6c XEN_SYSCTL_CPU_LEVELCAP_thermal_ecx -#define LCAP_7ab0 (XEN_SYSCTL_CPU_LEVELCAP_l7s0_eax | \ - XEN_SYSCTL_CPU_LEVELCAP_l7s0_ebx) +#define LCAP_faulting (1U << 0)/* CPUID Faulting */ +#define LCAP_1cd (1U << 1)/* 0x00000001.ecx/edx */ +#define LCAP_e1cd (1U << 2)/* 0x80000001.ecx/edx */ +#define LCAP_Da1 (1U << 3)/* 0x0000000D:1.eax */ +#define LCAP_6c (1U << 4)/* 0x00000006.ecx */ +#define LCAP_7ab0 (1U << 5)/* 0x00000007:0.eax/ebx */ extern unsigned int expected_levelling_cap, levelling_caps;struct cpuidmasks
xen/arch/x86/sysctl.c +0 -6
@@ -289,12 +289,6 @@ long arch_do_sysctl(break ; } -case XEN_SYSCTL_get_cpu_levelling_caps: - sysctl->u.cpu_levelling_caps.caps = levelling_caps; -if (__copy_field_to_guest (u_sysctl, sysctl, u.cpu_levelling_caps.caps) ) - ret = -EFAULT ; -break ; -case XEN_SYSCTL_get_cpu_featureset: {static const struct cpu_policy *const policy_table[6 ] = {
xen/include/public/sysctl.h +1 -21
@@ -932,25 +932,6 @@ struct xen_sysctl_psr_alloc { } u; }; -/* -* XEN_SYSCTL_get_cpu_levelling_caps (x86 specific) -* -* Return hardware capabilities concerning masking or faulting of the cpuid -* instruction for PV guests. -*/ -struct xen_sysctl_cpu_levelling_caps { -#define XEN_SYSCTL_CPU_LEVELCAP_faulting (1UL << 0)/* CPUID faulting */ -#define XEN_SYSCTL_CPU_LEVELCAP_ecx (1UL << 1)/* 0x00000001.ecx */ -#define XEN_SYSCTL_CPU_LEVELCAP_edx (1UL << 2)/* 0x00000001.edx */ -#define XEN_SYSCTL_CPU_LEVELCAP_extd_ecx (1UL << 3)/* 0x80000001.ecx */ -#define XEN_SYSCTL_CPU_LEVELCAP_extd_edx (1UL << 4)/* 0x80000001.edx */ -#define XEN_SYSCTL_CPU_LEVELCAP_xsave_eax (1UL << 5)/* 0x0000000D:1.eax */ -#define XEN_SYSCTL_CPU_LEVELCAP_thermal_ecx (1UL << 6)/* 0x00000006.ecx */ -#define XEN_SYSCTL_CPU_LEVELCAP_l7s0_eax (1UL << 7)/* 0x00000007:0.eax */ -#define XEN_SYSCTL_CPU_LEVELCAP_l7s0_ebx (1UL << 8)/* 0x00000007:0.ebx */ -uint32_t caps; -}; -/* * XEN_SYSCTL_get_cpu_featureset (x86 specific) *
@@ -1270,7 +1251,7 @@ struct xen_sysctl {#define XEN_SYSCTL_pcitopoinfo 22#define XEN_SYSCTL_psr_alloc 23/* #define XEN_SYSCTL_tmem_op 24 */ -#define XEN_SYSCTL_get_cpu_levelling_caps 25 +/* #define XEN_SYSCTL_get_cpu_levelling_caps 25 */ #define XEN_SYSCTL_get_cpu_featureset 26#define XEN_SYSCTL_livepatch_op 27/* #define XEN_SYSCTL_set_parameter 28 */
@@ -1300,7 +1281,6 @@ struct xen_sysctl {struct xen_sysctl_coverage_op coverage_op;struct xen_sysctl_psr_cmt_op psr_cmt_op;struct xen_sysctl_psr_alloc psr_alloc; -struct xen_sysctl_cpu_levelling_caps cpu_levelling_caps;struct xen_sysctl_cpu_featureset cpu_featureset;struct xen_sysctl_livepatch_op livepatch;#if defined(__i386__) || defined(__x86_64__)
xen/xsm/flask/hooks.c +0 -4
@@ -884,10 +884,6 @@ static int cf_check flask_sysctl(int cmd)return avc_current_has_perm (SECINITSID_XEN ,SECCLASS_XEN2 ,XEN2__PSR_ALLOC ,NULL ); -case XEN_SYSCTL_get_cpu_levelling_caps: -return avc_current_has_perm (SECINITSID_XEN ,SECCLASS_XEN2 , -XEN2__GET_CPU_LEVELLING_CAPS ,NULL ); -case XEN_SYSCTL_get_cpu_featureset:return avc_current_has_perm (SECINITSID_XEN ,SECCLASS_XEN2 ,XEN2__GET_CPU_FEATURESET ,NULL );
xen/xsm/flask/policy/access_vectors +0 -2
@@ -87,8 +87,6 @@ class xen2 pmu_ctrl # PMU use (domains, including unprivileged ones, will be using this operation) pmu_use -# XEN_SYSCTL_get_cpu_levelling_caps - get_cpu_levelling_caps # XEN_SYSCTL_get_cpu_featureset get_cpu_featureset # XEN_SYSCTL_livepatch_op
Signature · 1 line
2.39.5
Re: [PATCH 08/16] xen/sysctl: Drop XEN_SYSCTL_get_cpu_levelling_caps
Quoted 5 lines · Andrew Cooper
This hypercall is an addition of mine from commit
67528a3f0649("x86/cpu:
Sysctl and common infrastructure for levelling context switching", 2016), but it never got wired into any toolstacks. In the meantime, how we handle CPUID for guests has evolved substantially.
Quoted 7 lines
In order to reuse the AMD levelling infrasturcture for boot time quirks,
levelling_capsis going to have to change. While it's probably safe to expose this difference, it's safer still to make it an internal detail.When re-plummbing the LCAP_* constants, turn them all into single bits.
Signed-off-by Andrew Cooper <[email protected]>
xen/arch/x86/include/asm/cpuid.h extern const uint32_t known_features[FSCAPINTS]; · line 24
Quoted 4 lines
xen/arch/x86/include/asm/cpuid.h +0
-0extern unsigned int expected_levelling_cap, levelling_caps;
Observation while doing the review: Why are both _probe_mask_msr()'s 2nd parameters uint64_t, when the variables here are unsigned int?
xen/arch/x86/include/asm/cpuid.h struct xen_sysctl { · line 1254
Quoted 6 lines
xen/arch/x86/include/asm/cpuid.h +1
-1@@ -1270,7 +1251,7 @@ struct xen_sysctl {#define XEN_SYSCTL_pcitopoinfo 22#define XEN_SYSCTL_psr_alloc 23/* #define XEN_SYSCTL_tmem_op 24 */ -#define XEN_SYSCTL_get_cpu_levelling_caps 25 +/* #define XEN_SYSCTL_get_cpu_levelling_caps 25 */
I realize this it to match the earlier line, yet would you mind rather ...
xen/arch/x86/include/asm/cpuid.h struct xen_sysctl { · line 1257
Quoted 3 lines
xen/arch/x86/include/asm/cpuid.h +0
-0#define XEN_SYSCTL_get_cpu_featureset 26#define XEN_SYSCTL_livepatch_op 27/* #define XEN_SYSCTL_set_parameter 28 */
... following this style? (I wouldn't mind if you also touched the malformed tmem line at the same time.)
Jan
Re: [PATCH 08/16] xen/sysctl: Drop XEN_SYSCTL_get_cpu_levelling_caps
In reply to Andrew CooperQuoted 203 lines · Andrew Cooper
This hypercall is an addition of mine from commit
67528a3f0649("x86/cpu:
Sysctl and common infrastructure for levelling context switching", 2016), but it never got wired into any toolstacks. In the meantime, how we handle CPUID for guests has evolved substantially.In order to reuse the AMD levelling infrasturcture for boot time quirks,
levelling_capsis going to have to change. While it's probably safe to expose this difference, it's safer still to make it an internal detail.When re-plummbing the LCAP_* constants, turn them all into single bits.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Daniel P. Smith <[email protected]>--- CHANGELOG.md | 2 ++ tools/flask/policy/modules/dom0.te | 1 - tools/include/xenguest.h | 1 - tools/libs/guest/xg_cpuid_x86.c | 14 -------------- xen/arch/x86/include/asm/cpuid.h | 15 ++++++--------- xen/arch/x86/sysctl.c | 6 ------ xen/include/public/sysctl.h | 22 +--------------------- xen/xsm/flask/hooks.c | 4 ---- xen/xsm/flask/policy/access_vectors | 2 -- 9 files changed, 9 insertions(+), 58 deletions(-)CHANGELOG.md +2
-0@@ -19,6 +19,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - The cpuid_mask_* command line options for legacy CPUs. These were deprecated in Xen 4.7 and noted not to work correctly with AMD CPUs from 2011 onwards, nor work at all with Intel CPUs from 2012. + - The SYSCTL_get_cpu_levelling_caps sysctl. This is not known to have been + used by any toolstack. - Xenoprofile support. Oprofile themselves removed support for Xen in 2014 prior to the version 1.0 release, and there has been no development since before then in Xen.tools/flask/policy/modules/dom0.te +0
-1@@ -43,7 +43,6 @@ allow dom0_t xen_t:xen2 { psr_alloc pmu_ctrl get_symbol - get_cpu_levelling_caps get_cpu_featureset livepatch_op coverage_optools/include/xenguest.h +0
-1@@ -822,7 +822,6 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy,bool xc_cpu_policy_is_compatible (xc_interface *xch,xc_cpu_policy_t *host,xc_cpu_policy_t *guest); -int xc_get_cpu_levelling_caps (xc_interface *xch,uint32_t *caps);int xc_get_cpu_featureset (xc_interface *xch,uint32_t index,uint32_t *nr_features,uint32_t *featureset);tools/libs/guest/xg_cpuid_x86.c +0
-14@@ -36,20 +36,6 @@ enum {#define bitmaskof (idx) (1u << ((idx) & 31))#define featureword_of (idx) ((idx) >> 5) -int xc_get_cpu_levelling_caps (xc_interface *xch,uint32_t *caps) -{ -struct xen_sysctl sysctl = {}; -int ret; - - sysctl.cmd = XEN_SYSCTL_get_cpu_levelling_caps; - ret =do_sysctl (xch, &sysctl); - -if ( !ret ) - *caps = sysctl.u.cpu_levelling_caps.caps; - -return ret; -} -int xc_get_cpu_featureset (xc_interface *xch,uint32_t index,uint32_t *nr_features,uint32_t *featureset) {xen/arch/x86/include/asm/cpuid.h +6
-9@@ -15,15 +15,12 @@ extern const uint32_t known_features[FSCAPINTS];* Expected levelling capabilities (given cpuid vendor/family information), * and levelling capabilities actually available (given MSR probing). */ -#define LCAP_faulting XEN_SYSCTL_CPU_LEVELCAP_faulting -#define LCAP_1cd (XEN_SYSCTL_CPU_LEVELCAP_ecx | \ - XEN_SYSCTL_CPU_LEVELCAP_edx) -#define LCAP_e1cd (XEN_SYSCTL_CPU_LEVELCAP_extd_ecx | \ - XEN_SYSCTL_CPU_LEVELCAP_extd_edx) -#define LCAP_Da1 XEN_SYSCTL_CPU_LEVELCAP_xsave_eax -#define LCAP_6c XEN_SYSCTL_CPU_LEVELCAP_thermal_ecx -#define LCAP_7ab0 (XEN_SYSCTL_CPU_LEVELCAP_l7s0_eax | \ - XEN_SYSCTL_CPU_LEVELCAP_l7s0_ebx) +#define LCAP_faulting (1U << 0)/* CPUID Faulting */ +#define LCAP_1cd (1U << 1)/* 0x00000001.ecx/edx */ +#define LCAP_e1cd (1U << 2)/* 0x80000001.ecx/edx */ +#define LCAP_Da1 (1U << 3)/* 0x0000000D:1.eax */ +#define LCAP_6c (1U << 4)/* 0x00000006.ecx */ +#define LCAP_7ab0 (1U << 5)/* 0x00000007:0.eax/ebx */ extern unsigned int expected_levelling_cap, levelling_caps;struct cpuidmasks xen/arch/x86/sysctl.c +0
-6@@ -289,12 +289,6 @@ long arch_do_sysctl(break ; } -case XEN_SYSCTL_get_cpu_levelling_caps: - sysctl->u.cpu_levelling_caps.caps = levelling_caps; -if (__copy_field_to_guest (u_sysctl, sysctl, u.cpu_levelling_caps.caps) ) - ret = -EFAULT ; -break ; -case XEN_SYSCTL_get_cpu_featureset: {static const struct cpu_policy *const policy_table[6 ] = {xen/include/public/sysctl.h +1
-21@@ -932,25 +932,6 @@ struct xen_sysctl_psr_alloc { } u; }; -/* -* XEN_SYSCTL_get_cpu_levelling_caps (x86 specific) -* -* Return hardware capabilities concerning masking or faulting of the cpuid -* instruction for PV guests. -*/ -struct xen_sysctl_cpu_levelling_caps { -#define XEN_SYSCTL_CPU_LEVELCAP_faulting (1UL << 0)/* CPUID faulting */ -#define XEN_SYSCTL_CPU_LEVELCAP_ecx (1UL << 1)/* 0x00000001.ecx */ -#define XEN_SYSCTL_CPU_LEVELCAP_edx (1UL << 2)/* 0x00000001.edx */ -#define XEN_SYSCTL_CPU_LEVELCAP_extd_ecx (1UL << 3)/* 0x80000001.ecx */ -#define XEN_SYSCTL_CPU_LEVELCAP_extd_edx (1UL << 4)/* 0x80000001.edx */ -#define XEN_SYSCTL_CPU_LEVELCAP_xsave_eax (1UL << 5)/* 0x0000000D:1.eax */ -#define XEN_SYSCTL_CPU_LEVELCAP_thermal_ecx (1UL << 6)/* 0x00000006.ecx */ -#define XEN_SYSCTL_CPU_LEVELCAP_l7s0_eax (1UL << 7)/* 0x00000007:0.eax */ -#define XEN_SYSCTL_CPU_LEVELCAP_l7s0_ebx (1UL << 8)/* 0x00000007:0.ebx */ -uint32_t caps; -}; -/* * XEN_SYSCTL_get_cpu_featureset (x86 specific) * @@ -1270,7 +1251,7 @@ struct xen_sysctl {#define XEN_SYSCTL_pcitopoinfo 22#define XEN_SYSCTL_psr_alloc 23/* #define XEN_SYSCTL_tmem_op 24 */ -#define XEN_SYSCTL_get_cpu_levelling_caps 25 +/* #define XEN_SYSCTL_get_cpu_levelling_caps 25 */ #define XEN_SYSCTL_get_cpu_featureset 26#define XEN_SYSCTL_livepatch_op 27/* #define XEN_SYSCTL_set_parameter 28 */ @@ -1300,7 +1281,6 @@ struct xen_sysctl {struct xen_sysctl_coverage_op coverage_op;struct xen_sysctl_psr_cmt_op psr_cmt_op;struct xen_sysctl_psr_alloc psr_alloc; -struct xen_sysctl_cpu_levelling_caps cpu_levelling_caps;struct xen_sysctl_cpu_featureset cpu_featureset;struct xen_sysctl_livepatch_op livepatch;#if defined(__i386__) || defined(__x86_64__)xen/xsm/flask/hooks.c +0
-4@@ -884,10 +884,6 @@ static int cf_check flask_sysctl(int cmd)return avc_current_has_perm (SECINITSID_XEN ,SECCLASS_XEN2 ,XEN2__PSR_ALLOC ,NULL ); -case XEN_SYSCTL_get_cpu_levelling_caps: -return avc_current_has_perm (SECINITSID_XEN ,SECCLASS_XEN2 , -XEN2__GET_CPU_LEVELLING_CAPS ,NULL ); -case XEN_SYSCTL_get_cpu_featureset:return avc_current_has_perm (SECINITSID_XEN ,SECCLASS_XEN2 ,XEN2__GET_CPU_FEATURESET ,NULL );xen/xsm/flask/policy/access_vectors +0
-0
xen/xsm/flask/policy/access_vectors class xen2 · line 92
Quoted 8 lines
xen/xsm/flask/policy/access_vectors +0
-2@@ -87,8 +87,6 @@ class xen2 pmu_ctrl # PMU use (domains, including unprivileged ones, will be using this operation) pmu_use -# XEN_SYSCTL_get_cpu_levelling_caps - get_cpu_levelling_caps # XEN_SYSCTL_get_cpu_featureset get_cpu_featureset # XEN_SYSCTL_livepatch_op
PATCH 9/16 x86/intel: Always check MSR_MISC_ENABLE on all CPUs
In reply to Andrew CooperCurrently, the BSP only leaves instructions for the APs to adjust MSR_MISC_ENABLE if the BSP is found to need adjustments. Particularly if XD_DISABLE is needed on an AP but not the BSP, the system will triple fault with no information provided to the user.
Rework the BSP and trampoline logic to always read MISC_ENABLE, and clear CPUID_LIMIT and XD_DISABLE if either are set.
Repurpose intel_unlock_cpuid_leaves() to be intel_check_misc_enable() and make it static in common.c. Replace trampoline_misc_enable_off with the smaller trampoline_check_misc_enable.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
This temporarily removes the printk() noting the reactivation of XD because the earlier BSP code has already done it, but that logic is about to be removed.
--- xen/arch/x86/boot/head.S | 1 - xen/arch/x86/boot/trampoline.S | 29 ++++++++++-------- xen/arch/x86/boot/wakeup.S | 27 ++++++++++------- xen/arch/x86/cpu/common.c | 43 ++++++++++++++++++++++++++- xen/arch/x86/cpu/cpu.h | 2 -- xen/arch/x86/cpu/intel.c | 19 ------------ xen/arch/x86/include/asm/trampoline.h | 7 +++-- 7 files changed, 79 insertions(+), 49 deletions(-)
xen/arch/x86/boot/head.S +0 -1
@@ -582,7 +582,6 @@ trampoline_setup: btr $2, %edx jnc .Lno_nx wrmsr - orb $MSR_IA32_MISC_ENABLE_XD_DISABLE >> 32, 4 + sym_esi(trampoline_misc_enable_off) /* Check again for NX */ mov $0x80000001, %eax
xen/arch/x86/boot/trampoline.S +17 -12
@@ -77,17 +77,22 @@ trampoline_protmode_entry: mov %eax,%cr3 /* Adjust IA32_MISC_ENABLE if needed (for NX enabling below). */ - mov bootsym_rel(trampoline_misc_enable_off,4,%esi) - mov bootsym_rel(trampoline_misc_enable_off+4,4,%edi) - mov %esi,%eax - or %edi,%eax - jz 1f + cmpb $1, bootsym_rel(trampoline_check_misc_enable, 5) + jne 1f + mov $MSR_IA32_MISC_ENABLE,%ecx rdmsr - not %esi - not %edi - and %esi,%eax - and %edi,%edx + + xor %edi, %edi + btr $22 /* ilog2(MSR_IA32_MISC_ENABLE_LIMIT_CPUID) */, %eax + adc %edi, %edi + + btr $34 /* ilog2(MSR_IA32_MISC_ENABLE_XD_DISABLE) */ - 32, %edx + adc %edi, %edi + + /* No bits need clearing? Nothing to do */ + jz 1f + wrmsr 1: /* Set up PAT before enabling paging. */
@@ -141,9 +146,6 @@ gdt_48: .long trampoline_gdt + BOOT_PSEUDORM_DS + 2 - . .popsection -GLOBAL(trampoline_misc_enable_off) - .quad 0 - /* EFER OR-mask for boot paths. SCE conditional on PV support, NX added when available. */ GLOBAL(trampoline_efer) .long EFER_LME | (EFER_SCE * IS_ENABLED(CONFIG_PV)) | \
@@ -155,6 +157,9 @@ GLOBAL(trampoline_xen_phys_start) GLOBAL(trampoline_cpu_started) .byte 0 +GLOBAL(trampoline_check_misc_enable) + .byte 0 + LABEL(trampoline_perm_end, 0) /* From here on early boot only. */
xen/arch/x86/boot/wakeup.S +16 -11
@@ -126,18 +126,23 @@ wakeup_32: add bootsym_rel(trampoline_xen_phys_start,4,%eax) mov %eax,%cr3 - /* Reapply IA32_MISC_ENABLE modifications from early_init_intel(). */ - mov bootsym_rel(trampoline_misc_enable_off, 4, %esi) - mov bootsym_rel(trampoline_misc_enable_off + 4, 4, %edi) - mov %esi, %eax - or %edi, %eax - jz 1f - mov $MSR_IA32_MISC_ENABLE, %ecx + /* Adjust IA32_MISC_ENABLE if needed (for NX enabling below). */ + cmpb $1, bootsym_rel(trampoline_check_misc_enable, 5) + jne 1f + + mov $MSR_IA32_MISC_ENABLE,%ecx rdmsr - not %esi - not %edi - and %esi, %eax - and %edi, %edx + + xor %edi, %edi + btr $22 /* ilog2(MSR_IA32_MISC_ENABLE_LIMIT_CPUID) */, %eax + adc %edi, %edi + + btr $34 /* ilog2(MSR_IA32_MISC_ENABLE_XD_DISABLE) */ - 32, %edx + adc %edi, %edi + + /* No bits need clearing? Nothing to do */ + jz 1f + wrmsr 1: /* Set up PAT before enabling paging. */
xen/arch/x86/cpu/common.c +42 -1
61 lines not on this page · raw message
xen/arch/x86/cpu/cpu.h +0 -2
@@ -27,6 +27,4 @@ void amd_init_ssbd(const struct cpuinfo_x86 *c);void amd_init_spectral_chicken (void );void detect_zen2_null_seg_behaviour (void ); -void intel_unlock_cpuid_leaves (struct cpuinfo_x86 *c); -#endif /* X86_CPU_H */
xen/arch/x86/cpu/intel.c +0 -19
@@ -309,22 +309,6 @@ static void __init intel_init_levelling(void) ctxt_switch_masking = intel_ctxt_switch_masking; } -/* Unmask CPUID levels if masked. */ -void __init intel_unlock_cpuid_leaves (struct cpuinfo_x86 *c) -{ -uint64_t misc_enable, disable; - -rdmsrl (MSR_IA32_MISC_ENABLE , misc_enable); - - disable = misc_enable &MSR_IA32_MISC_ENABLE_LIMIT_CPUID ; -if (disable) { -wrmsrl (MSR_IA32_MISC_ENABLE , misc_enable & ~disable); -bootsym (trampoline_misc_enable_off) |= disable; - c->cpuid_level =cpuid_eax (0 ); -printk (KERN_INFO "revised cpuid level: %u\n" , c->cpuid_level); - } -} -/* * Errata BA80, AAK120, AAM108, AAO67, BD59, AAY54: Rapid Core C3/C6 Transition * May Cause Unpredictable System Behavior
@@ -392,9 +376,6 @@ static void __init probe_mwait_errata(void) static void __init cf_check early_init_intel(void) { -if (bootsym (trampoline_misc_enable_off) &MSR_IA32_MISC_ENABLE_XD_DISABLE ) -printk (KERN_INFO "re-enabled NX (Execute Disable) protection\n" ); -check_memory_type_self_snoop_errata ();/*
xen/arch/x86/include/asm/trampoline.h +4 -3
@@ -153,10 +153,11 @@ extern uint8_t trampoline_cpu_started;extern uint32_t trampoline_efer;/* -* When nonzero, clear the specified bits in MSR_MISC_ENABLE. This is -* necessary to clobber XD_DISABLE before trying to set MSR_EFER.NXE. +* Instruction from the BSP to APs that MSR_MISC_ENABLE is available and +* should be checked to remove limitations. This is necessary to clobber +* XD_DISABLE before trying to set MSR_EFER.NXE. */ -extern uint64_t trampoline_misc_enable_off; +extern bool trampoline_check_misc_enable;/* Quirks about video mode-setting on S3 resume. */ extern uint8_t video_flags;
Signature · 1 line
2.39.5
Re: [PATCH 09/16] x86/intel: Always check MSR_MISC_ENABLE on all CPUs
Quoted 19 lines · Andrew Cooper
Currently, the BSP only leaves instructions for the APs to adjust
MSR_MISC_ENABLEif the BSP is found to need adjustments. Particularly ifXD_DISABLEis needed on an AP but not the BSP, the system will triple fault with no information provided to the user.Rework the BSP and trampoline logic to always read
MISC_ENABLE, and clearCPUID_LIMITandXD_DISABLEif either are set.Repurpose
intel_unlock_cpuid_leaves()to beintel_check_misc_enable()and make it static incommon.c. Replacetrampoline_misc_enable_offwith the smallertrampoline_check_misc_enable.Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
Quoted 3 lines
This temporarily removes the
printk()noting the reactivation of XD because the earlier BSP code has already done it, but that logic is about to be removed.
Actually, I'd forgotten that this is still reachable, via xen.efi, and is the bug that kicked off all this work originally.
Julien has requested that I try to integrate the two series together, which I'll do for v2.
~Andrew
Re: [PATCH 09/16] x86/intel: Always check MSR_MISC_ENABLE on all CPUs
In reply to Andrew CooperQuoted 10 lines · Andrew Cooper
Currently, the BSP only leaves instructions for the APs to adjust
MSR_MISC_ENABLEif the BSP is found to need adjustments. Particularly ifXD_DISABLEis needed on an AP but not the BSP, the system will triple fault with no information provided to the user.Rework the BSP and trampoline logic to always read
MISC_ENABLE, and clearCPUID_LIMITandXD_DISABLEif either are set.Repurpose
intel_unlock_cpuid_leaves()to beintel_check_misc_enable()and make it static incommon.c.
Being able to make it static is of course nice. But moving Intel-only code out of intel.c isn't. Personally I'd favor it staying in intel.c.
Jan
Re: [PATCH 09/16] x86/intel: Always check MSR_MISC_ENABLE on all CPUs
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Andrew Cooper
Currently, the BSP only leaves instructions for the APs to adjust
MSR_MISC_ENABLEif the BSP is found to need adjustments. Particularly ifXD_DISABLEis needed on an AP but not the BSP, the system will triple fault with no information provided to the user.
Quoted 7 lines
Quoted 5 lines
Rework the BSP and trampoline logic to always read
MISC_ENABLE, and clearCPUID_LIMITandXD_DISABLEif either are set.Repurpose
intel_unlock_cpuid_leaves()to beintel_check_misc_enable()and make it static incommon.c.Being able to make it static is of course nice. But moving Intel-only code out of
intel.cisn't. Personally I'd favor it staying inintel.c.
Alejandro's DCE work will cause this to be eliminated in !INTEL builds.
It's slightly ugly, but it's less ugly than having 3 separate hooks.
~Andrew
PATCH 10/16 x86/amd: Always probe and configure the masking MSRs
In reply to Andrew CooperThis allows the infrastructure to reused for system-wide quirk/errata adjustments.
Replace the call to ctxt_switch_levelling() with amd_ctxt_switch_masking() instead. The CPUID Faulting aspect is not interesting at this point in boot, and we want to explicitly propagate the masking MSR defaults into APs.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/amd.c | 15 +++++++++++---- xen/arch/x86/cpu/cpu.h | 1 + xen/arch/x86/cpu/hygon.c | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-)
xen/arch/x86/cpu/amd.c +11 -4
@@ -162,7 +162,7 @@ static void __init noinline probe_masking_msrs(void)* parameter of NULL is used to context switch to the default host state (by * the cpu bringup-code, crash path, etc). */ -static void cf_check amd_ctxt_switch_masking(const struct vcpu *next) +void cf_check amd_ctxt_switch_masking(const struct vcpu *next) {struct cpuidmasks *these_masks = &this_cpu (cpuidmasks);const struct domain *nextd = next ? next->domain :NULL ;
@@ -242,9 +242,12 @@ static void __init amd_init_levelling(void) boot_cpu_has(X86_FEATURE_CPUID_USER_DIS)) { expected_levelling_cap |= LCAP_faulting; levelling_caps |= LCAP_faulting; -return ; } +/* +* Always probe for the MSRs too. We reuse the infrastruture for +* quirks/errata/etc during boot. +*/ probe_masking_msrs ();if ((levelling_caps & LCAP_1cd) == LCAP_1cd) {
@@ -299,7 +302,7 @@ static void __init amd_init_levelling(void) (uint32_t)cpuidmask_defaults._6c); } -if (levelling_caps) +if (levelling_caps && !(levelling_caps & LCAP_faulting)) ctxt_switch_masking = amd_ctxt_switch_masking; }
@@ -1015,7 +1018,11 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)u32 l, h;uint64_t value; -ctxt_switch_levelling (NULL ); +/* +* Reuse amd_ctxt_switch_masking() explicitly. This propagates +* quirk/errata adjustments made duing early_init_amd() into the APs. +*/ +amd_ctxt_switch_masking (NULL );amd_init_de_cfg (c);
xen/arch/x86/cpu/cpu.h +1 -0
@@ -20,6 +20,7 @@ extern void detect_ht(struct cpuinfo_x86 *c);extern bool detect_extended_topology (struct cpuinfo_x86 *c); void cf_check early_init_amd(void); +void cf_check amd_ctxt_switch_masking(const struct vcpu *next);void amd_log_freq (const struct cpuinfo_x86 *c);void amd_init_de_cfg (const struct cpuinfo_x86 *c);void amd_init_lfence_dispatch (void );
xen/arch/x86/cpu/hygon.c +1 -1
@@ -32,7 +32,7 @@ static void cf_check init_hygon(struct cpuinfo_x86 *c) {unsigned long long value; -ctxt_switch_levelling (NULL ); +amd_ctxt_switch_masking (NULL );amd_init_de_cfg (c);
Signature · 1 line
2.39.5
Re: [PATCH 10/16] x86/amd: Always probe and configure the masking MSRs
Quoted 8 lines · Andrew Cooper
This allows the infrastructure to reused for system-wide quirk/errata adjustments.
Replace the call to
ctxt_switch_levelling()withamd_ctxt_switch_masking()instead. The CPUID Faulting aspect is not interesting at this point in boot, and we want to explicitly propagate the masking MSR defaults into APs.Signed-off-by Andrew Cooper <[email protected]>
with two comment nits:
Quoted 13 lines
xen/arch/x86/cpu/amd.c +1
-1@@ -162,7 +162,7 @@ static void __init noinline probe_masking_msrs(void)* parameter of NULL is used to context switch to the default host state (by * the cpu bringup-code, crash path, etc). */ -static void cf_check amd_ctxt_switch_masking(const struct vcpu *next) +void cf_check amd_ctxt_switch_masking(const struct vcpu *next) {struct cpuidmasks *these_masks = &this_cpu (cpuidmasks);const struct domain *nextd = next ? next->domain :NULL ;@@ -242,9 +242,12 @@ static void __init amd_init_levelling(void) boot_cpu_has(X86_FEATURE_CPUID_USER_DIS)) {
xen/arch/x86/cpu/amd.c static void __init amd_init_levelling(void) · line 251
Quoted 10 lines
xen/arch/x86/cpu/amd.c +4
-1expected_levelling_cap |= LCAP_faulting; levelling_caps |= LCAP_faulting; -return ; } +/* +* Always probe for the MSRs too. We reuse the infrastruture for +* quirks/errata/etc during boot. +*/ probe_masking_msrs ();
This isn't just about boot, but also soft-onlining of CPUs and S3 resume.
xen/arch/x86/cpu/amd.c static void cf_check init_amd(struct cpuinfo_x86 *c) · line 1025
Quoted 10 lines
xen/arch/x86/cpu/amd.c +5
-1@@ -1015,7 +1018,11 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)u32 l, h;uint64_t value; -ctxt_switch_levelling (NULL ); +/* +* Reuse amd_ctxt_switch_masking() explicitly. This propagates +* quirk/errata adjustments made duing early_init_amd() into the APs. +*/ +amd_ctxt_switch_masking (NULL );
Have the same comment also ...
xen/arch/x86/cpu/hygon.c static void cf_check init_hygon(struct cpuinfo_x86 *c) · line 35
Quoted 8 lines
xen/arch/x86/cpu/hygon.c +1
-1@@ -32,7 +32,7 @@ static void cf_check init_hygon(struct cpuinfo_x86 *c) {unsigned long long value; -ctxt_switch_levelling (NULL ); +amd_ctxt_switch_masking (NULL );
... here?
Jan
PATCH 11/16 x86/amd: Fix re-activation of TopoExt on Fam15h CPUs
In reply to Andrew Cooperinit_amd() tries to re-activate TOPOEXT on certain systems, but only after amd_init_levelling() has calculated the levelling defaults, meaning that the re-activation will be lost on the next context switch.
Move the logic into early_init_amd() so it takes effect before calculating the levelling defaults.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/amd.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-)
xen/arch/x86/cpu/amd.c +24 -16
@@ -620,9 +620,32 @@ void amd_process_freq(const struct cpuinfo_x86 *c, *low_mhz =amd_parse_freq (c->x86, lo); } +static void amd_early_adjust_cpuid_extd (void ) +{ +struct cpuinfo_x86 *c = &boot_cpu_data; +uint64_t val; + +/* Re-enable TopologyExtensions if switched off by BIOS */ +if ( c->family ==0x15 && c->model >=0x10 && c->model <=0x1f && + !boot_cpu_has (X86_FEATURE_TOPOEXT ) && + !rdmsr_safe (MSR_K8_EXT_FEATURE_MASK , &val) ) + { + val |=1ULL <<54 ; +wrmsr_safe (MSR_K8_EXT_FEATURE_MASK , val); + val =rdmsr (MSR_K8_EXT_FEATURE_MASK ); +if ( val & (1ULL <<54 ) ) + { +__set_bit (X86_FEATURE_TOPOEXT , c->x86_capability); +printk (XENLOG_INFO "CPU: Re-enabling disabled Topology Extensions Support\n" ); + } + } +} + void __init cf_check early_init_amd(void) { -amd_init_levelling (); +amd_early_adjust_cpuid_extd (); + +amd_init_levelling ();/* Capture defaults after early CPUID adjustments */ }void amd_log_freq (const struct cpuinfo_x86 *c)
@@ -1145,21 +1168,6 @@ static void cf_check init_amd(struct cpuinfo_x86 *c) } } -/* re-enable TopologyExtensions if switched off by BIOS */ -if ((c->x86 ==0x15 ) && - (c->x86_model >=0x10 ) && (c->x86_model <=0x1f ) && - !cpu_has (c,X86_FEATURE_TOPOEXT ) && - !rdmsr_safe (MSR_K8_EXT_FEATURE_MASK , &value)) { - value |=1ULL <<54 ; -wrmsr_safe (MSR_K8_EXT_FEATURE_MASK , value); -rdmsrl (MSR_K8_EXT_FEATURE_MASK , value); -if (value & (1ULL <<54 )) { -__set_bit (X86_FEATURE_TOPOEXT , c->x86_capability); -printk (KERN_INFO "CPU: Re-enabling disabled " -"Topology Extensions Support\n" ); - } - } -/* * The way access filter has a performance penalty on some workloads. * Disable it on the affected CPUs.
Signature · 1 line
2.39.5
Re: [PATCH 11/16] x86/amd: Fix re-activation of TopoExt on Fam15h CPUs
Quoted 8 lines · Andrew Cooper
init_amd()tries to re-activate TOPOEXT on certain systems, but only afteramd_init_levelling()has calculated the levelling defaults, meaning that the re-activation will be lost on the next context switch.Move the logic into
early_init_amd()so it takes effect before calculating the levelling defaults.Signed-off-by Andrew Cooper <[email protected]>
I'm sorry, but as this is being moved and tidied some, I've got some remarks:
xen/arch/x86/cpu/amd.c void amd_process_freq(const struct cpuinfo_x86 *c, · line 623
Quoted 7 lines
xen/arch/x86/cpu/amd.c +1
-0@@ -620,9 +620,32 @@ void amd_process_freq(const struct cpuinfo_x86 *c, *low_mhz =amd_parse_freq (c->x86, lo); } +static void amd_early_adjust_cpuid_extd (void )
__init?
xen/arch/x86/cpu/amd.c void amd_process_freq(const struct cpuinfo_x86 *c, · line 629
Quoted 6 lines
xen/arch/x86/cpu/amd.c +6
-0+{ +struct cpuinfo_x86 *c = &boot_cpu_data; +uint64_t val; + +/* Re-enable TopologyExtensions if switched off by BIOS */ + if ( c->family == 0x15 && c->model >= 0x10 && c->model <= 0x1f &&
If this is done by BIOSes, why would it be constrained to a certain model range of a certain family?
xen/arch/x86/cpu/amd.c void amd_process_freq(const struct cpuinfo_x86 *c, · line 638
Quoted 9 lines
xen/arch/x86/cpu/amd.c +9
-0+ !boot_cpu_has(X86_FEATURE_TOPOEXT) && + !rdmsr_safe(MSR_K8_EXT_FEATURE_MASK, &val) ) + { + val |=1ULL <<54 ; +wrmsr_safe (MSR_K8_EXT_FEATURE_MASK , val); + val =rdmsr (MSR_K8_EXT_FEATURE_MASK ); +if ( val & (1ULL <<54 ) ) + { +__set_bit (X86_FEATURE_TOPOEXT , c->x86_capability);
This shouldn't be needed, as identify_cpu() will obtain the updated value anyway.
Jan
PATCH 12/16 x86/amd: Probe for NX support and re-activate if possible
In reply to Andrew CooperAn AMD Ryzen system has been found with a firmware option to disable NX. Like we do on Intel systems, try to detect and undo this stupidity.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
Somewhat RFC. I don't particularly like the double handling of MSR_K8_EXT_FEATURE_MASK in this function, but I can't find any way of making the logic legible while trying to dedup the MSR accesses.
--- xen/arch/x86/cpu/amd.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
xen/arch/x86/cpu/amd.c +35 -0
@@ -17,6 +17,7 @@#include <asm/msr.h> #include <asm/processor.h> #include <asm/spec_ctrl.h> +#include <asm/trampoline.h> #include "cpu.h"
@@ -639,6 +640,40 @@ static void amd_early_adjust_cpuid_extd(void)printk (XENLOG_INFO "CPU: Re-enabling disabled Topology Extensions Support\n" ); } } + +/* +* Probe for NX support if it appears to be unavailable. All 64-bit +* capable AMD CPUs support it, but some firmwares have an option to hide +* it in CPUID, apparently for "feature parity" with Intel platforms. +* +* Unlike Intel, there's no active indication that this has been done. A +* conversation with AMD suggests that if we can set EFER.NXE, then NX +* will work. Use this as a heuristic to probe for support, coping with +* the fact that a hypervisor might have really disabled and blocked NX, +* and not emulate the mask MSRs either. +*/ +if ( !boot_cpu_has (X86_FEATURE_NX ) ) + { +uint64_t *this_efer = &this_cpu (efer); + +if (wrmsr_safe (MSR_EFER , *this_efer |EFER_NXE ) ==0 ) + { + *this_efer |=EFER_NXE ; + +if ( !rdmsr_safe (MSR_K8_EXT_FEATURE_MASK , &val) ) + { + val |=1ULL <<cpufeat_bit (X86_FEATURE_NX ); +wrmsr_safe (MSR_K8_EXT_FEATURE_MASK , val); + val =rdmsr (MSR_K8_EXT_FEATURE_MASK ); +if ( val & (1ULL <<cpufeat_bit (X86_FEATURE_NX )) ) + { +__set_bit (X86_FEATURE_NX , c->x86_capability); +printk (XENLOG_INFO "re-enabled NX protection\n" ); +bootsym (trampoline_efer) |=EFER_NXE ; + } + } + } + } } void __init cf_check early_init_amd(void)
Signature · 1 line
2.39.5
Re: [PATCH 12/16] x86/amd: Probe for NX support and re-activate if possible
Quoted 11 lines · Andrew Cooper
An AMD Ryzen system has been found with a firmware option to disable NX. Like we do on Intel systems, try to detect and undo this stupidity.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
Quoted 3 lines
Somewhat RFC. I don't particularly like the double handling of
MSR_K8_EXT_FEATURE_MASKin this function, but I can't find any way of making the logic legible while trying to dedup the MSR accesses.
Looks reasonable to me as is. If later someone has a neat idea for de-duplication, it can always be done incrementally.
Quoted 11 lines
xen/arch/x86/cpu/amd.c +7
-0@@ -639,6 +640,40 @@ static void amd_early_adjust_cpuid_extd(void)printk (XENLOG_INFO "CPU: Re-enabling disabled Topology Extensions Support\n" ); } } + +/* +* Probe for NX support if it appears to be unavailable. All 64-bit +* capable AMD CPUs support it, but some firmwares have an option to hide +* it in CPUID, apparently for "feature parity" with Intel platforms. +* +* Unlike Intel, there's no active indication that this has been done. A
xen/arch/x86/cpu/amd.c static void amd_early_adjust_cpuid_extd(void) · line 659
Quoted 10 lines
xen/arch/x86/cpu/amd.c +10
-0+* conversation with AMD suggests that if we can set EFER.NXE, then NX +* will work. Use this as a heuristic to probe for support, coping with +* the fact that a hypervisor might have really disabled and blocked NX, +* and not emulate the mask MSRs either. +*/ +if ( !boot_cpu_has (X86_FEATURE_NX ) ) + { +uint64_t *this_efer = &this_cpu (efer); + +if (wrmsr_safe (MSR_EFER , *this_efer |EFER_NXE ) ==0 )
Would you mind using ! here, just like you do ...
xen/arch/x86/cpu/amd.c static void amd_early_adjust_cpuid_extd(void) · line 663
Quoted 4 lines
xen/arch/x86/cpu/amd.c +4
-0+ { + *this_efer |=EFER_NXE ; + +if ( !rdmsr_safe (MSR_K8_EXT_FEATURE_MASK , &val) )
... here?
xen/arch/x86/cpu/amd.c static void amd_early_adjust_cpuid_extd(void) · line 670
Quoted 7 lines
xen/arch/x86/cpu/amd.c +7
-0+ { + val |=1ULL <<cpufeat_bit (X86_FEATURE_NX ); +wrmsr_safe (MSR_K8_EXT_FEATURE_MASK , val); + val =rdmsr (MSR_K8_EXT_FEATURE_MASK ); +if ( val & (1ULL <<cpufeat_bit (X86_FEATURE_NX )) ) + { +__set_bit (X86_FEATURE_NX , c->x86_capability);
Again this shouldn't be needed, as identify_cpu() takes care. Unless in this case it matters for the time in between?
Jan
PATCH 13/16 x86/cpu: Drop NOISY_CAPS
In reply to Andrew CooperThese were plausibly useful for debugging when there were 4 words in x86_capability[], but it's currently 22 words and growing.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
Even I can't read it in hex any more.
--- xen/arch/x86/cpu/common.c | 14 -------------- 1 file changed, 14 deletions(-)
xen/arch/x86/cpu/common.c +0 -14
@@ -598,13 +598,6 @@ void identify_cpu(struct cpuinfo_x86 *c) c->x86_capability[FEATURESET_m10Ah] = val >>32 ; } -#ifdef NOISY_CAPS -printk (KERN_DEBUG "CPU: After vendor identify, caps:" ); -for (i =0 ; i <NCAPINTS ; i++) -printk (" %08x" , c->x86_capability[i]); -printk ("\n" ); -#endif -/* * Vendor-specific initialization. In this section we * canonicalize the feature flags, meaning if there are
@@ -641,13 +634,6 @@ void identify_cpu(struct cpuinfo_x86 *c)xstate_init (c); -#ifdef NOISY_CAPS -printk (KERN_DEBUG "CPU: After all inits, caps:" ); -for (i =0 ; i <NCAPINTS ; i++) -printk (" %08x" , c->x86_capability[i]); -printk ("\n" ); -#endif -/* * If RDRAND is available, make an attempt to check that it actually * (still) works.
Signature · 1 line
2.39.5
Re: [PATCH 13/16] x86/cpu: Drop NOISY_CAPS
Quoted 4 lines · Andrew Cooper
These were plausibly useful for debugging when there were 4 words in x86_capability[], but it's currently 22 words and growing.
Signed-off-by Andrew Cooper <[email protected]>
PATCH 14/16 x86/cpu: Drop default_init() and default_cpu
In reply to Andrew CooperWhile the comment is reasonable, clearing SEP as the only action for an unknown CPU is useless. Drop the infrastructure.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/common.c | 10 ---------- 1 file changed, 10 deletions(-)
xen/arch/x86/cpu/common.c +0 -10
@@ -100,15 +100,6 @@ bool __init is_forced_cpu_cap(unsigned int cap)return test_bit (cap, forced_caps) ||test_bit (cap, cleared_caps); } -static void cf_check default_init(struct cpuinfo_x86 * c) -{ -/* Not much we can do here... */ -__clear_bit (X86_FEATURE_SEP , c->x86_capability); -} - -static const struct cpu_dev __initconst_cf_clobber __used default_cpu = { - .c_init = default_init, -};static struct cpu_dev __ro_after_init actual_cpu; static DEFINE_PER_CPU(uint64_t, msr_misc_features);
@@ -375,7 +366,6 @@ void __init early_cpu_init(bool verbose)case X86_VENDOR_SHANGHAI : actual_cpu = shanghai_cpu_dev;break ;case X86_VENDOR_HYGON : actual_cpu = hygon_cpu_dev;break ;default : - actual_cpu = default_cpu;if (!verbose)break ; printk(XENLOG_ERR
Signature · 1 line
2.39.5
Re: [PATCH 14/16] x86/cpu: Drop default_init() and default_cpu
Quoted 2 lines · Andrew Cooper
While the comment is reasonable, clearing SEP as the only action for an unknown CPU is useless. Drop the infrastructure.
Fair enough.
Quoted 1 line
Signed-off-by Andrew Cooper <[email protected]>
Jan
PATCH 15/16 x86/cpu: Clean up use of LCAP_* constants
In reply to Andrew CooperNow that the LCAP_* constants are single bits, we can simplify the expressions using them.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/cpu/amd.c | 12 ++++++------ xen/arch/x86/domain.c | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-)
xen/arch/x86/cpu/amd.c +6 -6
@@ -171,7 +171,7 @@ void cf_check amd_ctxt_switch_masking(const struct vcpu *next) (nextd &&is_pv_domain (nextd) && nextd->arch.pv.cpuidmasks) ? nextd->arch.pv.cpuidmasks : &cpuidmask_defaults; -if ((levelling_caps & LCAP_1cd) == LCAP_1cd) { +if (levelling_caps & LCAP_1cd) {uint64_t val = masks->_1cd;/*
@@ -192,7 +192,7 @@ void cf_check amd_ctxt_switch_masking(const struct vcpu *next)#define LAZY (cap, msr, field) \ ({ \ if (unlikely(these_masks->field != masks->field) && \ - ((levelling_caps & cap) == cap)) \ + (levelling_caps & cap)) \ { \ wrmsr_amd(msr, masks->field); \ these_masks->field = masks->field; \
@@ -251,7 +251,7 @@ static void __init amd_init_levelling(void)*/ probe_masking_msrs (); -if ((levelling_caps & LCAP_1cd) == LCAP_1cd) { +if (levelling_caps & LCAP_1cd) {uint32_t ecx, edx, tmp;cpuid (0x00000001 , &tmp, &tmp, &ecx, &edx);
@@ -264,7 +264,7 @@ static void __init amd_init_levelling(void) cpuidmask_defaults._1cd = ((uint64_t )ecx <<32 ) | edx; } -if ((levelling_caps & LCAP_e1cd) == LCAP_e1cd) { +if (levelling_caps & LCAP_e1cd) {uint32_t ecx, edx, tmp;cpuid (0x80000001 , &tmp, &tmp, &ecx, &edx);
@@ -275,7 +275,7 @@ static void __init amd_init_levelling(void) cpuidmask_defaults.e1cd = ((uint64_t )ecx <<32 ) | edx; } -if ((levelling_caps & LCAP_7ab0) == LCAP_7ab0) { +if (levelling_caps & LCAP_7ab0) {uint32_t eax, ebx, tmp;cpuid (0x00000007 , &eax, &ebx, &tmp, &tmp);
@@ -283,7 +283,7 @@ static void __init amd_init_levelling(void) cpuidmask_defaults._7ab0 &= ((uint64_t )eax <<32 ) | ebx; } -if ((levelling_caps & LCAP_6c) == LCAP_6c) { +if (levelling_caps & LCAP_6c) {uint32_t ecx =cpuid_ecx (6 ); cpuidmask_defaults._6c &= (~0ULL <<32 ) | ecx;
xen/arch/x86/domain.c +5 -5
@@ -303,7 +303,7 @@ void domain_cpu_policy_changed(struct domain *d)if (is_pv_domain (d) ) { -if ( ((levelling_caps & LCAP_1cd) == LCAP_1cd) ) +if ( levelling_caps & LCAP_1cd ) {uint64_t mask = cpuidmask_defaults._1cd;uint32_t ecx = p->basic._1c;
@@ -368,7 +368,7 @@ void domain_cpu_policy_changed(struct domain *d) d->arch.pv.cpuidmasks->_1cd = mask; } -if ( ((levelling_caps & LCAP_6c) == LCAP_6c) ) +if ( levelling_caps & LCAP_6c ) {uint64_t mask = cpuidmask_defaults._6c;
@@ -378,7 +378,7 @@ void domain_cpu_policy_changed(struct domain *d) d->arch.pv.cpuidmasks->_6c = mask; } -if ( ((levelling_caps & LCAP_7ab0) == LCAP_7ab0) ) +if ( levelling_caps & LCAP_7ab0 ) {uint64_t mask = cpuidmask_defaults._7ab0;
@@ -395,7 +395,7 @@ void domain_cpu_policy_changed(struct domain *d) d->arch.pv.cpuidmasks->_7ab0 = mask; } -if ( ((levelling_caps & LCAP_Da1) == LCAP_Da1) ) +if ( levelling_caps & LCAP_Da1 ) {uint64_t mask = cpuidmask_defaults.Da1;uint32_t eax = p->xstate.Da1;
@@ -406,7 +406,7 @@ void domain_cpu_policy_changed(struct domain *d) d->arch.pv.cpuidmasks->Da1 = mask; } -if ( ((levelling_caps & LCAP_e1cd) == LCAP_e1cd) ) +if ( levelling_caps & LCAP_e1cd ) {uint64_t mask = cpuidmask_defaults.e1cd;uint32_t ecx = p->extd.e1c;
Signature · 1 line
2.39.5
Re: [PATCH 15/16] x86/cpu: Clean up use of LCAP_* constants
Quoted 6 lines · Andrew Cooper
Now that the LCAP_* constants are single bits, we can simplify the expressions using them.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
I was meaning to ask in reply to patch 08, but luckily this time I remembered to peek ahead in the series.
Jan
PATCH 16/16 x86/cpuid: Drop the include of public/sysctl.h
In reply to Andrew CooperFollowing the removal of XEN_SYSCTL_get_cpu_levelling_caps, asm/cpuid.h doesn't need to include public/sysctl.h, but several other header files were picking up their includes transitively through asm/cpuid.h. Untangle them.
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
--- xen/arch/x86/include/asm/cpuid.h | 2 -- xen/arch/x86/include/asm/hvm/hvm.h | 2 ++ xen/arch/x86/include/asm/hvm/vlapic.h | 2 ++ xen/arch/x86/include/asm/hvm/vpt.h | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)
xen/arch/x86/include/asm/cpuid.h +0 -2
@@ -7,8 +7,6 @@#include <xen/kernel.h> #include <xen/percpu.h> -#include <public/sysctl.h> -extern const uint32_t known_features[FSCAPINTS ];/*
xen/arch/x86/include/asm/hvm/hvm.h +2 -0
@@ -19,6 +19,8 @@#include <asm/x86_emulate.h> struct pirq ;/* needed by pi_update_irte */ +struct hvm_hw_cpu ; +struct xen_domctl_createdomain ;#ifdef CONFIG_HVM_FEP /* Permit use of the Forced Emulation Prefix in HVM guests */
xen/arch/x86/include/asm/hvm/vlapic.h +2 -0
@@ -12,6 +12,8 @@#include <xen/tasklet.h> #include <asm/hvm/vpt.h> +#include <public/hvm/save.h> +#define vcpu_vlapic (x) (&(x)->arch.hvm.vlapic)#define vlapic_vcpu (x) (container_of((x), struct vcpu, arch.hvm.vlapic))#define const_vlapic_vcpu (x) (container_of((x), const struct vcpu, \
xen/arch/x86/include/asm/hvm/vpt.h +2 -0
@@ -12,6 +12,8 @@#include <xen/list.h> #include <xen/rwlock.h> +#include <public/hvm/save.h> +/* * Abstract layer of periodic time, one short time. */
Signature · 1 line
2.39.5
Re: [PATCH 16/16] x86/cpuid: Drop the include of public/sysctl.h
Quoted 7 lines · Andrew Cooper
Following the removal of
XEN_SYSCTL_get_cpu_levelling_caps,asm/cpuid.hdoesn't need to includepublic/sysctl.h, but several other header files were picking up their includes transitively throughasm/cpuid.h. Untangle them.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Le 26/01/2026 à 18:56, Andrew Cooper a écrit :
Quoted 53 lines
I was hoping this to be a patch or two, but it got out of hand...
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287078891
https://gitlab.com/xen-project/hardware/xen-staging/-/commits/andrew/nxThe branch has one extra patch to fake up the firmware settings being set to Gitlab CI, not included in this series.
Julien: This ought to suitable to rebase your cleanup on to. In the end, I did the AMD adjustment mostly because I needed it to test the correctness of the prior cleanup.
The final 4 patches are tangential cleanup which I've kept out of the prior work in case we wish to backport it. Everything prior is relevant to untangling, and mostly for the benefit of the AMD side.
The early patches are hopefully non-controvertial. Later patches are a little more RFC, and in need of further testing.
Andrew Cooper (16):
x86/cpu: Fix boot time cache flushing
x86/cpu: Dropcpuid_leveladjustment fromgeneric_identify()x86/intel: Drop thepaddr_bitsworkaround for P4 Nocona/Prescott CPUs x86/cpu: Foldgeneric_identify()into its single caller x86/cpu: Move per-CPU actions out of the vendorearly_init()hook x86/cpu: Rework the vendorearly_init()hooks to be__initx86/cpu: Call the vendorearly_init()hook inearly_cpu_init()xen/sysctl: DropXEN_SYSCTL_get_cpu_levelling_capsx86/intel: Always checkMSR_MISC_ENABLEon all CPUs x86/amd: Always probe and configure the masking MSRs x86/amd: Fix re-activation of TopoExt on Fam15h CPUs x86/amd: Probe for NX support and re-activate if possible x86/cpu: DropNOISY_CAPS
x86/cpu: Dropdefault_init()anddefault_cpu
x86/cpu: Clean up use of LCAP_* constants
x86/cpuid: Drop the include ofpublic/sysctl.hCHANGELOG.md | 2 + tools/flask/policy/modules/dom0.te | 1 - tools/include/xenguest.h | 1 - tools/libs/guest/xg_cpuid_x86.c | 14 --- xen/arch/x86/boot/head.S | 1 - xen/arch/x86/boot/trampoline.S | 29 +++--- xen/arch/x86/boot/wakeup.S | 27 +++--- xen/arch/x86/cpu/amd.c | 107 ++++++++++++++------ xen/arch/x86/cpu/common.c | 135 +++++++++++++------------- xen/arch/x86/cpu/cpu.h | 7 +- xen/arch/x86/cpu/hygon.c | 2 + xen/arch/x86/cpu/intel.c | 74 ++++---------- xen/arch/x86/domain.c | 10 +- xen/arch/x86/flushtlb.c | 19 ++-- xen/arch/x86/include/asm/cpuid.h | 17 ++-- xen/arch/x86/include/asm/hvm/hvm.h | 2 +
Quoted 9 lines
xen/arch/x86/include/asm/hvm/vlapic.h | 2 + xen/arch/x86/include/asm/hvm/vpt.h | 2 + xen/arch/x86/include/asm/trampoline.h | 7 +- xen/arch/x86/sysctl.c | 6 -- xen/include/public/sysctl.h | 22 +---- xen/xsm/flask/hooks.c | 4 - xen/xsm/flask/policy/access_vectors | 2 - 23 files changed, 238 insertions(+), 255 deletions(-)
Tested on a Intel machine with "DEP" disabled, and "Require NX support" disabled, I get a pagefault in hpet code
Quoted 187 lines
(XEN) Xen version 4.22-unstable (tsnake41@(none)) (gcc (Alpine 15.2.0) 15.2.0) debug=y Tue Jan 27 12:06:46 CET 2026 (XEN) Latest ChangeSet: Mon Jan 26 17:53:45 2026 +0000 git:6491616ddd
(XEN) build-id:035024497a4cadebf9e5a2ded61f63ac
(XEN) re-enabled NX (Execute Disable) protection
(XEN) CPU Vendor: Intel, Family 6 (0x6), Model 60 (0x3c), Stepping 3 (raw000306c3)
(XEN) BSP microcode revision:0x0000001a
(XEN) microcode: Bad data in container
(XEN) Microcode: Parse error -22
(XEN) Bootloader: EFI
(XEN) Command line: dom0_mem=2G iommu=verbose,debug console=com1 com1=115200,8n1 guest_loglvl=all loglvl=all (XEN) Xen image load base address:0xc3a00000
(XEN) Video information:
(XEN) VGA is graphics mode 1920x1080, 32 bpp
(XEN) VBE/DDC methods: none; EDID transfer time: 0 seconds
(XEN) Disc information:
(XEN) Found 0 MBR signatures
(XEN) Found 1 EDD information structures
(XEN) EFI RAM map:(XEN) [0000000000000000, 000000000004efff] (usable) (XEN) [000000000004f000, 000000000004ffff] (reserved) (XEN) [0000000000050000, 000000000009dfff] (usable) (XEN) [000000000009e000, 000000000009ffff] (reserved) (XEN) [0000000000100000, 00000000c60c3fff] (usable) (XEN) [00000000c60c4000, 00000000c60cafff] (ACPI NVS) (XEN) [00000000c60cb000, 00000000c650ffff] (usable) (XEN) [00000000c6510000, 00000000c68c6fff] (reserved) (XEN) [00000000c68c7000, 00000000d9867fff] (usable) (XEN) [00000000d9868000, 00000000d98f1fff] (reserved) (XEN) [00000000d98f2000, 00000000d991bfff] (ACPI data) (XEN) [00000000d991c000, 00000000d9a06fff] (ACPI NVS) (XEN) [00000000d9a07000, 00000000d9ffefff] (reserved) (XEN) [00000000d9fff000, 00000000d9ffffff] (usable) (XEN) [00000000dc000000, 00000000de1fffff] (reserved) (XEN) [00000000f8000000, 00000000fbffffff] (reserved) (XEN) [00000000fec00000, 00000000fec00fff] (reserved) (XEN) [00000000fed00000, 00000000fed03fff] (reserved) (XEN) [00000000fed1c000, 00000000fed1ffff] (reserved) (XEN) [00000000fee00000, 00000000fee00fff] (reserved) (XEN) [00000000ff000000, 00000000ffffffff] (reserved) (XEN) [0000000100000000, 000000041fdfffff] (usable)(XEN) ACPI: RSDP D9901298, 0024 (r2 HPQOEM)
(XEN) ACPI: XSDT D99012BC, 00B4 (r1 HPQOEM SLIC-BPC 20170509 AMI 10013)
(XEN) ACPI: FACP D9910018, 010C (r5 HPQOEM SLIC-BPC 20170509 AMI 10013)
(XEN) ACPI: DSDT D99021D0, DE46 (r2 HPQOEM SLIC-BPC 1 INTL 20091112)
(XEN) ACPI: FACS D9A05080, 0040
(XEN) ACPI: APIC D9910128, 0072 (r3 HPQOEM SLIC-BPC 20170509 AMI 10013)
(XEN) ACPI: FPDT D99101A0, 0044 (r1 HPQOEM SLIC-BPC 20170509 AMI 10013)(XEN) ACPI: SSDT D99101E8, 0539 (r1 PmRef Cpu0Ist 3000 INTL 20120711) (XEN) ACPI: SSDT D9910728, 0AD8 (r1 PmRef CpuPm 3000 INTL 20120711) (XEN) ACPI: SSDT D9911200, 01C7 (r1 PmRef LakeTiny 3000 INTL 20120711)(XEN) ACPI: MCFG D99113C8, 003C (r1 HPQOEM SLIC-BPC 20170509 MSFT 97)
(XEN) ACPI: HPET D9911408, 0038 (r1 HPQOEM SLIC-BPC 20170509 AMI. 5)
(XEN) ACPI: SSDT D9911440, 036D (r1 SataRe SataTabl 1000 INTL 20120711)
(XEN) ACPI: SSDT D99117B0, 348C (r1 SaSsdt SaSsdt 3000 INTL 20091112)
(XEN) ACPI: SSDT D9914C40, 668F (r1 COMPAQ WMI 1 MSFT 3000001)
(XEN) ACPI: SLIC D991B2D0, 0176 (r1 HPQOEM SLIC-BPC 1 0)
(XEN) ACPI: MSDM D991B448, 0055 (r3 HPQOEM SLIC-BPC 20170509 HPQ 10013)
(XEN) ACPI: ASF! D991B4A0, 00A5 (r32 INTEL HCG 1 TFSM F4240)
(XEN) ACPI: TCPA D991B548, 0032 (r2 APTIO4 NAPAASF 1 MSFT 1000013)
(XEN) ACPI: BGRT D991B580, 0038 (r0 HPQOEM SLIC-BPC 20170509 AMI 10013)
(XEN) ACPI: DMAR D991B5B8, 00B8 (r1 INTEL HSW 1 INTL 1)
(XEN) ACPI: WPBT D9901370, 0034 (r1 ABT-NT ABT-WPBT 1 ABTW 20120402)
(XEN) System RAM: 16274MB (16664864kB)
(XEN) No NUMA configuration found
(XEN) Faking a node at 0000000000000000-000000041fe00000
(XEN) Domain heap initialised
(XEN) SMBIOS 2.7 present.
(XEN) DMI 2.7 present.
(XEN) PCI: MCFG configuration 0: basef8000000segment 0000 buses 00 - 3f
(XEN) PCI: MCFG area atf8000000reserved in E820
(XEN) PCI: Using MCFG for segment 0000 bus 00-3f
(XEN) [VT-D]Host address width 39
(XEN) [VT-D]foundACPI_DMAR_DRHD:
(XEN) [VT-D]dmaru->address=fed90000
(XEN) [VT-D]drhd->address =fed90000iommu->reg=ffff82c000209000
(XEN) [VT-D]cap =c0000020660462ecap = f0101a
(XEN) [VT-D] endpoint: 0000:00:02.0
(XEN) [VT-D]foundACPI_DMAR_DRHD:
(XEN) [VT-D]dmaru->address=fed91000
(XEN) [VT-D]drhd->address =fed91000iommu->reg=ffff82c00020b000
(XEN) [VT-D]cap =d2008020660462ecap = f010da
(XEN) [VT-D] IOAPIC: 0000:f0:1f.0
(XEN) [VT-D] MSI HPET: 0000:f0:0f.0
(XEN) [VT-D] flags:INCLUDE_ALL
(XEN) [VT-D]foundACPI_DMAR_RMRR:
(XEN) [VT-D] endpoint: 0000:00:1d.0
(XEN) [VT-D] endpoint: 0000:00:1a.0
(XEN) [VT-D] endpoint: 0000:00:14.0
(XEN) [VT-D]drivers/passthrough/vtd/dmar.c:610: RMRR: [d9888000,d9894fff]
(XEN) [VT-D]foundACPI_DMAR_RMRR:
(XEN) [VT-D] endpoint: 0000:00:02.0
(XEN) [VT-D]drivers/passthrough/vtd/dmar.c:610: RMRR: [dc000000,de1fffff]
(XEN) Using APIC driver default
(XEN) ACPI: PM-Timer IO Port:0x408(24 bits)
(XEN) ACPI: v5 SLEEP INFO: control[0:0], status[0:0]
(XEN) ACPI: SLEEP INFO: pm1x_cnt[1:404,1:0], pm1x_evt[1:400,1:0]
(XEN) ACPI: 32/64X FACS address mismatch in FADT - d9a05080/0000000000000000, using 32
(XEN) ACPI: wakeup_vec[d9a0508c], vec_size[20]
(XEN) ACPI: Local APIC address0xfee00000
(XEN) ACPI: IOAPIC (id[0x08] address[0xfec00000] gsi_base[0])
(XEN) IOAPIC[0]:apic_id8, version 32, address0xfec00000, GSI 0-23
(XEN) ACPI:INT_SRC_OVR(bus 0bus_irq0global_irq2 dfl dfl)
(XEN) ACPI:INT_SRC_OVR(bus 0bus_irq9global_irq9 high level)
(XEN) ACPI: IRQ0 used by override.
(XEN) ACPI: IRQ2 used by override.
(XEN) ACPI: IRQ9 used by override.
(XEN) ACPI: HPET id:0x8086a701base:0xfed00000
(XEN) ACPI: BGRT: invalidating v1 image at0xcbc74018
(XEN) Using ACPI (MADT) for SMP configuration information
(XEN) SMP: Allowing 4 CPUs (0 hotplug CPUs)
(XEN) IRQ limits: 24 GSI, 808 MSI/MSI-X
(XEN) [VT-D]drivers/passthrough/vtd/qinval.c:520: QI: using 256-entry ring(s)
(XEN) Switched to APIC driverx2apic_mixed
(XEN)arch/x86/i8259.c:384: PIC aliasing mask: 1c
(XEN) CPU0: 800 ... 3400 MHz
(XEN) xstate: size:0x340and states:0x7
(XEN)arch/x86/cpu/mcheck/mce_intel.c:773: MCA Capability: firstbank 0, extended MCE MSR 0, BCAST, CMCI (XEN) CPU0: Intel machine check reporting enabled
(XEN) Speculative mitigation facilities:(XEN) Hardware hints: (XEN) Hardware features: (XEN) Compiled-in support: INDIRECT_THUNK RETURN_THUNK SHADOW_PAGING HARDEN_ARRAY HARDEN_BRANCH HARDEN_GUEST_ACCESS HARDEN_LOCK (XEN) Xen settings: BTI-Thunk: RETPOLINE, SPEC_CTRL: No, Other: BRANCH_HARDEN (XEN) L1TF: believed vulnerable, maxphysaddr L1D 46, CPUID 39, Safe address 8000000000 (XEN) Support for HVM VMs: RSB EAGER_FPU (XEN) Support for PV VMs: EAGER_FPU (XEN) XPTI (64-bit PV only): Dom0 enabled, DomU enabled (with PCID) (XEN) PV L1TF shadowing: Dom0 disabled, DomU enabled (XEN) Using scheduler: SMP Credit Scheduler rev2 (credit2) (XEN) Initializing Credit2 scheduler (XEN) load_precision_shift: 18 (XEN) load_window_shift: 30 (XEN) underload_balance_tolerance: 0 (XEN) overload_balance_tolerance: -3 (XEN) runqueues arrangement: socket (XEN) cap enforcement granularity: 10ms(XEN) load tracking window length 1073741824 ns
(XEN) Using IDT event delivery
(XEN)arch/x86/time.c:495: PIT aliasing mask: 10
(XEN) ----[ Xen-4.22-unstablex86_64debug=y Not tainted ]----
(XEN) CPU: 0
(XEN) RIP: e008:[<ffff82d04064a6f8>]hpet_setup+0x6b/0x120
(XEN) RFLAGS: 0000000000010082 CONTEXT: hypervisor(XEN) rax: ffff82cffff3a000 rbx: 0000000000000000 rcx: 000000000000000c (XEN) rdx: ffff82fffffffffe rsi: 8000000000000000 rdi: ffff8300c421fff8 (XEN) rbp: ffff82d04065fd28 rsp: ffff82d04065fd18 r8: 0000000000000046 (XEN) r9: ffff82d04092e180 r10: ffff82d04092e188 r11: 0000000000000010 (XEN) r12: ffff82d04069c0c0 r13: ffff82d040666530 r14: ffff82d04092f0a8 (XEN) r15: ffff82d04069c0d8 cr0: 000000008005003b cr4: 00000000001506e0 (XEN) cr3: 00000000c4222000 cr2: ffff82cffff3a000 (XEN) fsb: 0000000000000000 gsb: 0000000000000000 gss: 0000000000000000(XEN) ds: 0000 es: 0000 fs: 0000 gs: 0000 ss: 0000 cs: e008
(XEN) Xen code around <ffff82d04064a6f8> (hpet_setup+0x6b/0x120):
(XEN) 00 a0 f3 ff cf 82 ff ff <8b> 10 84 d2 0f 84 80 00 00 00 a1 04 a0 f3 ff cf (XEN) Xen stack trace from rsp=ffff82d04065fd18:(XEN) ffff82d040666530 ffff82d04092f0a8 ffff82d04065fd48 ffff82d04064963a (XEN) ffff82d040666530 ffff82d04092f0a8 ffff82d04065fd78 ffff82d0406497c9 (XEN) 0000000000000010 ffff82d04069c0c0 ffff82d040666530 ffff82d04092f0a8 (XEN) ffff82d04065fdb8 ffff82d040649fef 0000000000000000 ffff82d04092f1a0 (XEN) ffff82d04092f1a0 ffff82d040808208 0000000000000002 ffff83041a9b8000 (XEN) ffff82d04065ff00 ffff82d0406449d2 ffff82d04069b020 000000041a9c8000 (XEN) ffff82d04069b050 0000000100000000 ffff82d04093ff08 0000000001102000 (XEN) ffff82d040696014 ffff82d04069aff0 000000041dfe5400 0000000000100000 (XEN) 0000000000000000 0000050000000000 ffffffff00000163 000000000041fe00 (XEN) 0000000000000019 0000000601000000 00000001ffffffff ffff82d04065ff08 (XEN) ffff82d04069b020 0000000000000000 0000000000000000 0000000000000000 (XEN) 0000000000000000 0000000000000000 0000000000000000 0000000000000000 (XEN) 0000000000000000 0000000000000000 0000000800000000 000000010000006e (XEN) 0000000000000003 00000000000002f8 ffff82d040927000 ffff82d040927000 (XEN) ffffffffffffffff 0000000000000000 00000000cbcffe58 0000000000000000 (XEN) 00000000c4068acb 00000000c29e2620 0000000000000000 0000000000000000 (XEN) 0000000000000000 0000000000000000 0000000000000000 0000000000000000 (XEN) 0000000000000000 0000000000000000 0000000000000000 0000000000000000 (XEN) 0000000000000000 0000000000000000 0000000000000000 0000000000000000 (XEN) 0000000000000000 0000000000000000 0000000000000000 0000000000000000 (XEN) Xen call trace: (XEN) [<ffff82d04064a6f8>] R hpet_setup+0x6b/0x120 (XEN) [<ffff82d04064963a>] F arch/x86/time.#init_hpet+0x30/0x119 (XEN) [<ffff82d0406497c9>] F arch/x86/time.#try_platform_timer+0x17/0x12b (XEN) [<ffff82d040649fef>] F early_time_init+0x1e7/0x2ec (XEN) [<ffff82d0406449d2>] F __start_xen+0x1f2e/0x25b1 (XEN) (XEN) Pagetable walk from ffff82cffff3a000: (XEN) L4[0x105] = 00000000c4221063 ffffffffffffffff (XEN) L3[0x13f] = 00000000c421f063 ffffffffffffffff (XEN) L2[0x1ff] = 00000000c432b063 ffffffffffffffff (XEN) L1[0x13a] = 80000000fed00173 ffffffffffffffff
Quoted 10 lines
(XEN)
(XEN) **************************************** (XEN) Panic on CPU 0:
(XEN) FATAL PAGE FAULT
(XEN) [error_code=0009]
(XEN) Faulting linear address:ffff82cffff3a000(XEN) **************************************** (XEN)
(XEN) Reboot in five seconds...
(XEN) Resetting with ACPI MEMORY or I/ORESET_REG.
With "require NX", I don't get anything on the serial console, and VGA gives a black screen after loading Xen. I'm not sure what's going on in this case.
If "DEP" is enabled in firmware, there are no issues so far.
Teddy
--
| Vates
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Quoted 17 lines · Teddy Astie
Le 26/01/2026 à 18:56, Andrew Cooper a écrit :
Quoted 16 lines
I was hoping this to be a patch or two, but it got out of hand...
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287078891
https://gitlab.com/xen-project/hardware/xen-staging/-/commits/andrew/nxThe branch has one extra patch to fake up the firmware settings being set to Gitlab CI, not included in this series.
Julien: This ought to suitable to rebase your cleanup on to. In the end, I did the AMD adjustment mostly because I needed it to test the correctness of the prior cleanup.
The final 4 patches are tangential cleanup which I've kept out of the prior work in case we wish to backport it. Everything prior is relevant to untangling, and mostly for the benefit of the AMD side.
Quoted 7 lines
Quoted 5 lines
The early patches are hopefully non-controvertial. Later patches are a little more RFC, and in need of further testing.
<snip>
Tested on a Intel machine with "DEP" disabled, and "Require NX support" disabled, I get a pagefault in hpet code
From above:
Quoted 1 line
Julien: This ought to suitable to rebase your cleanup on to.
This is cleanup only. I've not got the bugfixes for EFI boot yet, so the behaviour you see is still expected for now.
Although, thinking about it, it might be better if I try to merge the two series, so everyone can test the end result.
Thoughts?
Quoted 8 lines
Quoted 8 lines
(XEN) Xen version 4.22-unstable (tsnake41@(none)) (gcc (Alpine 15.2.0) 15.2.0) debug=y Tue Jan 27 12:06:46 CET 2026 (XEN) Latest ChangeSet: Mon Jan 26 17:53:45 2026 +0000 git:6491616ddd
(XEN) build-id:035024497a4cadebf9e5a2ded61f63ac
(XEN) re-enabled NX (Execute Disable) protection
(XEN) CPU Vendor: Intel, Family 6 (0x6), Model 60 (0x3c), Stepping 3 (raw000306c3)
(XEN) BSP microcode revision:0x0000001a
(XEN) microcode: Bad data in container
(XEN) Microcode: Parse error -22
As a tangent, what's going on here?
This is the first time I've seen the error outside of my own testing. Is it a container you expect to be good, or some leftovers on a test machine?
~Andrew
Le 27/01/2026 à 12:39, Andrew Cooper a écrit :
Quoted 30 lines · Teddy Astie
Quoted 17 lines
Le 26/01/2026 à 18:56, Andrew Cooper a écrit :
Quoted 16 lines
I was hoping this to be a patch or two, but it got out of hand...
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287078891
https://gitlab.com/xen-project/hardware/xen-staging/-/commits/andrew/nxThe branch has one extra patch to fake up the firmware settings being set to Gitlab CI, not included in this series.
Julien: This ought to suitable to rebase your cleanup on to. In the end, I did the AMD adjustment mostly because I needed it to test the correctness of the prior cleanup.
The final 4 patches are tangential cleanup which I've kept out of the prior work in case we wish to backport it. Everything prior is relevant to untangling, and mostly for the benefit of the AMD side.
Quoted 7 lines
Quoted 5 lines
The early patches are hopefully non-controvertial. Later patches are a little more RFC, and in need of further testing.
<snip>
Tested on a Intel machine with "DEP" disabled, and "Require NX support" disabled, I get a pagefault in hpet code
From above:
Quoted 1 line
Julien: This ought to suitable to rebase your cleanup on to.
Quoted 8 lines
This is cleanup only. I've not got the bugfixes for EFI boot yet, so the behaviour you see is still expected for now.
Although, thinking about it, it might be better if I try to merge the two series, so everyone can test the end result.
Thoughts?
+1
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
(XEN) Xen version 4.22-unstable (tsnake41@(none)) (gcc (Alpine 15.2.0) 15.2.0) debug=y Tue Jan 27 12:06:46 CET 2026 (XEN) Latest ChangeSet: Mon Jan 26 17:53:45 2026 +0000 git:6491616ddd
(XEN) build-id:035024497a4cadebf9e5a2ded61f63ac
(XEN) re-enabled NX (Execute Disable) protection
(XEN) CPU Vendor: Intel, Family 6 (0x6), Model 60 (0x3c), Stepping 3 (raw000306c3)
(XEN) BSP microcode revision:0x0000001a
(XEN) microcode: Bad data in container
(XEN) Microcode: Parse error -22
Quoted 6 lines
As a tangent, what's going on here?
This is the first time I've seen the error outside of my own testing. Is it a container you expect to be good, or some leftovers on a test machine?
I'm trying to load a Intel ucode (taken from Alpine Linux intel-ucode package) using ucode=intel-ucode.img in xen.cfg (UEFI direct boot).
Many distros ship microcode in a single CPIO image with e.g "kernel/x86/microcode/GenuineIntel.bin" in it.
Quoted 2 lines
~Andrew
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
Quoted 53 lines · Teddy Astie
Le 27/01/2026 à 12:39, Andrew Cooper a écrit :
Quoted 27 lines · Teddy Astie
Quoted 17 lines
Le 26/01/2026 à 18:56, Andrew Cooper a écrit :
Quoted 16 lines
I was hoping this to be a patch or two, but it got out of hand...
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287078891
https://gitlab.com/xen-project/hardware/xen-staging/-/commits/andrew/nxThe branch has one extra patch to fake up the firmware settings being set to Gitlab CI, not included in this series.
Julien: This ought to suitable to rebase your cleanup on to. In the end, I did the AMD adjustment mostly because I needed it to test the correctness of the prior cleanup.
The final 4 patches are tangential cleanup which I've kept out of the prior work in case we wish to backport it. Everything prior is relevant to untangling, and mostly for the benefit of the AMD side.
Quoted 7 lines
Quoted 5 lines
The early patches are hopefully non-controvertial. Later patches are a little more RFC, and in need of further testing.
<snip>
Tested on a Intel machine with "DEP" disabled, and "Require NX support" disabled, I get a pagefault in hpet code
From above:
Quoted 9 lines
Quoted 1 line
Julien: This ought to suitable to rebase your cleanup on to.
This is cleanup only. I've not got the bugfixes for EFI boot yet, so the behaviour you see is still expected for now.
Although, thinking about it, it might be better if I try to merge the two series, so everyone can test the end result.
Thoughts?
+1
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(XEN) Xen version 4.22-unstable (tsnake41@(none)) (gcc (Alpine 15.2.0) 15.2.0) debug=y Tue Jan 27 12:06:46 CET 2026 (XEN) Latest ChangeSet: Mon Jan 26 17:53:45 2026 +0000 git:6491616ddd
(XEN) build-id:035024497a4cadebf9e5a2ded61f63ac
(XEN) re-enabled NX (Execute Disable) protection
(XEN) CPU Vendor: Intel, Family 6 (0x6), Model 60 (0x3c), Stepping 3 (raw000306c3)
(XEN) BSP microcode revision:0x0000001a
(XEN) microcode: Bad data in container
(XEN) Microcode: Parse error -22Quoted 6 lines
As a tangent, what's going on here?
This is the first time I've seen the error outside of my own testing. Is it a container you expect to be good, or some leftovers on a test machine?
Quoted 5 lines
I'm trying to load a Intel ucode (taken from Alpine Linux intel-ucode package) using
ucode=intel-ucode.imgin xen.cfg (UEFI direct boot).Many distros ship microcode in a single CPIO image with e.g "
kernel/x86/microcode/GenuineIntel.bin" in it.
Ah, that's a known thing that doesn't work and has never been addressed. People have been complaining for years, but not on xen-devel.
It's also the subject of a documentation fix that is still pending (and now needs yet another rebase).
https://lore.kernel.org/xen-devel/[email protected]
Now that the ucode boot module handling is clean, we can probably try both a CPIO and raw probe when given a fixed module.
~Andrew
Quoted 63 lines · Andrew Cooper
Quoted 53 lines · Teddy Astie
Le 27/01/2026 à 12:39, Andrew Cooper a écrit :
Quoted 27 lines · Teddy Astie
Quoted 17 lines
Le 26/01/2026 à 18:56, Andrew Cooper a écrit :
Quoted 16 lines
I was hoping this to be a patch or two, but it got out of hand...
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287078891
https://gitlab.com/xen-project/hardware/xen-staging/-/commits/andrew/nxThe branch has one extra patch to fake up the firmware settings being set to Gitlab CI, not included in this series.
Julien: This ought to suitable to rebase your cleanup on to. In the end, I did the AMD adjustment mostly because I needed it to test the correctness of the prior cleanup.
The final 4 patches are tangential cleanup which I've kept out of the prior work in case we wish to backport it. Everything prior is relevant to untangling, and mostly for the benefit of the AMD side.
Quoted 7 lines
Quoted 5 lines
The early patches are hopefully non-controvertial. Later patches are a little more RFC, and in need of further testing.
<snip>
Tested on a Intel machine with "DEP" disabled, and "Require NX support" disabled, I get a pagefault in hpet code
From above:
Quoted 9 lines
Quoted 1 line
Julien: This ought to suitable to rebase your cleanup on to.
This is cleanup only. I've not got the bugfixes for EFI boot yet, so the behaviour you see is still expected for now.
Although, thinking about it, it might be better if I try to merge the two series, so everyone can test the end result.
Thoughts?
+1
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(XEN) Xen version 4.22-unstable (tsnake41@(none)) (gcc (Alpine 15.2.0) 15.2.0) debug=y Tue Jan 27 12:06:46 CET 2026 (XEN) Latest ChangeSet: Mon Jan 26 17:53:45 2026 +0000 git:6491616ddd
(XEN) build-id:035024497a4cadebf9e5a2ded61f63ac
(XEN) re-enabled NX (Execute Disable) protection
(XEN) CPU Vendor: Intel, Family 6 (0x6), Model 60 (0x3c), Stepping 3 (raw000306c3)
(XEN) BSP microcode revision:0x0000001a
(XEN) microcode: Bad data in container
(XEN) Microcode: Parse error -22Quoted 6 lines
As a tangent, what's going on here?
This is the first time I've seen the error outside of my own testing. Is it a container you expect to be good, or some leftovers on a test machine?
Quoted 5 lines
I'm trying to load a Intel ucode (taken from Alpine Linux intel-ucode package) using
ucode=intel-ucode.imgin xen.cfg (UEFI direct boot).Many distros ship microcode in a single CPIO image with e.g "
kernel/x86/microcode/GenuineIntel.bin" in it.Ah, that's a known thing that doesn't work and has never been addressed. People have been complaining for years, but not on xen-devel.
Quoted 6 lines
It's also the subject of a documentation fix that is still pending (and now needs yet another rebase).
https://lore.kernel.org/xen-devel/[email protected]Now that the ucode boot module handling is clean, we can probably try both a CPIO and raw probe when given a fixed module.
What does "raw probe" here mean? "ucode=" with a proper ucode blob specified has always been working for me ... (In fact I don't think I ever really tried the "scan" approach.)
Jan
Quoted 67 lines · Jan Beulich
Quoted 66 lines · Andrew Cooper
Quoted 53 lines · Teddy Astie
Le 27/01/2026 à 12:39, Andrew Cooper a écrit :
Quoted 27 lines · Teddy Astie
Quoted 17 lines
Le 26/01/2026 à 18:56, Andrew Cooper a écrit :
Quoted 16 lines
I was hoping this to be a patch or two, but it got out of hand...
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287078891
https://gitlab.com/xen-project/hardware/xen-staging/-/commits/andrew/nxThe branch has one extra patch to fake up the firmware settings being set to Gitlab CI, not included in this series.
Julien: This ought to suitable to rebase your cleanup on to. In the end, I did the AMD adjustment mostly because I needed it to test the correctness of the prior cleanup.
The final 4 patches are tangential cleanup which I've kept out of the prior work in case we wish to backport it. Everything prior is relevant to untangling, and mostly for the benefit of the AMD side.
Quoted 7 lines
Quoted 5 lines
The early patches are hopefully non-controvertial. Later patches are a little more RFC, and in need of further testing.
<snip>
Tested on a Intel machine with "DEP" disabled, and "Require NX support" disabled, I get a pagefault in hpet code
From above:
Quoted 9 lines
Quoted 1 line
Julien: This ought to suitable to rebase your cleanup on to.
This is cleanup only. I've not got the bugfixes for EFI boot yet, so the behaviour you see is still expected for now.
Although, thinking about it, it might be better if I try to merge the two series, so everyone can test the end result.
Thoughts?
+1
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(XEN) Xen version 4.22-unstable (tsnake41@(none)) (gcc (Alpine 15.2.0) 15.2.0) debug=y Tue Jan 27 12:06:46 CET 2026 (XEN) Latest ChangeSet: Mon Jan 26 17:53:45 2026 +0000 git:6491616ddd
(XEN) build-id:035024497a4cadebf9e5a2ded61f63ac
(XEN) re-enabled NX (Execute Disable) protection
(XEN) CPU Vendor: Intel, Family 6 (0x6), Model 60 (0x3c), Stepping 3 (raw000306c3)
(XEN) BSP microcode revision:0x0000001a
(XEN) microcode: Bad data in container
(XEN) Microcode: Parse error -22Quoted 6 lines
As a tangent, what's going on here?
This is the first time I've seen the error outside of my own testing. Is it a container you expect to be good, or some leftovers on a test machine?
Quoted 5 lines
I'm trying to load a Intel ucode (taken from Alpine Linux intel-ucode package) using
ucode=intel-ucode.imgin xen.cfg (UEFI direct boot).Many distros ship microcode in a single CPIO image with e.g "
kernel/x86/microcode/GenuineIntel.bin" in it.Ah, that's a known thing that doesn't work and has never been addressed. People have been complaining for years, but not on xen-devel.
It's also the subject of a documentation fix that is still pending (and now needs yet another rebase).
https://lore.kernel.org/xen-devel/[email protected]
Quoted 5 lines
Quoted 2 lines
Now that the ucode boot module handling is clean, we can probably try both a CPIO and raw probe when given a fixed module.
What does "raw probe" here mean? "ucode=" with a proper ucode blob specified has always been working for me ... (In fact I don't think I ever really tried the "scan" approach.)
This isn't (really) about scan.
What both Arch (where I noticed this complaint first) and Alpine do is pass:
ucode=CPIO(GenuineIntel.bin, AuthenticAMD.bin)
as would otherwise be prepended to the initrd, and Xen rejects this because it's not a valid vendor blob.
What I'm thinking of is something like this:
xen/arch/x86/cpu/microcode/core.c +0 -0
@@ -847,6 +847,11 @@ static int __init early_microcode_load(struct boot_info *bi)
idx, size);
return -ENODEV;
}
+
+ if ( is_cpio(data) &&
+ find_cpio_data(ucode_ops.cpio_path, data, size) ) + ...;
+
goto found;
}
where we'd accept both raw and CPIO-wrapped blobs any time we nominate an explicit module (whether via Grub, or implicitly via EFI).
~Andrew
Quoted 103 lines · Andrew Cooper
Quoted 67 lines · Jan Beulich
Quoted 66 lines · Andrew Cooper
Quoted 53 lines · Teddy Astie
Le 27/01/2026 à 12:39, Andrew Cooper a écrit :
Quoted 27 lines · Teddy Astie
Quoted 17 lines
Le 26/01/2026 à 18:56, Andrew Cooper a écrit :
Quoted 16 lines
I was hoping this to be a patch or two, but it got out of hand...
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287078891
https://gitlab.com/xen-project/hardware/xen-staging/-/commits/andrew/nxThe branch has one extra patch to fake up the firmware settings being set to Gitlab CI, not included in this series.
Julien: This ought to suitable to rebase your cleanup on to. In the end, I did the AMD adjustment mostly because I needed it to test the correctness of the prior cleanup.
The final 4 patches are tangential cleanup which I've kept out of the prior work in case we wish to backport it. Everything prior is relevant to untangling, and mostly for the benefit of the AMD side.
Quoted 7 lines
Quoted 5 lines
The early patches are hopefully non-controvertial. Later patches are a little more RFC, and in need of further testing.
<snip>
Tested on a Intel machine with "DEP" disabled, and "Require NX support" disabled, I get a pagefault in hpet code
From above:
Quoted 9 lines
Quoted 1 line
Julien: This ought to suitable to rebase your cleanup on to.
This is cleanup only. I've not got the bugfixes for EFI boot yet, so the behaviour you see is still expected for now.
Although, thinking about it, it might be better if I try to merge the two series, so everyone can test the end result.
Thoughts?
+1
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
(XEN) Xen version 4.22-unstable (tsnake41@(none)) (gcc (Alpine 15.2.0) 15.2.0) debug=y Tue Jan 27 12:06:46 CET 2026 (XEN) Latest ChangeSet: Mon Jan 26 17:53:45 2026 +0000 git:6491616ddd
(XEN) build-id:035024497a4cadebf9e5a2ded61f63ac
(XEN) re-enabled NX (Execute Disable) protection
(XEN) CPU Vendor: Intel, Family 6 (0x6), Model 60 (0x3c), Stepping 3 (raw000306c3)
(XEN) BSP microcode revision:0x0000001a
(XEN) microcode: Bad data in container
(XEN) Microcode: Parse error -22Quoted 6 lines
As a tangent, what's going on here?
This is the first time I've seen the error outside of my own testing. Is it a container you expect to be good, or some leftovers on a test machine?
Quoted 5 lines
I'm trying to load a Intel ucode (taken from Alpine Linux intel-ucode package) using
ucode=intel-ucode.imgin xen.cfg (UEFI direct boot).Many distros ship microcode in a single CPIO image with e.g "
kernel/x86/microcode/GenuineIntel.bin" in it.Ah, that's a known thing that doesn't work and has never been addressed. People have been complaining for years, but not on xen-devel.
It's also the subject of a documentation fix that is still pending (and now needs yet another rebase).
https://lore.kernel.org/xen-devel/[email protected]Quoted 5 lines
Quoted 2 lines
Now that the ucode boot module handling is clean, we can probably try both a CPIO and raw probe when given a fixed module.
What does "raw probe" here mean? "ucode=" with a proper ucode blob specified has always been working for me ... (In fact I don't think I ever really tried the "scan" approach.)
This isn't (really) about scan.
What both Arch (where I noticed this complaint first) and Alpine do is pass:
ucode=CPIO(GenuineIntel.bin, AuthenticAMD.bin)
as would otherwise be prepended to the initrd, and Xen rejects this because it's not a valid vendor blob.
What I'm thinking of is something like this:
xen/arch/x86/cpu/microcode/core.c +5
-0@@ -847,6 +847,11 @@ static int __init early_microcode_load(struct boot_info *bi) idx, size); return -ENODEV; } + + if ( is_cpio(data) && + find_cpio_data(ucode_ops.cpio_path, data, size) ) + ...; + goto found; }
Quoted 2 lines
where we'd accept both raw and CPIO-wrapped blobs any time we nominate an explicit module (whether via Grub, or implicitly via EFI).
Ah, I see.
Jan