public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Brijesh Singh <brijesh.singh@amd.com>, edk2-devel@lists.01.org
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: Re: [PATCH 1/1] OvmfPkg/VirtioBlk: Check the returns status of unmap data buffer
Date: Wed, 30 Aug 2017 19:41:34 +0200	[thread overview]
Message-ID: <9f1d24ab-8e40-7b9d-1d42-49a83d1d9770@redhat.com> (raw)
In-Reply-To: <1504110509-2306-1-git-send-email-brijesh.singh@amd.com>

On 08/30/17 18:28, Brijesh Singh wrote:
> when "RequestIsWrite" is FALSE -- i.e., the CPU wants data from
> the device, we map "Buffer" for VirtioOperationBusMasterWrite. In
> this case, checking the return status of
> 
> Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping);
> 
> is must. If the unmapping fails, then "Buffer" will not contain the
> actual data from the device, and we must fail the request with
> EFI_DEVICE_ERROR.
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
> ---
>  OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
> index 6abd937f86c6..5a63986b3f39 100644
> --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
> +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
> @@ -260,6 +260,7 @@ SynchronousRequest (
>    EFI_PHYSICAL_ADDRESS    HostStatusDeviceAddress;
>    EFI_PHYSICAL_ADDRESS    RequestDeviceAddress;
>    EFI_STATUS              Status;
> +  EFI_STATUS              UnmapStatus;
>  
>    BlockSize = Dev->BlockIoMedia.BlockSize;
>  
> @@ -430,7 +431,13 @@ SynchronousRequest (
>  
>  UnmapDataBuffer:
>    if (BufferSize > 0) {
> -    Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping);
> +    UnmapStatus = Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, BufferMapping);
> +    if (EFI_ERROR (UnmapStatus) && !RequestIsWrite && !EFI_ERROR (Status)) {
> +      //
> +      // Data from the bus master may not reach the caller; fail the request.
> +      //
> +      Status = EFI_DEVICE_ERROR;
> +    }
>    }
>  
>  UnmapRequestBuffer:
> 

I slightly corrected the subject:

-OvmfPkg/VirtioBlk: Check the returns status of unmap data buffer
+OvmfPkg/VirtioBlkDxe: Check the return status of unmap data buffer

I tested this patch in the following environments:
- no SEV, legacy virtio, X64: PASS
- no SEV, modern virtio, X64: PASS
- SEV, modern virtio: PASS

[lersek@redhat.com: fix typos in subject]
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>

Pushed as commit ea8314e4402f.

Thanks!
Laszlo


      reply	other threads:[~2017-08-30 17:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 16:28 [PATCH 1/1] OvmfPkg/VirtioBlk: Check the returns status of unmap data buffer Brijesh Singh
2017-08-30 17:41 ` Laszlo Ersek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9f1d24ab-8e40-7b9d-1d42-49a83d1d9770@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox