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

Re: [PATCH v5 05/12] arm/sve: save/restore SVE context switch


  • To: Julien Grall <julien@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Thu, 13 Apr 2023 14:35:44 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lXArFAPv3OLfJYe5yu5owMpv8nCKDOluVtSJurcjWrs=; b=IPgl0oMCmOrux1K8jv6or0ejTQ3v9mAs7o1aymsxttX487SEvHrzfM0Q4NzlQ24n8OTwsCc/b48S0hYvvM3HZVlsfc42usYfdZtRBlYnzCw1gQ6eCirca4iUIVN/MK6oykv+d0GXlszuA9NQ2XeWih4IyuddrqlceN3g/EaohU7wVz0X9zeNjHS8OIIly9IhjDx4v6MuV3ESafFS8A4yUYt0PebPBjOkxKILX74TyAysMzbkEItwRLAmO7Acj6Q4zd3K7rId2I/D4pnsLcYcQAhe+LreQLJ0teZsn5lenq9Uywa9kC/3R6ItyKJ5o65SmjKDVxhI9flR0XK7KxqLsQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FNX86LFJq/Y116OYwhQ4i3eeZCPtd1ERpd12kq3u7VTytPexCK7mlfPabjTxFwCB3sO10EQT/FJKoGWQ9+xK7GDcMzh6KUiXZ6OXnV+kvdB3H0a5PP0C1+9YtswwqgDA3A1oDN0sZBj2Su9pnursseFm19Mvf5GAO4uFxbpy9TyMYQblEJOubcJHt51AGE/DyRUHPKO56YAC0OuuzSybds09YssTI8yXvytKBjpMLYhL65rjyOr8U6ZPL1Z8WHgcjxGHRDXjXrbYn/NW0lDj1LruWWX7uBG//BIa9Q1+maodmFtT4z4XXWVymk6DB5ny/dgtOrUMya3wDBauDaDHrg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 13 Apr 2023 14:36:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZbSQ26+FC1T02dEGoq+zimN/6Ra8pOLQAgAAXa4A=
  • Thread-topic: [PATCH v5 05/12] arm/sve: save/restore SVE context switch


> On 13 Apr 2023, at 14:11, Julien Grall <julien@xxxxxxx> wrote:
> 
> 
> 
> On 12/04/2023 10:49, Luca Fancellu wrote:
>> Save/restore context switch for SVE, allocate memory to contain
>> the Z0-31 registers whose length is maximum 2048 bits each and
>> FFR who can be maximum 256 bits, the allocated memory depends on
>> how many bits is the vector length for the domain and how many bits
>> are supported by the platform.
>> Save P0-15 whose length is maximum 256 bits each, in this case the
>> memory used is from the fpregs field in struct vfp_state,
>> because V0-31 are part of Z0-31 and this space would have been
>> unused for SVE domain otherwise.
>> Create zcr_el{1,2} fields in arch_vcpu, initialise zcr_el2 on vcpu
>> creation given the requested vector length and restore it on
>> context switch, save/restore ZCR_EL1 value as well.
>> Remove headers from sve.c that are already included using
>> xen/sched.h.
> I dislike this because ...
> 
>> diff --git a/xen/arch/arm/arm64/sve.c b/xen/arch/arm/arm64/sve.c
>> index 78f7482619da..5485648850a0 100644
>> --- a/xen/arch/arm/arm64/sve.c
>> +++ b/xen/arch/arm/arm64/sve.c
>> @@ -5,14 +5,29 @@
>>   * Copyright (C) 2022 ARM Ltd.
>>   */
>>  -#include <xen/types.h>
>> -#include <asm/cpufeature.h>
> 
> ... it is not entirely obvious that sched.h will import asm/cpufeatures.h. 
> This could easily change in the future and would only require us to re-add 
> those includes.

Ok I will reintroduce #include <asm/cpufeature.h>, do I understand correctly 
that is the only header you would like me to retain?

> 
>> +#include <xen/sched.h>
>> +#include <xen/sizes.h> >   #include <asm/arm64/sve.h>
>> -#include <asm/arm64/sysregs.h>
>> -#include <asm/processor.h>
>> -#include <asm/system.h>
>>    extern unsigned int sve_get_hw_vl(void);
>> +extern void sve_save_ctx(uint64_t *sve_ctx, uint64_t *pregs, int save_ffr);
>> +extern void sve_load_ctx(uint64_t const *sve_ctx, uint64_t const *pregs,
>> +                         int restore_ffr);
>> +
>> +static inline unsigned int sve_zreg_ctx_size(unsigned int vl)
>> +{
>> +    /*
>> +     * Z0-31 registers size in bytes is computed from VL that is in bits, 
>> so VL
>> +     * in bytes is VL/8.
>> +     */
>> +    return (vl / 8U) * 32U;
>> +}
>> +
>> +static inline unsigned int sve_ffrreg_ctx_size(unsigned int vl)
>> +{
>> +    /* FFR register size is VL/8, which is in bytes (VL/8)/8 */
>> +    return (vl / 64U);
>> +}
>>    register_t compute_max_zcr(void)
>>  {
>> @@ -60,3 +75,46 @@ unsigned int get_sys_vl_len(void)
>>      return ((system_cpuinfo.zcr64.bits[0] & ZCR_ELx_LEN_MASK) + 1U) *
>>              SVE_VL_MULTIPLE_VAL;
>>  }
>> +
>> +int sve_context_init(struct vcpu *v)
>> +{
>> +    unsigned int sve_vl_bits = sve_decode_vl(v->domain->arch.sve_vl);
>> +    uint64_t *ctx = _xzalloc(sve_zreg_ctx_size(sve_vl_bits) +
>> +                             sve_ffrreg_ctx_size(sve_vl_bits),
>> +                             L1_CACHE_BYTES);
>> +
>> +    if ( !ctx )
>> +        return -ENOMEM;
>> +
>> +    v->arch.vfp.sve_context = ctx;
>> +
>> +    return 0;
>> +}
>> +
>> +void sve_context_free(struct vcpu *v)
>> +{
>> +    xfree(v->arch.vfp.sve_context);
>> +}
> 
> Please use XFREE().

Sure I’ll do

> 
> Cheers,
> 
> -- 
> Julien Grall


 


Rackspace

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