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

Re: [PATCH v5 07/12] xen: enable Dom0 to use SVE feature


  • To: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Wed, 19 Apr 2023 07:21:06 +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=wMg3ZPl2fYI3hMPRJtCOP9wN1cxUOVBWkBIJKA0EJfk=; b=A+TkcPYMJ3G5rHo9hW1BY+zar6TLXN0B3amESMuQk5+MBKUXSIcU8UTrF/hcl2BWt87l8f1hImyEMZqPSGVmkSleG59y28Hhaxdr63Ulb9iGdGDZlEn5qpEOak4Sadj6vmaIauQAD+p9WNS/DIZdBAGUwHwu9wSNz8kyeaVfX7HWvTFnFXWWjSG2k02/kGfz90Ch+dRaje5FOYT4r4c2anBTKNJS/ZZCSOclvrVwqGR3qgxnOLZTPCIOV7TIhsu9a9AaZ+0mXb2k9dWRq6JuMFuwJ6V1wzHzacve94AHc3+kFawUaTTVU3mO/mweTDMIXlwItCsJiIDii3lH3yImtw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RBripDd4xF5cBIonh4MA4r2zPuyJ6ObaQ+7H4EB0x2j+4VoJ661ChRT1OWWn3BK/pHTZgLjs/MzULH6QbJOfM/UKFpP910UfU5vNaqHcdnr8A8IYx/OI5J3YXTOi0aowFPGv4bi21wh1z8BuoHJyFi/lGC3xOr580ev6fy7laeFKcHXszAYYqMRsO7gYRHLcuTnropSChI2ETzqOnGb2xLjSrIVllxfvscBetCMaDn/L6E0qBlTXWPjEjGyBrdQlcUG57MxC6KOFpQWS/SZGTNdVWLniAXsApYlLRGUg2oru4TDXk4cw42oJORPfNzmsiO1TXkg9YVIHOcdEINH1FA==
  • 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>, Wei Chen <Wei.Chen@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 19 Apr 2023 07:21:37 +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: AQHZbSQxHdlbNP/OhU+SnBXlOek6la8xDZGAgAE1nQCAAAF/gA==
  • Thread-topic: [PATCH v5 07/12] xen: enable Dom0 to use SVE feature

Hi Luca,

> On 19 Apr 2023, at 09:15, Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
> 
> Hi Bertrand,
> 
>>> 
>>> diff --git a/xen/arch/arm/arm64/sve.c b/xen/arch/arm/arm64/sve.c
>>> index 5485648850a0..ad5db62e1805 100644
>>> --- a/xen/arch/arm/arm64/sve.c
>>> +++ b/xen/arch/arm/arm64/sve.c
>>> @@ -9,6 +9,9 @@
>>> #include <xen/sizes.h>
>>> #include <asm/arm64/sve.h>
>>> 
>>> +/* opt_dom0_sve: allow Dom0 to use SVE and set maximum vector length. */
>>> +int __initdata opt_dom0_sve;
>>> +
>>> 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,
>>> @@ -118,3 +121,21 @@ void sve_restore_state(struct vcpu *v)
>>> 
>>>   sve_load_ctx(sve_ctx_zreg_end, v->arch.vfp.fpregs, 1);
>>> }
>>> +
>>> +int __init sve_sanitize_vl_param(int val, unsigned int *out)
>>> +{
>>> +    /*
>>> +     * Negative SVE parameter value means to use the maximum supported
>>> +     * vector length, otherwise if a positive value is provided, check if 
>>> the
>>> +     * vector length is a multiple of 128 and not bigger than the maximum 
>>> value
>>> +     * 2048
>>> +     */
>>> +    if ( val < 0 )
>>> +        *out = get_sys_vl_len();
>>> +    else if ( ((val % SVE_VL_MULTIPLE_VAL) == 0) && (val <= 
>>> SVE_VL_MAX_BITS) )
>>> +        *out = val;
>> 
>> Shouldn't you also check if it is not greater than the maximum vector length 
>> ?
> 
> I don’t understand, I am checking that the value is below or equal to 
> SVE_VL_MAX_BITS,
> If you mean if it should be checked also against the maximum supported length 
> by the platform,
> I think this is not the right place, the check is already in 
> arch_sanitise_domain_config(), introduced
> in patch #2

If this is not the right place to check it then why checking the rest here ?

From a user or a developer point of view I would expect the validity of the 
input to be checked only
in one place.
If here is not the place for that it is ok but then i would check everything in 
arch_sanitise_domain_config
(multiple, min and supported) instead of doing it partly in 2 places.

> 
>> 
>>> +    else
>>> +        return -1;
>>> +
>>> +    return 0;
>>> +}
>>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>>> index eeb4662f0eee..3f30ef5c37b6 100644
>>> --- a/xen/arch/arm/domain_build.c
>>> +++ b/xen/arch/arm/domain_build.c
>>> @@ -26,6 +26,7 @@
>>> #include <asm/platform.h>
>>> #include <asm/psci.h>
>>> #include <asm/setup.h>
>>> +#include <asm/arm64/sve.h>
>>> #include <asm/cpufeature.h>
>>> #include <asm/domain_build.h>
>>> #include <xen/event.h>
>>> @@ -61,6 +62,21 @@ custom_param("dom0_mem", parse_dom0_mem);
>>> 
>>> int __init parse_arch_dom0_param(const char *s, const char *e)
>>> {
>>> +    long long val;
>>> +
>>> +    if ( !parse_signed_integer("sve", s, e, &val) )
>>> +    {
>>> +#ifdef CONFIG_ARM64_SVE
>>> +        if ( (val >= INT_MIN) && (val <= INT_MAX) )
>>> +            opt_dom0_sve = val;
>>> +        else
>>> +            printk(XENLOG_INFO "'sve=%lld' value out of range!\n", val);
>>> +#else
>>> +        no_config_param("ARM64_SVE", "sve", s, e);
>>> +#endif
>> 
>> Correct me if my understanding is wrong but here you just ignore the sve
>> parameter if SVE is not supported by Xen ?
>> 
>> I am a bit wondering if we should not just refuse it here as the user might
>> wrongly think that his parameter had some effect.
>> 
>> Or is it a usual way to handle this case ?
> 
> Jan suggested this approach, as it should be the preferred way to handle the 
> case,
> looking into the x86 code it seems so.
> 

This is somehow going around the global discussion: is it really ok to ignore 
sve 
param if it is not supported. Let's have this discussion on the other thread 
instead.

Cheers
Bertrand



 


Rackspace

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