From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x242.google.com (mail-oi0-x242.google.com [IPv6:2607:f8b0:4003:c06::242]) (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 E11D780408 for ; Tue, 21 Mar 2017 14:13:45 -0700 (PDT) Received: by mail-oi0-x242.google.com with SMTP id a94so7282093oic.0 for ; Tue, 21 Mar 2017 14:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=FplWb6kLd1trYKcGjsiAEfE1kQEOGjaTujOAwxRaIeM=; b=QQ17THbj9Ei8fN6W6DLYhUOfEzrwgBdZXCuzVBMQmsaThsm1JOa0++Flt/AmyOcuql MgzCS9n3MuR2Sc+G52q5wUZiI+IAqIItWVHZ86BG+MnkQElj+Z94SpEzlmjg5RoBmGaI kJmE5WBFBj3inrX+ErqtR9Dj7dEHGpasl48kPSmETMf6RLSQF2jikIfOZ7ektOWCzry/ ORTUX5kU9wfKTPYPBOrGkX297a5NpTegE7AAJmzOZ9am6wkImYmEvu70uYH91X9J5LsB cVeIWRHGt8ou6eHL4Xubne9Jgi9/j0zy9NETt9WhztpqezveGvYlpgVuQqHRFofbI1dk u1mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=FplWb6kLd1trYKcGjsiAEfE1kQEOGjaTujOAwxRaIeM=; b=AwSJ/q1NkmljCW7N9NzFdDTWjet2pGqFwajYQFSPcR6muJr7T6M589p0xZurJJ97ZA CfUruuVIV7Zhp5hOxTDpY6y0Yo10ufNB8un+7/8yPEcm0wudltCtJgKDCUEqDI1nmFAY rNw1mPzlRc1vnVZ8UmQT3SLXrCBFaM9VAbxg4EyeL7QkSAy5HXbalVELc4aghRdT7hfE ZZZR7sjF07yWNUBzAdZcDGMsD/QrOUevMTMjYhYWWJ8aI7WW5p8AAXA5VnX1uE/B43JX vFWojuho0cugg+6+oYdc4n6pucKs6zvwkkWBU0qUu5owRxnOJBDUq5jivnbQkfFIgJKi OLrw== X-Gm-Message-State: AFeK/H1WZjdKpGF05i1fzYWUHB19WqRL1ss6+coumF8DT56eqSFfZZg1wQkgQ6ZNPX2G1A== X-Received: by 10.202.190.67 with SMTP id o64mr17958716oif.0.1490130825263; Tue, 21 Mar 2017 14:13:45 -0700 (PDT) Received: from [127.0.1.1] ([165.204.77.1]) by smtp.gmail.com with ESMTPSA id c35sm9227567otb.48.2017.03.21.14.13.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Mar 2017 14:13:44 -0700 (PDT) From: Brijesh Singh X-Google-Original-From: Brijesh Singh To: michael.d.kinney@intel.com, jordan.l.justen@intel.com, edk2-devel@ml01.01.org, lersek@redhat.com, liming.gao@intel.com Cc: leo.duran@amd.com, brijesh.singh@amd.com, Thomas.Lendacky@amd.com Date: Tue, 21 Mar 2017 17:13:44 -0400 Message-ID: <149013082409.27235.9271750185308365336.stgit@brijesh-build-machine> In-Reply-To: <149013076154.27235.10725020825643505862.stgit@brijesh-build-machine> References: <149013076154.27235.10725020825643505862.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [RFC PATCH v2 10/10] OvmfPkg/QemuVideoDxe: Clear the C-bit from framebuffer region when SEV is enabled X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 21:13:46 -0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Since the framebuffer memory region is shared between the guest and hypervisor hence we must clear the memory encryption bit from this memory region when SEV is enabled. Signed-off-by: Brijesh Singh --- OvmfPkg/QemuVideoDxe/Gop.c | 15 +++++++++++++++ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 1 + 2 files changed, 16 insertions(+) diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c index 359e921..96661d1 100644 --- a/OvmfPkg/QemuVideoDxe/Gop.c +++ b/OvmfPkg/QemuVideoDxe/Gop.c @@ -13,6 +13,8 @@ **/ +#include + #include "Qemu.h" STATIC @@ -65,6 +67,19 @@ QemuVideoCompleteModeData ( (VOID**) &FrameBufDesc ); + // + // Framebuffer memory region is shared between hypervisor and guest, + // Clear the memory encryption mask when SEV is active. + // + if (MemEncryptSevIsEnabled ()) { + EFI_STATUS Status; + + Status = MemEncryptSevClearPageEncMask (FrameBufDesc->AddrRangeMin, EFI_SIZE_TO_PAGES (FrameBufDesc->AddrLen)); + if (EFI_ERROR(Status)) { + DEBUG ((EFI_D_WARN, "Failed to clear memory encryption mask 0x%#Lx+0x%x\n", FrameBufDesc->AddrRangeMin, FrameBufDesc->AddrLen)); + } + } + Mode->FrameBufferBase = FrameBufDesc->AddrRangeMin; Mode->FrameBufferSize = Info->HorizontalResolution * Info->VerticalResolution; Mode->FrameBufferSize = Mode->FrameBufferSize * ((ModeData->ColorDepth + 7) / 8); diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf index affb6ff..83ea86c 100644 --- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf +++ b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf @@ -60,6 +60,7 @@ UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + MemEncryptSevLib [Protocols] gEfiDriverSupportedEfiVersionProtocolGuid # PROTOCOL ALWAYS_PRODUCED