[PATCH v4 13/34] KVM: arm64: Enable access to sanitized CPU features at EL2

Will Deacon will at kernel.org
Fri Mar 12 09:25:56 GMT 2021


On Fri, Mar 12, 2021 at 06:34:09AM +0000, Quentin Perret wrote:
> On Thursday 11 Mar 2021 at 19:36:39 (+0000), Will Deacon wrote:
> > On Wed, Mar 10, 2021 at 05:57:30PM +0000, Quentin Perret wrote:
> > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > > index 4f2f1e3145de..84be93df52fa 100644
> > > --- a/arch/arm64/kvm/sys_regs.c
> > > +++ b/arch/arm64/kvm/sys_regs.c
> > > @@ -21,6 +21,7 @@
> > >  #include <asm/debug-monitors.h>
> > >  #include <asm/esr.h>
> > >  #include <asm/kvm_arm.h>
> > > +#include <asm/kvm_cpufeature.h>
> > >  #include <asm/kvm_emulate.h>
> > >  #include <asm/kvm_hyp.h>
> > >  #include <asm/kvm_mmu.h>
> > > @@ -2775,3 +2776,23 @@ void kvm_sys_reg_table_init(void)
> > >  	/* Clear all higher bits. */
> > >  	cache_levels &= (1 << (i*3))-1;
> > >  }
> > > +
> > > +#undef KVM_HYP_CPU_FTR_REG
> > > +#define KVM_HYP_CPU_FTR_REG(id, name) \
> > > +	{ .sys_id = id, .dst = (struct arm64_ftr_reg *)&kvm_nvhe_sym(name) },
> > > +struct __ftr_reg_copy_entry {
> > > +	u32			sys_id;
> > > +	struct arm64_ftr_reg	*dst;
> > > +} hyp_ftr_regs[] __initdata = {
> > > +	#include <asm/kvm_cpufeature.h>
> > > +};
> > 
> > This looks a bit elaborate to me. Why can't you just spell things out here
> > like:
> > 
> > #define KVM_HYP_CPU_FTR_REG(id, name) \
> > 	{ .sys_id = id, .dst = (struct arm64_ftr_reg *)&kvm_nvhe_sym(name) }
> > 
> > struct __ftr_reg_copy_entry {
> > 	u32			sys_id;
> > 	struct arm64_ftr_reg	*dst;
> > } hyp_ftr_regs[] __initdata = {
> > 	KVM_HYP_CPU_FTR_REG(SYS_CTR_EL0, arm64_ftr_reg_ctrel0),
> > 	...
> > };
> > 
> > and then have the header file be a normal, guarded header which just
> > declares these things? The id parameter to the macro isn't used there.
> 
> I just tried to reduce the boilerplate as much as possible -- in the
> current form you only need to add additional features to the header
> it'll 'just work'.

I don't really think it's worth it -- people are used to having to add
declarations for things, so keeping it simple should be fine.

Will



More information about the linux-arm-kernel mailing list