[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1a22993a-00c2-fdec-58e3-8c39159de67a@I-love.SAKURA.ne.jp>
Date: Wed, 22 Jun 2022 22:31:28 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Tony Lindgren <tony@...mide.com>,
LKML <linux-kernel@...r.kernel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH] ARM: spectre-v2: fix smp_processor_id() warning
On 2022/06/22 20:21, Russell King (Oracle) wrote:
>> static inline void harden_branch_predictor(void)
>> {
>> - harden_branch_predictor_fn_t fn = per_cpu(harden_branch_predictor_fn,
>> - smp_processor_id());
>> + harden_branch_predictor_fn_t fn;
>> +
>> + preempt_disable_notrace();
>> + fn = per_cpu(harden_branch_predictor_fn, raw_smp_processor_id());
>> + preempt_enable_no_resched_notrace();
>> if (fn)
>> fn();
>
> The idea is to get the function for the specific CPU, and then to run it
> _on_ that CPU, and in theory the CPU that took the fault. However, I
> seem to remember there are issues trying to achieve that, and I don't
> have a solution for it.
Hmm, since some ARM processors support Asymmetric Multiprocessing, whether
invalidation is needed depends on which processor was assigned, and that's
the reason smp_processor_id() is used?
I'm not familiar with hardware, but if a CPU assigned to current thread
changes, wouldn't sufficient invalidation take place? In other words, do
we need to worry about fn() call if the CPU that took the fault and the CPU
which runs the code after harden_branch_predictor() returned differs?
If some instructions for CPU-A is not supported by CPU-B, I guess that
reading instructions for CPU-A at per_cpu(harden_branch_predictor_fn) and
executing instructions on CPU-B at fn() causes problems. Is it guaranteed
that all instructions used by fn() are supported by all processors?
If it is not guaranteed, we would need to make sure that fn() runs on a CPU
which per_cpu(harden_branch_predictor_fn) was done for?
Powered by blists - more mailing lists