From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web09.4505.1607405698678793456 for ; Mon, 07 Dec 2020 21:34:58 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=o+r4q45b; spf=pass (domain: oracle.com, ip: 141.146.126.79, mailfrom: ankur.a.arora@oracle.com) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B85PwVH160290; Tue, 8 Dec 2020 05:34:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=uZlnXEwH7GW1MpINVcNhlXLzJeXHUoSyiQZ4VfFLt+o=; b=o+r4q45beFpoyoAWtM6dsvMu8Q6VyqHciqfjctwMoGXDrBHqT9SAfcF1Gh27IboA/h7E fGhxpYR77iYhbL1RTBhL4vg1BTEhYs6t4lfb+p/RIxLbxKHBFx+odjfX36t3K95XJ5I3 YsPxMlLKqhszT9lTdaSxDemCPOFqA7OQOBL9fqZVaahfvUmZSozU2hL9a8Tm7EtMUbDR OlmGvRKUVdfIdzHAw+NV3tsLlstIbBto0uvhsm03ZF7i48mEcxwED/CEi5TgJgjmzldb 7mYnqBytnt2DYRdK8Z7bZ9k3NpZLZPdqNO3huEBxxs81Px6cf1Nf9eJ6+cCGTyr52a7F ag== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 357yqbs09e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 08 Dec 2020 05:34:58 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0B85QSLP057828; Tue, 8 Dec 2020 05:34:57 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 358m3x8mfe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Dec 2020 05:34:57 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0B85Yutn015887; Tue, 8 Dec 2020 05:34:56 GMT Received: from localhost.localdomain (/70.36.60.91) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Dec 2020 21:34:56 -0800 From: "Ankur Arora" To: devel@edk2.groups.io Cc: imammedo@redhat.com, lersek@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora Subject: [RFC PATCH 2/5] OvmfPkg/CpuHotplugSmm: handle fw_remove Date: Mon, 7 Dec 2020 21:34:29 -0800 Message-Id: <20201208053432.2690694-3-ankur.a.arora@oracle.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201208053432.2690694-1-ankur.a.arora@oracle.com> References: <20201208053432.2690694-1-ankur.a.arora@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9828 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080032 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9828 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 spamscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012080032 Content-Transfer-Encoding: quoted-printable Limit collection of APIC IDs for hot-unplug events to CPUs with fw_remove set. Additionally we now ignore CPUs which have only remove set. Protocol documented here: https://lore.kernel.org/qemu-devel/20201204170939.1815522-3-imammedo@redhat= .com/ Also define QEMU_CPUHP_STAT_EJECTED while we are at it. Signed-off-by: Ankur Arora --- OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 35 ++++++++++++++----- .../Include/IndustryStandard/QemuCpuHotplug.h | 2 ++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.c index 8d4a6693c8d6..2dd783ebf42e 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c @@ -205,7 +205,7 @@ QemuCpuhpCollectApicIds ( UINT8 CpuStatus;=0D APIC_ID *ExtendIds;=0D UINT32 *ExtendCount;=0D - APIC_ID NewApicId;=0D + APIC_ID OpApicId;=0D =0D //=0D // Write CurrentSelector (which is valid) to the CPU selector register= .=0D @@ -245,10 +245,10 @@ QemuCpuhpCollectApicIds ( if ((CpuStatus & QEMU_CPUHP_STAT_INSERT) !=3D 0) {=0D //=0D // The "insert" event guarantees the "enabled" status; plus it exclu= des=0D - // the "remove" event.=0D + // the "fw_remove" event.=0D //=0D if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0 ||=0D - (CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) {=0D + (CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) {=0D DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%x: "= =0D "inconsistent CPU status\n", __FUNCTION__, CurrentSelector,=0D CpuStatus));=0D @@ -260,12 +260,31 @@ QemuCpuhpCollectApicIds ( =0D ExtendIds =3D PluggedApicIds;=0D ExtendCount =3D PluggedCount;=0D - } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) {=0D - DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: remove\n", __FUNCT= ION__,=0D + } else if ((CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) {=0D + //=0D + // "fw_remove" event guarantees "enabled".=0D + //=0D + if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0) {=0D + DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%x: "= =0D + "inconsistent CPU status\n", __FUNCTION__, CurrentSelector,=0D + CpuStatus));=0D + return EFI_PROTOCOL_ERROR;=0D + }=0D +=0D + DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: fw_remove\n", __FU= NCTION__,=0D CurrentSelector));=0D =0D ExtendIds =3D ToUnplugApicIds;=0D ExtendCount =3D ToUnplugCount;=0D + } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) {=0D + //=0D + // Let the OSPM deal with the "remove" event.=0D + //=0D + DEBUG ((DEBUG_INFO, "%a: CurrentSelector=3D%u: remove (ignored)\n", = __FUNCTION__,=0D + CurrentSelector));=0D +=0D + CurrentSelector++;=0D + continue;=0D } else {=0D DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: no event\n",=0D __FUNCTION__, CurrentSelector));=0D @@ -281,10 +300,10 @@ QemuCpuhpCollectApicIds ( return EFI_BUFFER_TOO_SMALL;=0D }=0D QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID);=0D - NewApicId =3D QemuCpuhpReadCommandData (MmCpuIo);=0D + OpApicId =3D QemuCpuhpReadCommandData (MmCpuIo);=0D DEBUG ((DEBUG_VERBOSE, "%a: ApicId=3D" FMT_APIC_ID "\n", __FUNCTION__,= =0D - NewApicId));=0D - ExtendIds[(*ExtendCount)++] =3D NewApicId;=0D + OpApicId, ExtendCount));=0D + ExtendIds[(*ExtendCount)++] =3D OpApicId;=0D =0D //=0D // We've processed the CPU with (known) pending events, but we must ne= ver=0D diff --git a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h b/OvmfPkg/In= clude/IndustryStandard/QemuCpuHotplug.h index a34a6d3fae61..692e3072598c 100644 --- a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h +++ b/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h @@ -34,6 +34,8 @@ #define QEMU_CPUHP_STAT_ENABLED BIT0=0D #define QEMU_CPUHP_STAT_INSERT BIT1=0D #define QEMU_CPUHP_STAT_REMOVE BIT2=0D +#define QEMU_CPUHP_STAT_EJECTED BIT3=0D +#define QEMU_CPUHP_STAT_FW_REMOVE BIT4=0D =0D #define QEMU_CPUHP_RW_CMD_DATA 0x8=0D =0D --=20 2.25.4