From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.12847.1678191645840335047 for ; Tue, 07 Mar 2023 04:20:46 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U0zFPViu; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678191644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uamgZ0F9fL5QONfG77t4iZq7guNSAzIukdTTxTiiflg=; b=U0zFPViuot91ZIjr9ocBSpcHtEaCBvMKBG5X9DobRxIqr+WV6KlTuxqcExbtdUk2Jjs9VB iE8m015p298U0h98YH/On6L0Zli5dXR7YxWXx4KrAiNFY5D1Ac0/5O39lc5f4hrIIzn+rv g/Qn/VSxv2DoYxSuw66FgO5YLJa8QfM= 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-50-sN93WdTdNCaxksMKzY0EQw-1; Tue, 07 Mar 2023 07:20:41 -0500 X-MC-Unique: sN93WdTdNCaxksMKzY0EQw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9BB185CCE2; Tue, 7 Mar 2023 12:20:39 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64AF318EC6; Tue, 7 Mar 2023 12:20:39 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6F4EA180061C; Tue, 7 Mar 2023 13:20:37 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ray Ni , Pawel Polawski , Rahul Kumar , Gerd Hoffmann , Oliver Steffen , Eric Dong Subject: [PATCH 1/1] UefiCpuPkg/MpInitLib: fix apic mode for cpu hotplug Date: Tue, 7 Mar 2023 13:20:37 +0100 Message-Id: <20230307122037.3100651-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true In case the number of CPUs can in increase beyond 255 due to CPU hotplug choose x2apic mode. Signed-off-by: Gerd Hoffmann --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index e5dc852ed95f..d73b95001263 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -526,7 +526,9 @@ CollectProcessorCount ( // // Enable x2APIC mode if // 1. Number of CPU is greater than 255; or - // 2. There are any logical processors reporting an Initial APIC ID of 255 or greater. + // 2. The platform exposed the exact *boot* CPU count to us in advance, and + // more than 255 logical processors are possible later, with hotplug; or + // 3. There are any logical processors reporting an Initial APIC ID of 255 or greater. // X2Apic = FALSE; if (CpuMpData->CpuCount > 255) { @@ -534,6 +536,10 @@ CollectProcessorCount ( // If there are more than 255 processor found, force to enable X2APIC // X2Apic = TRUE; + } else if ((PcdGet32 (PcdCpuBootLogicalProcessorNumber) > 0) && + (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 255)) + { + X2Apic = TRUE; } else { CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob; for (Index = 0; Index < CpuMpData->CpuCount; Index++) { -- 2.39.2