From patchwork Tue Mar 5 13:32:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 159661 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4975292jad; Tue, 5 Mar 2019 05:33:31 -0800 (PST) X-Google-Smtp-Source: APXvYqw1xXFI+q50X9UrKtytp0Q3zTiEstJ7qfa+xCNgR0BQOnGNkWjMiN2vGlOXRp5YIOTyi9ni X-Received: by 2002:a63:b242:: with SMTP id t2mr1400851pgo.451.1551792811232; Tue, 05 Mar 2019 05:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551792811; cv=none; d=google.com; s=arc-20160816; b=pXpDWEIROtgHN9/fMcKKcv2JlYMzRglBP5yjY213wSz3yCmXij/xhAY9QUsCpvVRU4 t8w/IMPa4gVqGSSW9nQ/5aIHfQMpx6gvByI8p26niHgaPS/ukXp03H3lA1rU5z2a/ZNb 7UMR+OGzMDbSPtLkpljNEQkV4TRhapccdl07DjUS64wFWTjqD7fGXejhHphPk0M/WPqM x37aVD2qsAy3tIWtdOY8qJ4f8ocYVXtVm+QTX5BHXIqeMkYqzHKotbDXOw0tns8OzDPL 7fcRvccvU2eTKy6di9tuqXwKTBhdW/5yLFhxk0SOBz6LMRoKjOw8MngQhGEZTxG0QBkX 05xw== 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=/jj3c63A06ZZxwflQzkja6F2zB1A6TQJgnd5zJ7PENU=; b=Lib77eEGQCxYXuQ5HRh0vjBM+8Hbl2uuDfGFbKlLdNxxXtLbw16YYy6umJtbrox6ZP SxmPyIl4VbnZCu99wWkBOTJt7omq48vclHGjdiYskziATgKTBvOllJbFqGz3a4Ei4izT Jxt20W7x5FjIiPBwbgknMH7w2ZYbHA9xIal0yuhioQTPjUyzOGRVy60fcmqkgHNrx5Ps EkSRlSYAX+zZ0AKgCPxTSZktghAsuzAJ1/PYDZlJf2xHASvxmyeEEAZ3uYxYEbdNfI8y XoQk5+erqQHotHn51DotVrJSaMtw4mlfPvdIjVpM+ee+YTdXMXA48mr8jUDEuuabqPgw Q1dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Dke9J6Mf; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id x8si8128862plv.137.2019.03.05.05.33.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 05:33:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Dke9J6Mf; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 A97F52194EB7B; Tue, 5 Mar 2019 05:33:10 -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::444; helo=mail-wr1-x444.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (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 EB0A32194EB7A for ; Tue, 5 Mar 2019 05:33:08 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id d17so9472914wre.10 for ; Tue, 05 Mar 2019 05:33:08 -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=GKLlsu5nPr6TraiRDsSRJA4IJsJWGA53r/rKj+rdtQU=; b=Dke9J6Mf8yXiLmAwrfdf7u4sDcGfwHO903WrFrQinbqsyHt3T3i2lgA8B/+WFL7MXK 1pKVcfHW7z5t0SHnmVrBPutlNkscqMH0Nl67ZKsHEV8IJGOOqk637voqaHVOUzSh/REl aTbZPgtnE5S6jl0IcYBo34Zv/YobE5dwgP1TiGYnDkBainhP5y9AFc7E6NOLvX3esswE ZSGqoajBPgspVhxRBRcamSsfJpENubZ885H+6xXlbhYtS5ht2ODi3APfqYIniNjB4ljD mvHjGBx8PERY598v2OBN5xbMh1az1qYd08lrpPSMEkDxwWjUuCqaejOCPr9twrBg+xvl KAtA== 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=GKLlsu5nPr6TraiRDsSRJA4IJsJWGA53r/rKj+rdtQU=; b=t8GxPSPoTJMefYuqf6pJiQWhBSCpPGRv7Tt4GY20+76a71NcflHWBEYCMNe2wbLK5W l9Z2rfHEVk+YdQG2W8dhvyxmNGMto2yDgnCr4BtPhFX8Axts5sZSQFoJfO6kPMHpbFUh eM+cYxdmW+bwJzeLydpfU14W/173HQflMWjjHL8aHnRBS0yrw/9nRK1OVazL1PrXd3he kPpErG9EczDLu0+NhKYG6PO/umYtl5KnQWTT3d1AicTpd0tynpeoqenpwJwMFBaVoAKe vfV63WjG28N0MGXpcZhJKDpP5ZuuXJiME5dNIKomFOn2RZUs6wy0fJ21WfHoMACbzGeC X44Q== X-Gm-Message-State: APjAAAWjwwKzetnslcmxIyIwy3Ue/uIgn1aZ8/VpA+1iV4zQTudnxWGy Y+15+IA8BT5XC2drU3HOIUa5g3WuwFs= X-Received: by 2002:a05:6000:1287:: with SMTP id f7mr17243853wrx.203.1551792787222; Tue, 05 Mar 2019 05:33:07 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 05:33:06 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 5 Mar 2019 14:32:47 +0100 Message-Id: <20190305133248.4828-10-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 09/10] StandaloneMmPkg/Core: remove legacy boot support 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" Remove the support for booting 'legacy' (i.e., non-UEFI boot) OSes. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- StandaloneMmPkg/Core/StandaloneMmCore.h | 22 ---- StandaloneMmPkg/Core/StandaloneMmCore.c | 124 ++++++-------------- 2 files changed, 33 insertions(+), 113 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/StandaloneMmCore.h b/StandaloneMmPkg/Core/StandaloneMmCore.h index 74338dc9da0d..5d336b3dbbf6 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.h +++ b/StandaloneMmPkg/Core/StandaloneMmCore.h @@ -635,28 +635,6 @@ MmDriverDispatchHandler ( @return Status Code -**/ -EFI_STATUS -EFIAPI -MmLegacyBootHandler ( - IN EFI_HANDLE DispatchHandle, - IN CONST VOID *Context, OPTIONAL - IN OUT VOID *CommBuffer, OPTIONAL - IN OUT UINTN *CommBufferSize OPTIONAL - ); - -/** - This function is the main entry point for an MM handler dispatch - or communicate-based callback. - - @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister(). - @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 diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c index 766cdb5c848c..fb6b3055e9c6 100644 --- a/StandaloneMmPkg/Core/StandaloneMmCore.c +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c @@ -87,21 +87,12 @@ EFI_MM_SYSTEM_TABLE gMmCoreMmst = { MmiHandlerUnRegister }; -// -// Flag to determine if the platform has performed a legacy boot. -// If this flag is TRUE, then the runtime code and runtime data associated with the -// MM IPL are converted to free memory, so the MM Core must guarantee that is -// does not touch of the code/data associated with the MM IPL if this flag is TRUE. -// -BOOLEAN mInLegacyBoot = FALSE; - // // Table of MMI Handlers that are registered by the MM Core when it is initialized // MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = { { MmReadyToLockHandler, &gEfiDxeMmReadyToLockProtocolGuid, NULL, TRUE }, { MmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, FALSE }, - { MmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE }, { MmExitBootServiceHandler,&gEfiEventExitBootServicesGuid, NULL, FALSE }, { MmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE }, { NULL, NULL, NULL, FALSE }, @@ -142,47 +133,6 @@ MmEfiNotAvailableYetArg5 ( return EFI_NOT_AVAILABLE_YET; } -/** - Software MMI handler that is called when a Legacy Boot event is signaled. The MM - Core uses this signal to know that a Legacy Boot has been performed and that - gMmCorePrivate that is shared between the UEFI and MM execution environments can - not be accessed from MM anymore since that structure is considered free memory by - a legacy OS. - - @param DispatchHandle The unique handle assigned to this handler by MmiHandlerRegister(). - @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 -MmLegacyBootHandler ( - IN EFI_HANDLE DispatchHandle, - IN CONST VOID *Context, OPTIONAL - IN OUT VOID *CommBuffer, OPTIONAL - IN OUT UINTN *CommBufferSize OPTIONAL - ) -{ - EFI_HANDLE MmHandle; - EFI_STATUS Status = EFI_SUCCESS; - - if (!mInLegacyBoot) { - MmHandle = NULL; - Status = MmInstallProtocolInterface ( - &MmHandle, - &gEfiEventLegacyBootGuid, - EFI_NATIVE_INTERFACE, - NULL - ); - } - mInLegacyBoot = TRUE; - return Status; -} - /** Software MMI handler that is called when a ExitBoot Service event is signaled. @@ -396,7 +346,6 @@ MmEntryPoint ( { EFI_STATUS Status; EFI_MM_COMMUNICATE_HEADER *CommunicateHeader; - BOOLEAN InLegacyBoot; DEBUG ((DEBUG_INFO, "MmEntryPoint ...\n")); @@ -413,44 +362,42 @@ MmEntryPoint ( // // If a legacy boot has occured, then make sure gMmCorePrivate is not accessed // - InLegacyBoot = mInLegacyBoot; - if (!InLegacyBoot) { - // - // TBD: Mark the InMm flag as TRUE - // - gMmCorePrivate->InMm = TRUE; + // + // TBD: Mark the InMm flag as TRUE + // + gMmCorePrivate->InMm = TRUE; + + // + // Check to see if this is a Synchronous MMI sent through the MM Communication + // Protocol or an Asynchronous MMI + // + if (gMmCorePrivate->CommunicationBuffer != 0) { // - // Check to see if this is a Synchronous MMI sent through the MM Communication - // Protocol or an Asynchronous MMI + // Synchronous MMI for MM Core or request from Communicate protocol // - if (gMmCorePrivate->CommunicationBuffer != 0) { + if (!MmIsBufferOutsideMmValid ((UINTN)gMmCorePrivate->CommunicationBuffer, gMmCorePrivate->BufferSize)) { + // + // If CommunicationBuffer is not in valid address scope, return EFI_INVALID_PARAMETER + // + gMmCorePrivate->CommunicationBuffer = 0; + gMmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER; + } else { + CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)gMmCorePrivate->CommunicationBuffer; + gMmCorePrivate->BufferSize -= OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data); + Status = MmiManage ( + &CommunicateHeader->HeaderGuid, + NULL, + CommunicateHeader->Data, + (UINTN *)&gMmCorePrivate->BufferSize + ); // - // Synchronous MMI for MM Core or request from Communicate protocol + // Update CommunicationBuffer, BufferSize and ReturnStatus + // Communicate service finished, reset the pointer to CommBuffer to NULL // - if (!MmIsBufferOutsideMmValid ((UINTN)gMmCorePrivate->CommunicationBuffer, gMmCorePrivate->BufferSize)) { - // - // If CommunicationBuffer is not in valid address scope, return EFI_INVALID_PARAMETER - // - gMmCorePrivate->CommunicationBuffer = 0; - gMmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER; - } else { - CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)gMmCorePrivate->CommunicationBuffer; - gMmCorePrivate->BufferSize -= OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data); - Status = MmiManage ( - &CommunicateHeader->HeaderGuid, - NULL, - CommunicateHeader->Data, - (UINTN *)&gMmCorePrivate->BufferSize - ); - // - // Update CommunicationBuffer, BufferSize and ReturnStatus - // Communicate service finished, reset the pointer to CommBuffer to NULL - // - gMmCorePrivate->BufferSize += OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data); - gMmCorePrivate->CommunicationBuffer = 0; - gMmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND; - } + gMmCorePrivate->BufferSize += OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data); + gMmCorePrivate->CommunicationBuffer = 0; + gMmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND; } } @@ -464,14 +411,9 @@ MmEntryPoint ( // // - // If a legacy boot has occured, then make sure gMmCorePrivate is not accessed + // Clear the InMm flag as we are going to leave MM // - if (!InLegacyBoot) { - // - // Clear the InMm flag as we are going to leave MM - // - gMmCorePrivate->InMm = FALSE; - } + gMmCorePrivate->InMm = FALSE; DEBUG ((DEBUG_INFO, "MmEntryPoint Done\n")); }