From: Stefano Stabellini <sstabellini@kernel.org>
To: Oleksandr Tyshchenko <olekstysh@gmail.com>
Cc: xen-devel@lists.xenproject.org,
Julien Grall <julien.grall@arm.com>,
Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Subject: Re: [PATCH V4 18/24] xen/dm: Introduce xendevicemodel_set_irq_level DM op
Date: Thu, 14 Jan 2021 17:32:27 -0800 (PST) [thread overview]
Message-ID: <alpine.DEB.2.21.2101141732100.31265@sstabellini-ThinkPad-T480s> (raw)
In-Reply-To: <1610488352-18494-19-git-send-email-olekstysh@gmail.com>
On Tue, 12 Jan 2021, Oleksandr Tyshchenko wrote:
> From: Julien Grall <julien.grall@arm.com>
>
> This patch adds ability to the device emulator to notify otherend
> (some entity running in the guest) using a SPI and implements Arm
> specific bits for it. Proposed interface allows emulator to set
> the logical level of a one of a domain's IRQ lines.
>
> We can't reuse the existing DM op (xen_dm_op_set_isa_irq_level)
> to inject an interrupt as the "isa_irq" field is only 8-bit and
> able to cover IRQ 0 - 255, whereas we need a wider range (0 - 1020).
>
> Please note, for egde-triggered interrupt (which is used for
> the virtio-mmio emulation) we only trigger the interrupt on Arm
> if the level is asserted (rising edge) and do nothing if the level
> is deasserted (falling edge), so the call could be named "trigger_irq"
> (without the level parameter). But, in order to model the line closely
> (to be able to support level-triggered interrupt) we need to know whether
> the line is low or high, so the proposed interface has been chosen.
> However, it is worth mentioning that in case of the level-triggered
> interrupt, we should keep injecting the interrupt to the guest until
> the line is deasserted (this is not covered by current patch).
>
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> [On Arm only]
> Tested-by: Wei Chen <Wei.Chen@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
> ---
> Please note, this is a split/cleanup/hardening of Julien's PoC:
> "Add support for Guest IO forwarding to a device emulator"
>
> Changes RFC -> V1:
> - check incoming parameters in arch_dm_op()
> - add explicit padding to struct xen_dm_op_set_irq_level
>
> Changes V1 -> V2:
> - update the author of a patch
> - update patch description
> - check that padding is always 0
> - mention that interface is Arm only and only SPIs are
> supported for now
> - allow to set the logical level of a line for non-allocated
> interrupts only
> - add xen_dm_op_set_irq_level_t
>
> Changes V2 -> V3:
> - no changes
>
> Changes V3 -> V4:
> - update patch description
> - update patch according to the IOREQ related dm-op handling changes
> ---
> tools/include/xendevicemodel.h | 4 +++
> tools/libs/devicemodel/core.c | 18 ++++++++++
> tools/libs/devicemodel/libxendevicemodel.map | 1 +
> xen/arch/arm/dm.c | 54 +++++++++++++++++++++++++++-
> xen/include/public/hvm/dm_op.h | 16 +++++++++
> 5 files changed, 92 insertions(+), 1 deletion(-)
>
> diff --git a/tools/include/xendevicemodel.h b/tools/include/xendevicemodel.h
> index e877f5c..c06b3c8 100644
> --- a/tools/include/xendevicemodel.h
> +++ b/tools/include/xendevicemodel.h
> @@ -209,6 +209,10 @@ int xendevicemodel_set_isa_irq_level(
> xendevicemodel_handle *dmod, domid_t domid, uint8_t irq,
> unsigned int level);
>
> +int xendevicemodel_set_irq_level(
> + xendevicemodel_handle *dmod, domid_t domid, unsigned int irq,
> + unsigned int level);
> +
> /**
> * This function maps a PCI INTx line to a an IRQ line.
> *
> diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
> index 4d40639..30bd79f 100644
> --- a/tools/libs/devicemodel/core.c
> +++ b/tools/libs/devicemodel/core.c
> @@ -430,6 +430,24 @@ int xendevicemodel_set_isa_irq_level(
> return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
> }
>
> +int xendevicemodel_set_irq_level(
> + xendevicemodel_handle *dmod, domid_t domid, uint32_t irq,
> + unsigned int level)
> +{
> + struct xen_dm_op op;
> + struct xen_dm_op_set_irq_level *data;
> +
> + memset(&op, 0, sizeof(op));
> +
> + op.op = XEN_DMOP_set_irq_level;
> + data = &op.u.set_irq_level;
> +
> + data->irq = irq;
> + data->level = level;
> +
> + return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
> +}
> +
> int xendevicemodel_set_pci_link_route(
> xendevicemodel_handle *dmod, domid_t domid, uint8_t link, uint8_t irq)
> {
> diff --git a/tools/libs/devicemodel/libxendevicemodel.map b/tools/libs/devicemodel/libxendevicemodel.map
> index 561c62d..a0c3012 100644
> --- a/tools/libs/devicemodel/libxendevicemodel.map
> +++ b/tools/libs/devicemodel/libxendevicemodel.map
> @@ -32,6 +32,7 @@ VERS_1.2 {
> global:
> xendevicemodel_relocate_memory;
> xendevicemodel_pin_memory_cacheattr;
> + xendevicemodel_set_irq_level;
> } VERS_1.1;
>
> VERS_1.3 {
> diff --git a/xen/arch/arm/dm.c b/xen/arch/arm/dm.c
> index e6dedf4..804830a 100644
> --- a/xen/arch/arm/dm.c
> +++ b/xen/arch/arm/dm.c
> @@ -20,6 +20,8 @@
> #include <xen/ioreq.h>
> #include <xen/nospec.h>
>
> +#include <asm/vgic.h>
> +
> static int dm_op(const struct dmop_args *op_args)
> {
> struct domain *d;
> @@ -35,6 +37,7 @@ static int dm_op(const struct dmop_args *op_args)
> [XEN_DMOP_unmap_io_range_from_ioreq_server] = sizeof(struct xen_dm_op_ioreq_server_range),
> [XEN_DMOP_set_ioreq_server_state] = sizeof(struct xen_dm_op_set_ioreq_server_state),
> [XEN_DMOP_destroy_ioreq_server] = sizeof(struct xen_dm_op_destroy_ioreq_server),
> + [XEN_DMOP_set_irq_level] = sizeof(struct xen_dm_op_set_irq_level),
> };
>
> rc = rcu_lock_remote_domain_by_id(op_args->domid, &d);
> @@ -73,7 +76,56 @@ static int dm_op(const struct dmop_args *op_args)
> if ( op.pad )
> goto out;
>
> - rc = ioreq_server_dm_op(&op, d, &const_op);
> + switch ( op.op )
> + {
> + case XEN_DMOP_set_irq_level:
> + {
> + const struct xen_dm_op_set_irq_level *data =
> + &op.u.set_irq_level;
> + unsigned int i;
> +
> + /* Only SPIs are supported */
> + if ( (data->irq < NR_LOCAL_IRQS) || (data->irq >= vgic_num_irqs(d)) )
> + {
> + rc = -EINVAL;
> + break;
> + }
> +
> + if ( data->level != 0 && data->level != 1 )
> + {
> + rc = -EINVAL;
> + break;
> + }
> +
> + /* Check that padding is always 0 */
> + for ( i = 0; i < sizeof(data->pad); i++ )
> + {
> + if ( data->pad[i] )
> + {
> + rc = -EINVAL;
> + break;
> + }
> + }
> +
> + /*
> + * Allow to set the logical level of a line for non-allocated
> + * interrupts only.
> + */
> + if ( test_bit(data->irq, d->arch.vgic.allocated_irqs) )
> + {
> + rc = -EINVAL;
> + break;
> + }
> +
> + vgic_inject_irq(d, NULL, data->irq, data->level);
> + rc = 0;
> + break;
> + }
> +
> + default:
> + rc = ioreq_server_dm_op(&op, d, &const_op);
> + break;
> + }
>
> if ( (!rc || rc == -ERESTART) &&
> !const_op && copy_to_guest_offset(op_args->buf[0].h, offset,
> diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h
> index 66cae1a..1f70d58 100644
> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -434,6 +434,21 @@ struct xen_dm_op_pin_memory_cacheattr {
> };
> typedef struct xen_dm_op_pin_memory_cacheattr xen_dm_op_pin_memory_cacheattr_t;
>
> +/*
> + * XEN_DMOP_set_irq_level: Set the logical level of a one of a domain's
> + * IRQ lines (currently Arm only).
> + * Only SPIs are supported.
> + */
> +#define XEN_DMOP_set_irq_level 19
> +
> +struct xen_dm_op_set_irq_level {
> + uint32_t irq;
> + /* IN - Level: 0 -> deasserted, 1 -> asserted */
> + uint8_t level;
> + uint8_t pad[3];
> +};
> +typedef struct xen_dm_op_set_irq_level xen_dm_op_set_irq_level_t;
> +
> struct xen_dm_op {
> uint32_t op;
> uint32_t pad;
> @@ -447,6 +462,7 @@ struct xen_dm_op {
> xen_dm_op_track_dirty_vram_t track_dirty_vram;
> xen_dm_op_set_pci_intx_level_t set_pci_intx_level;
> xen_dm_op_set_isa_irq_level_t set_isa_irq_level;
> + xen_dm_op_set_irq_level_t set_irq_level;
> xen_dm_op_set_pci_link_route_t set_pci_link_route;
> xen_dm_op_modified_memory_t modified_memory;
> xen_dm_op_set_mem_type_t set_mem_type;
> --
> 2.7.4
>
next prev parent reply other threads:[~2021-01-15 1:32 UTC|newest]
Thread overview: 144+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 21:52 [PATCH V4 00/24] IOREQ feature (+ virtio-mmio) on Arm Oleksandr Tyshchenko
2021-01-12 21:52 ` [PATCH V4 01/24] x86/ioreq: Prepare IOREQ feature for making it common Oleksandr Tyshchenko
2021-01-15 15:16 ` Julien Grall
2021-01-15 16:41 ` Jan Beulich
2021-01-16 9:48 ` Oleksandr
2021-01-18 8:22 ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 02/24] x86/ioreq: Add IOREQ_STATUS_* #define-s and update code for moving Oleksandr Tyshchenko
2021-01-15 15:17 ` Julien Grall
2021-01-18 8:24 ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 03/24] x86/ioreq: Provide out-of-line wrapper for the handle_mmio() Oleksandr Tyshchenko
2021-01-15 14:48 ` Alex Bennée
2021-01-15 15:19 ` Julien Grall
2021-01-18 8:29 ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 04/24] xen/ioreq: Make x86's IOREQ feature common Oleksandr Tyshchenko
2021-01-15 14:55 ` Alex Bennée
2021-01-15 15:23 ` Julien Grall
2021-01-18 8:48 ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 05/24] xen/ioreq: Make x86's hvm_ioreq_needs_completion() common Oleksandr Tyshchenko
2021-01-15 15:25 ` Julien Grall
2021-01-20 8:48 ` Alex Bennée
2021-01-20 9:31 ` Julien Grall
2021-01-12 21:52 ` [PATCH V4 06/24] xen/ioreq: Make x86's hvm_mmio_first(last)_byte() common Oleksandr Tyshchenko
2021-01-15 15:34 ` Julien Grall
2021-01-20 8:57 ` Alex Bennée
2021-01-20 16:15 ` Jan Beulich
2021-01-20 20:47 ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 07/24] xen/ioreq: Make x86's hvm_ioreq_(page/vcpu/server) structs common Oleksandr Tyshchenko
2021-01-15 15:36 ` Julien Grall
2021-01-18 8:59 ` Paul Durrant
2021-01-20 8:58 ` Alex Bennée
2021-01-12 21:52 ` [PATCH V4 08/24] xen/ioreq: Move x86's ioreq_server to struct domain Oleksandr Tyshchenko
2021-01-15 15:44 ` Julien Grall
2021-01-18 9:09 ` Paul Durrant
2021-01-20 9:00 ` Alex Bennée
2021-01-12 21:52 ` [PATCH V4 09/24] xen/ioreq: Make x86's IOREQ related dm-op handling common Oleksandr Tyshchenko
2021-01-18 9:17 ` Paul Durrant
2021-01-18 10:19 ` Oleksandr
2021-01-18 10:34 ` Paul Durrant
2021-01-20 16:21 ` Jan Beulich
2021-01-21 10:23 ` Oleksandr
2021-01-21 10:27 ` Jan Beulich
2021-01-21 11:13 ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 10/24] xen/ioreq: Move x86's io_completion/io_req fields to struct vcpu Oleksandr Tyshchenko
2021-01-15 19:34 ` Julien Grall
2021-01-18 9:35 ` Paul Durrant
2021-01-20 16:24 ` Jan Beulich
2021-01-12 21:52 ` [PATCH V4 11/24] xen/mm: Make x86's XENMEM_resource_ioreq_server handling common Oleksandr Tyshchenko
2021-01-14 3:58 ` Wei Chen
2021-01-14 15:31 ` Oleksandr
2021-01-15 14:35 ` Alex Bennée
2021-01-18 17:42 ` Oleksandr
2021-01-18 9:38 ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 12/24] xen/ioreq: Remove "hvm" prefixes from involved function names Oleksandr Tyshchenko
2021-01-18 9:55 ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 13/24] xen/ioreq: Use guest_cmpxchg64() instead of cmpxchg() Oleksandr Tyshchenko
2021-01-15 19:37 ` Julien Grall
2021-01-17 11:32 ` Oleksandr
2021-01-18 10:00 ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 14/24] arm/ioreq: Introduce arch specific bits for IOREQ/DM features Oleksandr Tyshchenko
2021-01-15 0:55 ` Stefano Stabellini
2021-01-17 12:45 ` Oleksandr
2021-01-20 0:23 ` Stefano Stabellini
2021-01-21 9:51 ` Oleksandr
2021-01-15 20:26 ` Julien Grall
2021-01-17 17:11 ` Oleksandr
2021-01-17 18:07 ` Julien Grall
2021-01-17 18:52 ` Oleksandr
2021-01-18 19:17 ` Julien Grall
2021-01-19 15:20 ` Oleksandr
2021-01-20 0:50 ` Stefano Stabellini
2021-01-20 15:57 ` Julien Grall
2021-01-20 19:47 ` Stefano Stabellini
2021-01-21 9:31 ` Oleksandr
2021-01-21 21:34 ` Stefano Stabellini
2021-01-20 15:50 ` Julien Grall
2021-01-21 8:50 ` Oleksandr
2021-01-27 10:24 ` Jan Beulich
2021-01-27 12:22 ` Oleksandr
2021-01-27 12:52 ` Jan Beulich
2021-01-18 10:44 ` Jan Beulich
2021-01-18 15:52 ` Oleksandr
2021-01-18 16:00 ` Jan Beulich
2021-01-18 16:29 ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 15/24] xen/arm: Stick around in leave_hypervisor_to_guest until I/O has completed Oleksandr Tyshchenko
2021-01-15 1:12 ` Stefano Stabellini
2021-01-15 20:55 ` Julien Grall
2021-01-17 20:23 ` Oleksandr
2021-01-18 10:57 ` Julien Grall
2021-01-18 13:23 ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 16/24] xen/mm: Handle properly reference in set_foreign_p2m_entry() on Arm Oleksandr Tyshchenko
2021-01-15 1:19 ` Stefano Stabellini
2021-01-15 20:59 ` Julien Grall
2021-01-21 13:57 ` Jan Beulich
2021-01-21 18:42 ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 17/24] xen/ioreq: Introduce domain_has_ioreq_server() Oleksandr Tyshchenko
2021-01-15 1:24 ` Stefano Stabellini
2021-01-18 10:23 ` Paul Durrant
2021-01-12 21:52 ` [PATCH V4 18/24] xen/dm: Introduce xendevicemodel_set_irq_level DM op Oleksandr Tyshchenko
2021-01-15 1:32 ` Stefano Stabellini [this message]
2021-01-12 21:52 ` [PATCH V4 19/24] xen/arm: io: Abstract sign-extension Oleksandr Tyshchenko
2021-01-15 1:35 ` Stefano Stabellini
2021-01-12 21:52 ` [PATCH V4 20/24] xen/arm: io: Harden sign extension check Oleksandr Tyshchenko
2021-01-15 1:48 ` Stefano Stabellini
2021-01-22 10:15 ` Volodymyr Babchuk
2021-01-12 21:52 ` [PATCH V4 21/24] xen/ioreq: Make x86's send_invalidate_req() common Oleksandr Tyshchenko
2021-01-18 10:31 ` Paul Durrant
2021-01-21 14:02 ` Jan Beulich
2021-01-12 21:52 ` [PATCH V4 22/24] xen/arm: Add mapcache invalidation handling Oleksandr Tyshchenko
2021-01-15 2:11 ` Stefano Stabellini
2021-01-21 19:47 ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 23/24] libxl: Introduce basic virtio-mmio support on Arm Oleksandr Tyshchenko
2021-01-15 21:30 ` Julien Grall
2021-01-17 22:22 ` Oleksandr
2021-01-20 16:40 ` Julien Grall
2021-01-20 20:35 ` Stefano Stabellini
2021-02-09 21:04 ` Oleksandr
2021-01-12 21:52 ` [PATCH V4 24/24] [RFC] libxl: Add support for virtio-disk configuration Oleksandr Tyshchenko
2021-01-14 17:20 ` Ian Jackson
2021-01-16 9:05 ` Oleksandr
2021-01-15 22:01 ` Julien Grall
2021-01-18 8:32 ` Oleksandr
2021-01-20 17:05 ` Julien Grall
2021-02-10 9:02 ` Oleksandr
2021-03-06 19:52 ` Julien Grall
2021-01-14 3:55 ` [PATCH V4 00/24] IOREQ feature (+ virtio-mmio) on Arm Wei Chen
2021-01-14 15:23 ` Oleksandr
2021-01-07 14:35 ` [ANNOUNCE] Xen 4.15 release schedule and feature tracking Ian Jackson
2021-01-07 15:45 ` Oleksandr
2021-01-14 16:11 ` [PATCH V4 00/24] IOREQ feature (+ virtio-mmio) on Arm Ian Jackson
2021-01-14 18:41 ` Oleksandr
2021-01-14 16:06 ` [ANNOUNCE] Xen 4.15 release schedule and feature tracking Ian Jackson
2021-01-14 19:02 ` Andrew Cooper
2021-01-15 9:57 ` Jan Beulich
2021-01-15 10:00 ` Julien Grall
2021-01-15 10:52 ` Andrew Cooper
2021-01-15 10:59 ` Andrew Cooper
2021-01-15 11:08 ` Jan Beulich
2021-01-15 10:43 ` Bertrand Marquis
2021-01-15 15:14 ` Lengyel, Tamas
2021-01-28 22:55 ` Dario Faggioli
2021-01-28 18:26 ` Dario Faggioli
2021-01-28 22:15 ` Dario Faggioli
2021-01-29 8:38 ` Jan Beulich
2021-01-29 9:22 ` Dario Faggioli
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=alpine.DEB.2.21.2101141732100.31265@sstabellini-ThinkPad-T480s \
--to=sstabellini@kernel.org \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=julien@xen.org \
--cc=oleksandr_tyshchenko@epam.com \
--cc=olekstysh@gmail.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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).