From: Stefan Hajnoczi <stefanha@redhat.com>
To: Jagannathan Raman <jag.raman@oracle.com>
Cc: eduardo@habkost.net, elena.ufimtseva@oracle.com,
thuth@redhat.com, john.g.johnson@oracle.com, berrange@redhat.com,
bleal@redhat.com, john.levon@nutanix.com, mst@redhat.com,
armbru@redhat.com, quintela@redhat.com, f4bug@amsat.org,
qemu-devel@nongnu.org, thanos.makatos@nutanix.com,
kanth.ghatraju@oracle.com, marcandre.lureau@redhat.com,
pbonzini@redhat.com, eblake@redhat.com, dgilbert@redhat.com
Subject: Re: [PATCH v8 14/17] vfio-user: handle PCI BAR accesses
Date: Mon, 25 Apr 2022 11:05:18 +0100 [thread overview]
Message-ID: <YmZyXrJWloInu5mo@stefanha-x1.localdomain> (raw)
In-Reply-To: <b01b6963d6d342aac6d715aa83695e7998826223.1650379269.git.jag.raman@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 1798 bytes --]
On Tue, Apr 19, 2022 at 04:44:19PM -0400, Jagannathan Raman wrote:
> +static size_t vfu_object_bar_rw(PCIDevice *pci_dev, int pci_bar,
> + hwaddr bar_offset, char * const buf,
> + hwaddr len, const bool is_write)
> +{
> + MemoryRegionSection section = { 0 };
> + uint8_t *ptr = (uint8_t *)buf;
> + MemoryRegion *section_mr = NULL;
> + uint64_t section_size;
> + hwaddr section_offset;
> + hwaddr size = 0;
> +
> + while (len) {
> + section = memory_region_find(pci_dev->io_regions[pci_bar].memory,
> + bar_offset, len);
> +
> + if (!section.mr) {
> + warn_report("vfu: invalid address 0x%"PRIx64"", bar_offset);
> + return size;
> + }
> +
> + section_mr = section.mr;
> + section_offset = section.offset_within_region;
> + section_size = int128_get64(section.size);
> +
> + if (is_write && section_mr->readonly) {
> + warn_report("vfu: attempting to write to readonly region in "
> + "bar %d - [0x%"PRIx64" - 0x%"PRIx64"]",
> + pci_bar, bar_offset,
> + (bar_offset + section_size));
> + memory_region_unref(section_mr);
> + return size;
> + }
> +
> + if (vfu_object_mr_rw(section_mr, ptr, section_offset,
> + section_size, is_write)) {
> + warn_report("vfu: failed to %s "
> + "[0x%"PRIx64" - 0x%"PRIx64"] in bar %d",
> + is_write ? "write to" : "read from", bar_offset,
> + (bar_offset + section_size), pci_bar);
> + return size;
Missing memory_region_unref(section_mr).
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-04-25 10:07 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-19 20:44 [PATCH v8 00/17] vfio-user server in QEMU Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 01/17] tests/avocado: Specify target VM argument to helper routines Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 02/17] qdev: unplug blocker for devices Jagannathan Raman
2022-04-21 14:55 ` Markus Armbruster
2022-04-21 17:49 ` Jag Raman
2022-04-22 5:18 ` Markus Armbruster
2022-04-22 14:18 ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 03/17] remote/machine: add HotplugHandler for remote machine Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 04/17] remote/machine: add vfio-user property Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 05/17] configure: require cmake 3.19 or newer Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 06/17] vfio-user: build library Jagannathan Raman
2022-04-25 8:22 ` Stefan Hajnoczi
2022-04-19 20:44 ` [PATCH v8 07/17] vfio-user: define vfio-user-server object Jagannathan Raman
2022-04-25 8:27 ` Stefan Hajnoczi
2022-04-19 20:44 ` [PATCH v8 08/17] vfio-user: instantiate vfio-user context Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 09/17] vfio-user: find and init PCI device Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 10/17] vfio-user: run vfio-user context Jagannathan Raman
2022-04-21 14:59 ` Markus Armbruster
2022-04-21 17:52 ` Jag Raman
2022-04-22 5:14 ` Markus Armbruster
2022-04-22 14:18 ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 11/17] vfio-user: handle PCI config space accesses Jagannathan Raman
2022-04-19 20:44 ` [PATCH v8 12/17] vfio-user: IOMMU support for remote device Jagannathan Raman
2022-04-20 11:15 ` Jag Raman
2022-04-25 9:38 ` Stefan Hajnoczi
2022-04-25 17:30 ` Jag Raman
2022-04-28 9:47 ` Stefan Hajnoczi
2022-04-25 9:31 ` Stefan Hajnoczi
2022-04-25 17:26 ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 13/17] vfio-user: handle DMA mappings Jagannathan Raman
2022-04-25 9:56 ` Stefan Hajnoczi
2022-04-25 17:34 ` Jag Raman
2022-04-26 19:53 ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 14/17] vfio-user: handle PCI BAR accesses Jagannathan Raman
2022-04-25 10:05 ` Stefan Hajnoczi [this message]
2022-04-25 17:36 ` Jag Raman
2022-04-19 20:44 ` [PATCH v8 15/17] vfio-user: handle device interrupts Jagannathan Raman
2022-04-25 10:27 ` Stefan Hajnoczi
2022-04-25 17:40 ` Jag Raman
2022-04-28 9:54 ` Stefan Hajnoczi
2022-05-05 16:22 ` Alex Williamson
2022-04-19 20:44 ` [PATCH v8 16/17] vfio-user: handle reset of remote device Jagannathan Raman
2022-04-25 10:27 ` Stefan Hajnoczi
2022-04-19 20:44 ` [PATCH v8 17/17] vfio-user: avocado tests for vfio-user Jagannathan Raman
2022-04-25 10:32 ` [PATCH v8 00/17] vfio-user server in QEMU Stefan Hajnoczi
2022-04-25 17:40 ` Jag Raman
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=YmZyXrJWloInu5mo@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=bleal@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=elena.ufimtseva@oracle.com \
--cc=f4bug@amsat.org \
--cc=jag.raman@oracle.com \
--cc=john.g.johnson@oracle.com \
--cc=john.levon@nutanix.com \
--cc=kanth.ghatraju@oracle.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=thanos.makatos@nutanix.com \
--cc=thuth@redhat.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).