tools/arm: Fix nr_spis handling v2

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: 55d62b8d46 ("tools/arm: Reject configuration with incorrect nr_spis value")
Reported-by: Luca Fancellu <luca.fancellu@arm.com>
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
This commit is contained in:
Michal Orzel authored and Anthony PERARD committed 2025-03-28 11:03:36 +01:00
1 parent 1e18f132af
commit 26d56ef796
3 files changed
+13 -7

No files matched your search

+1
View File
@@ -1579,6 +1579,7 @@ bool libxl_defbool_val(libxl_defbool db);
const char *libxl_defbool_to_string(libxl_defbool b); 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_TIMER_MODE_DEFAULT -1
#define LIBXL_MEMKB_DEFAULT ~0ULL #define LIBXL_MEMKB_DEFAULT ~0ULL
+11 -6
View File
@@ -84,7 +84,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
libxl_domain_config *d_config, libxl_domain_config *d_config,
struct xen_domctl_createdomain *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; unsigned int i;
uint32_t vuart_irq, virtio_irq = 0; uint32_t vuart_irq, virtio_irq = 0;
bool vuart_enabled = false, virtio_enabled = false; 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"); LOG(DEBUG, "Configure the domain");
if (nr_spis > d_config->b_info.arch_arm.nr_spis) { /* Check if a user provided a value or not */
LOG(ERROR, "Provided nr_spis value is too small (minimum required %u)\n", if (cfg_nr_spis != LIBXL_NR_SPIS_DEFAULT) {
nr_spis); if (nr_spis > cfg_nr_spis) {
return ERROR_FAIL; 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); LOG(DEBUG, " - Allocate %u SPIs", config->arch.nr_spis);
switch (d_config->b_info.arch_arm.gic_version) { switch (d_config->b_info.arch_arm.gic_version) {
+1 -1
View File
@@ -723,7 +723,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
("arch_arm", Struct(None, [("gic_version", libxl_gic_version), ("arch_arm", Struct(None, [("gic_version", libxl_gic_version),
("vuart", libxl_vuart_type), ("vuart", libxl_vuart_type),
("sve_vl", libxl_sve_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), ("arch_x86", Struct(None, [("msr_relaxed", libxl_defbool),
])), ])),
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.