From nobody Mon May 6 10:13:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+62561+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62561+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594752201; cv=none; d=zohomail.com; s=zohoarc; b=benzTd4FiWeNF3zxCAiLuc/s/M2ivRR2giYrJuHxUyn4fgSi0a/m64GI771+wuFdYP/X07CL35j5bBh2mTgw+kWNoaMZCLhd+0QmeRnxhtEdWSpxCOeRzkgaGY2h34WdubMohJGtPE3HiD28iQxAYRrahMiyO2rNj3zaViLnEkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594752201; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=ZjTWMQap/EjR9EFBqHTlNqBjJjoBlvgoU3K1zoqS5EM=; b=nGlPKI1XDa2HuEIlNKibCbMjVdBi4euNY1ITzI6QInHKLsXxwYDbFrkALVOoejUonVC7jDgELsn8PCjczbCan9j05iCTOcTr3ZYnV2bgZgp1qCu+Nuxd6r1UguAZT2slhLZoXSVwmj/BjUjFWO205va54ntfBMAxqK94wf7cjWg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+62561+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1594752201279720.3340183609049; Tue, 14 Jul 2020 11:43:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CBVnYY1788612xlCW5Nknl2h; Tue, 14 Jul 2020 11:43:20 -0700 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web10.3141.1594752198960785018 for ; Tue, 14 Jul 2020 11:43:19 -0700 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-279--b4V_BSeNBKKOX8qpSmNpg-1; Tue, 14 Jul 2020 14:43:09 -0400 X-MC-Unique: -b4V_BSeNBKKOX8qpSmNpg-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A612C106B251; Tue, 14 Jul 2020 18:43:08 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-232.ams2.redhat.com [10.36.112.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF5E472E5E; Tue, 14 Jul 2020 18:43:06 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Igor Mammedov , Jordan Justen , Liran Alon , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH] OvmfPkg/SmmControl2Dxe: negotiate ICH9_LPC_SMI_F_CPU_HOTPLUG Date: Tue, 14 Jul 2020 20:43:05 +0200 Message-Id: <20200714184305.9814-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: w0mZ8HTCwLfWLqpnLpP7obS5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594752200; bh=ZjTWMQap/EjR9EFBqHTlNqBjJjoBlvgoU3K1zoqS5EM=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Gh3AJaEpLT/rQX8+MB7ICZwmC327gAhYOrSPH7jBfYJx3fgE8u1rEg33JQZzqYLFvem Xky8mVBzGvCmJuF5gSljZObVMi7wnVotjgojieeJYynEZlfHxK0RbZspUERseFWYg47RM 8hTiRTFWsoNaID13oQP+QBaPWz3mZkKdGFw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The ICH9_LPC_SMI_F_BROADCAST and ICH9_LPC_SMI_F_CPU_HOTPLUG feature flags cause QEMU to behave as follows: BROADCAST CPU_HOTPLUG use case / behavior --------- ----------- ------------------------------------------------ clear clear OVMF built without SMM_REQUIRE; or very old OVMF (from before commit a316d7ac91d3 / 2017-02-07). QEMU permits CPU hotplug operations, and does not cause the OS to inject an SMI upon hotplug. Firmware is not expected to be aware of hotplug events. clear set Invalid feature set; QEMU rejects the feature negotiation. set clear OVMF after a316d7ac91d3 / 2017-02-07, built with SMM_REQUIRE, but no support for CPU hotplug. QEMU gracefully refuses hotplug operations. set set OVMF after a316d7ac91d3 / 2017-02-07, built with SMM_REQUIRE, and supporting CPU hotplug. QEMU permits CPU hotplug operations, and causes the OS to inject an SMI upon hotplug. Firmware is expected to deal with hotplug events. Negotiate ICH9_LPC_SMI_F_CPU_HOTPLUG -- but only if SEV is disabled, as OvmfPkg/CpuHotplugSmm can't deal with SEV yet. Cc: Ard Biesheuvel Cc: Boris Ostrovsky Cc: Igor Mammedov Cc: Jordan Justen Cc: Liran Alon Cc: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude --- Notes: This is the OVMF counterpart to Igor's QEMU series: =20 - [RFC 0/3] x86: fix cpu hotplug with secure boot https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg03746.html message-id: <20200710161704.309824-1-imammedo@redhat.com> =20 Repo: https://pagure.io/lersek/edk2.git Branch: negotiate_cpuhp_with_smi_rhbz1849177 OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf | 1 + OvmfPkg/SmmControl2Dxe/SmiFeatures.c | 26 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf b/OvmfPkg/SmmControl= 2Dxe/SmmControl2Dxe.inf index 3abed141e644..b8fdea8deb84 100644 --- a/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf +++ b/OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf @@ -46,6 +46,7 @@ [LibraryClasses] BaseLib DebugLib IoLib + MemEncryptSevLib MemoryAllocationLib PcdLib PciLib diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c b/OvmfPkg/SmmControl2Dxe/= SmiFeatures.c index 6210b7515e3e..c9d875543205 100644 --- a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c +++ b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c @@ -9,6 +9,7 @@ =20 #include #include +#include #include #include #include @@ -21,6 +22,12 @@ // "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg fi= les. // #define ICH9_LPC_SMI_F_BROADCAST BIT0 +// +// The following bit value stands for "enable CPU hotplug, and inject an S= MI +// with control value ICH9_APM_CNT_CPU_HOTPLUG upon hotplug", in the +// "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg fi= les. +// +#define ICH9_LPC_SMI_F_CPU_HOTPLUG BIT1 =20 // // Provides a scratch buffer (allocated in EfiReservedMemoryType type memo= ry) @@ -67,6 +74,7 @@ NegotiateSmiFeatures ( UINTN SupportedFeaturesSize; UINTN RequestedFeaturesSize; UINTN FeaturesOkSize; + UINT64 RequestedFeaturesMask; =20 // // Look up the fw_cfg files used for feature negotiation. The selector k= eys @@ -104,9 +112,16 @@ NegotiateSmiFeatures ( QemuFwCfgReadBytes (sizeof mSmiFeatures, &mSmiFeatures); =20 // - // We want broadcast SMI and nothing else. + // We want broadcast SMI, SMI on CPU hotplug, and nothing else. // - mSmiFeatures &=3D ICH9_LPC_SMI_F_BROADCAST; + RequestedFeaturesMask =3D ICH9_LPC_SMI_F_BROADCAST; + if (!MemEncryptSevIsEnabled ()) { + // + // For now, we only support hotplug with SEV disabled. + // + RequestedFeaturesMask |=3D ICH9_LPC_SMI_F_CPU_HOTPLUG; + } + mSmiFeatures &=3D RequestedFeaturesMask; QemuFwCfgSelectItem (mRequestedFeaturesItem); QemuFwCfgWriteBytes (sizeof mSmiFeatures, &mSmiFeatures); =20 @@ -144,6 +159,13 @@ NegotiateSmiFeatures ( DEBUG ((DEBUG_INFO, "%a: using SMI broadcast\n", __FUNCTION__)); } =20 + if ((mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) =3D=3D 0) { + DEBUG ((DEBUG_INFO, "%a: CPU hotplug not negotiated\n", __FUNCTION__)); + } else { + DEBUG ((DEBUG_INFO, "%a: CPU hotplug with SMI negotiated\n", + __FUNCTION__)); + } + // // Negotiation successful (although we may not have gotten the optimal // feature set). --=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 (#62561): https://edk2.groups.io/g/devel/message/62561 Mute This Topic: https://groups.io/mt/75505395/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-