[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 3/7] xen/arm: create a cpuinfo structure for guest


  • To: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 10 Dec 2020 15:48:53 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KtWqv1julNLuzMbcf9ge/fy7J8uVhFzcvlP2ga7XGZM=; b=XTCE0c8DSz85PFHliobQsVm6GfPh61Gyzdr/LNI3KGP56ndy/jfCoQ4OfxBkj9oiPcfILj7hXYsMp0XpfJc7HZxdWguY/IjvAlxNQ1v0Ck343NMq29oPX5yRBMSJ/58apzHJqOXhuB7VIqqXgl14ysSwDJasAXx62O94+uYAxEemZ0TjsKhdkY7t9g+Fn5ZlQsotT6gvaKuCcu7RolZXIzSLTsFztKIHJpqL68G/zPTO2dYTphrECQi46kUR+Jgpv5R/9FdjHwv5JmE0swXKbYAMd4di2UDmwwIEN2JcV5qo5I9gzA6PF+o2mIg3EI3A6SqQ5YhO51PS/KO03tsKSg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nxGzgy67q2xfrBSIR2B0QIRvpl0hUhnYmKBEiVNcMflnh1qxWjjtVRfCS8bnPbVG09SkdWNUTUR6vcG5Omb/zhXXDNaIfs/NQY1Ipt5iQ+0YeTHwS3GMfrLqzf2zAwgbD2G4yJAwOBm4p6NLpDoY8zw61fzNEwcVoZx1tuqpAE3uCi/slbaQMdnqkJwlG8pVpiW9R0jGRwhf5naZjE+otc2CBwAtMIoaC2GX+7o7os86pkIJiyiCE2gfJG/2/cKfX1xGyRjQsyLzIiUGOgC6G0BgszXxvhKbu7oFp4oqvVghYU8b2Mdt+KE2k3+H+X0MwJo5LXnH0sBNNPU6CMp2tQ==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 10 Dec 2020 15:49:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWzklW+4XymezDRUeCGhvhzW8UY6nvZCkAgAEXL4A=
  • Thread-topic: [PATCH v3 3/7] xen/arm: create a cpuinfo structure for guest

Hi Julien,

> On 9 Dec 2020, at 23:09, Julien Grall <julien@xxxxxxx> wrote:
> 
> Hi Bertand,
> 
> On 09/12/2020 16:30, Bertrand Marquis wrote:
>> Create a cpuinfo structure for guest and mask into it the features that
>> we do not support in Xen or that we do not want to publish to guests.
>> Modify some values in the cpuinfo structure for guests to mask some
>> features which we do not want to allow to guests (like AMU) or we do not
>> support (like SVE).
>> The code is trying to group together registers modifications for the
>> same feature to be able in the long term to easily enable/disable a
>> feature depending on user parameters or add other registers modification
>> in the same place (like enabling/disabling HCR bits).
>> Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>> ---
>> Changes in V2: Rebase
>> Changes in V3:
>>   Use current_cpu_data info instead of recalling identify_cpu
>> ---
>>  xen/arch/arm/cpufeature.c        | 51 ++++++++++++++++++++++++++++++++
>>  xen/include/asm-arm/cpufeature.h |  2 ++
>>  2 files changed, 53 insertions(+)
>> diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c
>> index bc7ee5ac95..7255383504 100644
>> --- a/xen/arch/arm/cpufeature.c
>> +++ b/xen/arch/arm/cpufeature.c
>> @@ -24,6 +24,8 @@
>>    DECLARE_BITMAP(cpu_hwcaps, ARM_NCAPS);
>>  +struct cpuinfo_arm __read_mostly guest_cpuinfo;
>> +
>>  void update_cpu_capabilities(const struct arm_cpu_capabilities *caps,
>>                               const char *info)
>>  {
>> @@ -157,6 +159,55 @@ void identify_cpu(struct cpuinfo_arm *c)
>>  #endif
>>  }
>>  +/*
>> + * This function is creating a cpuinfo structure with values modified to 
>> mask
>> + * all cpu features that should not be published to guest.
>> + * The created structure is then used to provide ID registers values to 
>> guests.
>> + */
>> +static int __init create_guest_cpuinfo(void)
>> +{
>> +    /*
>> +     * TODO: The code is currently using only the features detected on the 
>> boot
>> +     * core. In the long term we should try to compute values containing 
>> only
>> +     * features supported by all cores.
>> +     */
>> +    guest_cpuinfo = current_cpu_data;
> 
> It would be more logical to use boot_cpu_data as this would be easier to 
> match with your comment.

Agree, I will fix that in V4.

> 
>> +
>> +#ifdef CONFIG_ARM_64
>> +    /* Disable MPAM as xen does not support it */
>> +    guest_cpuinfo.pfr64.mpam = 0;
>> +    guest_cpuinfo.pfr64.mpam_frac = 0;
>> +
>> +    /* Disable SVE as Xen does not support it */
>> +    guest_cpuinfo.pfr64.sve = 0;
>> +    guest_cpuinfo.zfr64.bits[0] = 0;
>> +
>> +    /* Disable MTE as Xen does not support it */
>> +    guest_cpuinfo.pfr64.mte = 0;
>> +#endif
>> +
>> +    /* Disable AMU */
>> +#ifdef CONFIG_ARM_64
>> +    guest_cpuinfo.pfr64.amu = 0;
>> +#endif
>> +    guest_cpuinfo.pfr32.amu = 0;
>> +
>> +    /* Disable RAS as Xen does not support it */
>> +#ifdef CONFIG_ARM_64
>> +    guest_cpuinfo.pfr64.ras = 0;
>> +    guest_cpuinfo.pfr64.ras_frac = 0;
>> +#endif
>> +    guest_cpuinfo.pfr32.ras = 0;
>> +    guest_cpuinfo.pfr32.ras_frac = 0;
> 
> How about all the fields that are currently marked as RES0/RES1? Shouldn't we 
> make sure they will stay like that even if newer architecture use them?

Definitely we can do more then this here (including allowing to enable some 
things for dom0 or for test reasons).
This is a first try to solve current issues with MPAM and SVE and I plan to 
continue to enhance this in the future
to enable more customisation here.
I do think we could do a bit more here to have some features controlled by the 
user but this will need a bit of
discussion to agree on a strategy.

Could we agree to keep the current scope for this serie (to have this in next 
release) and work then on future
enhancements like this ?

Cheers
Bertrand

> 
>> +
>> +    return 0;
>> +}
>> +/*
>> + * This function needs to be run after all smp are started to have
>> + * cpuinfo structures for all cores.
>> + */
>> +__initcall(create_guest_cpuinfo);
>> +
>>  /*
>>   * Local variables:
>>   * mode: C
>> diff --git a/xen/include/asm-arm/cpufeature.h 
>> b/xen/include/asm-arm/cpufeature.h
>> index 6cf83d775b..10b62bd324 100644
>> --- a/xen/include/asm-arm/cpufeature.h
>> +++ b/xen/include/asm-arm/cpufeature.h
>> @@ -283,6 +283,8 @@ extern void identify_cpu(struct cpuinfo_arm *);
>>  extern struct cpuinfo_arm cpu_data[];
>>  #define current_cpu_data cpu_data[smp_processor_id()]
>>  +extern struct cpuinfo_arm guest_cpuinfo;
>> +
>>  #endif /* __ASSEMBLY__ */
>>    #endif
> 
> -- 
> Julien Grall




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.