qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Alexander Graf <agraf@suse.de>, Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH 4/6] kvm: Don't assume irqchip-in-kernel implies irqfds
Date: Wed, 25 Jul 2012 17:47:21 +0200	[thread overview]
Message-ID: <50101509.8060805@siemens.com> (raw)
In-Reply-To: <1343222672-25312-5-git-send-email-peter.maydell@linaro.org>

On 2012-07-25 15:24, Peter Maydell wrote:
> Instead of assuming that we can use irqfds if and only if
> kvm_irqchip_in_kernel(), add a bool to the KVMState which
> indicates this, and is set only on x86 and only if the
> irqchip is in the kernel.
> 
> The kernel documentation implies that the only thing
> you need to use KVM_IRQFD is that KVM_CAP_IRQFD is
> advertised, but this seems to be untrue. In particular
> the kernel does not (alas) return a sensible error if you
> try to set up an irqfd when you haven't created an irqchip.
> If it did we could remove all this nonsense and let the
> kernel return the error code.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  kvm-all.c         |    3 ++-
>  kvm-stub.c        |    1 +
>  kvm.h             |   10 ++++++++++
>  target-i386/kvm.c |    4 ++++
>  4 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index 8e21d81..a88b8ad 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -101,6 +101,7 @@ struct KVMState
>  KVMState *kvm_state;
>  bool kvm_kernel_irqchip;
>  bool kvm_async_interrupt_injection;
> +bool kvm_irqfds_allowed;

Why allowed vs enabled? You only have kvm_async_interrupt_injection as well.

>  
>  static const KVMCapabilityInfo kvm_required_capabilites[] = {
>      KVM_CAP_INFO(USER_MEMORY),
> @@ -1126,7 +1127,7 @@ static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int virq, bool assign)
>          .flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN,
>      };
>  
> -    if (!kvm_irqchip_in_kernel()) {
> +    if (!kvm_irqfds_enabled()) {
>          return -ENOSYS;
>      }
>  
> diff --git a/kvm-stub.c b/kvm-stub.c
> index af1cb5e..179e5de 100644
> --- a/kvm-stub.c
> +++ b/kvm-stub.c
> @@ -20,6 +20,7 @@
>  KVMState *kvm_state;
>  bool kvm_kernel_irqchip;
>  bool kvm_async_interrupt_injection;
> +bool kvm_irqfds_allowed;
>  
>  int kvm_init_vcpu(CPUArchState *env)
>  {
> diff --git a/kvm.h b/kvm.h
> index e6cbf12..2337eb0 100644
> --- a/kvm.h
> +++ b/kvm.h
> @@ -25,6 +25,7 @@
>  extern int kvm_allowed;
>  extern bool kvm_kernel_irqchip;
>  extern bool kvm_async_interrupt_injection;
> +extern bool kvm_irqfds_allowed;
>  
>  #if defined CONFIG_KVM || !defined NEED_CPU_H
>  #define kvm_enabled()           (kvm_allowed)
> @@ -38,10 +39,19 @@ extern bool kvm_async_interrupt_injection;
>   * (where the vcpu must be stopped at a suitable point first).
>   */
>  #define kvm_async_interrupt_injection() (kvm_async_interrupt_injection)
> +/**
> + * kvm_irqfds_enabled:
> + *
> + * Returns: true if we can use irqfds to inject interrupts into
> + * a KVM CPU (ie the kernel supports irqfds and we are running
> + * with a configuration where it is meaningful to use them).
> + */
> +#define kvm_irqfds_enabled() (kvm_irqfds_allowed)
>  #else
>  #define kvm_enabled()           (0)
>  #define kvm_irqchip_in_kernel() (false)
>  #define kvm_async_interrupt_injection() (false)
> +#define kvm_irqfds_enabled() (false)
>  #endif
>  
>  struct kvm_run;
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 503abeb..8e19a4d 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -2045,4 +2045,8 @@ void kvm_arch_init_irq_routing(KVMState *s)
>           */
>          no_hpet = 1;
>      }
> +    /* We know at this point that we're using the in-kernel
> +     * irqchip, so we can use irqfds.
> +     */
> +    kvm_irqfds_allowed = true;
>  }
> 

Otherwise:

Acked-by: Jan Kiszka <jan.kiszka@siemens.com>

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux

  reply	other threads:[~2012-07-25 15:47 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-25 13:24 [Qemu-devel] [PATCH 0/6] split out uses of kvm_irqchip_in_kernel() Peter Maydell
2012-07-25 13:24 ` [Qemu-devel] [PATCH 1/6] kvm: Decouple 'interrupt injection is async' from 'kernel irqchip' Peter Maydell
2012-07-25 15:41   ` Jan Kiszka
2012-07-25 13:24 ` [Qemu-devel] [PATCH 2/6] kvm: Rename kvm_irqchip_set_irq to kvm_inject_async_irq Peter Maydell
2012-07-25 15:43   ` Jan Kiszka
2012-07-25 15:47   ` Avi Kivity
2012-07-25 15:53     ` Jan Kiszka
2012-07-25 15:55       ` Avi Kivity
2012-07-25 15:56         ` Peter Maydell
2012-07-25 15:58           ` Jan Kiszka
2012-07-25 16:09             ` Peter Maydell
2012-07-25 16:11               ` Jan Kiszka
2012-07-25 16:18                 ` Peter Maydell
2012-07-25 16:24                   ` Peter Maydell
2012-07-25 16:28                     ` Jan Kiszka
2012-07-25 16:36                       ` Avi Kivity
2012-07-25 16:41                       ` Peter Maydell
2012-07-25 16:56                         ` Jan Kiszka
2012-07-25 16:00           ` Avi Kivity
2012-07-25 15:55     ` Peter Maydell
2012-07-25 16:02       ` Avi Kivity
2012-07-25 13:24 ` [Qemu-devel] [PATCH 3/6] kvm: Move kvm_allows_irq0_override() to target-i386 Peter Maydell
2012-07-25 15:44   ` Jan Kiszka
2012-07-25 13:24 ` [Qemu-devel] [PATCH 4/6] kvm: Don't assume irqchip-in-kernel implies irqfds Peter Maydell
2012-07-25 15:47   ` Jan Kiszka [this message]
2012-07-25 15:52     ` Peter Maydell
2012-07-25 15:54       ` Jan Kiszka
2012-07-25 13:24 ` [Qemu-devel] [PATCH 5/6] kvm: Don't assume irqchip implies MSI routing via irqfds Peter Maydell
2012-07-25 15:49   ` Jan Kiszka
2012-07-25 13:24 ` [Qemu-devel] [PATCH 6/6] kvm: Add documentation comment for kvm_irqchip_in_kernel() Peter Maydell
2012-07-25 15:40   ` Andreas Färber
2012-07-25 16:47     ` Jan Kiszka

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=50101509.8060805@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).