From patchwork Tue Mar 5 13:32:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 159659 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4975135jad; Tue, 5 Mar 2019 05:33:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyf4GMVF0iXXJ/RTpl4Ik+TinRtzQJ9KJJoe6btxC+VWMpXJ3uJ7ECBU+arw4Qd7CfosnmS X-Received: by 2002:a17:902:59c3:: with SMTP id d3mr1263139plj.214.1551792803243; Tue, 05 Mar 2019 05:33:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551792803; cv=none; d=google.com; s=arc-20160816; b=w393yEzleet3vPVd2CmYnw7JarexCNOqmnO994+vg9r18EFP75V0iLIhcB0B5t23Qz uoMroYrPxaJFFqfkVrLIxkvW4SO0xP6m3QK0MlctcbATxPQH3ot2D4LLFEEbXcO9CLdU wappinajve4hyS2Rq/3Lb6IpeA+WAsZ4i3LfjdmnCWyErBdCwnF8IW/qLZU2hImuiYG1 PY8C0un3pLCJykXEHHYUMm/73D4DBgEcRyai64bQZzWpJ7aOm1cEBCOlJk7gwzLGIU8o YQ11fRmmr+iHIGZDDRpKffW30twd8ec85zWOLxuvIb7EpN8K1gycFgnNLSRuza7dO6Zi 9F/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=e9R7ZsSaMamXMqVc+ZqBgkbaksOvwixg4W5qtqyZBOg=; b=Fe8X/bi0R4dVTL4uqld13ZNjTpC4SjXGZIVqgpXpQlNZ2y2ba4Qw95sy/ZUjZgHLYZ viusZt/N3xFJQ7DgxeKePwCJlOxqK07k4xecXRJaXg2pf54PPMEQ/crETGGIPvI9uvic jMaVbpb4kdnqg7g9Rz+eWFesfoDqtSfo5XiGn4UW1hC0hG6rhtEYQdp8apuds7eYZbAN tmQr8LdunNsba7yIG8US40hM3piYQwplqATbaqZxbG5AxE5h9DCMGzHl60EKvPI3+WRC vLs14xTnK8xCCpAFBo2dHWPi3R9vXvCczLYUtLrd3OVhqPUMR+6e5Bo0hS+u5+Pz+MwZ /ZbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=rdQm5l4f; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id e67si8423637pfh.212.2019.03.05.05.33.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 05:33:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=rdQm5l4f; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 44FC5211D5069; Tue, 5 Mar 2019 05:33:08 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::442; helo=mail-wr1-x442.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B4EB3211D5046 for ; Tue, 5 Mar 2019 05:33:06 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id r5so9472030wrg.9 for ; Tue, 05 Mar 2019 05:33:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1RE1+vGgiZiOcu4jfk79Td4okKIeFX+7ziOiGqVMEW8=; b=rdQm5l4f4hW1fFtewXynDMPleiJjI6VpDoocybfD/xdD1tgJv/kAy3Jze4exIJL0iU SCbqTQf57irKB4fgnjKiSnSoNYS6FgSlt/4WzteGq+BIngMduk621zPrULvZu9l8l+on 9tNcobYC7S+Mj39oyLvjBg7yFpPpRK3HZm5pExAq67gH0HMNXKArB8+PlJvYG8weU6Nh OW2z7XB/KErvWmWEWdCKmGiX/zOFHRcn0Y62VFieyeO0nCd/YH2d6zZW1eZ/s7p3/DSd x5fPtpwJSQRdwtZ4QjT/ZIKQofTZnhaNrwy0d9B1VDFS5yaqmIrudlM8gNPczHr+Ovkb apeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1RE1+vGgiZiOcu4jfk79Td4okKIeFX+7ziOiGqVMEW8=; b=L+AwAkRE5HtX6KZkLwDfe1mNFHBvLUcuuehpbN41lH2+/yglxjXhfxxpMHttlvc+ZH 9mfW31o3j8TxDWSxZi9N2HXM50/QkOINb5k4lKTSp6Ym2U0bjU0r5dByy20umCXBeTsS 1NoNlWtOoX8wDGDkzi52Gq8CYts153afAkEFODktMswCIu2tj7+fDTQ7KXXCGcOvFY6E NAgF71D8iyVszPUgTxPOzQMbSbwwOCTluxPYdsnGShMEuSY/T/XcHyUNgBl2u+hBaWlY D2wFSZV5EWXaXOleur87xSb85tVYBsSe37P5/rMLPiJb+VOdFF4KOfD4l0iWLKS+4kPK V/dA== X-Gm-Message-State: APjAAAXQS0wTKWBpX6tTzB3PamjuZoa3HwvSiKJrwG9G75lyt74f7HIk fQBto+PEv1lxrZOTY0ZzawK4UzLp2Cc= X-Received: by 2002:adf:ba84:: with SMTP id p4mr16569400wrg.156.1551792784990; Tue, 05 Mar 2019 05:33:04 -0800 (PST) Received: from localhost.localdomain (aputeaux-684-1-18-114.w90-86.abo.wanadoo.fr. [90.86.221.114]) by smtp.gmail.com with ESMTPSA id i4sm8370097wrw.19.2019.03.05.05.33.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 05:33:04 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 5 Mar 2019 14:32:45 +0100 Message-Id: <20190305133248.4828-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305133248.4828-1-ard.biesheuvel@linaro.org> References: <20190305133248.4828-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH 07/10] StandaloneMmPkg/Core: dispatch all drivers at init time X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Instead of deferring dispatch of the remaining MM drivers once the CPU driver has been dispatched, proceed and dispatch all drivers. This makes sense for standalone MM, since all dispatchable drivers should be present in the initial firmware volume anyway: dispatch of additional FVs originating in the non-secure side is not supported. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Core/Dispatcher.c | 92 -------------------- StandaloneMmPkg/Core/StandaloneMmCore.c | 1 - 2 files changed, 93 deletions(-) -- 2.20.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: jiewen.yao@intel.com Reviewed-by: achin.gupta@arm.com diff --git a/StandaloneMmPkg/Core/Dispatcher.c b/StandaloneMmPkg/Core/Dispatcher.c index 8a2ad5118d92..bede4832cfb7 100644 --- a/StandaloneMmPkg/Core/Dispatcher.c +++ b/StandaloneMmPkg/Core/Dispatcher.c @@ -575,7 +575,6 @@ MmDispatcher ( LIST_ENTRY *Link; EFI_MM_DRIVER_ENTRY *DriverEntry; BOOLEAN ReadyToRun; - BOOLEAN PreviousMmEntryPointRegistered; DEBUG ((DEBUG_INFO, "MmDispatcher\n")); @@ -639,11 +638,6 @@ MmDispatcher ( DriverEntry->Initialized = TRUE; RemoveEntryList (&DriverEntry->ScheduledLink); - // - // Cache state of MmEntryPointRegistered before calling entry point - // - PreviousMmEntryPointRegistered = gMmCorePrivate->MmEntryPointRegistered; - // // For each MM driver, pass NULL as ImageHandle // @@ -661,20 +655,6 @@ MmDispatcher ( DEBUG ((DEBUG_INFO, "StartImage Status - %r\n", Status)); MmFreePages(DriverEntry->ImageBuffer, DriverEntry->NumberOfPage); } - - if (!PreviousMmEntryPointRegistered && gMmCorePrivate->MmEntryPointRegistered) { - // - // Return immediately if the MM Entry Point was registered by the MM - // Driver that was just dispatched. The MM IPL will reinvoke the MM - // Core Dispatcher. This is required so MM Mode may be enabled as soon - // as all the dependent MM Drivers for MM Mode have been dispatched. - // Once the MM Entry Point has been registered, then MM Mode will be - // used. - // - gRequestDispatch = TRUE; - gDispatcherRunning = FALSE; - return EFI_NOT_READY; - } } // @@ -903,78 +883,6 @@ MmAddToDriverList ( return EFI_SUCCESS; } -/** - This function is the main entry point for an MM handler dispatch - or communicate-based callback. - - Event notification that is fired every time a FV dispatch protocol is added. - More than one protocol may have been added when this event is fired, so you - must loop on MmLocateHandle () to see how many protocols were added and - do the following to each FV: - If the Fv has already been processed, skip it. If the Fv has not been - processed then mark it as being processed, as we are about to process it. - Read the Fv and add any driver in the Fv to the mDiscoveredList.The - mDiscoveredList is never free'ed and contains variables that define - the other states the MM driver transitions to.. - While you are at it read the A Priori file into memory. - Place drivers in the A Priori list onto the mScheduledQueue. - - @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister(). - @param Context Points to an optional handler context which was specified when the handler was registered. - @param CommBuffer A pointer to a collection of data in memory that will - be conveyed from a non-MM environment into an MM environment. - @param CommBufferSize The size of the CommBuffer. - - @return Status Code - -**/ -EFI_STATUS -EFIAPI -MmDriverDispatchHandler ( - IN EFI_HANDLE DispatchHandle, - IN CONST VOID *Context, OPTIONAL - IN OUT VOID *CommBuffer, OPTIONAL - IN OUT UINTN *CommBufferSize OPTIONAL - ) -{ - EFI_STATUS Status; - - DEBUG ((DEBUG_INFO, "MmDriverDispatchHandler\n")); - - // - // Execute the MM Dispatcher on any newly discovered FVs and previously - // discovered MM drivers that have been discovered but not dispatched. - // - Status = MmDispatcher (); - - // - // Check to see if CommBuffer and CommBufferSize are valid - // - if (CommBuffer != NULL && CommBufferSize != NULL) { - if (*CommBufferSize > 0) { - if (Status == EFI_NOT_READY) { - // - // If a the MM Core Entry Point was just registered, then set flag to - // request the MM Dispatcher to be restarted. - // - *(UINT8 *)CommBuffer = COMM_BUFFER_MM_DISPATCH_RESTART; - } else if (!EFI_ERROR (Status)) { - // - // Set the flag to show that the MM Dispatcher executed without errors - // - *(UINT8 *)CommBuffer = COMM_BUFFER_MM_DISPATCH_SUCCESS; - } else { - // - // Set the flag to show that the MM Dispatcher encountered an error - // - *(UINT8 *)CommBuffer = COMM_BUFFER_MM_DISPATCH_ERROR; - } - } - } - - return EFI_SUCCESS; -} - /** This function is the main entry point for an MM handler dispatch or communicate-based callback. diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c index 74432320bfc7..ec53b8d8bec4 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.c +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c @@ -100,7 +100,6 @@ BOOLEAN mInLegacyBoot = FALSE; // MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = { { MmFvDispatchHandler, &gMmFvDispatchGuid, NULL, TRUE }, - { MmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, TRUE }, { MmReadyToLockHandler, &gEfiDxeMmReadyToLockProtocolGuid, NULL, TRUE }, { MmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, FALSE }, { MmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE },