[PATCH 1/2] KVM: arm64: Track physical CPU number at EL2

Fuad Tabba fuad.tabba at linux.dev
Mon Oct 19 04:43:56 PDT 2026


Hi Marc,

On Mon, 19 Oct 2026 11:34:23 +0100, Marc Zyngier <maz at kernel.org> wrote:
[...]
> > diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h
[...]
> > +DECLARE_PER_CPU(int, hyp_cpu_number);
> > +
> > +#define hyp_smp_processor_id() (__this_cpu_read(hyp_cpu_number))
> >
> 
> Do we really need this? I was hoping that TPIDR_EL2 would give us a
> way to compute the CPU number more or less directly, without having to
> maintain per-CPU variable (which is pretty backward, when you think
> about it...).

No. There's no direct way from TPIDR_EL2 to the CPU number, since
init_hyp_mode() allocates each CPU's hyp per-CPU area separately, but
patch 2 can do without the number. I'll drop this patch in v2, and
patch 2 will keep the last vCPU in a per-CPU array indexed by the VM's
table entry.

Cheers,
/fuad



More information about the linux-arm-kernel mailing list