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

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


  • To: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 1 Dec 2020 11:41:47 +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=KPRYrYgKzdOlPiRSzRXRF9NtPFmB1OkjPCYy8XGSXNc=; b=O/lzXBVjMZBhnUZB9WFSI+gl7LOJ3Qnc2sTm59PnR33Qy5fTszuymlKtzQwG+lu1PtvrxKyA5cVdxZytq5+qJ7TnnLRo/uwUpTyccEL2S9tIAc20b2oF8N3ZCWBisKGyIhqP5zKnrbWkG+2wSx5LnjdOcYGtouPNecvWjqQftzafoFr5NBelyL4FajHaXXwgbf53o2StYxAk7CqVX05Nz2cabOXidIvAH5lzACf6KGQGVxO5FPY3ZMaC95VnbgTIe+44EFkUnO3/+5dMg/LP0h5vOHZv0I+xwntdamuLiY36ocn7tVUtIHYgI6JO8+qRXEmneX6e1WzqHm7Rxj+Hyg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FoC1wxvdUYH5F1i1a0L1V2RWdC9y7t1okYMHXHrBI6d/0skP0L2ISgtJql6RaxgFc7N+NrDqBIdfHtwCDPiGzjQn3QjufiuNjtZN7jemX+NpRD0N+FaIVud02K4kAOmu3QE9bAvb2OQcECU395C7AGkznD8ygAwRTrsrHiOWp7smLpuSiTzAUGKCQ6So3sWi8IeGP69D5oEJ/sV4RJr/DALMkihBWQ8zuun44rJl+UoYg6iIUrMoctpv8+sHS5mm/oaBc/s9tX4jLyGxT5bCAJB7tT5uh/3HPFEZD/nYRWD8P1/08a7ecilyURTKomtpd4/t4FwMItFymydl/HZ6qA==
  • Authentication-results-original: epam.com; dkim=none (message not signed) header.d=none;epam.com; dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Tue, 01 Dec 2020 11:42:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: epam.com; dkim=none (message not signed) header.d=none;epam.com; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWxyRpRLPV3+rSX0iDOmZYGXBVV6nhHOuAgAECsoA=
  • Thread-topic: [PATCH v2 3/7] xen/arm: create a cpuinfo structure for guest

Hi Volodymyr,

> On 30 Nov 2020, at 20:15, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx> 
> wrote:
> 
> 
> Bertrand Marquis writes:
> 
>> 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
>> ---
>> 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 204be9b084..309941ff37 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)
>> {
>> @@ -156,6 +158,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.
>> +     */
>> +    identify_cpu(&guest_cpuinfo);
>> +
>> +#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;
>> +
>> +    return 0;
>> +}
>> +/*
>> + * This function needs to be run after all smp are started to have
>> + * cpuinfo structures for all cores.
>> + */
> 
> This comment contradicts with TODO at the beginning of
> create_guest_cpuinfo().
> 

I think the comment is coherent as it is a prerequisite to solve the TODO.
I made it this way so that nothing would need to be modified there to handle 
the TODO.

So I do not really see a contradiction there, what would you suggest to say 
instead ?

Regards
Bertrand

>> +__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 64354c3f19..0ab6dd42a0 100644
>> --- a/xen/include/asm-arm/cpufeature.h
>> +++ b/xen/include/asm-arm/cpufeature.h
>> @@ -290,6 +290,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
> 
> 
> -- 
> Volodymyr Babchuk at EPAM




 


Rackspace

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