Re: [PATCH] x86/cpufeatures: make bits in cpu_caps_cleared[] and cpu_cpus_set[] exclusive

From: Xiaoyao Li
Date: Wed Mar 18 2020 - 08:58:04 EST


On 3/18/2020 6:32 PM, Borislav Petkov wrote:
On Wed, Mar 18, 2020 at 02:16:24PM +0800, Xiaoyao Li wrote:
In apply_forced_caps(), cpu_caps_set[] overrides cpu_caps_cleared[], so
that setup_clear_cpu_cap() cannot clear one cap if setup_force_cpu_cap()
sets the cap before it.

Context pls: what is the observation, what are you trying to do,
reproducer, etc?

Well. I use setup_force_cup_cap(XXX) to set one flag, XXX, during early boot. And use setup_clear_cpu_cap(XXX) to clear this flag when something wrong later. However, it turns out that the flag is still set when I use cpu_has(c, XXX) to check when init each AP. I have to clear the flag XXX explicitly using clear_cpu_cap(c, XXX). However, in /proc/cpuinfo, this XXX flag still presents on every CPU.

Thx.