From nobody Thu Nov 14 16:53:11 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+70761+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+70761+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611643499116961.6578110720325; Mon, 25 Jan 2021 22:44:59 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2I2bYY1788612xW4ByouaM3T; Mon, 25 Jan 2021 22:44:58 -0800 X-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 X-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 X-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 X-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 X-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 X-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 X-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: [edk2-devel] [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> 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 X-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 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HNZxriMNg/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 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,ankur.a.arora@oracle.com X-Gm-Message-State: S1D2WRlmnL9vvpWBslXJZ26Dx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611643498; bh=pt2F8mBxaY4O5RUnncFiDRvipBFUJXqv6qLxnYI3Wcg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=aJoPJr3eHh2h/d1ThhLPYTB3ZwdSvzefQF7JJc1RgbOKIy+59LdX0FKpJG+aAw5BRCl CygqjkpCgZ2OzHIml0mbDbpCw0D2EbHKu1p0zYjpZ2Y69HEwtxmQuQTuXvZEISdnmOOEM zGEtejpHoZWcw6s+zpnEZhA2tJ0NVRRSIKA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 #define QEMU_CPUHP_STAT_INSERT BIT1 #define QEMU_CPUHP_STAT_REMOVE BIT2 +#define QEMU_CPUHP_STAT_EJECTED BIT3 +#define QEMU_CPUHP_STAT_FW_REMOVE BIT4 =20 #define QEMU_CPUHP_RW_CMD_DATA 0x8 =20 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; APIC_ID *ExtendIds; UINT32 *ExtendCount; - APIC_ID NewApicId; + APIC_ID OpApicId; =20 // // Write CurrentSelector (which is valid) to the CPU selector register. @@ -245,10 +245,10 @@ QemuCpuhpCollectApicIds ( if ((CpuStatus & QEMU_CPUHP_STAT_INSERT) !=3D 0) { // // The "insert" event guarantees the "enabled" status; plus it exclu= des - // the "remove" event. + // the "fw_remove" event. // if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0 || - (CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + (CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) { DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%x: " "inconsistent CPU status\n", __FUNCTION__, CurrentSelector, CpuStatus)); @@ -260,12 +260,31 @@ QemuCpuhpCollectApicIds ( =20 ExtendIds =3D PluggedApicIds; ExtendCount =3D PluggedCount; - } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { - DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: remove\n", __FUNCT= ION__, + } else if ((CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) { + // + // "fw_remove" event guarantees "enabled". + // + if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%x: " + "inconsistent CPU status\n", __FUNCTION__, CurrentSelector, + CpuStatus)); + return EFI_PROTOCOL_ERROR; + } + + DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: fw_remove\n", __FU= NCTION__, CurrentSelector)); =20 ExtendIds =3D ToUnplugApicIds; ExtendCount =3D ToUnplugCount; + } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + // + // Let the OSPM deal with the "remove" event. + // + DEBUG ((DEBUG_INFO, "%a: CurrentSelector=3D%u: remove (ignored)\n", = __FUNCTION__, + CurrentSelector)); + + CurrentSelector++; + continue; } else { DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: no event\n", __FUNCTION__, CurrentSelector)); @@ -281,10 +300,10 @@ QemuCpuhpCollectApicIds ( return EFI_BUFFER_TOO_SMALL; } QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID); - NewApicId =3D QemuCpuhpReadCommandData (MmCpuIo); + OpApicId =3D QemuCpuhpReadCommandData (MmCpuIo); DEBUG ((DEBUG_VERBOSE, "%a: ApicId=3D" FMT_APIC_ID "\n", __FUNCTION__, - NewApicId)); - ExtendIds[(*ExtendCount)++] =3D NewApicId; + OpApicId, ExtendCount)); + ExtendIds[(*ExtendCount)++] =3D OpApicId; =20 // // We've processed the CPU with (known) pending events, but we must ne= ver --=20 2.9.3 -=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 (#70761): https://edk2.groups.io/g/devel/message/70761 Mute This Topic: https://groups.io/mt/80125309/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-