From nobody Tue Apr 23 08:34:15 2024 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+70166+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+70166+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610479191; cv=none; d=zohomail.com; s=zohoarc; b=LdtewqONPmCxOOGE9wCEuGzZWPDiQrO04h3y0yBX5eVLvWCr79jyzAMEKv8yM/nL2/MMjyHZ2psXANXsTsfd05JDXJpY1qZ9Xvrp0p47ishle9G9f24ZZuH7G4KZm4j00Z5XLEejoETOmanPeY/c1Uzkas5ZkFJkTjEq3c8ws3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610479191; 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=RRu23QYhNwbp3UXEHI7KZSouPkjgXK+sDKfN1LeTdUo=; b=DmqLFMJNhZVcULbB/Do0oMm9HiggnyYl4uaxUtfQW1kdLQoQeArrd2Ivswm3h7Wfljm/38puOYRcJAo/Mzg+wUSDnuzvP/Wq4XzYHeNZIxThV74KLvZRdAAp4To+/2XUXfJ4vZYV7vdRHa+T2RMj167BeS39a9VDDJGBs31Qlqs= 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+70166+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 1610479191020423.4374977044363; Tue, 12 Jan 2021 11:19:51 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9VHhYY1788612xnlne5S0KSo; Tue, 12 Jan 2021 11:19:50 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.14481.1610479185712541871 for ; Tue, 12 Jan 2021 11:19:46 -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-197-scCiyGwqMieaIgtfvqvouw-1; Tue, 12 Jan 2021 14:19:42 -0500 X-MC-Unique: scCiyGwqMieaIgtfvqvouw-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 2BD6A87951F; Tue, 12 Jan 2021 19:19:41 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id A353F60D07; Tue, 12 Jan 2021 19:19:39 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Eric Dong , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Rahul Kumar , Ray Ni , Star Zeng Subject: [edk2-devel] [PATCH 1/3] UefiCpuPkg/AcpiCpuData: update comments on register table fields Date: Tue, 12 Jan 2021 20:19:32 +0100 Message-Id: <20210112191934.12459-2-lersek@redhat.com> In-Reply-To: <20210112191934.12459-1-lersek@redhat.com> References: <20210112191934.12459-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: MFhS0rNqFMOcPm4LLRbVnMgFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610479190; bh=RRu23QYhNwbp3UXEHI7KZSouPkjgXK+sDKfN1LeTdUo=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=MSyozyLOK0+X3MFgcT0ZGKH664ljx/POW8AKISlCjlOaK0Ghx6AIeMQTdeeWDLsMIY0 l7dKo90oBqkMCiIqx8/KgCc5MnMrHG97+jzOPPKtst5Nj+lAShd4ysgcUbfGYlU44i8vU f7QHxw3mEi/o2hYgLnvSJ2hfn15xiKijQdw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" After commit e992cc3f4859 ("UefiCpuPkg PiSmmCpuDxeSmm: Reduce SMRAM consumption in CpuS3.c", 2021-01-11), it is valid for a CPU S3 Data DXE Driver to set "ACPI_CPU_DATA.PreSmmInitRegisterTable" and/or "ACPI_CPU_DATA.RegisterTable" to 0, in case none of the CPUs needs a register table of the corresponding kind, during S3 resume. Document this fact in the "UefiCpuPkg/Include/AcpiCpuData.h" header file. 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: Philippe Mathieu-Daude Reviewed-by: Ray Ni --- UefiCpuPkg/Include/AcpiCpuData.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UefiCpuPkg/Include/AcpiCpuData.h b/UefiCpuPkg/Include/AcpiCpuD= ata.h index b5a69ad80c88..62a01b2c6bac 100644 --- a/UefiCpuPkg/Include/AcpiCpuData.h +++ b/UefiCpuPkg/Include/AcpiCpuData.h @@ -178,6 +178,8 @@ typedef struct { // If TableLength is > 0, then elements of RegisterTableEntry are used to // initialize the CPU that matches InitialApicId, during an ACPI S3 resu= me, // before SMBASE relocation is performed. + // If a register table is not required for any one of the CPUs, then + // PreSmmInitRegisterTable may be set to 0. // EFI_PHYSICAL_ADDRESS PreSmmInitRegisterTable; // @@ -187,6 +189,8 @@ typedef struct { // If TableLength is > 0, then elements of RegisterTableEntry are used to // initialize the CPU that matches InitialApicId, during an ACPI S3 resu= me, // after SMBASE relocation is performed. + // If a register table is not required for any one of the CPUs, then + // RegisterTable may be set to 0. // EFI_PHYSICAL_ADDRESS RegisterTable; // --=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 (#70166): https://edk2.groups.io/g/devel/message/70166 Mute This Topic: https://groups.io/mt/79632016/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- From nobody Tue Apr 23 08:34:15 2024 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+70168+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+70168+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610479193; cv=none; d=zohomail.com; s=zohoarc; b=OVFAFtFkIy/oB8Bqf1QmEEtoOnZY56+FYG613hIt+aEBrjOj+o7PDqh4JTrjTxUlgztY7H5XFYP2KD8+lGvvUrIsb9Vk6ybSverGcuwy/Kgp4NNL0VfZuI8URqauu5ryKnoDEyUKmXeNytHyh9ZX4v+ViObAIKq4XaxEL8vtvgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610479193; 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=UIHvnIcISQ4ulaERzCJISjjFrTunQJq/Ps8qFZtzl9g=; b=Ox1As39PODkeatw1bRrA2HAiXshDQD5nJudPKH1FQ9DmKe2Irx8bb1sXxV7M5n3R5LX8bHiiv3zMMm7yJBD1VTYYUctIDjiC/ORLMeMHyxF40+sCSQcWl5i/Q0iQp6tuguVyCmxOfM5evtOQdCNydFwrxxZ7ytNvE1wfp9BpIH0= 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+70168+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 1610479193275611.0015049175147; Tue, 12 Jan 2021 11:19:53 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id KT3PYY1788612xlabmGtd4mJ; Tue, 12 Jan 2021 11:19:52 -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.web11.14560.1610479186766203379 for ; Tue, 12 Jan 2021 11:19:46 -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-526-DspxDoMPPWG79-YJM03tWQ-1; Tue, 12 Jan 2021 14:19:44 -0500 X-MC-Unique: DspxDoMPPWG79-YJM03tWQ-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 086971015947; Tue, 12 Jan 2021 19:19:43 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8345C6E522; Tue, 12 Jan 2021 19:19:41 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Eric Dong , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Rahul Kumar , Ray Ni , Star Zeng Subject: [edk2-devel] [PATCH 2/3] UefiCpuPkg/CpuS3DataDxe: do not allocate useless register tables Date: Tue, 12 Jan 2021 20:19:33 +0100 Message-Id: <20210112191934.12459-3-lersek@redhat.com> In-Reply-To: <20210112191934.12459-1-lersek@redhat.com> References: <20210112191934.12459-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: YKDh7EEJGOCbgmvE76PAOMVgx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610479192; bh=UIHvnIcISQ4ulaERzCJISjjFrTunQJq/Ps8qFZtzl9g=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=FFpbJ0ZmQJUW2yiM+eOaHxgu//tNOsj/lqYtFi1u0po48PYB/CXI8a59Cpn1wJlcFz7 HoiN6FvdKK1lKbeLifWXHMW0d8aCm5x0/5LqnetEhJOmR4/5iUOVwulZDxuS/cvv24YG1 tUh9MAEOEO1O7RxQlBW20DqgsxQ5lNaDqzg= 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: 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 (#70168): https://edk2.groups.io/g/devel/message/70168 Mute This Topic: https://groups.io/mt/79632018/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- From nobody Tue Apr 23 08:34:15 2024 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+70169+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+70169+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1610479197; cv=none; d=zohomail.com; s=zohoarc; b=V0pXSQaxct+NPN8Twz5/1JJbdH3aUa8XN6EBaolVyRtY3/tIVJYqwvd8Ie09uqYWBIAiHiQqyZJyv1hUJb2HGzG1SHGcdVvfaR6gyJplI3/o88BEhLrQhzyyUeCz6zj7t+R1HNT7ezexniDD+DbRxgiTOp0m6GSpq9/qoT6VuNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610479197; 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=kPn36nBGgFL+Q3Mm+P04f25rTOZbSuWhiUUifJf0Gvo=; b=gEG4odSggzpilH/Cs5te/7jiOujpKjPBQJJsfLy0qOV1CTJUcBAsKp1fc0DOmePFW9PfQ2UJJeV1dUkNCQHnB+I5yjXVkKLnYm3oPr5F7qIvQC/vYAfrBrbhdsGiYVLSpO24V6FqtVb9Ts1eiTCUbxMgM7VDMhkd3i+UoBkI28o= 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+70169+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 1610479197840266.5238843573459; Tue, 12 Jan 2021 11:19:57 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ybFsYY1788612xitz8WZPUPh; Tue, 12 Jan 2021 11:19:56 -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.web11.14562.1610479190469021496 for ; Tue, 12 Jan 2021 11:19:50 -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-134-QqO6r1aXNQ-Zs2U7N9OKjw-1; Tue, 12 Jan 2021 14:19:47 -0500 X-MC-Unique: QqO6r1aXNQ-Zs2U7N9OKjw-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 F0D521922029; Tue, 12 Jan 2021 19:19:45 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EF0060CEB; Tue, 12 Jan 2021 19:19:43 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jordan Justen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH 3/3] OvmfPkg/CpuS3DataDxe: do not allocate useless register tables Date: Tue, 12 Jan 2021 20:19:34 +0100 Message-Id: <20210112191934.12459-4-lersek@redhat.com> In-Reply-To: <20210112191934.12459-1-lersek@redhat.com> References: <20210112191934.12459-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: rf7hA1la9251PPLdWOuWM4wjx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610479196; bh=kPn36nBGgFL+Q3Mm+P04f25rTOZbSuWhiUUifJf0Gvo=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=OV7qZvq+cMyNOsAO6EORrT1GWn/HQYm4EI1a3ldWoTsmNmLGp2sYyOb/xovO5Y3qZGo y6MUo89nTChGVl7Xh2eBBegl5oGKffbCjHqR+7kwsvRHfqAZbafbH9wpToxXT7CY5Dc1l bEG8zJ24CpWAqT3KG5uNa18Ls2nmze4Hb9g= 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. (This simplification backs out a good chunk of commit 1158fc8e2c7b ("OvmfPkg/CpuS3DataDxe: enable S3 resume after CPU hotplug", 2020-03-04). But CpuS3DataDxe still differs between UefiCpuPkg and OvmfPkg, due to the latter supporting CPU hotplug; thus, we can't remove OvmfPkg/CpuS3DataDxe altogether.) Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Philippe Mathieu-Daud=C3=A9 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3159 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf | 1 - OvmfPkg/CpuS3DataDxe/CpuS3Data.c | 70 +------------------- 2 files changed, 1 insertion(+), 70 deletions(-) diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf b/OvmfPkg/CpuS3DataDxe/C= puS3DataDxe.inf index ceae1d4078c7..228d5ae1b260 100644 --- a/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf +++ b/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf @@ -42,7 +42,6 @@ [LibraryClasses] BaseLib BaseMemoryLib DebugLib - IoLib MemoryAllocationLib MtrrLib UefiBootServicesTableLib diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c b/OvmfPkg/CpuS3DataDxe/CpuS3D= ata.c index bac7285aa2f3..5ffe1f3cd74e 100644 --- a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c +++ b/OvmfPkg/CpuS3DataDxe/CpuS3Data.c @@ -23,7 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include #include #include #include @@ -31,9 +30,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include =20 -#include -#include - // // Data structure used to allocate ACPI_CPU_DATA and its supporting struct= ures // @@ -168,17 +164,12 @@ CpuS3DataInitialize ( EFI_MP_SERVICES_PROTOCOL *MpServices; UINTN NumberOfCpus; VOID *Stack; - UINTN TableSize; - CPU_REGISTER_TABLE *RegisterTable; - UINTN Index; - EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; UINTN GdtSize; UINTN IdtSize; VOID *Gdt; VOID *Idt; EFI_EVENT Event; ACPI_CPU_DATA *OldAcpiCpuData; - BOOLEAN FetchPossibleApicIds; =20 if (!PcdGetBool (PcdAcpiS3Enable)) { return EFI_UNSUPPORTED; @@ -193,13 +184,7 @@ CpuS3DataInitialize ( ASSERT (AcpiCpuDataEx !=3D NULL); AcpiCpuData =3D &AcpiCpuDataEx->AcpiCpuData; =20 - // - // The "SMRAM at default SMBASE" feature guarantees that - // QEMU_CPUHP_CMD_GET_ARCH_ID too is available. - // - FetchPossibleApicIds =3D PcdGetBool (PcdQ35SmramAtDefaultSmbase); - - if (FetchPossibleApicIds) { + if (PcdGetBool (PcdQ35SmramAtDefaultSmbase)) { NumberOfCpus =3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber); } else { UINTN NumberOfEnabledProcessors; @@ -271,59 +256,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); - - if (FetchPossibleApicIds) { - // - // Write a valid selector so that other hotplug registers can be - // accessed. - // - IoWrite32 (ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_W_CPU_SEL, 0); - // - // We'll be fetching the APIC IDs. - // - IoWrite8 (ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_W_CMD, - QEMU_CPUHP_CMD_GET_ARCH_ID); - } - for (Index =3D 0; Index < NumberOfCpus; Index++) { - UINT32 InitialApicId; - - if (FetchPossibleApicIds) { - IoWrite32 (ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_W_CPU_SEL, - (UINT32)Index); - InitialApicId =3D IoRead32 ( - ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_RW_CMD_DATA); - } else { - Status =3D MpServices->GetProcessorInfo ( - MpServices, - Index, - &ProcessorInfoBuffer - ); - ASSERT_EFI_ERROR (Status); - InitialApicId =3D (UINT32)ProcessorInfoBuffer.ProcessorId; - } - - DEBUG ((DEBUG_VERBOSE, "%a: Index=3D%05Lu ApicId=3D0x%08x\n", __FUNC= TION__, - (UINT64)Index, InitialApicId)); - - RegisterTable[Index].InitialApicId =3D InitialApicId; - RegisterTable[Index].TableLength =3D 0; - RegisterTable[Index].AllocatedSize =3D 0; - RegisterTable[Index].RegisterTableEntry =3D 0; - - RegisterTable[NumberOfCpus + Index].InitialApicId =3D InitialAp= icId; - 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 (#70169): https://edk2.groups.io/g/devel/message/70169 Mute This Topic: https://groups.io/mt/79632020/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-