From nobody Thu Jan 8 17:20:52 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; 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; dkim=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1766067769; cv=none; d=zohomail.com; s=zohoarc; b=DCK3CSbDlGHaod7SQ6MJ5GzPlM96xkS92IOt8jq4Bt6+3AiwDnqsqGg5VHSMXk4F+9U648NgvAmzvimNp1cWz5Iu4iwKPl+x7pNvl6Y6CEiD+SdnvpwdQD0+Sa7uyNknTEG6vrOvjUnbwiizf+NO6zm0Z32zok6EjFcSjZw5h7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766067769; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qjMqUDTOPTxrmqmlAzpdZsg9bO4lkWNc7k62rKcAr10=; b=oAg9GedgGG5vX0R5ENjc933gCizKs1Q3eHbhV6YGUmCMt1n3kNiyxbEcyJtt6PeS/ItYzdVruO12+ZlXyznz4grTlz932iKSn74KHrrAzIYz4RJZzpSX3fNZPZs0yYbbFK9oWsji2te68SpT/2KoFM3Zz7xojqK5CFktCyc6jAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1766067769453571.7263641551489; Thu, 18 Dec 2025 06:22:49 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1189718.1510416 (Exim 4.92) (envelope-from ) id 1vWEtk-0001R0-Lr; Thu, 18 Dec 2025 14:22:32 +0000 Received: by outflank-mailman (output) from mailman id 1189718.1510416; Thu, 18 Dec 2025 14:22:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vWEtk-0001Qt-HF; Thu, 18 Dec 2025 14:22:32 +0000 Received: by outflank-mailman (input) for mailman id 1189718; Thu, 18 Dec 2025 14:22:31 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vWEtj-0001Ql-Ja for xen-devel@lists.xenproject.org; Thu, 18 Dec 2025 14:22:31 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fb64f23f-dc1c-11f0-b15b-2bf370ae4941; Thu, 18 Dec 2025 15:22:28 +0100 (CET) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-640c1fda178so1245493a12.1 for ; Thu, 18 Dec 2025 06:22:28 -0800 (PST) Received: from fedora (user-109-243-71-38.play-internet.pl. [109.243.71.38]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64b585eddfasm2683571a12.15.2025.12.18.06.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Dec 2025 06:22:27 -0800 (PST) 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: fb64f23f-dc1c-11f0-b15b-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766067748; x=1766672548; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qjMqUDTOPTxrmqmlAzpdZsg9bO4lkWNc7k62rKcAr10=; b=Zkm97K+gU6TFItTC3NDgBPotrgL9vz0/Y7fif/YYpryNsgq/zRPokJMmkKqglh4iGn nkYxB7hdASH4UoZ82D+Cb9Ve1SXwLFc/7WP6YFf9aIu2aDmclXFoKNAEMAugq+XydQtb yNNRjlcLTFmcOGyBbii9LtFTEJOpDTwbj5DwtwFKMnx9mTUs2HiFV6JwPJReGVjBwQPG +ZQN33s7F4qmj7C1FIM4KbjndP63vX9wiasfWit8qqU3O7EmhoDysA+nEeDSQt7V5Gug VVMidDQookAD460fUtbHywACjDmc513F1jbCJZua6oFgU1Pe3Rz7RzbRNbuJih9Dl7h8 i/Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766067748; x=1766672548; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qjMqUDTOPTxrmqmlAzpdZsg9bO4lkWNc7k62rKcAr10=; b=kj2kBV9XFtnjbf8QMqFK5itEGFwq239YrG4fg7Ss0cFloE3eRzBA2/uGIrOSHOGvbu FuESs6CkOAGEhf7MoTBu2K3Op34YBzWLG/EhVzZoZr1FR9gUbQ3Z6RkhcW/cIwlu9886 1+1s8tzGcqJS4SONgugf+iUMoR5YxKiEt0X1adA7N/nwltpUgnzJIUUQL9YoQa2Me1Pa IFogfkWoaLkAMLPhVgSYqeSIaBIInWDVi0u8Ev53m/Si1xxhWGUuel8xHoH5o+oTBam2 erAL+xVRKgdPBeKZxnts9rUAMGZ/PbQzRf/vXAPubEXyGtFZsiteElAB3BAG4uED6Dy0 7gCQ== X-Gm-Message-State: AOJu0YyNhA8ap87mE0lrgseferDGSdFnbSaZlBI9vlPud2fN6tZNEHCn Z/xSslmPI9h/c8ZQQ/T841Cbu1cYxPlnV1bAExPEzBQG7biY2Qv1+AAiQkHvEw== X-Gm-Gg: AY/fxX55YrZKhIJYtmatkxxWpQwr7WcrRrJ85UZirxLKXqYMkoMPjdEsVDBpA4YW3Xh gpzY4n+vTsQ9nTyncTT8bsyJc4M/DUMy3c2cAY7Ybaq+F2c9iiU8D0si2YkdQzh0GDK4ng8BnFF bJKPWd5bX74WVRB2fyM/kDQeaMmxQK6SupZ8Oh2eJaTBOs0dVmuWUwiPgcKLXuyBFjrO31K4zu1 opEQLWRZG/YTrscPya9Zr92kQtw91D+IpYESVDiq9lQM10oOT+nJS+UeFA0cqTf5UF79t01UMTj bhLzENzzEool5WFah0mQ5dIPeTEFeaR+rYFBnP8rN8dmYKpJnl9PqkXI36mD/lAuAPEEr56JN2Z GnIIRSoRkoFWA8E+WHEvq+VVB5DF2kkgVgW5+ZjXUI7pd2pm9XoqwB+uqA5yAZpQn86GK7yu72d oCe2Shd9vJzF/9vXktnEqQ11JfHERuzKnWrCkIUhf4PCVk0Z65GdI4OHc= X-Google-Smtp-Source: AGHT+IF48XDoCzvWX8YN114TuI73BnnnKUwHGkubFE9MebNp7YAUy2yjL8c5eQ1QenyK/rtXaZIIeA== X-Received: by 2002:a05:6402:1468:b0:64b:58bf:a05 with SMTP id 4fb4d7f45d1cf-64b58bf0c9emr2902881a12.18.1766067747410; Thu, 18 Dec 2025 06:22:27 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Yann Dirson , Yann Sionneau Subject: [PATCH v1] acpi/arm: relax MADT GICC entry length check to support newer ACPI revisions Date: Thu, 18 Dec 2025 15:22:14 +0100 Message-ID: <929f7a0fb8f92112d445015726db30122a05eb9f.1766060265.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1766067770492158500 Newer ACPI revisions define the MADT GICC entry with Length =3D 82 bytes [1= ]. The current BAD_MADT_GICC_ENTRY() check rejects entries whose length does n= ot match the known values, which leads to: GICv3: No valid GICC entries exist. as observed on the AmpereOne platform. To fix this, import the logic from import from Linux commit 9eb1c92: The BAD_MADT_GICC_ENTRY check is a little too strict because it rejects MADT entries that don't match the currently known lengths. We should remove this restriction to avoid problems if the table length changes. Future code which might depend on additional fields should be written to validate those fields before using them, rather than trying to globally check known MADT version lengths. Link: https://lkml.kernel.org/r/20181012192937.3819951-1-jeremy.linton@ar= m.com Signed-off-by: Jeremy Linton [lorenzo.pieralisi@arm.com: added MADT macro comments] Signed-off-by: Lorenzo Pieralisi Acked-by: Sudeep Holla Cc: Will Deacon Cc: Catalin Marinas Cc: Al Stone Cc: "Rafael J. Wysocki" Signed-off-by: Will Deacon As ACPI_MADT_GICC_LENGTH is dropped, update the functions where it is used. As we rewrite the MADT for hwdom, reuse the host GICC header length instead of ACPI_MADT_GICC_LENGTH. [1] https://uefi.org/specs/ACPI/6.6/05_ACPI_Software_Programming_Model.html= #gic-cpu-interface-gicc-structure Reported-By: Yann Dirson Co-developed-by: Yann Sionneau Signed-off-by: Oleksii Kurochko Reviewed-by: Stefano Stabellini --- I ran CI tests where it made sense for this patch, as I don=E2=80=99t see a= ny CI job that builds Xen with CONFIG_ACPI=3Dy: https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/2222160666 I also built Xen manually with CONFIG_ACPI=3Dy enabled and tested it on the AmpereOne platform. --- xen/arch/arm/gic-v2.c | 3 ++- xen/arch/arm/gic-v3.c | 3 ++- xen/arch/arm/gic.c | 12 +++++++++++- xen/arch/arm/include/asm/acpi.h | 21 +++++++++++++++------ 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index b23e72a3d0..aae6a7bf30 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -1121,7 +1121,8 @@ static int gicv2_make_hwdom_madt(const struct domain = *d, u32 offset) host_gicc =3D container_of(header, struct acpi_madt_generic_interrupt, header); =20 - size =3D ACPI_MADT_GICC_LENGTH; + size =3D host_gicc->header.length; + /* Add Generic Interrupt */ for ( i =3D 0; i < d->max_vcpus; i++ ) { diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index bc07f97c16..75b89efad4 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1672,7 +1672,8 @@ static int gicv3_make_hwdom_madt(const struct domain = *d, u32 offset) =20 host_gicc =3D container_of(header, struct acpi_madt_generic_interrupt, header); - size =3D ACPI_MADT_GICC_LENGTH; + size =3D host_gicc->header.length; + for ( i =3D 0; i < d->max_vcpus; i++ ) { gicc =3D (struct acpi_madt_generic_interrupt *)(base_ptr + table_l= en); diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index ee75258fc3..a0ccda14bf 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -418,8 +418,18 @@ unsigned long gic_get_hwdom_madt_size(const struct dom= ain *d) { unsigned long madt_size; =20 + struct acpi_subtable_header *header; + struct acpi_madt_generic_interrupt *host_gicc; + + header =3D acpi_table_get_entry_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,= 0); + if ( !header ) + panic("Can't get GICC entry"); + + host_gicc =3D container_of(header, struct acpi_madt_generic_interrupt, + header); + madt_size =3D sizeof(struct acpi_table_madt) - + ACPI_MADT_GICC_LENGTH * d->max_vcpus + + host_gicc->header.length * d->max_vcpus + sizeof(struct acpi_madt_generic_distributor) + gic_hw_ops->get_hwdom_extra_madt_size(d); =20 diff --git a/xen/arch/arm/include/asm/acpi.h b/xen/arch/arm/include/asm/acp= i.h index 13756dd341..30bc446d1f 100644 --- a/xen/arch/arm/include/asm/acpi.h +++ b/xen/arch/arm/include/asm/acpi.h @@ -53,13 +53,22 @@ void acpi_smp_init_cpus(void); */ paddr_t acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index); =20 -/* Macros for consistency checks of the GICC subtable of MADT */ -#define ACPI_MADT_GICC_LENGTH \ - (acpi_gbl_FADT.header.revision < 6 ? 76 : 80) +/* + * MADT GICC minimum length refers to the MADT GICC structure table length= as + * defined in the earliest ACPI version supported on arm64, ie ACPI 5.1. + * + * The efficiency_class member was added to the + * struct acpi_madt_generic_interrupt to represent the MADT GICC structure + * "Processor Power Efficiency Class" field, added in ACPI 6.0 whose offset + * is therefore used to delimit the MADT GICC structure minimum length + * appropriately. + */ +#define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ + struct acpi_madt_generic_interrupt, efficiency_class) =20 -#define BAD_MADT_GICC_ENTRY(entry, end) \ - (!(entry) || (unsigned long)(entry) + sizeof(*(entry)) > (end) || \ - (entry)->header.length !=3D ACPI_MADT_GICC_LENGTH) +#define BAD_MADT_GICC_ENTRY(entry, end) \ + (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ + (unsigned long)(entry) + (entry)->header.length > (end)) =20 #ifdef CONFIG_ACPI extern bool acpi_disabled; --=20 2.52.0