From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 69030D804CC for ; Wed, 11 Oct 2023 10:07:01 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=tYNK/4sUpkjzqG4AiMFsfu6jFij+28ZMtviyReQYRUs=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1697018820; v=1; b=Cm7lDLRZw3YcRw1HtQC3vpp6BkQa166Q9DhL5ozXA+n1H698VhNJtN6tCzdi9ZSC+aU2wAH6 DDt3N2BH9SK/Dz192dE4ppFisY8ACbAsSqxHU51flwYGMcycvseXmq0aaoUKE7lCm8bjEaBJzso qE1Pmo5/oLT3Qbf06HpQPs/E= X-Received: by 127.0.0.2 with SMTP id 1fVbYY7687511xIR2vUrAl4f; Wed, 11 Oct 2023 03:07:00 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.13114.1697018819298849451 for ; Wed, 11 Oct 2023 03:06:59 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-perFZz2yN3qk342WmTSiZA-1; Wed, 11 Oct 2023 06:06:56 -0400 X-MC-Unique: perFZz2yN3qk342WmTSiZA-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5613D185A7B2; Wed, 11 Oct 2023 10:06:56 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.95]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 218401C060B0; Wed, 11 Oct 2023 10:06:56 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DCAE01800936; Wed, 11 Oct 2023 12:06:54 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Rahul Kumar , Ray Ni , Eric Dong , Oliver Steffen , Gerd Hoffmann Subject: [edk2-devel] [PATCH 1/1] UefiCpuPkg/BaseXApicX2ApicLib: fix CPUID_V2_EXTENDED_TOPOLOGY detection Date: Wed, 11 Oct 2023 12:06:54 +0200 Message-ID: <20231011100654.3313309-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: bsc7hEpqmD0mrQcSk3gJKgxWx7686176AA= Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Cm7lDLRZ; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none) Checking the max cpuid leaf is not enough to figure whenever CPUID_V2_EXTENDED_TOPOLOGY is supported. Quoting a comment for CPUID_EXTENDED_TOPOLOGY in GetProcessorLocationByApicId(): // If CPUID.(EAX=0BH, ECX=0H):EBX returns zero and maximum input value for // basic CPUID information is greater than 0BH, then CPUID.0BH leaf is not // supported on that processor. Add a similar check for CPUID_V2_EXTENDED_TOPOLOGY to GetProcessorLocation2ByApicId(). Without this fix OVMF triggers an ASSERT when running in a kvm guest on latest (12th gen) intel processors. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2241388 Signed-off-by: Gerd Hoffmann --- UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c index aa4eb11181f6..eff7f1f2043b 100644 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c @@ -1424,6 +1424,7 @@ GetProcessorLocation2ByApicId ( ) { CPUID_EXTENDED_TOPOLOGY_EAX ExtendedTopologyEax; + CPUID_EXTENDED_TOPOLOGY_EBX ExtendedTopologyEbx; CPUID_EXTENDED_TOPOLOGY_ECX ExtendedTopologyEcx; UINT32 MaxStandardCpuIdIndex; UINT32 Index; @@ -1440,6 +1441,12 @@ GetProcessorLocation2ByApicId ( // AsmCpuid (CPUID_SIGNATURE, &MaxStandardCpuIdIndex, NULL, NULL, NULL); if (MaxStandardCpuIdIndex < CPUID_V2_EXTENDED_TOPOLOGY) { + ExtendedTopologyEbx.Uint32 = 0; + } else { + AsmCpuidEx (CPUID_V2_EXTENDED_TOPOLOGY, 0, NULL, &ExtendedTopologyEbx.Uint32, NULL, NULL); + } + + if (ExtendedTopologyEbx.Uint32 == 0) { if (Die != NULL) { *Die = 0; } -- 2.41.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109523): https://edk2.groups.io/g/devel/message/109523 Mute This Topic: https://groups.io/mt/101893551/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-