From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web11.9039.1611643498015058179 for ; Mon, 25 Jan 2021 22:44:58 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=0CbZNFh7; spf=pass (domain: oracle.com, ip: 141.146.126.78, mailfrom: ankur.a.arora@oracle.com) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10Q6YvET010751; Tue, 26 Jan 2021 06:44:54 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 : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=JO/raDJ4HMvhNf8WxomZMZn/nfw/Qb1vg6iTfoNMO4A=; b=0CbZNFh7eDIvaO2PMICWHTiUQwDguukIBEXbrxHqbZDSiFfoHTx2iCqGOFMfhG6qNUNl pkdG3nPe7SQpu1iEVcgF8FyOOn1y/CeXjBI2zk/e0FFStX2Nq4Al+BG5UBPLqM8koea1 fIRbb+2O/y03OUnM0JUfAZbVdHKYB1AYvN8mKYEAMyiohUXZOj3GkTjRWUSuITcv4YaV EJqeEm6VfoSRIrrnG0zluuk1gReEkoy/gKoMUHdhbPlB8o6Stz3nrpXpcBGD9+vDF30H osqih3LFdsPWz8ggk7eOszYefPqaut57BtC9wW80P9JZVa0mwoTRzonS+9iHv8DaD+pZ OA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 368brkgkq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:54 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10Q6a5jP097050; Tue, 26 Jan 2021 06:44:53 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2046.outbound.protection.outlook.com [104.47.74.46]) by userp3030.oracle.com with ESMTP id 368wqw1qb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QygkeQokqI2QvwY1YnkvQSltKeyfqo7vZpKh8g4VsQWHeqBJf6tQFiKdzLrdZlRVLNTab3qAkyc/vS2VV/AFLHKsqp0p//2U2e6aQaRIRSNrfOv5qmfGix9t4bYQK0mQY4gPoU4khFNIruQAl98j+PZhA72T6/yOHsqmPqr7bSL/VfWEokUeoTPPSP58mFAbVxdvI30ZclVRN6dm5hMqanKOTjIOc8xFCRgutxHWUbycxi4fVvRiqS6oo1zDdrMwsmusWctGimt2fDp7HXrq4VYAxzY3U5/s+UQNMNFBlW/w1m7uJsKIUJfCmfa6XCVUAJe2DTEep0Q2fAffqnFAoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JO/raDJ4HMvhNf8WxomZMZn/nfw/Qb1vg6iTfoNMO4A=; b=Vy8KYxknFXjQhwRAf/IwfZqnUCfBye+FtjlpB88uBtrr+UUln/rlpD7+LQZlekVzGhclLbiGJQ4tQjYcgCDnWBwtchOeYXHetRx9WvtcJOFV6aQyaTga0i1wvP81W0saFPReQuWhPC5CjslU0uC2VA1PuPYh+YwjMzQ0/RWcmYuSEH4RTRPO/e1g8KNZbRe0Mn/UjxW3z/hinixAc1dJlfxCWSLbfjFRUla35um5WdCR3EbStPW1SIROfavsYZh3RzR9puhEY3BwCd6ryRp7Qnj4z5PNou9AOjiMF6lOWJw3wKfx+UQgiw50D40qRgx/eZqy9JeAwfoOyjlt8vcAhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JO/raDJ4HMvhNf8WxomZMZn/nfw/Qb1vg6iTfoNMO4A=; b=A85+u4i6XnGj/ITdF646k2fp+zR1ohIXk3m8zWRijhjrZo7PiKMrmYu4rCbfTUzQLWN2XXKFo2lr1/fnyhmrNS5MqsJlkdQ2QumygxUmBs3PF8Ax2S1ovjHULaDTtwthaIYhK0iiwxXi4VXnNc+MPxZdEJN8ep147PRTKau0APY= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=oracle.com; Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2184.namprd10.prod.outlook.com (2603:10b6:910:45::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.14; Tue, 26 Jan 2021 06:44:51 +0000 Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3784.019; Tue, 26 Jan 2021 06:44:51 +0000 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [PATCH v5 2/9] OvmfPkg/CpuHotplugSmm: collect hot-unplug events Date: Mon, 25 Jan 2021 22:44:33 -0800 Message-Id: <20210126064440.299596-3-ankur.a.arora@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210126064440.299596-1-ankur.a.arora@oracle.com> References: <20210126064440.299596-1-ankur.a.arora@oracle.com> X-Originating-IP: [70.36.60.91] X-ClientProxiedBy: MWHPR18CA0061.namprd18.prod.outlook.com (2603:10b6:300:39::23) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (70.36.60.91) by MWHPR18CA0061.namprd18.prod.outlook.com (2603:10b6:300:39::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Tue, 26 Jan 2021 06:44:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e4d1287-b0d1-4ce9-40c5-08d8c1c5e170 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MSZfxnWMTm6o1bSYiL/uv1/qI1aPYo2gpX9ynTO1GJfJtX1tUKyZIebLF78tHlFrgjB4F592qGIqeTbaSQCxgo4phCtyDkeVqPDi5oRqELFaI3JGLgtAKFsNU0fxdsiGnWtcGCgn9YRBQ/11zSSDj/GY1gkbNkdd89+BgM5iODv8dy1XlxL+8dWmXmLPvbXO9JdKi39iUhwIA8qnrUuiLPR7MsryzzYveEKBfnXz8ykWhJycQq24QVF/xdKefETTMbUC9IPHTTg7UXocm2ZORWH2Ojm6xv4NR4A0m0Y2ZlrzMPAfcrm1BkwztNZ4zmU+K73TqgPIgAPYPwSq9LHv5ckrpdFxhQyS5R/MgTrUCXKCTs4YbOVyNLR8tVE8syVm+Z3k0SzcspuhS7Ar46qeDtEZTGOSFv8OwHKvsH55tjfVrfe2lIxrN567zjwivyk5VLqsT7kH8mJ4NmNZ4s7uOPOYdo2tubMmqjpzNOQJjVBiJiOgL4M3IQJ1KC8n8QNIdQ/I1RR73mG4LO5jWDH14g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR10MB1718.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(396003)(39860400002)(376002)(346002)(136003)(69590400011)(6916009)(2616005)(4326008)(6512007)(52116002)(956004)(66556008)(6486002)(36756003)(186003)(6506007)(26005)(66476007)(6666004)(478600001)(8676002)(8936002)(83380400001)(966005)(1076003)(2906002)(86362001)(5660300002)(66946007)(103116003)(316002)(54906003)(16526019)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?EOUkZJaJ+CPdOMI4EYZLiKLs6Ut5Rdv0T0EJ/+mFc3RDDZj1bv1BYH1bHP7H?= =?us-ascii?Q?ph1DxODxROB1byAeHyQfsD/VNM/tgQFIehmZBts+60Ofz3Ap/GKMdODatWS/?= =?us-ascii?Q?S1PT2sdsZC6aUvbgCI1jzYJkXesH4ukxpzv8Uapen8zl50fAkOmkeqpLpQaW?= =?us-ascii?Q?7zMJhAROa5gbbyNX9DZrS8fQdws12LO/SZEbMNlrRagrKMaolaMW+5QWJaA6?= =?us-ascii?Q?oWfw22vmV8s12B/3aLMczW0Rj8ecloJlagwEcGu/ZoipkFd/YwyuXRebRE6a?= =?us-ascii?Q?IYc3eYFDqcJxkgRqzFnpmGJZS1QMGuNf89+T0cpdy/ClQvNynXu46Xu9EWgS?= =?us-ascii?Q?M4UgWkHTjGeA/1PYCxo3AhB0ZMi3EerItPXHNZxriMNg/jHZW1hx7WUTCfEW?= =?us-ascii?Q?0mMpKXRN8jMpDbsqhgoVT+RmbuVqFKN+bjeg3t4vGn4n/mUwyy16kF2YCjyz?= =?us-ascii?Q?GqZJ28Mhcd8KhjlklWsAPU3V9OWp37+n3i6ught/ItHeHxV+WzRtIynwXOJ2?= =?us-ascii?Q?pWout6pckSv7aRGlyPWSsXgeRghIMZFb7lFihEAHWShIIvVWJP+3lo6+ahLA?= =?us-ascii?Q?bsEPRuXk3n+01c9GKHXJZXhqsEBJRvZqMCgoesEDdPAM1uMBzY3ZSC/6Yg/d?= =?us-ascii?Q?NCZsQ307HQI5UkYOtw/qnwmXcu3p0ugXIQ/QAeKT9RM3NlDhbUb/PypycVdz?= =?us-ascii?Q?GOkpL2WS47oyukFWSqWz/O9y76PbQLYS/G3feSp2YF2nWX2KuAo2c4+At/v/?= =?us-ascii?Q?bl0w+hUf5Q2jekGAmxPvLvGilVbnnQoNCOxJJE8psuqaKyHgjUEN9ShdNKpa?= =?us-ascii?Q?wnXXemER/AecNTEL6XogrzckMbGOALLE3vUx5JFz9Zl+7GpbPzt1fkfDf+4Z?= =?us-ascii?Q?46m058gcdQZ4jPEUY+al4k+VkQiy9mSO2XXwJobfmJKDS3sAYaliQVFQn7bX?= =?us-ascii?Q?LpJEBcUy/SK53g3wBqeozl69Dw8FOr1eFg6HWcI975v2NDUGPEvxZ6bHMXLD?= =?us-ascii?Q?HaR7GSzuRp0V+ETz9hju2pWXOrZNB9pGidTrazasRVMUMJA28eeCJ7PZB6ay?= =?us-ascii?Q?xJUhNVa1?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e4d1287-b0d1-4ce9-40c5-08d8c1c5e170 X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 06:44:50.9942 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TiT19wLIOl0808phvOmfLUfmgnT+inQj2HCtGNylNQYzyO9saThZDkE4GiFlr8OXNs8y3GzADVX/V2th7UqR7aGFhB+smFtvumyVzHqJH/w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2184 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9875 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101260035 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9875 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 phishscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 spamscore=0 mlxscore=0 suspectscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101260035 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Process fw_remove events in QemuCpuhpCollectApicIds() and collect corresponding APIC IDs for CPUs that are being hot-unplugged. In addition, we now ignore CPUs which only have remove set. These CPUs haven't been processed by OSPM yet. This is based on the QEMU hot-unplug protocol documented here: https://lore.kernel.org/qemu-devel/20201204170939.1815522-3-imammedo@redh= at.com/ Also define QEMU_CPUHP_STAT_EJECTED while we are at it. 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=3D3132 Signed-off-by: Ankur Arora --- OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h | 2 ++ OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 35 +++++++++++++++++--= ---- 2 files changed, 29 insertions(+), 8 deletions(-) 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 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 --=20 2.9.3