From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: APXvYqyPw8cPFqPGXubAKdiVdKzYqF06HY0ZdPird7K7p8nQOuRgdW96soVwlpDin0lZNxtar337ig== 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 Cc: Ard Biesheuvel , Achin Gupta , Supreeth Venkatesh , Jiewen Yao , Leif Lindholm , Jagadeesh Ujja 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: [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: , X-List-Received-Date: Tue, 05 Mar 2019 13:33:11 -0000 Content-Transfer-Encoding: 8bit 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(-) 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 ( -- 2.20.1