From nobody Sun May 19 05:50:58 2024 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1691401239987484.1286481194302; Mon, 7 Aug 2023 02:40:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.577935.905060 (Exim 4.92) (envelope-from ) id 1qSwip-0002Iy-7J; Mon, 07 Aug 2023 09:40:19 +0000 Received: by outflank-mailman (output) from mailman id 577935.905060; Mon, 07 Aug 2023 09:40:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qSwip-0002Ir-4M; Mon, 07 Aug 2023 09:40:19 +0000 Received: by outflank-mailman (input) for mailman id 577935; Mon, 07 Aug 2023 09:40:17 +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 1qSwin-0002Ij-GS for xen-devel@lists.xenproject.org; Mon, 07 Aug 2023 09:40:17 +0000 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 679d72dc-3506-11ee-b27d-6b7b168915f2; Mon, 07 Aug 2023 11:40:15 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 431FF3200583; Mon, 7 Aug 2023 05:40:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 07 Aug 2023 05:40:10 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 7 Aug 2023 05:40:07 -0400 (EDT) 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: 679d72dc-3506-11ee-b27d-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t= 1691401209; x=1691487609; bh=CQofn4kIIMGyS3oRnZGe7L+ew6Ute4sCDJJ Fql2/Wzo=; b=VoQvsoUsTgoYMIcsh1iIBzf9FfYI7JymX5ew1jXBGtJGRkgzp8+ BzR5ji4sK+cscLabQPEW9W0Bfzsoa8f8TRAExLhnHA0L6z1UCKDhOIl/Xg206cAK afofzpilWyFdoDcdaz6XIhLgsDiGH+8icS2uSeehCGgl3y6DN1PQGRhAeGiIGkhH N6A4I4cz1e6ScUrXS81ZA+Z48a3AEs9F8ZoXpBs8kZVhiBAk3wm9Kq77pTM2gejm 0kptXcV+GWxqqJ3efFihK17LeHIfSGHpKPM3rYQ0DSqMXOR+xMajLSvhlg5mPRDD J5Nlu9lyjhsi20U1+7MLo1YrLFbuLUEW33Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1691401209; x=1691487609; bh=CQofn4kIIMGyS 3oRnZGe7L+ew6Ute4sCDJJFql2/Wzo=; b=bLP2urWte1cys9qMwAxSC/kFcKFAV NlwqlsP+9BROhFDF+k4ZTxEXmrv8GiQma3zZCD9BGraox8+yJ0svJeE8B1NN2J/c jgIIyEgEZZAtnNITJgPgoFLwshGQj1Esjf0MzC2UrjjIX+InbS3pv1EpCUESEQQg PZ7z8fj2U2iYxdL5P0XJ9aC6LD2rTFj1WlsyjSKI6EIeJfTF3i3LxJorWTJGUsfV rx7kGSclO964m0LEFLve+bAfRDK87vGyWjtMiC8YpsAUjXQVsuxpwdo/7joWT7s7 niK7WnWsFoNgiN35JvU8iYgKVr6jLuEXH3PRol4vz1n6JHfPnXqEZt0Bw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrledtgddujecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefuihhmohhnucfi rghishgvrhcuoehsihhmohhnsehinhhvihhsihgslhgvthhhihhnghhslhgrsgdrtghomh eqnecuggftrfgrthhtvghrnhepueevheegtdefgeefuddvfeduueduffffffejveeugeef udefiedugedugeevudfgnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsihhmohhnsehinhhv ihhsihgslhgvthhhihhnghhslhgrsgdrtghomh X-ME-Proxy: Feedback-ID: idc5945a3:Fastmail From: Simon Gaiser To: xen-devel@lists.xenproject.org Cc: Simon Gaiser , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [XEN PATCH] x86/ACPI: Ignore entries with invalid APIC IDs when parsing MADT Date: Mon, 7 Aug 2023 11:38:25 +0200 Message-Id: <7f158a54548456daba9f2e105d099d2e5e2c2f38.1691399031.git.simon@invisiblethingslab.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1691401241980100001 Content-Type: text/plain; charset="utf-8" It seems some firmwares put dummy entries in the ACPI MADT table for non existing processors. On my NUC11TNHi5 those have the invalid APIC ID 0xff. Linux already has code to handle those cases both in acpi_parse_lapic [1] as well as in acpi_parse_x2apic [2]. So add the same check to Xen. Note that on some older (2nd gen Core i) laptop of mine I also saw dummy entries with a valid APIC ID. Linux would still ignore those because they have !ACPI_MADT_ENABLED && !ACPI_MADT_ONLINE_CAPABLE. But in Xen this check is only active for madt_revision >=3D 5. But since this version check seems to be intentionally I leave that alone. Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3Df3bf1dbe64b62a2058dd1944c00990df203e8e7a # [1] Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3D10daf10ab154e31237a8c07242be3063fb6a9bf4 # [2] Signed-off-by: Simon Gaiser Acked-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/acpi/boot.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/acpi/boot.c b/xen/arch/x86/acpi/boot.c index 54b72d716b..4a62822fa9 100644 --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -87,14 +87,17 @@ acpi_parse_x2apic(struct acpi_subtable_header *header, = const unsigned long end) if (BAD_MADT_ENTRY(processor, end)) return -EINVAL; =20 + /* Ignore entries with invalid apicid */ + if (processor->local_apic_id =3D=3D 0xffffffff) + return 0; + /* Don't register processors that cannot be onlined. */ if (madt_revision >=3D 5 && !(processor->lapic_flags & ACPI_MADT_ENABLED) && !(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE)) return 0; =20 - if ((processor->lapic_flags & ACPI_MADT_ENABLED) || - processor->local_apic_id !=3D 0xffffffff || opt_cpu_info) { + if ((processor->lapic_flags & ACPI_MADT_ENABLED) || opt_cpu_info) { acpi_table_print_madt_entry(header); log =3D true; } @@ -143,14 +146,17 @@ acpi_parse_lapic(struct acpi_subtable_header * header= , const unsigned long end) if (BAD_MADT_ENTRY(processor, end)) return -EINVAL; =20 + /* Ignore entries with invalid apicid */ + if (processor->id =3D=3D 0xff) + return 0; + /* Don't register processors that cannot be onlined. */ if (madt_revision >=3D 5 && !(processor->lapic_flags & ACPI_MADT_ENABLED) && !(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE)) return 0; =20 - if ((processor->lapic_flags & ACPI_MADT_ENABLED) || - processor->id !=3D 0xff || opt_cpu_info) + if ((processor->lapic_flags & ACPI_MADT_ENABLED) || opt_cpu_info) acpi_table_print_madt_entry(header); =20 /* Record local apic id only when enabled */ --=20 2.40.1