From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Andre Przywara <andre.przywara@arm.com>,
Will Deacon <will@kernel.org>,
Julien Thierry <julien.thierry.kdev@gmail.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
Marc Zyngier <maz@kernel.org>,
Sami Mujawar <sami.mujawar@arm.com>
Subject: Re: [PATCH kvmtool v2 17/22] virtio: Switch trap handling to use MMIO handler
Date: Tue, 9 Mar 2021 14:43:28 +0000 [thread overview]
Message-ID: <aaef044c-f39b-046b-7078-e67d139f6eb7@arm.com> (raw)
In-Reply-To: <20210225005915.26423-18-andre.przywara@arm.com>
Hi Andre,
On 2/25/21 12:59 AM, Andre Przywara wrote:
> With the planned retirement of the special ioport emulation code, we
> need to provide an emulation function compatible with the MMIO prototype.
>
> Adjust the existing MMIO callback routine to automatically determine
> the region this trap came through, and call the existing I/O handlers.
> Register the ioport region using the new registration function.
Looks good to me:
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Thanks,
Alex
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> virtio/pci.c | 46 ++++++++++++++--------------------------------
> 1 file changed, 14 insertions(+), 32 deletions(-)
>
> diff --git a/virtio/pci.c b/virtio/pci.c
> index 6eea6c68..eb91f512 100644
> --- a/virtio/pci.c
> +++ b/virtio/pci.c
> @@ -178,15 +178,6 @@ static bool virtio_pci__data_in(struct kvm_cpu *vcpu, struct virtio_device *vdev
> return ret;
> }
>
> -static bool virtio_pci__io_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void *data, int size)
> -{
> - struct virtio_device *vdev = ioport->priv;
> - struct virtio_pci *vpci = vdev->virtio;
> - unsigned long offset = port - virtio_pci__port_addr(vpci);
> -
> - return virtio_pci__data_in(vcpu, vdev, offset, data, size);
> -}
> -
> static void update_msix_map(struct virtio_pci *vpci,
> struct msix_table *msix_entry, u32 vecnum)
> {
> @@ -334,20 +325,6 @@ static bool virtio_pci__data_out(struct kvm_cpu *vcpu, struct virtio_device *vde
> return ret;
> }
>
> -static bool virtio_pci__io_out(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, void *data, int size)
> -{
> - struct virtio_device *vdev = ioport->priv;
> - struct virtio_pci *vpci = vdev->virtio;
> - unsigned long offset = port - virtio_pci__port_addr(vpci);
> -
> - return virtio_pci__data_out(vcpu, vdev, offset, data, size);
> -}
> -
> -static struct ioport_operations virtio_pci__io_ops = {
> - .io_in = virtio_pci__io_in,
> - .io_out = virtio_pci__io_out,
> -};
> -
> static void virtio_pci__msix_mmio_callback(struct kvm_cpu *vcpu,
> u64 addr, u8 *data, u32 len,
> u8 is_write, void *ptr)
> @@ -455,12 +432,19 @@ static void virtio_pci__io_mmio_callback(struct kvm_cpu *vcpu,
> {
> struct virtio_device *vdev = ptr;
> struct virtio_pci *vpci = vdev->virtio;
> - u32 mmio_addr = virtio_pci__mmio_addr(vpci);
> + u32 ioport_addr = virtio_pci__port_addr(vpci);
> + u32 base_addr;
> +
> + if (addr >= ioport_addr &&
> + addr < ioport_addr + pci__bar_size(&vpci->pci_hdr, 0))
> + base_addr = ioport_addr;
> + else
> + base_addr = virtio_pci__mmio_addr(vpci);
>
> if (!is_write)
> - virtio_pci__data_in(vcpu, vdev, addr - mmio_addr, data, len);
> + virtio_pci__data_in(vcpu, vdev, addr - base_addr, data, len);
> else
> - virtio_pci__data_out(vcpu, vdev, addr - mmio_addr, data, len);
> + virtio_pci__data_out(vcpu, vdev, addr - base_addr, data, len);
> }
>
> static int virtio_pci__bar_activate(struct kvm *kvm,
> @@ -478,10 +462,8 @@ static int virtio_pci__bar_activate(struct kvm *kvm,
>
> switch (bar_num) {
> case 0:
> - r = ioport__register(kvm, bar_addr, &virtio_pci__io_ops,
> - bar_size, vdev);
> - if (r > 0)
> - r = 0;
> + r = kvm__register_pio(kvm, bar_addr, bar_size,
> + virtio_pci__io_mmio_callback, vdev);
> break;
> case 1:
> r = kvm__register_mmio(kvm, bar_addr, bar_size, false,
> @@ -510,7 +492,7 @@ static int virtio_pci__bar_deactivate(struct kvm *kvm,
>
> switch (bar_num) {
> case 0:
> - r = ioport__unregister(kvm, bar_addr);
> + r = kvm__deregister_pio(kvm, bar_addr);
> break;
> case 1:
> case 2:
> @@ -625,7 +607,7 @@ int virtio_pci__exit(struct kvm *kvm, struct virtio_device *vdev)
> virtio_pci__reset(kvm, vdev);
> kvm__deregister_mmio(kvm, virtio_pci__mmio_addr(vpci));
> kvm__deregister_mmio(kvm, virtio_pci__msix_io_addr(vpci));
> - ioport__unregister(kvm, virtio_pci__port_addr(vpci));
> + kvm__deregister_pio(kvm, virtio_pci__port_addr(vpci));
>
> return 0;
> }
next prev parent reply other threads:[~2021-03-09 14:43 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 0:58 [PATCH kvmtool v2 00/22] Unify I/O port and MMIO trap handling Andre Przywara
2021-02-25 0:58 ` [PATCH kvmtool v2 01/22] ioport: Remove ioport__setup_arch() Andre Przywara
2021-03-02 18:02 ` Alexandru Elisei
2021-02-25 0:58 ` [PATCH kvmtool v2 02/22] hw/serial: Use device abstraction for FDT generator function Andre Przywara
2021-02-25 0:58 ` [PATCH kvmtool v2 03/22] ioport: Retire .generate_fdt_node functionality Andre Przywara
2021-02-25 0:58 ` [PATCH kvmtool v2 04/22] mmio: Extend handling to include ioport emulation Andre Przywara
2021-03-03 17:58 ` Alexandru Elisei
2021-03-15 12:24 ` Andre Przywara
2021-02-25 0:58 ` [PATCH kvmtool v2 05/22] hw/i8042: Clean up data types Andre Przywara
2021-02-25 0:58 ` [PATCH kvmtool v2 06/22] hw/i8042: Refactor trap handler Andre Przywara
2021-03-08 17:16 ` Alexandru Elisei
2021-02-25 0:59 ` [PATCH kvmtool v2 07/22] hw/i8042: Switch to new trap handlers Andre Przywara
2021-03-08 17:22 ` Alexandru Elisei
2021-02-25 0:59 ` [PATCH kvmtool v2 08/22] x86/ioport: Refactor " Andre Przywara
2021-03-09 11:49 ` Alexandru Elisei
2021-03-15 12:26 ` Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 09/22] x86/ioport: Switch to new " Andre Przywara
2021-03-09 12:09 ` Alexandru Elisei
2021-03-15 12:26 ` Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 10/22] hw/rtc: Refactor " Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 11/22] hw/rtc: Switch to new trap handler Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 12/22] hw/vesa: Switch trap handling to use MMIO handler Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 13/22] hw/serial: Refactor trap handler Andre Przywara
2021-03-12 11:29 ` Alexandru Elisei
2021-03-15 12:26 ` Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 14/22] hw/serial: Switch to new trap handlers Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 15/22] vfio: Refactor ioport trap handler Andre Przywara
2021-03-09 14:21 ` Alexandru Elisei
2021-02-25 0:59 ` [PATCH kvmtool v2 16/22] vfio: Switch to new ioport trap handlers Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 17/22] virtio: Switch trap handling to use MMIO handler Andre Przywara
2021-03-09 14:43 ` Alexandru Elisei [this message]
2021-02-25 0:59 ` [PATCH kvmtool v2 18/22] pci: " Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 19/22] Remove ioport specific routines Andre Przywara
2021-03-09 15:13 ` Alexandru Elisei
2021-02-25 0:59 ` [PATCH kvmtool v2 20/22] arm: Reorganise and document memory map Andre Przywara
2021-03-09 15:46 ` Alexandru Elisei
2021-03-15 12:27 ` Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 21/22] hw/serial: ARM/arm64: Use MMIO at higher addresses Andre Przywara
2021-03-09 16:02 ` Alexandru Elisei
2021-03-15 12:27 ` Andre Przywara
2021-02-25 0:59 ` [PATCH kvmtool v2 22/22] hw/rtc: " Andre Przywara
2021-03-09 16:06 ` Alexandru Elisei
2021-03-02 17:57 ` [PATCH kvmtool v2 00/22] Unify I/O port and MMIO trap handling Alexandru Elisei
2021-03-03 18:41 ` Andre Przywara
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=aaef044c-f39b-046b-7078-e67d139f6eb7@arm.com \
--to=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=sami.mujawar@arm.com \
--cc=will@kernel.org \
/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).