From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-x244.google.com (mail-oi0-x244.google.com [IPv6:2607:f8b0:4003:c06::244]) (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 6EA5821951C95 for ; Tue, 25 Apr 2017 09:36:24 -0700 (PDT) Received: by mail-oi0-x244.google.com with SMTP id y11so35432245oie.1 for ; Tue, 25 Apr 2017 09:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A4w8j6jdW9KFXn2QRSNSNg4ZXCTUe4iRynynOK7+2Rw=; b=Q+IAOY2hCEH54Lf94P7QHCf4CNUmRzxBu6o0nJmU+5jpV9JaXgIjfi5l0KVL5VmT9I P9OmQ00F4APnlYSD3jML3XReAsJRZNf/ymu8SIs8M1D25zqAH2TLLIZibEAHYMTyFycB EdvR8WfL7L2TWIPs99ZS/9ufl9MWQ5B+tsFNmtwCEnLzQ9jYj7aYtwcje1qPCeP+wKjq CtrAtl+QAOGCMZ5KBPXP7T3bR2EMbOx/rJG1dmpCK0xwquyXR1m0m/DmxDCy7LCnoxf3 ln24h3Xym5MqKEBuF82KTXS1+ih6C9AeLI8IX7sXTZT9dufQKN1ZqT5/0kwb7nobGJ4r L0rg== 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; bh=A4w8j6jdW9KFXn2QRSNSNg4ZXCTUe4iRynynOK7+2Rw=; b=QPW+nlq3TKh1hcFrBN0hfHX0QdvLoZgvsnkCyOsCQAGv7ZFTiTOynClzb2YWNmLBxF OKzE3eFNrhPP6rKR895Y/zMwAnCMEIHzlS7Ze3+lVe6o4zG+tQvR6LAP0+/2mTkqiQks CB6nTvN+jO7G07MIga69Lzw/6pl184DBgcWKG/rdPTc447SRbrZpmyojcKHxr97AgQkg ce1k7cvh1U3vb64Jy4XKbl3/r328vmcCSmu564rxIzU3a/vS+I3PmKAdt4SujrdUnAqK flXd4YehGkJNhS434WdawDhoss1JVb7hGpdJlIeIRmmyO1n91uj0MaR6uUr7S0jQEGne pJxQ== X-Gm-Message-State: AN3rC/5dWjcXLaDMuMMcMztEzwoMW8zzWsPvYxfkJV155eha9J36eJHf mrPcb6AhbCV1NL6cy8I= X-Received: by 10.157.36.137 with SMTP id z9mr2575886ota.112.1493138183665; Tue, 25 Apr 2017 09:36:23 -0700 (PDT) Received: from brijesh-build-machine.amd.com ([165.204.77.1]) by smtp.gmail.com with ESMTPSA id j17sm9666356ota.24.2017.04.25.09.36.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 09:36:23 -0700 (PDT) From: Brijesh Singh To: edk2-devel@lists.01.org, lersek@redhat.com, jordan.l.justen@intel.com Cc: jiewen.yao@intel.com, leo.duran@amd.com, star.zeng@intel.com, liming.gao@intel.com, ard.biesheuvel@linaro.org, brijesh.singh@amd.com, William.Tambe@amd.com, thomas.lendacky@amd.com Date: Tue, 25 Apr 2017 12:34:22 -0400 Message-Id: <1493138064-7816-14-git-send-email-brijesh.ksingh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493138064-7816-1-git-send-email-brijesh.ksingh@gmail.com> References: <1493138064-7816-1-git-send-email-brijesh.ksingh@gmail.com> Subject: [RFC v3 13/15] OvmfPkg/QemuFwCfgLib: Add option to dynamic alloc FW_CFG_DMA Access 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, 25 Apr 2017 16:36:24 -0000 From: Brijesh Singh Update InternalQemuFwCfgDmaBytes() to work with DMA Access pointer. The change provides the flexibility to dynamically allocate the "Access" when SEV is enabled. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brijesh Singh --- OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c index 1bf725d8b7ae..73a19772bee1 100644 --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c @@ -68,7 +68,8 @@ InternalQemuFwCfgDmaBytes ( IN UINT32 Control ) { - volatile FW_CFG_DMA_ACCESS Access; + volatile FW_CFG_DMA_ACCESS LocalAccess; + volatile FW_CFG_DMA_ACCESS *Access; UINT32 AccessHigh, AccessLow; UINT32 Status; @@ -79,9 +80,11 @@ InternalQemuFwCfgDmaBytes ( return; } - Access.Control = SwapBytes32 (Control); - Access.Length = SwapBytes32 (Size); - Access.Address = SwapBytes64 ((UINTN)Buffer); + Access = &LocalAccess; + + Access->Control = SwapBytes32 (Control); + Access->Length = SwapBytes32 (Size); + Access->Address = SwapBytes64 ((UINTN)Buffer); // // Delimit the transfer from (a) modifications to Access, (b) in case of a @@ -92,8 +95,8 @@ InternalQemuFwCfgDmaBytes ( // // Start the transfer. // - AccessHigh = (UINT32)RShiftU64 ((UINTN)&Access, 32); - AccessLow = (UINT32)(UINTN)&Access; + AccessHigh = (UINT32)RShiftU64 ((UINTN)Access, 32); + AccessLow = (UINT32)(UINTN)Access; IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh)); IoWrite32 (FW_CFG_IO_DMA_ADDRESS + 4, SwapBytes32 (AccessLow)); @@ -106,7 +109,7 @@ InternalQemuFwCfgDmaBytes ( // Wait for the transfer to complete. // do { - Status = SwapBytes32 (Access.Control); + Status = SwapBytes32 (Access->Control); ASSERT ((Status & FW_CFG_DMA_CTL_ERROR) == 0); } while (Status != 0); -- 2.7.4