Skip to contentSkip to conversation

x86/cpu: populate CPUID 0x1.edx features early for self-snoop detection

PATCH In review Roger Pau Monne 4 participants 10 messages Sep 24, 2025 – Sep 25, 2025 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/cpu: populate CPUID 0x1.edx features early for self-snoop detection

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data. However that creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")
---
 xen/arch/x86/cpu/common.c | 3 +++
 1 file changed, 3 insertions(+)
xen/arch/x86/cpu/common.c +3 -0
index 530b9eb39abc..35dcdf0c8801 100644
@@ -490,6 +490,9 @@ static void generic_identify(struct cpuinfo_x86 *c)
 	c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0);
 	c->phys_proc_id = c->apicid;
 
+	/* Early init of Self Snoop support requires 0x1.edx. */
+	c->x86_capability[FEATURESET_1d] = edx;
+
 	eax = cpuid_eax(0x80000000);
 	if ((eax >> 16) == 0x8000)
 		c->extended_cpuid_level = eax;
Signature · 1 line
2.51.0
#1 lore raw
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Quoted 10 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

~Andrew

A message that is not in the archive (sent off-list or not yet received): 2d17d2d502df489f97b51e43a2d86535@DM6PR03MB5227.namprd03.prod.outlook.com

#3 lore raw
Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Well, that's the reason for the rant here. The reset at the top of identify_cpu() has been there since 2005. It's arguably to make sure the BSP and the APs have the same empty state in the passed cpuinfo_x86 struct, as for the BSP this would be already partially initialized due to what's done in early_cpu_init().

The underlying question is whether we would rather prefer to not do the reset for the BSP, but that would lead to differences in the contents of cpuinfo_x86 struct between the BSP and the APs. In the past we have arranged for leaves needed early to be populated in generic_identify(), like FEATURESET_e21a, hence the proposed patch does that for FEATURESET_1d.

Quoted 4 lines
Quoted 4 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

Quoted 8 lines
Quoted 6 lines

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

I think the Fixes tag is accurate; the code was OK before that change. Nothing in c_early_init hooks depended on (some of) the x86_capability fields being populated, which is required after the change.

Thanks, Roger.

Reviewed-by
#4 lore raw
Quoted 32 lines · Roger Pau Monné
Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Well, that's the reason for the rant here. The reset at the top of identify_cpu() has been there since 2005. It's arguably to make sure the BSP and the APs have the same empty state in the passed cpuinfo_x86 struct, as for the BSP this would be already partially initialized due to what's done in early_cpu_init().

The underlying question is whether we would rather prefer to not do the reset for the BSP, but that would lead to differences in the contents of cpuinfo_x86 struct between the BSP and the APs. In the past we have arranged for leaves needed early to be populated in generic_identify(), like FEATURESET_e21a, hence the proposed patch does that for FEATURESET_1d.

Quoted 8 lines
Quoted 8 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

I think the Fixes tag is accurate; the code was OK before that change. Nothing in c_early_init hooks depended on (some of) the x86_capability fields being populated, which is required after the change.

I agree. Hence:

I wonder though whether while there we wouldn't want to also store ecx if we already have it. (Really there is the question of whether we haven't other cpu_has_* uses which similarly come "too early".)

Jan

#5 lore raw
Quoted 42 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Well, that's the reason for the rant here. The reset at the top of identify_cpu() has been there since 2005. It's arguably to make sure the BSP and the APs have the same empty state in the passed cpuinfo_x86 struct, as for the BSP this would be already partially initialized due to what's done in early_cpu_init().

The underlying question is whether we would rather prefer to not do the reset for the BSP, but that would lead to differences in the contents of cpuinfo_x86 struct between the BSP and the APs. In the past we have arranged for leaves needed early to be populated in generic_identify(), like FEATURESET_e21a, hence the proposed patch does that for FEATURESET_1d.

Quoted 8 lines
Quoted 8 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

I think the Fixes tag is accurate; the code was OK before that change. Nothing in c_early_init hooks depended on (some of) the x86_capability fields being populated, which is required after the change.

Quoted 6 lines

I agree. Hence:

I wonder though whether while there we wouldn't want to also store ecx if we already have it. (Really there is the question of whether we haven't other cpu_has_* uses which similarly come "too early".)

Yeah, I was about to do it, but it's not strictly needed for c_early_init, and it's done anyway just after the call to c_early_init. I can set that field also, but then I would need to tweak the comment ahead, something like:

	/*
	 * Early init of Self Snoop support requires 0x1.edx, while
	 * there also set 0x1.ecx as the value is already in context.
	 */
	c->x86_capability[FEATURESET_1d] = edx;
	c->x86_capability[FEATURESET_1c] = ecx;

Thanks, Roger.

#6 lore raw
Quoted 46 lines · Roger Pau Monné
Quoted 45 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Well, that's the reason for the rant here. The reset at the top of identify_cpu() has been there since 2005. It's arguably to make sure the BSP and the APs have the same empty state in the passed cpuinfo_x86 struct, as for the BSP this would be already partially initialized due to what's done in early_cpu_init().

The underlying question is whether we would rather prefer to not do the reset for the BSP, but that would lead to differences in the contents of cpuinfo_x86 struct between the BSP and the APs. In the past we have arranged for leaves needed early to be populated in generic_identify(), like FEATURESET_e21a, hence the proposed patch does that for FEATURESET_1d.

Quoted 8 lines
Quoted 8 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

I think the Fixes tag is accurate; the code was OK before that change. Nothing in c_early_init hooks depended on (some of) the x86_capability fields being populated, which is required after the change.

I agree. Hence:

Quoted 8 lines
Quoted 3 lines

I wonder though whether while there we wouldn't want to also store ecx if we already have it. (Really there is the question of whether we haven't other cpu_has_* uses which similarly come "too early".)

Yeah, I was about to do it, but it's not strictly needed for c_early_init, and it's done anyway just after the call to c_early_init. I can set that field also, but then I would need to tweak the comment ahead, something like:

Sure, i.e. fine with me.

Jan

Quoted 8 lines
	/*
	 * Early init of Self Snoop support requires 0x1.edx, while
	 * there also set 0x1.ecx as the value is already in context.
	 */
	c->x86_capability[FEATURESET_1d] = edx;
	c->x86_capability[FEATURESET_1c] = ecx;

Thanks, Roger.

#7 lore raw
Quoted 51 lines · Jan Beulich
Quoted 50 lines · Roger Pau Monné
Quoted 48 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Well, that's the reason for the rant here. The reset at the top of identify_cpu() has been there since 2005. It's arguably to make sure the BSP and the APs have the same empty state in the passed cpuinfo_x86 struct, as for the BSP this would be already partially initialized due to what's done in early_cpu_init().

The underlying question is whether we would rather prefer to not do the reset for the BSP, but that would lead to differences in the contents of cpuinfo_x86 struct between the BSP and the APs. In the past we have arranged for leaves needed early to be populated in generic_identify(), like FEATURESET_e21a, hence the proposed patch does that for FEATURESET_1d.

Quoted 8 lines
Quoted 8 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

I think the Fixes tag is accurate; the code was OK before that change. Nothing in c_early_init hooks depended on (some of) the x86_capability fields being populated, which is required after the change.

I agree. Hence:

I wonder though whether while there we wouldn't want to also store ecx if we already have it. (Really there is the question of whether we haven't other cpu_has_* uses which similarly come "too early".)

Quoted 6 lines
Quoted 4 lines

Yeah, I was about to do it, but it's not strictly needed for c_early_init, and it's done anyway just after the call to c_early_init. I can set that field also, but then I would need to tweak the comment ahead, something like:

Sure, i.e. fine with me.

Thanks!

Oleksii, can I please get a release-ack for this to go in?

Regards, Roger.

#8 lore raw
Quoted 52 lines · Roger Pau Monné
Quoted 51 lines · Jan Beulich
Quoted 50 lines · Roger Pau Monné
Quoted 48 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Well, that's the reason for the rant here. The reset at the top of identify_cpu() has been there since 2005. It's arguably to make sure the BSP and the APs have the same empty state in the passed cpuinfo_x86 struct, as for the BSP this would be already partially initialized due to what's done in early_cpu_init().

The underlying question is whether we would rather prefer to not do the reset for the BSP, but that would lead to differences in the contents of cpuinfo_x86 struct between the BSP and the APs. In the past we have arranged for leaves needed early to be populated in generic_identify(), like FEATURESET_e21a, hence the proposed patch does that for FEATURESET_1d.

Quoted 8 lines
Quoted 8 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

I think the Fixes tag is accurate; the code was OK before that change. Nothing in c_early_init hooks depended on (some of) the x86_capability fields being populated, which is required after the change.

I agree. Hence:

I wonder though whether while there we wouldn't want to also store ecx if we already have it. (Really there is the question of whether we haven't other cpu_has_* uses which similarly come "too early".)

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Yeah, I was about to do it, but it's not strictly needed for c_early_init, and it's done anyway just after the call to c_early_init. I can set that field also, but then I would need to tweak the comment ahead, something like:

Sure, i.e. fine with me.

Oleksii, can I please get a release-ack for this to go in?

Do bug fixes actually need release-acks just yet?

Jan

#9 lore raw
Quoted 58 lines · Jan Beulich
Quoted 57 lines · Roger Pau Monné
Quoted 56 lines · Jan Beulich
Quoted 54 lines · Roger Pau Monné
Quoted 42 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Well, that's the reason for the rant here. The reset at the top of identify_cpu() has been there since 2005. It's arguably to make sure the BSP and the APs have the same empty state in the passed cpuinfo_x86 struct, as for the BSP this would be already partially initialized due to what's done in early_cpu_init().

The underlying question is whether we would rather prefer to not do the reset for the BSP, but that would lead to differences in the contents of cpuinfo_x86 struct between the BSP and the APs. In the past we have arranged for leaves needed early to be populated in generic_identify(), like FEATURESET_e21a, hence the proposed patch does that for FEATURESET_1d.

Quoted 8 lines
Quoted 8 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

I think the Fixes tag is accurate; the code was OK before that change. Nothing in c_early_init hooks depended on (some of) the x86_capability fields being populated, which is required after the change.

Quoted 6 lines

I agree. Hence:

I wonder though whether while there we wouldn't want to also store ecx if we already have it. (Really there is the question of whether we haven't other cpu_has_* uses which similarly come "too early".)

Yeah, I was about to do it, but it's not strictly needed for c_early_init, and it's done anyway just after the call to c_early_init. I can set that field also, but then I would need to tweak the comment ahead, something like:

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Sure, i.e. fine with me.

Oleksii, can I please get a release-ack for this to go in?

Do bug fixes actually need release-acks just yet?

I always err on the side of caution and ask for them. Maybe Oleksii can state if/when he formally wants release-acks for bugfixes.

Regards, Roger.

#10 lore raw
Quoted 52 lines · Roger Pau Monné
Quoted 51 lines · Jan Beulich
Quoted 50 lines · Roger Pau Monné
Quoted 49 lines · Jan Beulich
Quoted 48 lines · Roger Pau Monné
Quoted 37 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 8 lines · Andrew Cooper
Quoted 6 lines · Roger Pau Monne

Otherwise the check for the SS feature in check_memory_type_self_snoop_errata() fails unconditionally, which leads to X86_FEATURE_XEN_SELFSNOOP never being set.

We could also avoid this by not doing the reset_cpuinfo() for the BSP in identify_cpu(), because SS detection uses boot_cpu_data.

Doesn't this, mean ...

Well, that's the reason for the rant here. The reset at the top of identify_cpu() has been there since 2005. It's arguably to make sure the BSP and the APs have the same empty state in the passed cpuinfo_x86 struct, as for the BSP this would be already partially initialized due to what's done in early_cpu_init().

The underlying question is whether we would rather prefer to not do the reset for the BSP, but that would lead to differences in the contents of cpuinfo_x86 struct between the BSP and the APs. In the past we have arranged for leaves needed early to be populated in generic_identify(), like FEATURESET_e21a, hence the proposed patch does that for FEATURESET_1d.

Quoted 8 lines
Quoted 8 lines

However that
creates an imbalance on the state of the BSP versus the APs in the identify_cpu() code.

I've opted for the less controversial solution of populating FEATURESET_1d in generic_identify(), as the value is already there. The same is done for the AMD faulting probe code.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Fixes f2663ca2e520 ("x86/cpu/intel: Clear cache self-snoop capability in CPUs with known errata")

... this Fixes tag is incorrect?

I think the Fixes tag is accurate; the code was OK before that change. Nothing in c_early_init hooks depended on (some of) the x86_capability fields being populated, which is required after the change.

Quoted 6 lines

I agree. Hence:

I wonder though whether while there we wouldn't want to also store ecx if we already have it. (Really there is the question of whether we haven't other cpu_has_* uses which similarly come "too early".)

Yeah, I was about to do it, but it's not strictly needed for c_early_init, and it's done anyway just after the call to c_early_init. I can set that field also, but then I would need to tweak the comment ahead, something like:

Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

Sure, i.e. fine with me.

Oleksii, can I please get a release-ack for this to go in?

Do bug fixes actually need release-acks just yet?

I always err on the side of caution and ask for them. Maybe Oleksii can state if/when he formally wants release-acks for bugfixes.

I am okay not to have release-acks for bugfixes until the end of code freeze.

When I will announce a next stages of release process, I would put such the information explicitly.

Thanks.

~ Oleksii

Quoted 1 line

Regards, Roger.