Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1529555 > unrolled thread

[PATCH 0/6] KVM: x86: minor irqchip improvements (API change)

Started byRadim Krčmář <rkrcmar@redhat.com>
First post2016-11-24 17:40 +0100
Last post2016-11-24 18:00 +0100
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/6] KVM: x86: minor irqchip improvements (API change) Radim Krčmář <rkrcmar@redhat.com> - 2016-11-24 17:40 +0100
    [PATCH 4/6] KVM: x86: refactor pic setup in kvm_set_routing_entry Radim Krčmář <rkrcmar@redhat.com> - 2016-11-24 17:40 +0100
    [PATCH 1/6] KVM: x86: do allow kvm irqchip with split irqchip Radim Krčmář <rkrcmar@redhat.com> - 2016-11-24 17:40 +0100
    [PATCH 5/6] KVM: x86: prevent setup of invalid routes Radim Krčmář <rkrcmar@redhat.com> - 2016-11-24 17:40 +0100
    Re: [PATCH 0/6] KVM: x86: minor irqchip improvements (API change) Paolo Bonzini <pbonzini@redhat.com> - 2016-11-24 18:00 +0100

#1529555 — [PATCH 0/6] KVM: x86: minor irqchip improvements (API change)

FromRadim Krčmář <rkrcmar@redhat.com>
Date2016-11-24 17:40 +0100
Subject[PATCH 0/6] KVM: x86: minor irqchip improvements (API change)
Message-ID<sH5e1-5eA-13@gated-at.bofh.it>
There are two API changes:
1) [1/6] forbids KVM_CREATE_IRQCHIP after KVM_CAP_SPLIT_IRQCHIP
2) [5/6] makes KVM_SET_GSI_ROUTING reject pic and ioapic routes in split
   irqchip mode, because they make no sense and are currently "working" only
   because of a hacky NULL check.

[1-4/6] are needed for [5/6]; [6/6] is just a cherry.

Radim Krčmář (6):
  KVM: x86: do allow kvm irqchip with split irqchip
  KVM: x86: decouple irqchip_in_kernel() and pic_irqchip()
  KVM: x86: make pic setup code look like ioapic setup
  KVM: x86: refactor pic setup in kvm_set_routing_entry
  KVM: x86: prevent setup of invalid routes
  KVM: x86: simplify conditions with split/kvm irqchip

 arch/x86/include/asm/kvm_host.h |  1 +
 arch/x86/kvm/i8259.c            | 16 +++++++++++-----
 arch/x86/kvm/irq.h              | 17 +++++++++--------
 arch/x86/kvm/irq_comm.c         | 29 ++++++++++-------------------
 arch/x86/kvm/x86.c              | 39 ++++++++++++++++++++-------------------
 5 files changed, 51 insertions(+), 51 deletions(-)

-- 
2.10.2

[toc] | [next] | [standalone]


#1529558 — [PATCH 4/6] KVM: x86: refactor pic setup in kvm_set_routing_entry

FromRadim Krčmář <rkrcmar@redhat.com>
Date2016-11-24 17:40 +0100
Subject[PATCH 4/6] KVM: x86: refactor pic setup in kvm_set_routing_entry
Message-ID<sH5e2-5eA-37@gated-at.bofh.it>
In reply to#1529555
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 arch/x86/kvm/irq_comm.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index ddd63b8b176e..913e054a68e9 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -289,15 +289,13 @@ int kvm_set_routing_entry(struct kvm *kvm,
 	case KVM_IRQ_ROUTING_IRQCHIP:
 		delta = 0;
 		switch (ue->u.irqchip.irqchip) {
+		case KVM_IRQCHIP_PIC_SLAVE:
+			delta = 8;
+			/* fall through */
 		case KVM_IRQCHIP_PIC_MASTER:
 			e->set = kvm_set_pic_irq;
 			max_pin = PIC_NUM_PINS;
 			break;
-		case KVM_IRQCHIP_PIC_SLAVE:
-			e->set = kvm_set_pic_irq;
-			max_pin = PIC_NUM_PINS;
-			delta = 8;
-			break;
 		case KVM_IRQCHIP_IOAPIC:
 			max_pin = KVM_IOAPIC_NUM_PINS;
 			e->set = kvm_set_ioapic_irq;
-- 
2.10.2

[toc] | [prev] | [next] | [standalone]


#1529562 — [PATCH 1/6] KVM: x86: do allow kvm irqchip with split irqchip

FromRadim Krčmář <rkrcmar@redhat.com>
Date2016-11-24 17:40 +0100
Subject[PATCH 1/6] KVM: x86: do allow kvm irqchip with split irqchip
Message-ID<sH5e2-5eA-47@gated-at.bofh.it>
In reply to#1529555
Split irqchip cannot be created after creating the kvm irqchip, but we
forgot to restrict the other way.  This is an API change.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 arch/x86/kvm/x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6f9c9ad13f88..dbed51045c37 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3901,7 +3901,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
 
 		mutex_lock(&kvm->lock);
 		r = -EEXIST;
-		if (kvm->arch.vpic)
+		if (irqchip_in_kernel(kvm))
 			goto create_irqchip_unlock;
 		r = -EINVAL;
 		if (kvm->created_vcpus)
-- 
2.10.2

[toc] | [prev] | [next] | [standalone]


#1529563 — [PATCH 5/6] KVM: x86: prevent setup of invalid routes

FromRadim Krčmář <rkrcmar@redhat.com>
Date2016-11-24 17:40 +0100
Subject[PATCH 5/6] KVM: x86: prevent setup of invalid routes
Message-ID<sH5e2-5eA-49@gated-at.bofh.it>
In reply to#1529555
The check in kvm_set_pic_irq() and kvm_set_ioapic_irq() was just a
temporary measure until the code improved enough for us to do this.

This changes APIC in a case when KVM_SET_GSI_ROUTING is called to set up pic
and ioapic routes before KVM_CREATE_IRQCHIP.  Those rules would get overwritten
by KVM_CREATE_IRQCHIP at best, so it is pointless to allow it.  Userspaces
hopefully noticed that things don't work if they do that and don't do that.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 arch/x86/kvm/irq_comm.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 913e054a68e9..2838c0c37279 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -41,15 +41,6 @@ static int kvm_set_pic_irq(struct kvm_kernel_irq_routing_entry *e,
 			   bool line_status)
 {
 	struct kvm_pic *pic = pic_irqchip(kvm);
-
-	/*
-	 * XXX: rejecting pic routes when pic isn't in use would be better,
-	 * but the default routing table is installed while kvm->arch.vpic is
-	 * NULL and KVM_CREATE_IRQCHIP can race with KVM_IRQ_LINE.
-	 */
-	if (!pic)
-		return -1;
-
 	return kvm_pic_set_irq(pic, e->irqchip.pin, irq_source_id, level);
 }
 
@@ -58,10 +49,6 @@ static int kvm_set_ioapic_irq(struct kvm_kernel_irq_routing_entry *e,
 			      bool line_status)
 {
 	struct kvm_ioapic *ioapic = kvm->arch.vioapic;
-
-	if (!ioapic)
-		return -1;
-
 	return kvm_ioapic_set_irq(ioapic, e->irqchip.pin, irq_source_id, level,
 				line_status);
 }
@@ -293,10 +280,16 @@ int kvm_set_routing_entry(struct kvm *kvm,
 			delta = 8;
 			/* fall through */
 		case KVM_IRQCHIP_PIC_MASTER:
+			if (!pic_in_kernel(kvm))
+				goto out;
+
 			e->set = kvm_set_pic_irq;
 			max_pin = PIC_NUM_PINS;
 			break;
 		case KVM_IRQCHIP_IOAPIC:
+			if (!ioapic_in_kernel(kvm))
+				goto out;
+
 			max_pin = KVM_IOAPIC_NUM_PINS;
 			e->set = kvm_set_ioapic_irq;
 			break;
-- 
2.10.2

[toc] | [prev] | [next] | [standalone]


#1529569

FromPaolo Bonzini <pbonzini@redhat.com>
Date2016-11-24 18:00 +0100
Message-ID<sH5xo-5lp-3@gated-at.bofh.it>
In reply to#1529555

----- Original Message -----
> From: "Radim Krčmář" <rkrcmar@redhat.com>
> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
> Cc: "Paolo Bonzini" <pbonzini@redhat.com>
> Sent: Thursday, November 24, 2016 5:31:28 PM
> Subject: [PATCH 0/6] KVM: x86: minor irqchip improvements (API change)
> 
> There are two API changes:
> 1) [1/6] forbids KVM_CREATE_IRQCHIP after KVM_CAP_SPLIT_IRQCHIP
> 2) [5/6] makes KVM_SET_GSI_ROUTING reject pic and ioapic routes in split
>    irqchip mode, because they make no sense and are currently "working" only
>    because of a hacky NULL check.
> 
> [1-4/6] are needed for [5/6]; [6/6] is just a cherry.

Looks good---but they don't apply directly on top of kvm/next so we have
to delay them until -rc2 or a second 4.11 pull request.

Anyway,

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

> Radim Krčmář (6):
>   KVM: x86: do allow kvm irqchip with split irqchip
>   KVM: x86: decouple irqchip_in_kernel() and pic_irqchip()
>   KVM: x86: make pic setup code look like ioapic setup
>   KVM: x86: refactor pic setup in kvm_set_routing_entry
>   KVM: x86: prevent setup of invalid routes
>   KVM: x86: simplify conditions with split/kvm irqchip
> 
>  arch/x86/include/asm/kvm_host.h |  1 +
>  arch/x86/kvm/i8259.c            | 16 +++++++++++-----
>  arch/x86/kvm/irq.h              | 17 +++++++++--------
>  arch/x86/kvm/irq_comm.c         | 29 ++++++++++-------------------
>  arch/x86/kvm/x86.c              | 39 ++++++++++++++++++++-------------------
>  5 files changed, 51 insertions(+), 51 deletions(-)
> 
> --
> 2.10.2
> 
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web