All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-06 17:05 ` Peter Maydell
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-06 17:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches, Avi Kivity, Marcelo Tosatti, Jan Kiszka, kvm

Move the init of the irqchip_inject_ioctl field of KVMState out of
kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
can be used even when no irqchip is created (for architectures
that support async interrupt notification even without an in
kernel irqchip).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
We can't just set irqchip_inject_ioctl in target-*/kvm.c because
the KVMState struct layout is private to kvm-all.c. Moving the
default initialisation of this field seemed the simplest approach.
It's safe because the use in kvm_set_irq() is guarded by a check of
kvm_async_interrupts_enabled().

The other approach would be to have a helper function for setting
the field, but that seems overkill when KVM_IRQ_LINE is the standard
default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
incidentally. I am going to assume it's another x86ism until somebody
does document it :-))

 kvm-all.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kvm-all.c b/kvm-all.c
index 6def6c9..9a1f001 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1200,7 +1200,6 @@ static int kvm_irqchip_create(KVMState *s)
         return ret;
     }
 
-    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
     if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
         s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
     }
@@ -1321,6 +1320,8 @@ int kvm_init(void)
     s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
 #endif
 
+    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
+
     ret = kvm_arch_init(s);
     if (ret < 0) {
         goto err;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-06 17:05 ` Peter Maydell
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-06 17:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcelo Tosatti, Jan Kiszka, Avi Kivity, kvm, patches

Move the init of the irqchip_inject_ioctl field of KVMState out of
kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
can be used even when no irqchip is created (for architectures
that support async interrupt notification even without an in
kernel irqchip).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
We can't just set irqchip_inject_ioctl in target-*/kvm.c because
the KVMState struct layout is private to kvm-all.c. Moving the
default initialisation of this field seemed the simplest approach.
It's safe because the use in kvm_set_irq() is guarded by a check of
kvm_async_interrupts_enabled().

The other approach would be to have a helper function for setting
the field, but that seems overkill when KVM_IRQ_LINE is the standard
default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
incidentally. I am going to assume it's another x86ism until somebody
does document it :-))

 kvm-all.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kvm-all.c b/kvm-all.c
index 6def6c9..9a1f001 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1200,7 +1200,6 @@ static int kvm_irqchip_create(KVMState *s)
         return ret;
     }
 
-    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
     if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
         s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
     }
@@ -1321,6 +1320,8 @@ int kvm_init(void)
     s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
 #endif
 
+    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
+
     ret = kvm_arch_init(s);
     if (ret < 0) {
         goto err;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-06 17:05 ` [Qemu-devel] " Peter Maydell
@ 2012-08-12 13:13   ` Peter Maydell
  -1 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-12 13:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcelo Tosatti, Jan Kiszka, Avi Kivity, kvm, patches

Ping? I don't think this one quite made it into Avi's pullreq...

thanks
-- PMM

On 6 August 2012 18:05, Peter Maydell <peter.maydell@linaro.org> wrote:
> Move the init of the irqchip_inject_ioctl field of KVMState out of
> kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
> can be used even when no irqchip is created (for architectures
> that support async interrupt notification even without an in
> kernel irqchip).
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> We can't just set irqchip_inject_ioctl in target-*/kvm.c because
> the KVMState struct layout is private to kvm-all.c. Moving the
> default initialisation of this field seemed the simplest approach.
> It's safe because the use in kvm_set_irq() is guarded by a check of
> kvm_async_interrupts_enabled().
>
> The other approach would be to have a helper function for setting
> the field, but that seems overkill when KVM_IRQ_LINE is the standard
> default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
> incidentally. I am going to assume it's another x86ism until somebody
> does document it :-))
>
>  kvm-all.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kvm-all.c b/kvm-all.c
> index 6def6c9..9a1f001 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1200,7 +1200,6 @@ static int kvm_irqchip_create(KVMState *s)
>          return ret;
>      }
>
> -    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
>      if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
>          s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
>      }
> @@ -1321,6 +1320,8 @@ int kvm_init(void)
>      s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
>  #endif
>
> +    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
> +
>      ret = kvm_arch_init(s);
>      if (ret < 0) {
>          goto err;
> --
> 1.7.9.5

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-12 13:13   ` Peter Maydell
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-12 13:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcelo Tosatti, Jan Kiszka, Avi Kivity, kvm, patches

Ping? I don't think this one quite made it into Avi's pullreq...

thanks
-- PMM

On 6 August 2012 18:05, Peter Maydell <peter.maydell@linaro.org> wrote:
> Move the init of the irqchip_inject_ioctl field of KVMState out of
> kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
> can be used even when no irqchip is created (for architectures
> that support async interrupt notification even without an in
> kernel irqchip).
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> We can't just set irqchip_inject_ioctl in target-*/kvm.c because
> the KVMState struct layout is private to kvm-all.c. Moving the
> default initialisation of this field seemed the simplest approach.
> It's safe because the use in kvm_set_irq() is guarded by a check of
> kvm_async_interrupts_enabled().
>
> The other approach would be to have a helper function for setting
> the field, but that seems overkill when KVM_IRQ_LINE is the standard
> default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
> incidentally. I am going to assume it's another x86ism until somebody
> does document it :-))
>
>  kvm-all.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kvm-all.c b/kvm-all.c
> index 6def6c9..9a1f001 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1200,7 +1200,6 @@ static int kvm_irqchip_create(KVMState *s)
>          return ret;
>      }
>
> -    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
>      if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
>          s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
>      }
> @@ -1321,6 +1320,8 @@ int kvm_init(void)
>      s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
>  #endif
>
> +    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
> +
>      ret = kvm_arch_init(s);
>      if (ret < 0) {
>          goto err;
> --
> 1.7.9.5

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-12 13:13   ` [Qemu-devel] " Peter Maydell
@ 2012-08-13 20:45     ` Marcelo Tosatti
  -1 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2012-08-13 20:45 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, Jan Kiszka, Avi Kivity, kvm, patches

On Sun, Aug 12, 2012 at 02:13:52PM +0100, Peter Maydell wrote:
> Ping? I don't think this one quite made it into Avi's pullreq...

Please post this with the rest of the code to support the new
s->irqchip_inject_ioctl value.

> thanks
> -- PMM
> 
> On 6 August 2012 18:05, Peter Maydell <peter.maydell@linaro.org> wrote:
> > Move the init of the irqchip_inject_ioctl field of KVMState out of
> > kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
> > can be used even when no irqchip is created (for architectures
> > that support async interrupt notification even without an in
> > kernel irqchip).
> >
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> > We can't just set irqchip_inject_ioctl in target-*/kvm.c because
> > the KVMState struct layout is private to kvm-all.c. Moving the
> > default initialisation of this field seemed the simplest approach.
> > It's safe because the use in kvm_set_irq() is guarded by a check of
> > kvm_async_interrupts_enabled().
> >
> > The other approach would be to have a helper function for setting
> > the field, but that seems overkill when KVM_IRQ_LINE is the standard
> > default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
> > incidentally. I am going to assume it's another x86ism until somebody
> > does document it :-))
> >
> >  kvm-all.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kvm-all.c b/kvm-all.c
> > index 6def6c9..9a1f001 100644
> > --- a/kvm-all.c
> > +++ b/kvm-all.c
> > @@ -1200,7 +1200,6 @@ static int kvm_irqchip_create(KVMState *s)
> >          return ret;
> >      }
> >
> > -    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
> >      if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
> >          s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
> >      }
> > @@ -1321,6 +1320,8 @@ int kvm_init(void)
> >      s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
> >  #endif
> >
> > +    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
> > +
> >      ret = kvm_arch_init(s);
> >      if (ret < 0) {
> >          goto err;
> > --
> > 1.7.9.5
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-13 20:45     ` Marcelo Tosatti
  0 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2012-08-13 20:45 UTC (permalink / raw)
  To: Peter Maydell; +Cc: patches, Jan Kiszka, qemu-devel, kvm, Avi Kivity

On Sun, Aug 12, 2012 at 02:13:52PM +0100, Peter Maydell wrote:
> Ping? I don't think this one quite made it into Avi's pullreq...

Please post this with the rest of the code to support the new
s->irqchip_inject_ioctl value.

> thanks
> -- PMM
> 
> On 6 August 2012 18:05, Peter Maydell <peter.maydell@linaro.org> wrote:
> > Move the init of the irqchip_inject_ioctl field of KVMState out of
> > kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
> > can be used even when no irqchip is created (for architectures
> > that support async interrupt notification even without an in
> > kernel irqchip).
> >
> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > ---
> > We can't just set irqchip_inject_ioctl in target-*/kvm.c because
> > the KVMState struct layout is private to kvm-all.c. Moving the
> > default initialisation of this field seemed the simplest approach.
> > It's safe because the use in kvm_set_irq() is guarded by a check of
> > kvm_async_interrupts_enabled().
> >
> > The other approach would be to have a helper function for setting
> > the field, but that seems overkill when KVM_IRQ_LINE is the standard
> > default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
> > incidentally. I am going to assume it's another x86ism until somebody
> > does document it :-))
> >
> >  kvm-all.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kvm-all.c b/kvm-all.c
> > index 6def6c9..9a1f001 100644
> > --- a/kvm-all.c
> > +++ b/kvm-all.c
> > @@ -1200,7 +1200,6 @@ static int kvm_irqchip_create(KVMState *s)
> >          return ret;
> >      }
> >
> > -    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
> >      if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
> >          s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
> >      }
> > @@ -1321,6 +1320,8 @@ int kvm_init(void)
> >      s->direct_msi = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0);
> >  #endif
> >
> > +    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
> > +
> >      ret = kvm_arch_init(s);
> >      if (ret < 0) {
> >          goto err;
> > --
> > 1.7.9.5
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-13 20:45     ` Marcelo Tosatti
@ 2012-08-13 21:40       ` Peter Maydell
  -1 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-13 21:40 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: qemu-devel, Jan Kiszka, Avi Kivity, kvm, patches

On 13 August 2012 21:45, Marcelo Tosatti <mtosatti@redhat.com> wrote:
> On Sun, Aug 12, 2012 at 02:13:52PM +0100, Peter Maydell wrote:
>> Ping? I don't think this one quite made it into Avi's pullreq...
>
> Please post this with the rest of the code to support the new
> s->irqchip_inject_ioctl value.

Er, which new irqchip_inject_ioctl value? There are still only
two possibilities, KVM_IRQ_LINE and KVM_IRQ_LINE_STATUS.
The patch just allows you to use kvm_set_irq() without having
called kvm_irqchip_create() first [which makes sense to me given
the previous patches which remove the assumption that you need
an in-kernel irqchip to be able to do KVM_IRQ_LINE style
interrupt delivery].

-- PMM

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-13 21:40       ` Peter Maydell
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-13 21:40 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: patches, Jan Kiszka, qemu-devel, kvm, Avi Kivity

On 13 August 2012 21:45, Marcelo Tosatti <mtosatti@redhat.com> wrote:
> On Sun, Aug 12, 2012 at 02:13:52PM +0100, Peter Maydell wrote:
>> Ping? I don't think this one quite made it into Avi's pullreq...
>
> Please post this with the rest of the code to support the new
> s->irqchip_inject_ioctl value.

Er, which new irqchip_inject_ioctl value? There are still only
two possibilities, KVM_IRQ_LINE and KVM_IRQ_LINE_STATUS.
The patch just allows you to use kvm_set_irq() without having
called kvm_irqchip_create() first [which makes sense to me given
the previous patches which remove the assumption that you need
an in-kernel irqchip to be able to do KVM_IRQ_LINE style
interrupt delivery].

-- PMM

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-06 17:05 ` [Qemu-devel] " Peter Maydell
@ 2012-08-14  7:33   ` Jan Kiszka
  -1 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14  7:33 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, patches, Avi Kivity, Marcelo Tosatti, kvm

[-- Attachment #1: Type: text/plain, Size: 1727 bytes --]

On 2012-08-06 19:05, Peter Maydell wrote:
> Move the init of the irqchip_inject_ioctl field of KVMState out of
> kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
> can be used even when no irqchip is created (for architectures
> that support async interrupt notification even without an in
> kernel irqchip).
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> We can't just set irqchip_inject_ioctl in target-*/kvm.c because
> the KVMState struct layout is private to kvm-all.c. Moving the
> default initialisation of this field seemed the simplest approach.
> It's safe because the use in kvm_set_irq() is guarded by a check of
> kvm_async_interrupts_enabled().
> 
> The other approach would be to have a helper function for setting
> the field, but that seems overkill when KVM_IRQ_LINE is the standard
> default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
> incidentally. I am going to assume it's another x86ism until somebody
> does document it :-))
> 
>  kvm-all.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index 6def6c9..9a1f001 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1200,7 +1200,6 @@ static int kvm_irqchip_create(KVMState *s)
>          return ret;
>      }
>  
> -    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
>      if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
>          s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
>      }

Either you move both or none.

KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
injection with feedback to allow lost-tick compensation) is the current
standard that other archs should pick up.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14  7:33   ` Jan Kiszka
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14  7:33 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Avi Kivity, Marcelo Tosatti, qemu-devel, kvm, patches

[-- Attachment #1: Type: text/plain, Size: 1727 bytes --]

On 2012-08-06 19:05, Peter Maydell wrote:
> Move the init of the irqchip_inject_ioctl field of KVMState out of
> kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
> can be used even when no irqchip is created (for architectures
> that support async interrupt notification even without an in
> kernel irqchip).
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> We can't just set irqchip_inject_ioctl in target-*/kvm.c because
> the KVMState struct layout is private to kvm-all.c. Moving the
> default initialisation of this field seemed the simplest approach.
> It's safe because the use in kvm_set_irq() is guarded by a check of
> kvm_async_interrupts_enabled().
> 
> The other approach would be to have a helper function for setting
> the field, but that seems overkill when KVM_IRQ_LINE is the standard
> default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
> incidentally. I am going to assume it's another x86ism until somebody
> does document it :-))
> 
>  kvm-all.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index 6def6c9..9a1f001 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1200,7 +1200,6 @@ static int kvm_irqchip_create(KVMState *s)
>          return ret;
>      }
>  
> -    s->irqchip_inject_ioctl = KVM_IRQ_LINE;
>      if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) {
>          s->irqchip_inject_ioctl = KVM_IRQ_LINE_STATUS;
>      }

Either you move both or none.

KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
injection with feedback to allow lost-tick compensation) is the current
standard that other archs should pick up.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-06 17:05 ` [Qemu-devel] " Peter Maydell
@ 2012-08-14  7:36   ` Jan Kiszka
  -1 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14  7:36 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, patches, Avi Kivity, Marcelo Tosatti, kvm

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

On 2012-08-06 19:05, Peter Maydell wrote:
> Move the init of the irqchip_inject_ioctl field of KVMState out of
> kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
> can be used even when no irqchip is created (for architectures
> that support async interrupt notification even without an in
> kernel irqchip).
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> We can't just set irqchip_inject_ioctl in target-*/kvm.c because
> the KVMState struct layout is private to kvm-all.c. Moving the
> default initialisation of this field seemed the simplest approach.
> It's safe because the use in kvm_set_irq() is guarded by a check of
> kvm_async_interrupts_enabled().
> 
> The other approach would be to have a helper function for setting
> the field, but that seems overkill when KVM_IRQ_LINE is the standard
> default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
> incidentally. I am going to assume it's another x86ism until somebody
> does document it :-))

Oh, and when implementing KVM_IRQ_LINE_STATUS for ARM, please also feel
free to document it in a way that it applies both to its x86 history and
new architectures.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14  7:36   ` Jan Kiszka
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14  7:36 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Avi Kivity, Marcelo Tosatti, qemu-devel, kvm, patches

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

On 2012-08-06 19:05, Peter Maydell wrote:
> Move the init of the irqchip_inject_ioctl field of KVMState out of
> kvm_irqchip_create() and into kvm_init(), so that kvm_set_irq()
> can be used even when no irqchip is created (for architectures
> that support async interrupt notification even without an in
> kernel irqchip).
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> We can't just set irqchip_inject_ioctl in target-*/kvm.c because
> the KVMState struct layout is private to kvm-all.c. Moving the
> default initialisation of this field seemed the simplest approach.
> It's safe because the use in kvm_set_irq() is guarded by a check of
> kvm_async_interrupts_enabled().
> 
> The other approach would be to have a helper function for setting
> the field, but that seems overkill when KVM_IRQ_LINE is the standard
> default value. (KVM_IRQ_LINE_STATUS seems to be undocumented,
> incidentally. I am going to assume it's another x86ism until somebody
> does document it :-))

Oh, and when implementing KVM_IRQ_LINE_STATUS for ARM, please also feel
free to document it in a way that it applies both to its x86 history and
new architectures.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14  7:33   ` [Qemu-devel] " Jan Kiszka
@ 2012-08-14  7:40     ` Peter Maydell
  -1 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-14  7:40 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, qemu-devel, kvm, patches

On 14 August 2012 08:33, Jan Kiszka <jan.kiszka@web.de> wrote:
> Either you move both or none.

OK.

> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
> injection with feedback to allow lost-tick compensation) is the current
> standard that other archs should pick up.

Can it be documented in the kernel api.txt then, please? Nobody
is going to use it otherwise... (If I'd been paying attention at the
time I'd have nak'd the qemu patches that added it on the grounds
they were using an undocumented kernel API :-))

-- PMM

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14  7:40     ` Peter Maydell
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-14  7:40 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, qemu-devel, kvm, patches

On 14 August 2012 08:33, Jan Kiszka <jan.kiszka@web.de> wrote:
> Either you move both or none.

OK.

> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
> injection with feedback to allow lost-tick compensation) is the current
> standard that other archs should pick up.

Can it be documented in the kernel api.txt then, please? Nobody
is going to use it otherwise... (If I'd been paying attention at the
time I'd have nak'd the qemu patches that added it on the grounds
they were using an undocumented kernel API :-))

-- PMM

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14  7:40     ` [Qemu-devel] " Peter Maydell
@ 2012-08-14  7:42       ` Jan Kiszka
  -1 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14  7:42 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Avi Kivity, Marcelo Tosatti, qemu-devel, kvm, patches

[-- Attachment #1: Type: text/plain, Size: 821 bytes --]

On 2012-08-14 09:40, Peter Maydell wrote:
> On 14 August 2012 08:33, Jan Kiszka <jan.kiszka@web.de> wrote:
>> Either you move both or none.
> 
> OK.
> 
>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>> injection with feedback to allow lost-tick compensation) is the current
>> standard that other archs should pick up.
> 
> Can it be documented in the kernel api.txt then, please? Nobody
> is going to use it otherwise... (If I'd been paying attention at the
> time I'd have nak'd the qemu patches that added it on the grounds
> they were using an undocumented kernel API :-))

The kernel API's documentation has in fact a much younger history than
KVM support in QEMU. I think we still need to add quite a few standard
IOCTLs to make it complete. Patches always welcome.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14  7:42       ` Jan Kiszka
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14  7:42 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Avi Kivity, Marcelo Tosatti, qemu-devel, kvm, patches

[-- Attachment #1: Type: text/plain, Size: 821 bytes --]

On 2012-08-14 09:40, Peter Maydell wrote:
> On 14 August 2012 08:33, Jan Kiszka <jan.kiszka@web.de> wrote:
>> Either you move both or none.
> 
> OK.
> 
>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>> injection with feedback to allow lost-tick compensation) is the current
>> standard that other archs should pick up.
> 
> Can it be documented in the kernel api.txt then, please? Nobody
> is going to use it otherwise... (If I'd been paying attention at the
> time I'd have nak'd the qemu patches that added it on the grounds
> they were using an undocumented kernel API :-))

The kernel API's documentation has in fact a much younger history than
KVM support in QEMU. I think we still need to add quite a few standard
IOCTLs to make it complete. Patches always welcome.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14  7:42       ` [Qemu-devel] " Jan Kiszka
@ 2012-08-14  7:52         ` Peter Maydell
  -1 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-14  7:52 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel, patches, Avi Kivity, Marcelo Tosatti, kvm

On 14 August 2012 08:42, Jan Kiszka <jan.kiszka@web.de> wrote:
> On 2012-08-14 09:40, Peter Maydell wrote:
>> On 14 August 2012 08:33, Jan Kiszka <jan.kiszka@web.de> wrote:
>>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>>> injection with feedback to allow lost-tick compensation) is the current
>>> standard that other archs should pick up.
>>
>> Can it be documented in the kernel api.txt then, please? Nobody
>> is going to use it otherwise... (If I'd been paying attention at the
>> time I'd have nak'd the qemu patches that added it on the grounds
>> they were using an undocumented kernel API :-))
>
> The kernel API's documentation has in fact a much younger history than
> KVM support in QEMU. I think we still need to add quite a few standard
> IOCTLs to make it complete. Patches always welcome.

Well, you appear to know what this variant ioctl does and why it's
better than KVM_IRQ_LINE, whereas I don't. I just want to deliver
an interrupt, KVM_IRQ_LINE lets me deliver an interrupt, why
do I need anything more? (What would I do with the status return, for
instance? I have to assert the incoming irq line, there's nothing for
me to do if the kernel says "sorry, can't do that" except abort qemu.)

-- PMM

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14  7:52         ` Peter Maydell
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-14  7:52 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, qemu-devel, kvm, patches

On 14 August 2012 08:42, Jan Kiszka <jan.kiszka@web.de> wrote:
> On 2012-08-14 09:40, Peter Maydell wrote:
>> On 14 August 2012 08:33, Jan Kiszka <jan.kiszka@web.de> wrote:
>>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>>> injection with feedback to allow lost-tick compensation) is the current
>>> standard that other archs should pick up.
>>
>> Can it be documented in the kernel api.txt then, please? Nobody
>> is going to use it otherwise... (If I'd been paying attention at the
>> time I'd have nak'd the qemu patches that added it on the grounds
>> they were using an undocumented kernel API :-))
>
> The kernel API's documentation has in fact a much younger history than
> KVM support in QEMU. I think we still need to add quite a few standard
> IOCTLs to make it complete. Patches always welcome.

Well, you appear to know what this variant ioctl does and why it's
better than KVM_IRQ_LINE, whereas I don't. I just want to deliver
an interrupt, KVM_IRQ_LINE lets me deliver an interrupt, why
do I need anything more? (What would I do with the status return, for
instance? I have to assert the incoming irq line, there's nothing for
me to do if the kernel says "sorry, can't do that" except abort qemu.)

-- PMM

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14  7:52         ` [Qemu-devel] " Peter Maydell
@ 2012-08-14  8:09           ` Jan Kiszka
  -1 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14  8:09 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, patches, Avi Kivity, Marcelo Tosatti, kvm

[-- Attachment #1: Type: text/plain, Size: 2720 bytes --]

On 2012-08-14 09:52, Peter Maydell wrote:
> On 14 August 2012 08:42, Jan Kiszka <jan.kiszka@web.de> wrote:
>> On 2012-08-14 09:40, Peter Maydell wrote:
>>> On 14 August 2012 08:33, Jan Kiszka <jan.kiszka@web.de> wrote:
>>>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>>>> injection with feedback to allow lost-tick compensation) is the current
>>>> standard that other archs should pick up.
>>>
>>> Can it be documented in the kernel api.txt then, please? Nobody
>>> is going to use it otherwise... (If I'd been paying attention at the
>>> time I'd have nak'd the qemu patches that added it on the grounds
>>> they were using an undocumented kernel API :-))
>>
>> The kernel API's documentation has in fact a much younger history than
>> KVM support in QEMU. I think we still need to add quite a few standard
>> IOCTLs to make it complete. Patches always welcome.
> 
> Well, you appear to know what this variant ioctl does and why it's
> better than KVM_IRQ_LINE, whereas I don't. I just want to deliver
> an interrupt, KVM_IRQ_LINE lets me deliver an interrupt, why
> do I need anything more? (What would I do with the status return, for
> instance? I have to assert the incoming irq line, there's nothing for
> me to do if the kernel says "sorry, can't do that" except abort qemu.)

Not sure how timekeeping of all your guests will work, but a classic
scenario on x86 is that some timer is programmed to deliver periodic
ticks (or one-shot ticks that also generates a virtual periodic timer)
and that those ticks will then be used to derive the system time of the
guest. Now, if the guest was unable to process the past tick completely
(due to host load) and we inject already another tick event, that one
will get lost. Some guests (older Linuxes but also many proprietary
OSes) are not prepared for such tick loss and will suffer from drifting
wall clocks.

For that reason, we allow userspace to find out if a (potentially) tick
driving IRQ was actually received by the guest or if it coalesced with
an ongoing event. In the latter case, userspace can reinject those
events once the guest is able to receive them again. All we need from
the kernel API is that feedback KVM_IRQ_LINE_STATUS provides. The return
values are "nicely" hidden in kvm_set_irq:

/*
 * Return value:
 *  < 0   Interrupt was ignored (masked or not delivered for other reasons)
 *  = 0   Interrupt was coalesced (previous irq is still pending)
 *  > 0   Number of CPUs interrupt was delivered to
 */

QEMU doesn't make use of that number of receiving CPUs and I'm mot sure
why we even report it. Maybe the kernel API should just state that >0
means delivered.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14  8:09           ` Jan Kiszka
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14  8:09 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Avi Kivity, Marcelo Tosatti, qemu-devel, kvm, patches

[-- Attachment #1: Type: text/plain, Size: 2720 bytes --]

On 2012-08-14 09:52, Peter Maydell wrote:
> On 14 August 2012 08:42, Jan Kiszka <jan.kiszka@web.de> wrote:
>> On 2012-08-14 09:40, Peter Maydell wrote:
>>> On 14 August 2012 08:33, Jan Kiszka <jan.kiszka@web.de> wrote:
>>>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>>>> injection with feedback to allow lost-tick compensation) is the current
>>>> standard that other archs should pick up.
>>>
>>> Can it be documented in the kernel api.txt then, please? Nobody
>>> is going to use it otherwise... (If I'd been paying attention at the
>>> time I'd have nak'd the qemu patches that added it on the grounds
>>> they were using an undocumented kernel API :-))
>>
>> The kernel API's documentation has in fact a much younger history than
>> KVM support in QEMU. I think we still need to add quite a few standard
>> IOCTLs to make it complete. Patches always welcome.
> 
> Well, you appear to know what this variant ioctl does and why it's
> better than KVM_IRQ_LINE, whereas I don't. I just want to deliver
> an interrupt, KVM_IRQ_LINE lets me deliver an interrupt, why
> do I need anything more? (What would I do with the status return, for
> instance? I have to assert the incoming irq line, there's nothing for
> me to do if the kernel says "sorry, can't do that" except abort qemu.)

Not sure how timekeeping of all your guests will work, but a classic
scenario on x86 is that some timer is programmed to deliver periodic
ticks (or one-shot ticks that also generates a virtual periodic timer)
and that those ticks will then be used to derive the system time of the
guest. Now, if the guest was unable to process the past tick completely
(due to host load) and we inject already another tick event, that one
will get lost. Some guests (older Linuxes but also many proprietary
OSes) are not prepared for such tick loss and will suffer from drifting
wall clocks.

For that reason, we allow userspace to find out if a (potentially) tick
driving IRQ was actually received by the guest or if it coalesced with
an ongoing event. In the latter case, userspace can reinject those
events once the guest is able to receive them again. All we need from
the kernel API is that feedback KVM_IRQ_LINE_STATUS provides. The return
values are "nicely" hidden in kvm_set_irq:

/*
 * Return value:
 *  < 0   Interrupt was ignored (masked or not delivered for other reasons)
 *  = 0   Interrupt was coalesced (previous irq is still pending)
 *  > 0   Number of CPUs interrupt was delivered to
 */

QEMU doesn't make use of that number of receiving CPUs and I'm mot sure
why we even report it. Maybe the kernel API should just state that >0
means delivered.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14  7:33   ` [Qemu-devel] " Jan Kiszka
@ 2012-08-14 11:01     ` Avi Kivity
  -1 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2012-08-14 11:01 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Peter Maydell, qemu-devel, patches, Marcelo Tosatti, kvm

On 08/14/2012 10:33 AM, Jan Kiszka wrote:
> 
> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
> injection with feedback to allow lost-tick compensation) is the current
> standard that other archs should pick up.

KVM_IRQ_LINE_STATUS may not make sense on all architectures.

I don't think we're really deprecating KVM_IRQ_LINE or discouraging its
use.  It's not like the kernel-allocated memory slot ioctls.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14 11:01     ` Avi Kivity
  0 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2012-08-14 11:01 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Peter Maydell, Marcelo Tosatti, qemu-devel, kvm, patches

On 08/14/2012 10:33 AM, Jan Kiszka wrote:
> 
> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
> injection with feedback to allow lost-tick compensation) is the current
> standard that other archs should pick up.

KVM_IRQ_LINE_STATUS may not make sense on all architectures.

I don't think we're really deprecating KVM_IRQ_LINE or discouraging its
use.  It's not like the kernel-allocated memory slot ioctls.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14 11:01     ` [Qemu-devel] " Avi Kivity
@ 2012-08-14 11:05       ` Jan Kiszka
  -1 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14 11:05 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Peter Maydell, Marcelo Tosatti, qemu-devel, kvm, patches

On 2012-08-14 13:01, Avi Kivity wrote:
> On 08/14/2012 10:33 AM, Jan Kiszka wrote:
>>
>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>> injection with feedback to allow lost-tick compensation) is the current
>> standard that other archs should pick up.
> 
> KVM_IRQ_LINE_STATUS may not make sense on all architectures.
> 
> I don't think we're really deprecating KVM_IRQ_LINE or discouraging its
> use.  It's not like the kernel-allocated memory slot ioctls.

I do not think it makes sense to provide both interfaces long term
(provided we ever do a cut). Also, it's almost trivial to provide the
add-on feature of KVM_IRQ_LINE_STATUS, and it keeps the door open for
IRQ decoalescing. If there is no way for an arch to detect coalescing,
it can still return >0 unconditionally.

Jan

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14 11:05       ` Jan Kiszka
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14 11:05 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Peter Maydell, Marcelo Tosatti, qemu-devel, kvm, patches

On 2012-08-14 13:01, Avi Kivity wrote:
> On 08/14/2012 10:33 AM, Jan Kiszka wrote:
>>
>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>> injection with feedback to allow lost-tick compensation) is the current
>> standard that other archs should pick up.
> 
> KVM_IRQ_LINE_STATUS may not make sense on all architectures.
> 
> I don't think we're really deprecating KVM_IRQ_LINE or discouraging its
> use.  It's not like the kernel-allocated memory slot ioctls.

I do not think it makes sense to provide both interfaces long term
(provided we ever do a cut). Also, it's almost trivial to provide the
add-on feature of KVM_IRQ_LINE_STATUS, and it keeps the door open for
IRQ decoalescing. If there is no way for an arch to detect coalescing,
it can still return >0 unconditionally.

Jan

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14  8:09           ` [Qemu-devel] " Jan Kiszka
@ 2012-08-14 13:10             ` Peter Maydell
  -1 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-14 13:10 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: qemu-devel, patches, Avi Kivity, Marcelo Tosatti, kvm, Marc Zyngier

On 14 August 2012 09:09, Jan Kiszka <jan.kiszka@web.de> wrote:
> On 2012-08-14 09:52, Peter Maydell wrote:
>> Well, you appear to know what this variant ioctl does and why it's
>> better than KVM_IRQ_LINE, whereas I don't. I just want to deliver
>> an interrupt, KVM_IRQ_LINE lets me deliver an interrupt, why
>> do I need anything more? (What would I do with the status return, for
>> instance? I have to assert the incoming irq line, there's nothing for
>> me to do if the kernel says "sorry, can't do that" except abort qemu.)
>
> Not sure how timekeeping of all your guests will work, but a classic
> scenario on x86 is that some timer is programmed to deliver periodic
> ticks (or one-shot ticks that also generates a virtual periodic timer)
> and that those ticks will then be used to derive the system time of the
> guest. Now, if the guest was unable to process the past tick completely
> (due to host load) and we inject already another tick event, that one
> will get lost. Some guests (older Linuxes but also many proprietary
> OSes) are not prepared for such tick loss and will suffer from drifting
> wall clocks.

So, for ARM the overwhelmingly common case will be that we use the in
kernel architectural timer for doing periodic / one-shot ticks. That's
all in the kernel anyway (both timer and VGIC interrupt controller).

The less plausible case uses the in-kernel interrupt controller but an
out of kernel timer device. The only link between the two is a qemu_irq line,
so we have (a) no way to tell if this interrupt line into the GIC is a timer
or not and (b) no back-channel to the timer device to report things anyway.

The really unlikely case (in that there is theoretically code to handle it
but in practice QEMU will refuse to configure itself this way) has an out
of kernel GIC. In this case the interrupts we deliver to the kernel are
pre-coalesced into a single IRQ line, and there's definitely not a lot
we could do with the status report.

Marc Z tells me we could make the kernel return the 'did this coalesce?'
status without too much difficulty, but unless it's actually possible
to do something useful with it in userspace I'm not sure I see the point.

-- PMM

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14 13:10             ` Peter Maydell
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Maydell @ 2012-08-14 13:10 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: kvm, patches, Marc Zyngier, Marcelo Tosatti, qemu-devel, Avi Kivity

On 14 August 2012 09:09, Jan Kiszka <jan.kiszka@web.de> wrote:
> On 2012-08-14 09:52, Peter Maydell wrote:
>> Well, you appear to know what this variant ioctl does and why it's
>> better than KVM_IRQ_LINE, whereas I don't. I just want to deliver
>> an interrupt, KVM_IRQ_LINE lets me deliver an interrupt, why
>> do I need anything more? (What would I do with the status return, for
>> instance? I have to assert the incoming irq line, there's nothing for
>> me to do if the kernel says "sorry, can't do that" except abort qemu.)
>
> Not sure how timekeeping of all your guests will work, but a classic
> scenario on x86 is that some timer is programmed to deliver periodic
> ticks (or one-shot ticks that also generates a virtual periodic timer)
> and that those ticks will then be used to derive the system time of the
> guest. Now, if the guest was unable to process the past tick completely
> (due to host load) and we inject already another tick event, that one
> will get lost. Some guests (older Linuxes but also many proprietary
> OSes) are not prepared for such tick loss and will suffer from drifting
> wall clocks.

So, for ARM the overwhelmingly common case will be that we use the in
kernel architectural timer for doing periodic / one-shot ticks. That's
all in the kernel anyway (both timer and VGIC interrupt controller).

The less plausible case uses the in-kernel interrupt controller but an
out of kernel timer device. The only link between the two is a qemu_irq line,
so we have (a) no way to tell if this interrupt line into the GIC is a timer
or not and (b) no back-channel to the timer device to report things anyway.

The really unlikely case (in that there is theoretically code to handle it
but in practice QEMU will refuse to configure itself this way) has an out
of kernel GIC. In this case the interrupts we deliver to the kernel are
pre-coalesced into a single IRQ line, and there's definitely not a lot
we could do with the status report.

Marc Z tells me we could make the kernel return the 'did this coalesce?'
status without too much difficulty, but unless it's actually possible
to do something useful with it in userspace I'm not sure I see the point.

-- PMM

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14 11:05       ` [Qemu-devel] " Jan Kiszka
@ 2012-08-14 13:14         ` Avi Kivity
  -1 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2012-08-14 13:14 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Peter Maydell, Marcelo Tosatti, qemu-devel, kvm, patches

On 08/14/2012 02:05 PM, Jan Kiszka wrote:
> On 2012-08-14 13:01, Avi Kivity wrote:
>> On 08/14/2012 10:33 AM, Jan Kiszka wrote:
>>>
>>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>>> injection with feedback to allow lost-tick compensation) is the current
>>> standard that other archs should pick up.
>> 
>> KVM_IRQ_LINE_STATUS may not make sense on all architectures.
>> 
>> I don't think we're really deprecating KVM_IRQ_LINE or discouraging its
>> use.  It's not like the kernel-allocated memory slot ioctls.
> 
> I do not think it makes sense to provide both interfaces long term
> (provided we ever do a cut). Also, it's almost trivial to provide the
> add-on feature of KVM_IRQ_LINE_STATUS, and it keeps the door open for
> IRQ decoalescing. If there is no way for an arch to detect coalescing,
> it can still return >0 unconditionally.

That's lying.  I don't see how anything bad can come out of it, but we
can always be surprised.  If we can't support something, let's not claim
we do.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14 13:14         ` Avi Kivity
  0 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2012-08-14 13:14 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Peter Maydell, Marcelo Tosatti, qemu-devel, kvm, patches

On 08/14/2012 02:05 PM, Jan Kiszka wrote:
> On 2012-08-14 13:01, Avi Kivity wrote:
>> On 08/14/2012 10:33 AM, Jan Kiszka wrote:
>>>
>>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>>> injection with feedback to allow lost-tick compensation) is the current
>>> standard that other archs should pick up.
>> 
>> KVM_IRQ_LINE_STATUS may not make sense on all architectures.
>> 
>> I don't think we're really deprecating KVM_IRQ_LINE or discouraging its
>> use.  It's not like the kernel-allocated memory slot ioctls.
> 
> I do not think it makes sense to provide both interfaces long term
> (provided we ever do a cut). Also, it's almost trivial to provide the
> add-on feature of KVM_IRQ_LINE_STATUS, and it keeps the door open for
> IRQ decoalescing. If there is no way for an arch to detect coalescing,
> it can still return >0 unconditionally.

That's lying.  I don't see how anything bad can come out of it, but we
can always be surprised.  If we can't support something, let's not claim
we do.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14 13:10             ` [Qemu-devel] " Peter Maydell
@ 2012-08-14 13:27               ` Jan Kiszka
  -1 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14 13:27 UTC (permalink / raw)
  To: Peter Maydell
  Cc: qemu-devel, patches, Avi Kivity, Marcelo Tosatti, kvm, Marc Zyngier

On 2012-08-14 15:10, Peter Maydell wrote:
> On 14 August 2012 09:09, Jan Kiszka <jan.kiszka@web.de> wrote:
>> On 2012-08-14 09:52, Peter Maydell wrote:
>>> Well, you appear to know what this variant ioctl does and why it's
>>> better than KVM_IRQ_LINE, whereas I don't. I just want to deliver
>>> an interrupt, KVM_IRQ_LINE lets me deliver an interrupt, why
>>> do I need anything more? (What would I do with the status return, for
>>> instance? I have to assert the incoming irq line, there's nothing for
>>> me to do if the kernel says "sorry, can't do that" except abort qemu.)
>>
>> Not sure how timekeeping of all your guests will work, but a classic
>> scenario on x86 is that some timer is programmed to deliver periodic
>> ticks (or one-shot ticks that also generates a virtual periodic timer)
>> and that those ticks will then be used to derive the system time of the
>> guest. Now, if the guest was unable to process the past tick completely
>> (due to host load) and we inject already another tick event, that one
>> will get lost. Some guests (older Linuxes but also many proprietary
>> OSes) are not prepared for such tick loss and will suffer from drifting
>> wall clocks.
> 
> So, for ARM the overwhelmingly common case will be that we use the in
> kernel architectural timer for doing periodic / one-shot ticks. That's
> all in the kernel anyway (both timer and VGIC interrupt controller).
> 
> The less plausible case uses the in-kernel interrupt controller but an
> out of kernel timer device. The only link between the two is a qemu_irq line,
> so we have (a) no way to tell if this interrupt line into the GIC is a timer
> or not and (b) no back-channel to the timer device to report things anyway.

(a) is userspace knowledge (if it implements some timer that guests may
use to drive a clock), so nothing the kernel needs to know. (b) will
likely come for x86 to clean up the current mess we have for
decoalescing RTC periodic timers and possibly adding HPET support.

> 
> The really unlikely case (in that there is theoretically code to handle it
> but in practice QEMU will refuse to configure itself this way) has an out
> of kernel GIC. In this case the interrupts we deliver to the kernel are
> pre-coalesced into a single IRQ line, and there's definitely not a lot
> we could do with the status report.

Agreed. In this case, the userspace GIC would have to provide the
coalescing information.

> 
> Marc Z tells me we could make the kernel return the 'did this coalesce?'
> status without too much difficulty, but unless it's actually possible
> to do something useful with it in userspace I'm not sure I see the point.

>From my point of view (but Avi seems to disagree), it would even make
sense to always return 1 if you cannot actually tell, just to
consolidate over a single IOCTL on the long run. But given that you can,
I would avoid over-simplifying, specifically as the embedded space is
known to add all sorts of special devices for special use cases, and you
cannot know in advance if the architectural (in-kernel) timer will
always be sufficient.

Jan

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14 13:27               ` Jan Kiszka
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14 13:27 UTC (permalink / raw)
  To: Peter Maydell
  Cc: kvm, patches, Marc Zyngier, Marcelo Tosatti, qemu-devel, Avi Kivity

On 2012-08-14 15:10, Peter Maydell wrote:
> On 14 August 2012 09:09, Jan Kiszka <jan.kiszka@web.de> wrote:
>> On 2012-08-14 09:52, Peter Maydell wrote:
>>> Well, you appear to know what this variant ioctl does and why it's
>>> better than KVM_IRQ_LINE, whereas I don't. I just want to deliver
>>> an interrupt, KVM_IRQ_LINE lets me deliver an interrupt, why
>>> do I need anything more? (What would I do with the status return, for
>>> instance? I have to assert the incoming irq line, there's nothing for
>>> me to do if the kernel says "sorry, can't do that" except abort qemu.)
>>
>> Not sure how timekeeping of all your guests will work, but a classic
>> scenario on x86 is that some timer is programmed to deliver periodic
>> ticks (or one-shot ticks that also generates a virtual periodic timer)
>> and that those ticks will then be used to derive the system time of the
>> guest. Now, if the guest was unable to process the past tick completely
>> (due to host load) and we inject already another tick event, that one
>> will get lost. Some guests (older Linuxes but also many proprietary
>> OSes) are not prepared for such tick loss and will suffer from drifting
>> wall clocks.
> 
> So, for ARM the overwhelmingly common case will be that we use the in
> kernel architectural timer for doing periodic / one-shot ticks. That's
> all in the kernel anyway (both timer and VGIC interrupt controller).
> 
> The less plausible case uses the in-kernel interrupt controller but an
> out of kernel timer device. The only link between the two is a qemu_irq line,
> so we have (a) no way to tell if this interrupt line into the GIC is a timer
> or not and (b) no back-channel to the timer device to report things anyway.

(a) is userspace knowledge (if it implements some timer that guests may
use to drive a clock), so nothing the kernel needs to know. (b) will
likely come for x86 to clean up the current mess we have for
decoalescing RTC periodic timers and possibly adding HPET support.

> 
> The really unlikely case (in that there is theoretically code to handle it
> but in practice QEMU will refuse to configure itself this way) has an out
> of kernel GIC. In this case the interrupts we deliver to the kernel are
> pre-coalesced into a single IRQ line, and there's definitely not a lot
> we could do with the status report.

Agreed. In this case, the userspace GIC would have to provide the
coalescing information.

> 
> Marc Z tells me we could make the kernel return the 'did this coalesce?'
> status without too much difficulty, but unless it's actually possible
> to do something useful with it in userspace I'm not sure I see the point.

>From my point of view (but Avi seems to disagree), it would even make
sense to always return 1 if you cannot actually tell, just to
consolidate over a single IOCTL on the long run. But given that you can,
I would avoid over-simplifying, specifically as the embedded space is
known to add all sorts of special devices for special use cases, and you
cannot know in advance if the architectural (in-kernel) timer will
always be sufficient.

Jan

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
  2012-08-14 13:14         ` [Qemu-devel] " Avi Kivity
@ 2012-08-14 13:36           ` Jan Kiszka
  -1 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14 13:36 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Peter Maydell, qemu-devel, patches, Marcelo Tosatti, kvm

On 2012-08-14 15:14, Avi Kivity wrote:
> On 08/14/2012 02:05 PM, Jan Kiszka wrote:
>> On 2012-08-14 13:01, Avi Kivity wrote:
>>> On 08/14/2012 10:33 AM, Jan Kiszka wrote:
>>>>
>>>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>>>> injection with feedback to allow lost-tick compensation) is the current
>>>> standard that other archs should pick up.
>>>
>>> KVM_IRQ_LINE_STATUS may not make sense on all architectures.
>>>
>>> I don't think we're really deprecating KVM_IRQ_LINE or discouraging its
>>> use.  It's not like the kernel-allocated memory slot ioctls.
>>
>> I do not think it makes sense to provide both interfaces long term
>> (provided we ever do a cut). Also, it's almost trivial to provide the
>> add-on feature of KVM_IRQ_LINE_STATUS, and it keeps the door open for
>> IRQ decoalescing. If there is no way for an arch to detect coalescing,
>> it can still return >0 unconditionally.
> 
> That's lying.  I don't see how anything bad can come out of it, but we
> can always be surprised.  If we can't support something, let's not claim
> we do.

Fortunately, we are not in this position on ARM. It has in in-kernel
irqchip and can tell if some line is still being processed.

Jan

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create()
@ 2012-08-14 13:36           ` Jan Kiszka
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2012-08-14 13:36 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Peter Maydell, Marcelo Tosatti, qemu-devel, kvm, patches

On 2012-08-14 15:14, Avi Kivity wrote:
> On 08/14/2012 02:05 PM, Jan Kiszka wrote:
>> On 2012-08-14 13:01, Avi Kivity wrote:
>>> On 08/14/2012 10:33 AM, Jan Kiszka wrote:
>>>>
>>>> KVM_IRQ_LINE is old-style, deprecated, KVM_IRQ_LINE_STATUS (i.e
>>>> injection with feedback to allow lost-tick compensation) is the current
>>>> standard that other archs should pick up.
>>>
>>> KVM_IRQ_LINE_STATUS may not make sense on all architectures.
>>>
>>> I don't think we're really deprecating KVM_IRQ_LINE or discouraging its
>>> use.  It's not like the kernel-allocated memory slot ioctls.
>>
>> I do not think it makes sense to provide both interfaces long term
>> (provided we ever do a cut). Also, it's almost trivial to provide the
>> add-on feature of KVM_IRQ_LINE_STATUS, and it keeps the door open for
>> IRQ decoalescing. If there is no way for an arch to detect coalescing,
>> it can still return >0 unconditionally.
> 
> That's lying.  I don't see how anything bad can come out of it, but we
> can always be surprised.  If we can't support something, let's not claim
> we do.

Fortunately, we are not in this position on ARM. It has in in-kernel
irqchip and can tell if some line is still being processed.

Jan

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2012-08-14 13:36 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-06 17:05 [PATCH] kvm-all.c: Move init of irqchip_inject_ioctl out of kvm_irqchip_create() Peter Maydell
2012-08-06 17:05 ` [Qemu-devel] " Peter Maydell
2012-08-12 13:13 ` Peter Maydell
2012-08-12 13:13   ` [Qemu-devel] " Peter Maydell
2012-08-13 20:45   ` Marcelo Tosatti
2012-08-13 20:45     ` Marcelo Tosatti
2012-08-13 21:40     ` Peter Maydell
2012-08-13 21:40       ` Peter Maydell
2012-08-14  7:33 ` Jan Kiszka
2012-08-14  7:33   ` [Qemu-devel] " Jan Kiszka
2012-08-14  7:40   ` Peter Maydell
2012-08-14  7:40     ` [Qemu-devel] " Peter Maydell
2012-08-14  7:42     ` Jan Kiszka
2012-08-14  7:42       ` [Qemu-devel] " Jan Kiszka
2012-08-14  7:52       ` Peter Maydell
2012-08-14  7:52         ` [Qemu-devel] " Peter Maydell
2012-08-14  8:09         ` Jan Kiszka
2012-08-14  8:09           ` [Qemu-devel] " Jan Kiszka
2012-08-14 13:10           ` Peter Maydell
2012-08-14 13:10             ` [Qemu-devel] " Peter Maydell
2012-08-14 13:27             ` Jan Kiszka
2012-08-14 13:27               ` [Qemu-devel] " Jan Kiszka
2012-08-14 11:01   ` Avi Kivity
2012-08-14 11:01     ` [Qemu-devel] " Avi Kivity
2012-08-14 11:05     ` Jan Kiszka
2012-08-14 11:05       ` [Qemu-devel] " Jan Kiszka
2012-08-14 13:14       ` Avi Kivity
2012-08-14 13:14         ` [Qemu-devel] " Avi Kivity
2012-08-14 13:36         ` Jan Kiszka
2012-08-14 13:36           ` [Qemu-devel] " Jan Kiszka
2012-08-14  7:36 ` Jan Kiszka
2012-08-14  7:36   ` [Qemu-devel] " Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.