kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [v2] Shared guest irq support
@ 2008-10-14  8:45 Zhang, Xiantao
  2008-10-15  2:36 ` Sheng Yang
  2008-10-15  7:19 ` Amit Shah
  0 siblings, 2 replies; 20+ messages in thread
From: Zhang, Xiantao @ 2008-10-14  8:45 UTC (permalink / raw)
  To: Amit Shah, avi; +Cc: Yang, Sheng, kvm

Hi, Amit/Sheng
	See the comments below. 
Xiantao
> Amit Shah wrote:
>> Sheng, can you check if this is fine? I'll need some time to test
>> this. 
>> 
>> Amit
> 
> index 71e37a5..6f0af16 100644
> --- a/arch/x86/kvm/irq.h
> +++ b/arch/x86/kvm/irq.h
> @@ -32,6 +32,8 @@
> 
>  #define PIC_NUM_PINS 16
> 
> +#define KVM_USERSPACE_IRQ_SOURCE_ID	0
> +
>  struct kvm;
>  struct kvm_vcpu

IA64 side also needs this macro, maybe we can put it in ioapic.h or
kvm_host.h ?

> 
> diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
> index 4b06ca8..f01e92e 100644
> --- a/include/asm-x86/kvm_host.h
> +++ b/include/asm-x86/kvm_host.h
> @@ -368,6 +368,9 @@ struct kvm_arch{
> 
>  	struct page *ept_identity_pagetable;
>  	bool ept_identity_pagetable_done;
> +
> +	unsigned long irq_sources_bitmap;
> +	unsigned long irq_states[KVM_IOAPIC_NUM_PINS];
>  };

Asm-ia64/kvm_host.h also needs these two fields to add.  Also do we need
logic to initialize these two fields? 

> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index dda478e..5d29c50 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1816,7 +1816,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
>                         goto out;
>                 if (irqchip_in_kernel(kvm)) {
>                         mutex_lock(&kvm->lock);
> -                       kvm_set_irq(kvm, irq_event.irq,
> irq_event.level); +                       kvm_set_irq(kvm,
> KVM_USERSPACE_IRQ_SOURCE_ID, +                                  
>                         irq_event.irq, irq_event.level);
>                         mutex_unlock(&kvm->lock); r = 0;
>                 }
> @@ -4115,6 +4116,9 @@ struct  kvm *kvm_arch_create_vm(void)
>         INIT_LIST_HEAD(&kvm->arch.active_mmu_pages);
>         INIT_LIST_HEAD(&kvm->arch.assigned_dev_head);
> 
> +       /* Reserve bit 0 of irq_sources_bitmap for userspace irq
> source */ +       kvm->arch.irq_sources_bitmap = 1;
> +
>         return kvm;
>  }

This change should be applied to kvm-ia64.c aslo. 

> diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
> index d0169f5..55ad76e 100644
> --- a/virt/kvm/irq_comm.c
> +++ b/virt/kvm/irq_comm.c
> @@ -25,15 +25,23 @@
>  #include "ioapic.h"
> 
>  /* This should be called with the kvm->lock mutex held */
> -void kvm_set_irq(struct kvm *kvm, int irq, int level)
> +void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int
>  level) {
> +       unsigned long *irq_state = (unsigned long
> *)&kvm->arch.irq_states[irq]; +
> +       /* Logical OR for level trig interrupt */
> +       if (level)
> +               set_bit(irq_source_id, irq_state);
> +       else
> +               clear_bit(irq_source_id, irq_state);
> +
>         /* Not possible to detect if the guest uses the PIC or the
>          * IOAPIC.  So set the bit in both. The guest will ignore
>          * writes to the unused one.
>          */
> -       kvm_ioapic_set_irq(kvm->arch.vioapic, irq, level);
> +       kvm_ioapic_set_irq(kvm->arch.vioapic, irq, !!(*irq_state));
>  #ifdef CONFIG_X86
> -       kvm_pic_set_irq(pic_irqchip(kvm), irq, level);
> +       kvm_pic_set_irq(pic_irqchip(kvm), irq, !!(*irq_state));
>  #endif
>  }
Seems the logic is strange.  Could you help to elaborate it ? Why not
implment the logic same with userspace? 
Thanks
Xiantao


^ permalink raw reply	[flat|nested] 20+ messages in thread
[parent not found: <305032847.30081223883050196.JavaMail.root@zmail02.collab.prod.int.phx2.redhat.com>]

end of thread, other threads:[~2008-10-16  8:47 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-14  8:45 [v2] Shared guest irq support Zhang, Xiantao
2008-10-15  2:36 ` Sheng Yang
2008-10-15  7:03   ` Amit Shah
2008-10-15  7:11     ` Sheng Yang
2008-10-15 10:03       ` Amit Shah
2008-10-15 10:11         ` Zhang, Xiantao
2008-10-15 13:44           ` Zhang, Xiantao
2008-10-15 13:56             ` Zhang, Xiantao
2008-10-16  8:21               ` Avi Kivity
2008-10-16  8:28                 ` Sheng Yang
2008-10-16  8:45                   ` Avi Kivity
2008-10-16  8:31                 ` Amit Shah
2008-10-16  8:47                   ` Avi Kivity
2008-10-15  7:19 ` Amit Shah
     [not found] <305032847.30081223883050196.JavaMail.root@zmail02.collab.prod.int.phx2.redhat.com>
2008-10-13  7:31 ` Amit Shah
2008-10-13  7:33   ` Zhang, Xiantao
2008-10-13  7:41     ` Amit Shah
2008-10-13  7:44       ` Zhang, Xiantao
2008-10-13  7:36   ` Sheng Yang
2008-10-14  8:00   ` Amit Shah

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).