From: cdall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/5] KVM: arm/arm64: Add ARM user space interrupt signaling ABI
Date: Wed, 5 Apr 2017 10:12:37 +0200 [thread overview]
Message-ID: <20170405081237.GB1526@cbox> (raw)
In-Reply-To: <5fe89e77-4fcc-f2e5-a796-a1e1f38eef9f@suse.de>
On Wed, Apr 05, 2017 at 02:14:11AM +0200, Alexander Graf wrote:
>
>
> On 21.02.17 12:41, Christoffer Dall wrote:
> >Hi Alex,
> >
> >On Fri, Feb 03, 2017 at 05:51:18PM +0000, Peter Maydell wrote:
> >>On 3 February 2017 at 14:56, Christoffer Dall <cdall@linaro.org> wrote:
> >>>From: Christoffer Dall <christoffer.dall@linaro.org>
> >>>
> >>>We have 2 modes for dealing with interrupts in the ARM world. We can
> >>>either handle them all using hardware acceleration through the vgic or
> >>>we can emulate a gic in user space and only drive CPU IRQ pins from
> >>>there.
> >>>
> >>>Unfortunately, when driving IRQs from user space, we never tell user
> >>>space about events from devices emulated inside the kernel, which may
> >>>result in interrupt line state changes, so we lose out on for example
> >>>timer and PMU events if we run with user space gic emulation.
> >>>
> >>>Define an ABI to publish such device output levels to userspace.
> >>>
> >>>Signed-off-by: Alexander Graf <agraf@suse.de>
> >>>Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> >>
> >>
> >>Acked-by: Peter Maydell <peter.maydell@linaro.org>
> >>
> >>for the userspace ABI/docs part.
> >>
> >
> >Given Peter's ack on this ABI, any chance you could take a look at
> >fixing the userspace SMP issue and respinning the userspace patches for
> >this series?
>
> The problem with user space SMP was simply a missing lock:
>
> diff --git a/target/arm/kvm.c b/target/arm/kvm.c
> index a66845f..1b33895 100644
> --- a/target/arm/kvm.c
> +++ b/target/arm/kvm.c
> @@ -548,10 +548,14 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs,
> struct kvm_run *run)
>
> /* Synchronize our internal vtimer irq line with the kvm one */
> if (run->s.regs.device_irq_level != cpu->device_irq_level) {
> - qemu_set_irq(ARM_CPU(cs)->gt_timer_outputs[GTIMER_VIRT],
> + qemu_mutex_lock_iothread();
> + qemu_set_irq(cpu->gt_timer_outputs[GTIMER_VIRT],
> run->s.regs.device_irq_level &
> KVM_ARM_DEV_EL1_VTIMER);
> + qemu_set_irq(cpu->gt_timer_outputs[GTIMER_PHYS],
> + run->s.regs.device_irq_level &
> KVM_ARM_DEV_EL1_PTIMER);
> /* TODO: Handle changes in PTIMER and PMU as well */
> cpu->device_irq_level = run->s.regs.device_irq_level;
> + qemu_mutex_unlock_iothread();
> }
>
> return MEMTXATTRS_UNSPECIFIED;
>
> ----
>
>
> I also wasn't able to use your series out of the box. There are
> several places in the code that check whether a timer is enabled
> (for register save/restore for example) and without vgic we never
> ended up setting that to true.
>
> I don't know how safe it is to set it to true regardless. It feels
> to me like someone has to put more thought into how to switch from
> an initialized user space timer state to a vgic one. For reference,
> my test patch is below:
>
> diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
> index 891a725..56a5d51 100644
> --- a/virt/kvm/arm/arch_timer.c
> +++ b/virt/kvm/arm/arch_timer.c
> @@ -629,8 +629,11 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu)
> return 0;
>
> /* Without a VGIC we do not map virtual IRQs to physical IRQs */
> - if (!irqchip_in_kernel(vcpu->kvm))
> + if (!irqchip_in_kernel(vcpu->kvm)) {
> + /* Enable timer for now, may be racy? */
> + timer->enabled = 1;
> return 0;
> + }
>
> if (!vgic_initialized(vcpu->kvm))
> return -ENODEV;
>
Heh, sorry about this, I accidentally pushed the wrong content to my git
repo, so I'm guessing you pulled from there instead of applying these
patches directly. If you want a branch with these patches as intended,
try this:
git://git.kernel.org/pub/scm/linux/kernel/git/cdall/linux.git irqs-to-user-v2-for-real
I have a v3 ready based on v4.11-rc1 plus other KVM fixes and I'll send
that out later today once I've tested with your qemu fix above.
Thanks,
-Christoffer
next prev parent reply other threads:[~2017-04-05 8:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 14:56 [PATCH v2 0/5] Support userspace irqchip with arch timers Christoffer Dall
2017-02-03 14:56 ` [PATCH v2 1/5] KVM: arm/arm64: Cleanup the arch timer code's irqchip checking Christoffer Dall
2017-02-03 14:56 ` [PATCH v2 2/5] KVM: arm/arm64: Add ARM user space interrupt signaling ABI Christoffer Dall
2017-02-03 17:51 ` Peter Maydell
2017-02-21 11:41 ` Christoffer Dall
2017-04-05 0:14 ` Alexander Graf
2017-04-05 8:12 ` Christoffer Dall [this message]
2017-02-03 14:56 ` [PATCH v2 3/5] KVM: arm/arm64: Support arch timers with a userspace gic Christoffer Dall
2017-02-03 14:56 ` [PATCH v2 4/5] KVM: arm/arm64: Report PMU overflow interrupts to userspace irqchip Christoffer Dall
2017-02-03 14:56 ` [PATCH v2 5/5] KVM: arm/arm64: Advertise support for KVM_CAP_ARM_USER_IRQ Christoffer Dall
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=20170405081237.GB1526@cbox \
--to=cdall@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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).