From mboxrd@z Thu Jan 1 00:00:00 1970 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.web09.37881.1612201266246785242 for ; Mon, 01 Feb 2021 09:41:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eN85us7a; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612201265; 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: in-reply-to:in-reply-to:references:references; bh=ut0Qmo9hY8QHHrQtWByxOdXr98vRDK5qSDIisjW0Qa0=; b=eN85us7a9VJMVx1lv2YMMblza4LSqXpY6B0FbpDHyScPg9sLFvXVtUi1awSC4BhTzTf5ll pChItlTCXf8ONb4gjepvWXYMjpHROmmaaoodRrJ2w2UqOGZHXb+JDkb1UN8ginYTYqOb+I q52Rl0lgtNXpxUh+LFIBmoH6JDTs+YE= 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-473-HYvrir3ZMnK1QshCcONtlg-1; Mon, 01 Feb 2021 12:41:01 -0500 X-MC-Unique: HYvrir3ZMnK1QshCcONtlg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33BEC107ACE4; Mon, 1 Feb 2021 17:41:00 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-253.ams2.redhat.com [10.36.114.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 731075D6D5; Mon, 1 Feb 2021 17:40:58 +0000 (UTC) Subject: Re: [PATCH v6 9/9] OvmfPkg/SmmControl2Dxe: negotiate CPU hot-unplug From: "Laszlo Ersek" To: Ankur Arora , devel@edk2.groups.io Cc: imammedo@redhat.com, boris.ostrovsky@oracle.com, Jordan Justen , Ard Biesheuvel , Aaron Young References: <20210129005950.467638-1-ankur.a.arora@oracle.com> <20210129005950.467638-10-ankur.a.arora@oracle.com> <92a29bb5-fc0e-c11f-2702-07c7729a11b4@redhat.com> Message-ID: Date: Mon, 1 Feb 2021 18:40:57 +0100 MIME-Version: 1.0 In-Reply-To: <92a29bb5-fc0e-c11f-2702-07c7729a11b4@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 02/01/21 18:37, Laszlo Ersek wrote: > On 01/29/21 01:59, Ankur Arora wrote: >> As part of the negotiation treat ICH9_LPC_SMI_F_CPU_HOT_UNPLUG as a >> subfeature of feature flag ICH9_LPC_SMI_F_CPU_HOTPLUG, so enable it >> only if the other is also being negotiated. >> >> Cc: Laszlo Ersek >> Cc: Jordan Justen >> Cc: Ard Biesheuvel >> Cc: Igor Mammedov >> Cc: Boris Ostrovsky >> Cc: Aaron Young >> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3132 >> Signed-off-by: Ankur Arora >> --- >> OvmfPkg/SmmControl2Dxe/SmiFeatures.c | 25 ++++++++++++++++++++++--- >> 1 file changed, 22 insertions(+), 3 deletions(-) >> >> diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c >> index c9d875543205..e70f3f8b58cb 100644 >> --- a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c >> +++ b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c >> @@ -29,6 +29,13 @@ >> // >> #define ICH9_LPC_SMI_F_CPU_HOTPLUG BIT1 >> >> +// The following bit value stands for "enable CPU hot unplug, and inject an SMI > > (1) s/hot unplug/hot-unplug/ > > >> +// with control value ICH9_APM_CNT_CPU_HOT_UNPLUG upon hot unplug", in the > > (2) There is no such thing as ICH9_APM_CNT_CPU_HOT_UNPLUG; we use the > same SMI command value ICH9_APM_CNT_CPU_HOTPLUG (= 4) for unplug. > > In QEMU, the macro is called OVMF_CPUHP_SMI_CMD. > > > (3) s/hot unplug/hot-unplug/. > > >> +// "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg files. >> +// Is only negotiated alongside ICH9_LPC_SMI_F_CPU_HOTPLUG. > > (4) Please drop the last sentence (see more on it below). > > >> +// >> +#define ICH9_LPC_SMI_F_CPU_HOT_UNPLUG BIT2 >> + >> // >> // Provides a scratch buffer (allocated in EfiReservedMemoryType type memory) >> // for the S3 boot script fragment to write to and read from. >> @@ -112,7 +119,8 @@ NegotiateSmiFeatures ( >> QemuFwCfgReadBytes (sizeof mSmiFeatures, &mSmiFeatures); >> >> // >> - // We want broadcast SMI, SMI on CPU hotplug, and nothing else. >> + // We want broadcast SMI, SMI on CPU hotplug, on CPU hot-unplug >> + // and nothing else. >> // >> RequestedFeaturesMask = ICH9_LPC_SMI_F_BROADCAST; >> if (!MemEncryptSevIsEnabled ()) { > > (5) Please spell out the full expression "SMI on CPU hot-unplug". > > >> @@ -120,8 +128,18 @@ NegotiateSmiFeatures ( >> // For now, we only support hotplug with SEV disabled. >> // >> RequestedFeaturesMask |= ICH9_LPC_SMI_F_CPU_HOTPLUG; >> + RequestedFeaturesMask |= ICH9_LPC_SMI_F_CPU_HOT_UNPLUG; >> } >> mSmiFeatures &= RequestedFeaturesMask; >> + >> + if (!(mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) && >> + (mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG)) { >> + DEBUG ((DEBUG_WARN, "%a CPU host-features %Lx, requested mask %Lx\n", >> + __FUNCTION__, mSmiFeatures, RequestedFeaturesMask)); >> + >> + mSmiFeatures &= ~ICH9_LPC_SMI_F_CPU_HOT_UNPLUG; >> + } >> + >> QemuFwCfgSelectItem (mRequestedFeaturesItem); >> QemuFwCfgWriteBytes (sizeof mSmiFeatures, &mSmiFeatures); >> > > (6) Please drop this hunk. We don't try to be smarter than QEMU, in > general, whenever we perform feature negotiation. ... obviously: don't drop the part where you set the new bit! :) Sorry, "hunk" was not the correct term. Thanks! Laszlo > > For example, the pre-patch code doesn't attempt to notice if QEMU > acknowledges ICH9_LPC_SMI_F_CPU_HOTPLUG but not ICH9_LPC_SMI_F_BROADCAST. > > >> @@ -162,8 +180,9 @@ NegotiateSmiFeatures ( >> if ((mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) == 0) { >> DEBUG ((DEBUG_INFO, "%a: CPU hotplug not negotiated\n", __FUNCTION__)); >> } else { >> - DEBUG ((DEBUG_INFO, "%a: CPU hotplug with SMI negotiated\n", >> - __FUNCTION__)); >> + DEBUG ((DEBUG_INFO, "%a: CPU hotplug%s with SMI negotiated\n", >> + __FUNCTION__, >> + (mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG) ? ", unplug" : "")); >> } >> >> // >> > > (7) Rather than combining these two in a common debug message, please > just add a separate "if" that follows the whole pattern seen with > ICH9_LPC_SMI_F_CPU_HOTPLUG. Thus, for each feature bit we care about, > we'll have a dedicated log message, saying yes or no. > > Thanks! > Laszlo >