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

Re: [PATCH v2] tools/arm: Fix nr_spis handling v2


  • To: Michal Orzel <michal.orzel@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 27 Mar 2025 08:46:32 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • 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=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=EI1GXSp91ZqWwTxDJmq6owfxW+3ZqdNpan591mDbQUQ=; b=qzcIua4Gz1LmeHONQ9AJNXFsv8CaejI5wXE+QjCwwYjRR89htuMLu529dnXP/cJ6KtZLs/PsRyoTIcB/sMxtJy2D1xJEO4NFrnI73x7sLknVpgpGaXBOf3a6ePxa5oH1T5jfn946bnCTJyrSfhO8brY1ymOuVSA2hE+x/3GL22NpEiEwvwxqaMTNCfqJmLPS8pSzQBlUayci7+1gmwd9XL57cLTGR9I23iG/H7rc+QzPuaxlgM8S6RP/NRd3TCv6FR56VPnYco2/d6ESUR1hh0EKUfOwVS/MxGsOaiKRRCKNnLB3puRPmQ7gVA3JppzmbPAPcz6OllKUEBeGBl3gzQ==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=EI1GXSp91ZqWwTxDJmq6owfxW+3ZqdNpan591mDbQUQ=; b=c2htxv7hkYa4HufKFFWpWwCIHB4mhJ07OPxVjQ5J1HrBjiifd7JWGv5rD7GWLyZn+1w2PkzRu3/WQWdXuvvqiQfS2//4ERjFOLouFkAYTSwP8FN4RGoqDiZpkQXe/Jss5ZprtlzRsnBJR8WfY3Xzbs7ZqFM88DbuIfnos0VcwXjGk++XJlEapqaceeJkiKaglX5USFJze0ql/go+o9RyJjy2wnOctHXx7CWnHWojtYknKmZxtWhID+SOuLBvJjNMgihR4C0DTx1QasGRDguOz9xWxfRb/LpnF4JcfB1PbdPHIe2M1XwN9khtu7RbIj93f2utGxAZeCzUabgUoFk6jQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=PaAzVZroQehIN9/fWwYlfZhNATlJOs3mKDJelQ9MJIsDKuOMmEt74lJZDcEM6jpnyd2/0Xkv6DjBEN6LjyPbkNZYaTCF9djVUr+jV9K/suGUSPZg7PxJK0pRrnM9fFht/sopEguY/Vf94HBip1Ac75XfSrgVJk4axqiHynAgPet69YOZ6sOQ0+rmwR19kaQClGVR4I7xKcE/kmFYQxCOuYa82KJp9hP4ctrMAtjBmO39c+NlM7p6p06ZuTkJhQfD6TFAVY2Mo1bNKli9gSVmd0x9sImqbWzrOH+0NWVmt6Bm00yIoB0zjPGNn+5uob2HMMa2MirqE4s69MKXpYYetQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QBxWuJ89q40f+OkzPTbr8piyQjn2Vr9VhMtAzhrCbXc7Dyvil/AqDwScDQMzn8E7E0N3Vanz+LZW9ZDQxTdSsAyGIuIOQn3XumVtF/D31p0FdpO/RdZzZa/LfNPe/YdPm7mgnO6G9DeTr4hFGL5nAAvRi7gjlfc0buFoT0G54qbOi5Qg/cvAURKAm/rH+c5Cl8QWCzAK6Mic0uVr+cTqDfR2TKuL+DAsJVYEWNr8jlYoh3wWPSsZwCoNvj76orGPLEVMgG1fCE039m8jMdjPw2GOCsT/zyOH7+5Q0ffGWPUjXowqaApJifXoRIgvb0kduSOnxkypgP8ZV3T/UMTSoQ==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Delivery-date: Thu, 27 Mar 2025 08:46:57 +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: AQHbnXUrXnaixHRQxUWMvvonoQrE9LOGroKA
  • Thread-topic: [PATCH v2] tools/arm: Fix nr_spis handling v2

Hi Michal,

> On 25 Mar 2025, at 12:00, Michal Orzel <michal.orzel@xxxxxxx> wrote:
> 
> We are missing a way to detect whether a user provided a value for
> nr_spis equal to 0 or did not provide any value (default is also 0) which
> can cause issues when calculated nr_spis is > 0 and the value from domain
> config is 0. Fix it by setting default value for nr_spis to newly added
> LIBXL_NR_SPIS_DEFAULT i.e. UINT32_MAX (max supported nr of SPIs is 960
> anyway).
> 
> Fixes: 55d62b8d4636 ("tools/arm: Reject configuration with incorrect nr_spis 
> value")
> Reported-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>

Sounds good to me, so for Arm side of things:

Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> Changes in v2:
> - add LIBXL_NR_SPIS_DEFAULT, rearrange checks
> ---
> tools/include/libxl.h            |  1 +
> tools/libs/light/libxl_arm.c     | 17 +++++++++++------
> tools/libs/light/libxl_types.idl |  2 +-
> 3 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/include/libxl.h b/tools/include/libxl.h
> index f8fe4afd7dca..b7ad7735ca4c 100644
> --- a/tools/include/libxl.h
> +++ b/tools/include/libxl.h
> @@ -1579,6 +1579,7 @@ bool libxl_defbool_val(libxl_defbool db);
> 
> const char *libxl_defbool_to_string(libxl_defbool b);
> 
> +#define LIBXL_NR_SPIS_DEFAULT (~(uint32_t)0)
> #define LIBXL_TIMER_MODE_DEFAULT -1
> #define LIBXL_MEMKB_DEFAULT ~0ULL
> 
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index 2d895408cac3..0adcaa373b54 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>                                       libxl_domain_config *d_config,
>                                       struct xen_domctl_createdomain *config)
> {
> -    uint32_t nr_spis = 0;
> +    uint32_t nr_spis = 0, cfg_nr_spis = d_config->b_info.arch_arm.nr_spis;
>     unsigned int i;
>     uint32_t vuart_irq, virtio_irq = 0;
>     bool vuart_enabled = false, virtio_enabled = false;
> @@ -181,13 +181,18 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
> 
>     LOG(DEBUG, "Configure the domain");
> 
> -    if (nr_spis > d_config->b_info.arch_arm.nr_spis) {
> -        LOG(ERROR, "Provided nr_spis value is too small (minimum required 
> %u)\n",
> -            nr_spis);
> -        return ERROR_FAIL;
> +    /* Check if a user provided a value or not */
> +    if (cfg_nr_spis != LIBXL_NR_SPIS_DEFAULT) {
> +        if (nr_spis > cfg_nr_spis) {
> +            LOG(ERROR, "Provided nr_spis value is too small (minimum 
> required %u)\n",
> +                nr_spis);
> +            return ERROR_FAIL;
> +        }
> +        config->arch.nr_spis = cfg_nr_spis;
>     }
> +    else
> +        config->arch.nr_spis = nr_spis;
> 
> -    config->arch.nr_spis = max(nr_spis, d_config->b_info.arch_arm.nr_spis);
>     LOG(DEBUG, " - Allocate %u SPIs", config->arch.nr_spis);
> 
>     switch (d_config->b_info.arch_arm.gic_version) {
> diff --git a/tools/libs/light/libxl_types.idl 
> b/tools/libs/light/libxl_types.idl
> index bd4b8721ff19..9bb296993199 100644
> --- a/tools/libs/light/libxl_types.idl
> +++ b/tools/libs/light/libxl_types.idl
> @@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
>     ("arch_arm", Struct(None, [("gic_version", libxl_gic_version),
>                                ("vuart", libxl_vuart_type),
>                                ("sve_vl", libxl_sve_type),
> -                               ("nr_spis", uint32),
> +                               ("nr_spis", uint32, {'init_val': 
> 'LIBXL_NR_SPIS_DEFAULT'}),
>                               ])),
>     ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool),
>                               ])),
> -- 
> 2.25.1
> 




 


Rackspace

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