qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Yi Min Zhao <zyimin@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Cc: pasic@linux.vnet.ibm.com, cohuck@redhat.com,
	pmorel@linux.vnet.ibm.com, borntraeger@de.ibm.com,
	alex.williamson@redhat.com, marcel@redhat.com,
	qemu-s390x@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] s390x/pci: fixup the code walking IOMMU tables
Date: Wed, 31 Jan 2018 08:42:59 +0100	[thread overview]
Message-ID: <4740d12b-4dc0-d836-2f9e-574b836b72e7@redhat.com> (raw)
In-Reply-To: <20180130094715.11578-2-zyimin@linux.vnet.ibm.com>

On 30.01.2018 10:47, Yi Min Zhao wrote:
> Current s390x PCI IOMMU code is lack of flags' checking, including:
> 1) protection bit
> 2) table length
> 3) table offset
> 4) intermediate tables' invalid bit
> 5) format control bit
> 
> This patch introduces a new struct named S390IOTLBEntry, and makes up
> these missed checkings. At the same time, inform the guest with the
> corresponding error number when the check fails.
> 
> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
> Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
> ---
>  hw/s390x/s390-pci-bus.c  | 223 ++++++++++++++++++++++++++++++++++++++---------
>  hw/s390x/s390-pci-bus.h  |  10 +++
>  hw/s390x/s390-pci-inst.c |  10 ---
>  3 files changed, 190 insertions(+), 53 deletions(-)
[...]
> @@ -374,26 +511,26 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr,
>      DPRINTF("iommu trans addr 0x%" PRIx64 "\n", addr);
>  
>      if (addr < iommu->pba || addr > iommu->pal) {
> -        return ret;
> +        error = ERR_EVENT_OORANGE;
> +        goto err;
>      }
>  
> -    pte = s390_guest_io_table_walk(s390_pci_get_table_origin(iommu->g_iota),
> -                                   addr);
> -    if (!pte) {
> -        return ret;
> -    }
> +    error = s390_guest_io_table_walk(iommu->g_iota, addr, &entry);
>  
> -    flags = pte & ZPCI_PTE_FLAG_MASK;
> -    ret.iova = addr;
> -    ret.translated_addr = pte & ZPCI_PTE_ADDR_MASK;
> -    ret.addr_mask = 0xfff;
> +    ret.iova = entry.iova;
> +    ret.translated_addr = entry.translated_addr;
> +    ret.addr_mask = entry.len - 1;
> +    ret.perm = entry.perm;
>  
> -    if (flags & ZPCI_PTE_INVALID) {
> -        ret.perm = IOMMU_NONE;
> -    } else {
> -        ret.perm = IOMMU_RW;
> +    if ((flag != IOMMU_NONE) && !(flag & ret.perm)) {

You could drop the parentheses around "flag != IOMMU_NONE".

For the rest of the patch: Sorry, can't review due to missing PCI spec :-(

 Thomas

  reply	other threads:[~2018-01-31  7:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30  9:47 [Qemu-devel] [PATCH 0/3] s390x/pci: fixup and optimize IOTLB code Yi Min Zhao
2018-01-30  9:47 ` [Qemu-devel] [PATCH 1/3] s390x/pci: fixup the code walking IOMMU tables Yi Min Zhao
2018-01-31  7:42   ` Thomas Huth [this message]
2018-01-31  8:46     ` Yi Min Zhao
2018-01-31 10:58   ` Cornelia Huck
2018-02-01 11:28     ` Yi Min Zhao
2018-02-01 11:56       ` Pierre Morel
2018-02-01 12:15         ` Cornelia Huck
2018-02-01 13:17           ` Pierre Morel
2018-01-30  9:47 ` [Qemu-devel] [PATCH 2/3] s390x/pci: fixup global refresh Yi Min Zhao
2018-01-31 11:35   ` Cornelia Huck
2018-02-01 12:55     ` Pierre Morel
2018-01-30  9:47 ` [Qemu-devel] [PATCH 3/3] s390x/pci: use the right pal and pba in reg_ioat() Yi Min Zhao
2018-01-31 11:44   ` Cornelia Huck
2018-02-01 11:33     ` Pierre Morel
2018-02-01 12:02       ` Cornelia Huck
2018-02-02  3:50         ` Yi Min Zhao

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-all 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=4740d12b-4dc0-d836-2f9e-574b836b72e7@redhat.com \
    --to=thuth@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=marcel@redhat.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=pmorel@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=zyimin@linux.vnet.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).