From nobody Tue Feb 10 04:30:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1685517905598564.7688449014528; Wed, 31 May 2023 00:25:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.541561.844519 (Exim 4.92) (envelope-from ) id 1q4GCI-0007vu-D2; Wed, 31 May 2023 07:24:42 +0000 Received: by outflank-mailman (output) from mailman id 541561.844519; Wed, 31 May 2023 07:24:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q4GCI-0007ua-6x; Wed, 31 May 2023 07:24:42 +0000 Received: by outflank-mailman (input) for mailman id 541561; Wed, 31 May 2023 07:24:40 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1q4GCG-0005os-8N for xen-devel@lists.xenproject.org; Wed, 31 May 2023 07:24:40 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 332b6d1a-ff84-11ed-8611-37d641c3527e; Wed, 31 May 2023 09:24:37 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 401E015DB; Wed, 31 May 2023 00:25:23 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C7DFA3F663; Wed, 31 May 2023 00:24:36 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 332b6d1a-ff84-11ed-8611-37d641c3527e From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, wei.chen@arm.com, Wei Liu , Anthony PERARD , George Dunlap , Nick Rosbrook , Juergen Gross Subject: [PATCH v8 10/12] xen/tools: add sve parameter in XL configuration Date: Wed, 31 May 2023 08:24:11 +0100 Message-Id: <20230531072413.868673-11-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531072413.868673-1-luca.fancellu@arm.com> References: <20230531072413.868673-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1685517906648100006 Content-Type: text/plain; charset="utf-8" Add sve parameter in XL configuration to allow guests to use SVE feature. Signed-off-by: Luca Fancellu Reviewed-by: Anthony PERARD --- Changes from v7: - add R-by Anthony Changes from v6: - Add check for sve_vl be multiple of 128 (Anthony) Changes from v5: - Update documentation - re-generated golang files Changes from v4: - Rename sve field to sve_vl (Anthony), changed type to libxl_sve_type - Sanity check of sve field in libxl instead of xl, update docs (Anthony) - drop Ack-by from George because of the changes in the Golang bits Changes from v3: - no changes Changes from v2: - domain configuration field name has changed to sve_vl, also its value now is VL/128. - Add Ack-by George for the Golang bits Changes from v1: - updated to use arch_capabilities field for vector length Changes from RFC: - changed libxl_types.idl sve field to uint16 - now toolstack uses info from physinfo to check against the sve XL value - Changed documentation --- docs/man/xl.cfg.5.pod.in | 16 ++++++++++++++ tools/golang/xenlight/helpers.gen.go | 2 ++ tools/golang/xenlight/types.gen.go | 23 +++++++++++++++++++ tools/include/libxl.h | 5 +++++ tools/libs/light/libxl_arm.c | 33 ++++++++++++++++++++++++++++ tools/libs/light/libxl_types.idl | 22 +++++++++++++++++++ tools/xl/xl_parse.c | 8 +++++++ 7 files changed, 109 insertions(+) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 24ac92718288..1b4e13ab647b 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2955,6 +2955,22 @@ Currently, only the "sbsa_uart" model is supported f= or ARM. =20 =3Dback =20 +=3Ditem B + +The `sve` parameter enables Arm Scalable Vector Extension (SVE) usage for = the +guest and sets the maximum SVE vector length, the option is applicable onl= y to +AArch64 guests. +A value equal to "disabled" disables the feature, this is the default valu= e. +Allowed values are "disabled", "128", "256", "384", "512", "640", "768", "= 896", +"1024", "1152", "1280", "1408", "1536", "1664", "1792", "1920", "2048", "h= w". +Specifying "hw" means that the maximum vector length supported by the plat= form +will be used. +Please be aware that if a specific vector length is passed and its value is +above the maximum vector length supported by the platform, an error will be +raised. + +=3Dback + =3Dhead3 x86 =20 =3Dover 4 diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 35397be2f9e2..cd1a16e32eac 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -1149,6 +1149,7 @@ default: return fmt.Errorf("invalid union key '%v'", x.Type)} x.ArchArm.GicVersion =3D GicVersion(xc.arch_arm.gic_version) x.ArchArm.Vuart =3D VuartType(xc.arch_arm.vuart) +x.ArchArm.SveVl =3D SveType(xc.arch_arm.sve_vl) if err :=3D x.ArchX86.MsrRelaxed.fromC(&xc.arch_x86.msr_relaxed);err !=3D = nil { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } @@ -1653,6 +1654,7 @@ default: return fmt.Errorf("invalid union key '%v'", x.Type)} xc.arch_arm.gic_version =3D C.libxl_gic_version(x.ArchArm.GicVersion) xc.arch_arm.vuart =3D C.libxl_vuart_type(x.ArchArm.Vuart) +xc.arch_arm.sve_vl =3D C.libxl_sve_type(x.ArchArm.SveVl) if err :=3D x.ArchX86.MsrRelaxed.toC(&xc.arch_x86.msr_relaxed); err !=3D n= il { return fmt.Errorf("converting field ArchX86.MsrRelaxed: %v", err) } diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index 3d968a496744..b131a7eedc9d 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -490,6 +490,28 @@ TeeTypeNone TeeType =3D 0 TeeTypeOptee TeeType =3D 1 ) =20 +type SveType int +const( +SveTypeHw SveType =3D -1 +SveTypeDisabled SveType =3D 0 +SveType128 SveType =3D 128 +SveType256 SveType =3D 256 +SveType384 SveType =3D 384 +SveType512 SveType =3D 512 +SveType640 SveType =3D 640 +SveType768 SveType =3D 768 +SveType896 SveType =3D 896 +SveType1024 SveType =3D 1024 +SveType1152 SveType =3D 1152 +SveType1280 SveType =3D 1280 +SveType1408 SveType =3D 1408 +SveType1536 SveType =3D 1536 +SveType1664 SveType =3D 1664 +SveType1792 SveType =3D 1792 +SveType1920 SveType =3D 1920 +SveType2048 SveType =3D 2048 +) + type RdmReserve struct { Strategy RdmReserveStrategy Policy RdmReservePolicy @@ -564,6 +586,7 @@ TypeUnion DomainBuildInfoTypeUnion ArchArm struct { GicVersion GicVersion Vuart VuartType +SveVl SveType } ArchX86 struct { MsrRelaxed Defbool diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 4fa09ff7635a..cac641a7eba2 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -283,6 +283,11 @@ */ #define LIBXL_HAVE_BUILDINFO_ARCH_ARM_TEE 1 =20 +/* + * libxl_domain_build_info has the arch_arm.sve_vl field. + */ +#define LIBXL_HAVE_BUILDINFO_ARCH_ARM_SVE_VL 1 + /* * LIBXL_HAVE_SOFT_RESET indicates that libxl supports performing * 'soft reset' for domains and there is 'soft_reset' shutdown reason diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 97c80d7ed0fa..35f76dfc21e4 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -3,6 +3,8 @@ #include "libxl_libfdt_compat.h" #include "libxl_arm.h" =20 +#include + #include #include #include @@ -211,6 +213,12 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return ERROR_FAIL; } =20 + /* Parameter is sanitised in libxl__arch_domain_build_info_setdefault = */ + if (d_config->b_info.arch_arm.sve_vl) { + /* Vector length is divided by 128 in struct xen_domctl_createdoma= in */ + config->arch.sve_vl =3D d_config->b_info.arch_arm.sve_vl / 128U; + } + return 0; } =20 @@ -1685,6 +1693,31 @@ int libxl__arch_domain_build_info_setdefault(libxl__= gc *gc, /* ACPI is disabled by default */ libxl_defbool_setdefault(&b_info->acpi, false); =20 + /* Sanitise SVE parameter */ + if (b_info->arch_arm.sve_vl) { + unsigned int max_sve_vl =3D + arch_capabilities_arm_sve(physinfo->arch_capabilities); + + if (!max_sve_vl) { + LOG(ERROR, "SVE is unsupported on this machine."); + return ERROR_FAIL; + } + + if (LIBXL_SVE_TYPE_HW =3D=3D b_info->arch_arm.sve_vl) { + b_info->arch_arm.sve_vl =3D max_sve_vl; + } else if (b_info->arch_arm.sve_vl > max_sve_vl) { + LOG(ERROR, + "Invalid sve value: %d. Platform supports up to %u bits", + b_info->arch_arm.sve_vl, max_sve_vl); + return ERROR_FAIL; + } else if (b_info->arch_arm.sve_vl % 128) { + LOG(ERROR, + "Invalid sve value: %d. It must be multiple of 128", + b_info->arch_arm.sve_vl); + return ERROR_FAIL; + } + } + if (b_info->type !=3D LIBXL_DOMAIN_TYPE_PV) return 0; =20 diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index fd31dacf7d5a..9e48bb772646 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -523,6 +523,27 @@ libxl_tee_type =3D Enumeration("tee_type", [ (1, "optee") ], init_val =3D "LIBXL_TEE_TYPE_NONE") =20 +libxl_sve_type =3D Enumeration("sve_type", [ + (-1, "hw"), + (0, "disabled"), + (128, "128"), + (256, "256"), + (384, "384"), + (512, "512"), + (640, "640"), + (768, "768"), + (896, "896"), + (1024, "1024"), + (1152, "1152"), + (1280, "1280"), + (1408, "1408"), + (1536, "1536"), + (1664, "1664"), + (1792, "1792"), + (1920, "1920"), + (2048, "2048") + ], init_val =3D "LIBXL_SVE_TYPE_DISABLED") + libxl_rdm_reserve =3D Struct("rdm_reserve", [ ("strategy", libxl_rdm_reserve_strategy), ("policy", libxl_rdm_reserve_policy), @@ -690,6 +711,7 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ =20 ("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("vuart", libxl_vuart_type), + ("sve_vl", libxl_sve_type), ])), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool), ])), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 1f6f47daf4e1..f036e56fc239 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2887,6 +2887,14 @@ skip_usbdev: } } =20 + if (!xlu_cfg_get_string (config, "sve", &buf, 1)) { + e =3D libxl_sve_type_from_string(buf, &b_info->arch_arm.sve_vl); + if (e) { + fprintf(stderr, "Unknown sve \"%s\" specified\n", buf); + exit(EXIT_FAILURE); + } + } + parse_vkb_list(config, d_config); =20 d_config->virtios =3D NULL; --=20 2.34.1