From nobody Mon Feb 9 23:39:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70550+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70550+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611071698; cv=none; d=zohomail.com; s=zohoarc; b=id4cTw38CqUsPEbHWdjEfSy+lSEhTZMe6peXv+ZId2ZnukwPfXUpv1dGbO6AgUj98rVGhoCLg+s2IJwijSSB/qn+cmbiv9r5gH7phjWiu2aKub5+hC+rgwV+ck2s14x6A8he/QoujaZYkbw3+15cAFVkruzecWd9GbVSK4WFqKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611071698; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=32Lr/pFLTIwvML4wKqNooLGayr5oeFcu2nfHBbeFSUE=; b=geUl0JZminnILh0Qv0waOsICICYwT5/+cVP9HZw96MoqxTO71dpan2D9lHNmGeGolgA2rLoA09UlbQ1TIj56n0SaYm+38+60wPRKlBdp61JNzh5jGlIc2SbR1PcrkB7JiFFxvE6QraODG+aMQBe1TLXr6zH+aKDxjgICxy4/DB8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70550+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611071698313893.0031492388205; Tue, 19 Jan 2021 07:54:58 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id eYPiYY1788612xkx3btMtSf1; Tue, 19 Jan 2021 07:54:55 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web09.12945.1611071695379241745 for ; Tue, 19 Jan 2021 07:54:55 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-578-av2DEKd7MTGl9n1fjwSm3w-1; Tue, 19 Jan 2021 10:54:52 -0500 X-MC-Unique: av2DEKd7MTGl9n1fjwSm3w-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75B80800D62; Tue, 19 Jan 2021 15:54:51 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-176.ams2.redhat.com [10.36.114.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02DBF614ED; Tue, 19 Jan 2021 15:54:49 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Eric Dong , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Rahul Kumar , Ray Ni , Star Zeng Subject: [edk2-devel] [PATCH v2 3/4] UefiCpuPkg/CpuS3DataDxe: do not allocate useless register tables Date: Tue, 19 Jan 2021 16:54:39 +0100 Message-Id: <20210119155440.2262-4-lersek@redhat.com> In-Reply-To: <20210119155440.2262-1-lersek@redhat.com> References: <20210119155440.2262-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: 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,lersek@redhat.com X-Gm-Message-State: BdUqTpKZDW1tvm4143X3AGcXx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611071695; bh=32Lr/pFLTIwvML4wKqNooLGayr5oeFcu2nfHBbeFSUE=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=gRgFISw/xBSvIRym7S0/MIGZSU08MnpuFjSGcJz/ZpL+zdbgwJRKW3ADWZ8SFzKU7fm 5iDUYugLeO4MNuR04bRktHLw157tUvv8iIXTnbB+FRv4454+PP+RDCLvp5jFfrGxEzMpB gUaxi7ILDHaa4vmDRM4iGlfb7/oFF0xaLQU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" CpuS3DataDxe allocates the "RegisterTable" and "PreSmmInitRegisterTable" arrays in ACPI_CPU_DATA just so every processor in the system can have its own empty register table, matched by APIC ID. This has never been useful in practice. Given commit e992cc3f4859 ("UefiCpuPkg PiSmmCpuDxeSmm: Reduce SMRAM consumption in CpuS3.c", 2021-01-11), simply leave both "AcpiCpuData->RegisterTable" and "AcpiCpuData->PreSmmInitRegisterTable" initialized to the zero address. This simplifies the driver, and saves both normal RAM (boot services data type memory) and -- in PiSmmCpuDxeSmm -- SMRAM. Cc: Eric Dong Cc: Philippe Mathieu-Daud=C3=A9 Cc: Rahul Kumar Cc: Ray Ni Cc: Star Zeng Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3159 Signed-off-by: Laszlo Ersek Reviewed-by: Ray Ni --- Notes: v2: =20 - no changes, pick up feedback tags =20 v1: =20 - Tested by temporarily replacing OvmfPkgPkg/CpuS3DataDxe in the OVMF IA32 and IA32X64 platforms with this driver -- this driver works OK in OVMF as long as no CPUs are hot-plugged. UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c | 32 -------------------- 1 file changed, 32 deletions(-) diff --git a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c b/UefiCpuPkg/CpuS3DataDxe/= CpuS3Data.c index 2be335d91903..078af36cfb41 100644 --- a/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c +++ b/UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c @@ -165,10 +165,6 @@ CpuS3DataInitialize ( UINTN NumberOfCpus; UINTN NumberOfEnabledProcessors; VOID *Stack; - UINTN TableSize; - CPU_REGISTER_TABLE *RegisterTable; - UINTN Index; - EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; UINTN GdtSize; UINTN IdtSize; VOID *Gdt; @@ -255,34 +251,6 @@ CpuS3DataInitialize ( AcpiCpuData->PreSmmInitRegisterTable =3D OldAcpiCpuData->PreSmmInitReg= isterTable; AcpiCpuData->ApLocation =3D OldAcpiCpuData->ApLocation; CopyMem (&AcpiCpuData->CpuStatus, &OldAcpiCpuData->CpuStatus, sizeof (= CPU_STATUS_INFORMATION)); - } else { - // - // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable= for all CPUs - // - TableSize =3D 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); - RegisterTable =3D (CPU_REGISTER_TABLE *)AllocateZeroPages (TableSize); - ASSERT (RegisterTable !=3D NULL); - - for (Index =3D 0; Index < NumberOfCpus; Index++) { - Status =3D MpServices->GetProcessorInfo ( - MpServices, - Index, - &ProcessorInfoBuffer - ); - ASSERT_EFI_ERROR (Status); - - RegisterTable[Index].InitialApicId =3D (UINT32)ProcessorInfoBuf= fer.ProcessorId; - RegisterTable[Index].TableLength =3D 0; - RegisterTable[Index].AllocatedSize =3D 0; - RegisterTable[Index].RegisterTableEntry =3D 0; - - RegisterTable[NumberOfCpus + Index].InitialApicId =3D (UINT32)P= rocessorInfoBuffer.ProcessorId; - RegisterTable[NumberOfCpus + Index].TableLength =3D 0; - RegisterTable[NumberOfCpus + Index].AllocatedSize =3D 0; - RegisterTable[NumberOfCpus + Index].RegisterTableEntry =3D 0; - } - AcpiCpuData->RegisterTable =3D (EFI_PHYSICAL_ADDRESS)(UINTN)= RegisterTable; - AcpiCpuData->PreSmmInitRegisterTable =3D (EFI_PHYSICAL_ADDRESS)(UINTN)= (RegisterTable + NumberOfCpus); } =20 // --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70550): https://edk2.groups.io/g/devel/message/70550 Mute This Topic: https://groups.io/mt/79954426/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-