From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.92.21.29]) by mx.groups.io with SMTP id smtpd.web11.90.1586884114343107071 for ; Tue, 14 Apr 2020 10:08:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Gz9vptIV; spf=pass (domain: outlook.com, ip: 40.92.21.29, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iBCEUCLwmvXQS3sUAqa2NlCY8WTN24RUOgEUxLwgCLC82LhjZCmJaWAYdHkgSAerGYzGGf2JZKO17znQyyL639WI/DgPuQdMnnm9aFNMSZoGrczliwdIavvmAhXAuJ9QQE+vQ51Aeja+TxU+5HUvC2ptnTbzuSagZnYpIKmtM32uxx+qPhCBXH9CPHA1C0j1chKvijuis4luy8HekYew5RhoGH05j7OJCst96FzdKTgTA6tv45PaWJx7dyq3Zkb8uR7qo7lmV+H//HSYxBjf3Ipixgnosr8DoYztHaRdYf0ujJq7de1cECeR0KHur3VqlSnAXe0ChZ1s8hNhYEsvxg== 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=GR3YYwVzVPV4pCNscwqwzBT3gX2/Ng8DZeA4HQgD2UM=; b=FvuZM96dTMzK7zlAslAIPYv6z+BoIEQ+VTMhx5mmYMDSE3dBb0tlC99wi7lmrYic84joHgwYwIaJjS4/7ZJpuOd3SahovIpt9vyIL+UmRw69SdswO0aPg+G8uulJJ/g+So5GFe6TmdPjLpVdKhdJNMfyktNMUUAV4dr5SZPcANy9CquSKK++CFO3dagU9fOZUqu15QJ63wQor23VyK9BfyOzVmwTBKqeTBQBrVbbxCsDTo8kilioG1dUInEQfU0/jX0/GP3m3JcNAcUhNPwLVUOYk5HikBxPVz7UQlwShWtNg0KmpqAzUdbpLsXaJRPTR4Ur2sXTKNr3QHyPCwhcVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GR3YYwVzVPV4pCNscwqwzBT3gX2/Ng8DZeA4HQgD2UM=; b=Gz9vptIV+FVrGbJZEXlHFxInZjBKVC17vTOj4xmsjVf4Jw5IGiWCLVOa6J20X+Y6ZRxOlGbXVmPQCRZekHbV8nhObHT9UFl2zqNvA4YzzYtSPYjK+TGGQ0A5w74lpLHjqbw4M6mdDcxYiZJ2rvI/dC740anuPlHBMpHhLoSpIxokQMC8x0OggPjJfkdjaFz3ILMU+R3GnaZ4oI7GKJ+k2uCAq2Hy1J/FWNgqQ4KooAIxlStkskX/i4Lw96ytGjtPSZB5HOXTcNOs0bXj+eICXvlVsQeOqdqin7JlJ2h/sOHuFoMXoqFAX18d4z/2UyjpYGLCCcJ8HgKyCfyAs6/kCw== Received: from MW2NAM12FT041.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::4c) by MW2NAM12HT007.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc65::328) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.12; Tue, 14 Apr 2020 17:08:32 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:fc65::4b) by MW2NAM12FT041.mail.protection.outlook.com (2a01:111:e400:fc65::257) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.12 via Frontend Transport; Tue, 14 Apr 2020 17:08:32 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:BDD39BBA43BD95CE01E26796D114A99FF177A81F02F4C428CE33F334C95F9A28;UpperCasedChecksum:B7672D9F07ED4AA8E7DEDC2FD0704477CEB4563E4C49F3D7D79E72536AC52FF3;SizeAsReceived:9144;Count:50 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::bcc9:271b:20db:52e3]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::bcc9:271b:20db:52e3%6]) with mapi id 15.20.2900.028; Tue, 14 Apr 2020 17:08:32 +0000 Subject: Re: [PATCH v1 1/1] NetworkPkg/SnpDxe: Register SnpNotifyExitBootServices at TPL_CALLBACK To: "Rabeda, Maciej" , devel@edk2.groups.io Cc: Siyuan Fu , Jiaxin Wu References: From: "Michael Kubacki" Message-ID: Date: Tue, 14 Apr 2020 10:08:32 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 In-Reply-To: X-ClientProxiedBy: MWHPR22CA0062.namprd22.prod.outlook.com (2603:10b6:300:12a::24) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2001:4898:d8:39:11b1:e140:ec31:dea1] (2001:4898:80e8:2:91d7:e140:ec31:dea1) by MWHPR22CA0062.namprd22.prod.outlook.com (2603:10b6:300:12a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.25 via Frontend Transport; Tue, 14 Apr 2020 17:08:32 +0000 X-Microsoft-Original-Message-ID: X-TMN: [okA0rxYgywi41TTzB0V1ij8xYcnVOr64yi3Zx0UmSUHJzgGSCa+CeEZu9qG+alSj] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 93a4aca0-77bd-4926-ea42-08d7e0967613 X-MS-TrafficTypeDiagnostic: MW2NAM12HT007: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mG+Eia1Pm6Z0LpK/awjfhPOHDgcjYZjIKmN2uDUPpvO5KcuteDEXkXeRTG9TnADT/mz/OcC7YnySvAEDgyIHW5ZwQf+vIQulMagfjF5ukDu5utC8Om9bK8X8lKQUII4kqel3ZaBHZHZbiORz6lbcQgiSLJk+7wujmhOL5Xag21oUBKtpBcRlLmdpLwq9WrbewbvtpwQDqSEgIIn1/rxf95zknWHr5I2TVIMg598Gawg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR07MB3440.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: a47VZ3nysCd1dxN+OmuHrBE//R1mMinY0IVzJkN+/IYCaWYZnncUrJa/a4MJaWl2oRyzFc8YmGVb5TF68bREuUFISx0r7OfHIKcpRdSgUq8cG1Q6v+ifoxHD+fOuo0sw0JWH8WTA64IY5jiMaA0Bj7XShYb88gInUcZm4i+CvdShPcHdLiQ2/i8FmmbzovIGVjApDVYHLnjWKIwwspofzw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93a4aca0-77bd-4926-ea42-08d7e0967613 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2020 17:08:32.9306 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM12HT007 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Hi Maciej, Thank you for summarizing the background. I would like to get others feedback as well. If the EBS notification is kept, I'd like to request this patch be included in edk2-stable202005. Thanks, Michael On 4/14/2020 2:59 AM, Rabeda, Maciej wrote: > Hi Michael, > > Some time ago we have introduced a patch in ExitBootServices (EBS) area > for SnpDxe to allow for EBS event creation control. > Commit: > https://github.com/tianocore/edk2/commit/61bb6eeb4d93c0a34c1995d87914ab41398f9550 > Patch: https://edk2.groups.io/g/devel/message/48899 > > Ideally, at EBS stage, SNP should not interface UNDI at all. > UEFI spec for EVT_SIGNAL_EXIT_BOOT_SERVICES events (should apply to > event tied to EBS GUID): > "The notification function for this event is not allowed to > use the Memory Allocation Services, or call any functions that use > the Memory Allocation Services and must only call functions that are > known not to use Memory Allocation Services, because these > services modify the current memory map." > > UEFI spec Appendix E states for UNDI->Stop(): > "The memory buffer assigned in the Initialize command can be released or > reassigned." > > Furthermore, all UEFI drivers controlling PCI devices are obliged to > shut down all DMA activity. > "Call to Action" section in: > https://software.intel.com/sites/default/files/managed/8d/88/intel-whitepaper-using-iommu-for-dma-protection-in-uefi.pdf > Quote: "The UEFI device driver should disable bus master and put > controller to halt state in ExitBootServices." > That would require UNDI drivers to create their own EBS event and > shutdown their adapters. > > Based on the information above, I was willing to remove the EBS event > creation altogether from SnpDxe due to misalignment with the UEFI spec. > The only argument for hesitance was potential backward compatibility > with older UNDI drivers, hence the event creation control via PCD. > > If we are observing issues on SNP<->UNDI line in EBS stage, I think the > subject is worth revisiting. > I would love to get any and all community input on that matter. > > Thanks, > Maciej > > On 09-Apr-20 20:16, michael.kubacki@outlook.com wrote: >> From: Michael Kubacki >> >> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1562 >> >> The current SnpDxe implementation registers its ExitBootServices event >> notification function (SnpNotifyExitBootServices ()) at TPL_NOTIFY. This >> function calls PxeShutdown() which issues an UNDI shutdown operation. >> Ultimately, this may invoke Shutdown() in EFI_SIMPLE_NETWORK_PROTOCOL. >> >> The UEFI specification 2.8A Table 27 "TPL Restrictions" restricts the TPL >> for Simple Network Protocol to <= TPL_CALLBACK. In addition, it has been >> observed in some 3rd party UNDI drivers to cause an issue further down >> the call stack if the TPL is higher than TPL_CALLBACK on invocation. >> >> Therefore, this commit changes the TPL of SnpNotifyExitBootServices() to >> TPL_CALLBACK. >> >> Cc: Siyuan Fu >> Cc: Maciej Rabeda >> Cc: Jiaxin Wu >> Signed-off-by: Michael Kubacki >> --- >> NetworkPkg/SnpDxe/Snp.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/NetworkPkg/SnpDxe/Snp.c b/NetworkPkg/SnpDxe/Snp.c >> index 078b27cf5edd..fe022e16eacc 100644 >> --- a/NetworkPkg/SnpDxe/Snp.c >> +++ b/NetworkPkg/SnpDxe/Snp.c >> @@ -2,6 +2,7 @@ >> Implementation of driver entry point and driver binding protocol. >> >> Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.
>> +Copyright (c) Microsoft Corporation.
>> SPDX-License-Identifier: BSD-2-Clause-Patent >> >> **/ >> @@ -653,7 +654,7 @@ SimpleNetworkDriverStart ( >> // >> Status = gBS->CreateEventEx ( >> EVT_NOTIFY_SIGNAL, >> - TPL_NOTIFY, >> + TPL_CALLBACK, >> SnpNotifyExitBootServices, >> Snp, >> &gEfiEventExitBootServicesGuid, >