From patchwork Tue Mar 5 13:32:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 159662 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4975363jad; Tue, 5 Mar 2019 05:33:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwbE3iGNjlNUpVankNm68QnKCeB4GeNWxg0HFFw4e9D9YJEnxXdi9PfseqM2oVG2InzTWnL X-Received: by 2002:a63:e90f:: with SMTP id i15mr1429091pgh.430.1551792815465; Tue, 05 Mar 2019 05:33:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551792815; cv=none; d=google.com; s=arc-20160816; b=v+HypNtaU8MqGwmylYlDpHeWK5jsTUjHyFqUP0YmkuFqMfMysBiYgveAA6tBCADaMd HTRLnh55U3GLMZIqdjFw5yili6PH8kptX7MlDq3UgniCQQjHkTrmTnqgUmIBvePBIhCE IzqLKMlVxqi0RZFcC7gHm9BWGIPvk9sk0TIwrqID1mZReRqnjCvuIoni1MAHrLjbtbCR bEGYjwLbFKodTUgUHGwLotAKEFu/WXVlfXaVsstVcEhXoVwiTJV2Vd8Cc2UDhEY2CGID nOy4Tkq3AmY+f5e7UY5nIvxDcT21b7I5nr88EdUD6fpFhUFIudOPBnxA0X91AvjCcVsT suiQ== 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=QnZmDSIZnwpLsFwxuDTM4XS02i/AVi1p8+Z+RAG0xbE=; b=LVa70ZjRraSjCDWLcazja/5NYprf71OCkEsJ1ubgwMbIEWTUakbUHOp2XTKA+psUPN dN4Q2cVoU9WaW18aRVtHoSgylm1vCi1k4Ger580a4PmnIn+15lVAddAb8Ec2iwOKH2LB er2Z9Y7O2b3oavRc9XNYJn8BFpdyrL5tCWWNMVNzhCkhIiAfzz3MuZBDBlK3mFQ6vmBG MKkzg09xM4QirsJTmbU5CzAB91LNvnmLssNymnSRl8IJx3wxz2iA/SMy73X9tb2GN+DX t/TZFHHY7Fdx1ShsSShp9GkLxsWhaqfMXu0RQ+pm+Fz9Uzm5mHUVvNaj19siIK5ktT6K rV7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=vCsuPcrj; 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 a22si7921796pfn.155.2019.03.05.05.33.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 05:33:35 -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=vCsuPcrj; 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 DB24B211D5061; Tue, 5 Mar 2019 05:33:11 -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::343; helo=mail-wm1-x343.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (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 97E7F211D5070 for ; Tue, 5 Mar 2019 05:33:10 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id q187so2586919wme.5 for ; Tue, 05 Mar 2019 05:33:10 -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=izJnbqx20UwVWwK2MOV2iHPnjnuq9uWru5WIPMCwKvg=; b=vCsuPcrjrqvm1A9OEllWgUFBNYCQ/dnX3nAnOYnxRLeN7tx2CPfMFvw5C15OrK2oyK 1XJfR9DvdjBRF4qN26MdODranaq+MRtRV9671QoVZKOl7lfX2bAfsbC83R8ZSZEifq23 yaNOQKb6Yzk5uJFMEJtitRaxut/SvhpYkTAK+UTWrli7UqfhBJP81hdTL7dx1LNsJW86 8OEN+w7FGUqYnoyxSqi3ZEy1vp0Pm4sUhHzEgXCbDoc2JLyUuJhn6vwDNA7S1c/NGJ1v N3VcqLAnv/ZuqRHZxnqytaQZ8pBuXvLLtc3oao0Gr92iIKLLPYM0izpHuctbY8jU6Htm pAeA== 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=izJnbqx20UwVWwK2MOV2iHPnjnuq9uWru5WIPMCwKvg=; b=Crcz1ZK4bDvZ97iel9I2cd57AbCGE54xHOH0Nd0w3kxVw8LYCykkUepiGzCID+/i8V Z/xrrneuu62+U18yDs4oYxR+j574oSrPelZRn3Z94z1CFZHS3kqPM/71IZ9mJ5RoLE4Y KlzDPPGoj/XVThjnU/6neJz93de9TiDPCUY0ZD8BurxMuIyFllkocYKZ0XcXOH6xe1t/ YN0TY65K7BzpPn71FolIhdpN9N+210+adamygSxWnFEd3Te8lkL2RGqlChygTy8l3HmL N/S0me2/G8RkPwZEJwv9oJ4qGw29/gQkuWlJAXpEK1DDPZhy/wFzK+HUf4EzrDykZPIh Lp2w== X-Gm-Message-State: APjAAAUTp+7NCskqVBRHTyHqex/tDDNqhCSRXBHxh3eViGJU6MSc7wr0 k1vTb+Q0G4IMvwg/VH74h09X6+Wpfkc= X-Received: by 2002:a1c:cf41:: with SMTP id f62mr2907316wmg.1.1551792788860; Tue, 05 Mar 2019 05:33:08 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 05:33:07 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 5 Mar 2019 14:32:48 +0100 Message-Id: <20190305133248.4828-11-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 10/10] ArmPkg/MmCommunicationDxe: signal architected PI events into MM context 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" PI defines a few architected events that have significance in the MM context as well as in the non-secure DXE context. So register notify handlers for these events, and relay them into the standalone MM world. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 5 +++ ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 47 +++++++++++++++++++- 2 files changed, 50 insertions(+), 2 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/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf index 88beafa39c05..8bf269270f9d 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf @@ -48,6 +48,11 @@ [LibraryClasses] [Protocols] gEfiMmCommunicationProtocolGuid ## PRODUCES +[Guids] + gEfiEndOfDxeEventGroupGuid + gEfiEventExitBootServicesGuid + gEfiEventReadyToBootGuid + [Pcd.common] gArmTokenSpaceGuid.PcdMmBufferBase gArmTokenSpaceGuid.PcdMmBufferSize diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c index feb9fa9f4ead..3203cf801a19 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -265,6 +265,43 @@ GetMmCompatibility () return Status; } +STATIC EFI_GUID* CONST mGuidedEventGuid[] = { + &gEfiEndOfDxeEventGroupGuid, + &gEfiEventExitBootServicesGuid, + &gEfiEventReadyToBootGuid, +}; + +STATIC EFI_EVENT mGuidedEvent[ARRAY_SIZE (mGuidedEventGuid)]; + +/** + Event notification that is fired when GUIDed Event Group is signaled. + + @param Event The Event that is being processed, not used. + @param Context Event Context, not used. + +**/ +STATIC +VOID +EFIAPI +MmGuidedEventNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_MM_COMMUNICATE_HEADER Header; + UINTN Size; + + // + // Use Guid to initialize EFI_SMM_COMMUNICATE_HEADER structure + // + CopyGuid (&Header.HeaderGuid, Context); + Header.MessageLength = 1; + Header.Data[0] = 0; + + Size = sizeof (Header); + MmCommunicationCommunicate (&mMmCommunication, &Header, &Size); +} + /** The Entry Point for MM Communication @@ -287,6 +324,7 @@ MmCommunicationInitialize ( ) { EFI_STATUS Status; + UINTN Index; // Check if we can make the MM call Status = GetMmCompatibility (); @@ -351,8 +389,13 @@ MmCommunicationInitialize ( NULL, &mSetVirtualAddressMapEvent ); - if (Status == EFI_SUCCESS) { - return Status; + ASSERT_EFI_ERROR (Status); + + for (Index = 0; Index < ARRAY_SIZE (mGuidedEventGuid); Index++) { + Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, + MmGuidedEventNotify, mGuidedEventGuid[Index], + mGuidedEventGuid[Index], &mGuidedEvent[Index]); + ASSERT_EFI_ERROR (Status); } gBS->UninstallProtocolInterface (