[PATCH] x86/amd: Only call setup_force_cpu_cap for boot CPU

Ross Lagerwall posted 1 patch 1 year, 8 months ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20220811105956.3984262-1-ross.lagerwall@citrix.com
xen/arch/x86/cpu/amd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] x86/amd: Only call setup_force_cpu_cap for boot CPU
Posted by Ross Lagerwall 1 year, 8 months ago
This should only be called for the boot CPU to avoid calling _init code
after it has been unloaded.

Fixes: 062868a5a8b4 ("x86/amd: Work around CLFLUSH ordering on older parts")
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---

This replaces "x86/cpu: Drop _init from *_cpu_cap functions".

 xen/arch/x86/cpu/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 29c59bcba4..d5f8e5e899 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -845,7 +845,7 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 	 * everything, including reads and writes to address, and
 	 * LFENCE/SFENCE instructions.
 	 */
-	if (!cpu_has_clflushopt)
+	if (c == &boot_cpu_data && !cpu_has_clflushopt)
 		setup_force_cpu_cap(X86_BUG_CLFLUSH_MFENCE);
 
 	switch(c->x86)
-- 
2.31.1
Re: [PATCH] x86/amd: Only call setup_force_cpu_cap for boot CPU
Posted by Jan Beulich 1 year, 8 months ago
On 11.08.2022 12:59, Ross Lagerwall wrote:
> This should only be called for the boot CPU to avoid calling _init code
> after it has been unloaded.
> 
> Fixes: 062868a5a8b4 ("x86/amd: Work around CLFLUSH ordering on older parts")
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
albeit ...

> --- a/xen/arch/x86/cpu/amd.c
> +++ b/xen/arch/x86/cpu/amd.c
> @@ -845,7 +845,7 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
>  	 * everything, including reads and writes to address, and
>  	 * LFENCE/SFENCE instructions.
>  	 */
> -	if (!cpu_has_clflushopt)
> +	if (c == &boot_cpu_data && !cpu_has_clflushopt)

... I would have put the two sides of the && the other way around.

Jan