x86/cpu: revert opt_allow_unsafe from __ro_after_init to __read_mostly
PATCH 1/1 x86/cpu: revert opt_allow_unsafe from __ro_after_init to __read_mostly
Making opt_allow_unsafe read only after init requires changes to the logic in init_amd(), otherwise the following #PF happens on CPU hotplug:
----[ Xen-4.20.0-1-d x86_64 debug=y Tainted: H ]----
CPU: 1
RIP: e008:[<ffff82d040291081>] arch/x86/cpu/amd.c#init_amd+0x37f/0x993
[...]
Xen call trace:
[<ffff82d040291081>] R arch/x86/cpu/amd.c#init_amd+0x37f/0x993 [<ffff82d040291fbe>] F identify_cpu+0x2d4/0x4db [<ffff82d04032eeaa>] F start_secondary+0x22e/0x3cf [<ffff82d040203327>] F __high_start+0x87/0xa0
Pagetable walk from ffff82d0404011ea:
L4[0x105] = 000000006fc2e063 ffffffffffffffff
L3[0x141] = 000000006fc2b063 ffffffffffffffff
L2[0x002] = 000000807c7ca063 ffffffffffffffff
L1[0x001] = 800000006f801121 ffffffffffffffff
****************************************
Panic on CPU 1:
FATAL PAGE FAULT
[error_code=0003]
Faulting linear address: ffff82d0404011ea
****************************************
For the time being revert opt_allow_unsafe to be __read_mostly.
--- xen/arch/x86/cpu/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpu/amd.c +1 -1
@@ -46,7 +46,7 @@ static unsigned int __initdata opt_cpuid_mask_thermal_ecx = ~0u;integer_param ("cpuid_mask_thermal_ecx" , opt_cpuid_mask_thermal_ecx);/* 1 = allow, 0 = don't allow guest creation, -1 = don't allow boot */ -int8_t __ro_after_init opt_allow_unsafe; +int8_t __read_mostly opt_allow_unsafe;boolean_param ("allow_unsafe" , opt_allow_unsafe);/* Signal whether the ACPI C1E quirk is required. */
Signature · 1 line
2.46.0
Quoted 19 lines · Roger Pau Monne
Making
opt_allow_unsaferead only after init requires changes to the logic ininit_amd(), otherwise the following #PF happens on CPU hotplug:----[ Xen-4.20.0-1-d
x86_64debug=y Tainted: H ]----
CPU: 1RIP: e008:[<ffff82d040291081>] arch/x86/cpu/amd.c#init_amd+0x37f/0x993 [...] Xen call trace: [<ffff82d040291081>] R arch/x86/cpu/amd.c#init_amd+0x37f/0x993 [<ffff82d040291fbe>] F identify_cpu+0x2d4/0x4db [<ffff82d04032eeaa>] F start_secondary+0x22e/0x3cf [<ffff82d040203327>] F __high_start+0x87/0xa0Pagetable walk from
ffff82d0404011ea:
L4[0x105] =000000006fc2e063ffffffffffffffff
L3[0x141] =000000006fc2b063ffffffffffffffff
L2[0x002] =000000807c7ca063ffffffffffffffff
L1[0x001] =800000006f801121ffffffffffffffff
Quoted 6 lines
****************************************
Panic on CPU 1:
FATAL PAGE FAULT
[error_code=0003]
Faulting linear address:ffff82d0404011ea
****************************************
Hmm, I specifically looked at that code, but I can see how I screwed up.
Quoted 1 line
For the time being revert
opt_allow_unsafeto be__read_mostly.
There's exactly one write that an AP can hit. Is it really worth moving back, rather than just doing
if (opt_allow_unsafe <= 0 && !cpu_has_amd_erratum(c, AMD_ERRATUM_121)) opt_allow_unsafe = 1; else if ...
?
Jan
Quoted 31 lines · Jan Beulich
Quoted 19 lines · Roger Pau Monne
Making
opt_allow_unsaferead only after init requires changes to the logic ininit_amd(), otherwise the following #PF happens on CPU hotplug:----[ Xen-4.20.0-1-d
x86_64debug=y Tainted: H ]----
CPU: 1RIP: e008:[<ffff82d040291081>] arch/x86/cpu/amd.c#init_amd+0x37f/0x993 [...] Xen call trace: [<ffff82d040291081>] R arch/x86/cpu/amd.c#init_amd+0x37f/0x993 [<ffff82d040291fbe>] F identify_cpu+0x2d4/0x4db [<ffff82d04032eeaa>] F start_secondary+0x22e/0x3cf [<ffff82d040203327>] F __high_start+0x87/0xa0Pagetable walk from
ffff82d0404011ea:
L4[0x105] =000000006fc2e063ffffffffffffffff
L3[0x141] =000000006fc2b063ffffffffffffffff
L2[0x002] =000000807c7ca063ffffffffffffffff
L1[0x001] =800000006f801121ffffffffffffffffQuoted 6 lines
****************************************
Panic on CPU 1:
FATAL PAGE FAULT
[error_code=0003]
Faulting linear address:ffff82d0404011ea
****************************************Hmm, I specifically looked at that code, but I can see how I screwed up.
Quoted 1 line
For the time being revert
opt_allow_unsafeto be__read_mostly.
Quoted 8 lines
There's exactly one write that an AP can hit. Is it really worth moving back, rather than just doing
if (opt_allow_unsafe <= 0 && !cpu_has_amd_erratum(c, AMD_ERRATUM_121)) opt_allow_unsafe = 1; else if ...?
I would rather move this logic so it's only the BSP that can set opt_allow_unsafe, and the APs check they match the configuration set by the BSP. I think the resulting logic would be cleaner, but I didn't want to do such a change as part of this fix.
Thanks, Roger.
Jan Beulich
Reviewed-byQuoted 39 lines · Roger Pau Monné
Quoted 38 lines · Jan Beulich
Quoted 19 lines · Roger Pau Monne
Making
opt_allow_unsaferead only after init requires changes to the logic ininit_amd(), otherwise the following #PF happens on CPU hotplug:----[ Xen-4.20.0-1-d
x86_64debug=y Tainted: H ]----
CPU: 1RIP: e008:[<ffff82d040291081>] arch/x86/cpu/amd.c#init_amd+0x37f/0x993 [...] Xen call trace: [<ffff82d040291081>] R arch/x86/cpu/amd.c#init_amd+0x37f/0x993 [<ffff82d040291fbe>] F identify_cpu+0x2d4/0x4db [<ffff82d04032eeaa>] F start_secondary+0x22e/0x3cf [<ffff82d040203327>] F __high_start+0x87/0xa0Pagetable walk from
ffff82d0404011ea:
L4[0x105] =000000006fc2e063ffffffffffffffff
L3[0x141] =000000006fc2b063ffffffffffffffff
L2[0x002] =000000807c7ca063ffffffffffffffff
L1[0x001] =800000006f801121ffffffffffffffffQuoted 6 lines
****************************************
Panic on CPU 1:
FATAL PAGE FAULT
[error_code=0003]
Faulting linear address:ffff82d0404011ea
****************************************Hmm, I specifically looked at that code, but I can see how I screwed up.
Quoted 1 line
For the time being revert
opt_allow_unsafeto be__read_mostly.There's exactly one write that an AP can hit. Is it really worth moving back, rather than just doing
if (opt_allow_unsafe <= 0 && !cpu_has_amd_erratum(c, AMD_ERRATUM_121)) opt_allow_unsafe = 1; else if ...
Quoted 6 lines
Quoted 1 line
?
I would rather move this logic so it's only the BSP that can set
opt_allow_unsafe, and the APs check they match the configuration set by the BSP. I think the resulting logic would be cleaner, but I didn't want to do such a change as part of this fix.
Well, okay then:
And I guess I'll put it in right away.
Jan