public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] ARM: KVM: VGIC fixes for 3.12
@ 2013-08-29 10:08 Marc Zyngier
  2013-08-29 10:08 ` [PATCH 1/4] ARM: KVM: vgic: simplify vgic_get_target_reg Marc Zyngier
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Marc Zyngier @ 2013-08-29 10:08 UTC (permalink / raw)
  To: pbonzini, gleb; +Cc: kvm, kvmarm

Gleb, Paolo,

Please pull the below tag for a few VGIC fixes to be merged in 3.12.

Thanks,

	M.

The following changes since commit d8dfad3876e4386666b759da3c833d62fb8b2267:

  Linux 3.11-rc7 (2013-08-25 17:43:22 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git tags/vgic-fixes-for-3.12

for you to fetch changes up to c375e1d55ee7987707622e3907f481ce2d9e6cc0:

  ARM: KVM: vgic: Bump VGIC_NR_IRQS to 256 (2013-08-29 10:27:19 +0100)

----------------------------------------------------------------
A few simple fixes for the in-kernel GIC emulation.

The only real change is the bump of the number of interrupts
sources (128 was a bit tiny).

----------------------------------------------------------------
Christoffer Dall (2):
  ARM: KVM: Bugfix: vgic_bytemap_get_reg per cpu regs
  ARM: KVM: vgic: Bump VGIC_NR_IRQS to 256

Marc Zyngier (2):
  ARM: KVM: vgic: simplify vgic_get_target_reg
  ARM: KVM: vgic: fix GICD_ICFGRn access

 include/kvm/arm_vgic.h |  2 +-
 virt/kvm/arm/vgic.c    | 22 ++++++++++------------
 2 files changed, 11 insertions(+), 13 deletions(-)

-- 
1.8.2.3



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

* [PATCH 1/4] ARM: KVM: vgic: simplify vgic_get_target_reg
  2013-08-29 10:08 [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Marc Zyngier
@ 2013-08-29 10:08 ` Marc Zyngier
  2013-08-29 10:08 ` [PATCH 2/4] ARM: KVM: vgic: fix GICD_ICFGRn access Marc Zyngier
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2013-08-29 10:08 UTC (permalink / raw)
  To: pbonzini, gleb; +Cc: kvm, kvmarm

vgic_get_target_reg is quite complicated, for no good reason.
Actually, it is fairly easy to write it in a much more efficient
way by using the target CPU array instead of the bitmap.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 virt/kvm/arm/vgic.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 17c5ac7..a2d478a 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -432,19 +432,13 @@ static bool handle_mmio_priority_reg(struct kvm_vcpu *vcpu,
 static u32 vgic_get_target_reg(struct kvm *kvm, int irq)
 {
 	struct vgic_dist *dist = &kvm->arch.vgic;
-	struct kvm_vcpu *vcpu;
-	int i, c;
-	unsigned long *bmap;
+	int i;
 	u32 val = 0;
 
 	irq -= VGIC_NR_PRIVATE_IRQS;
 
-	kvm_for_each_vcpu(c, vcpu, kvm) {
-		bmap = vgic_bitmap_get_shared_map(&dist->irq_spi_target[c]);
-		for (i = 0; i < GICD_IRQS_PER_ITARGETSR; i++)
-			if (test_bit(irq + i, bmap))
-				val |= 1 << (c + i * 8);
-	}
+	for (i = 0; i < GICD_IRQS_PER_ITARGETSR; i++)
+		val |= 1 << (dist->irq_spi_cpu[irq + i] + i * 8);
 
 	return val;
 }
-- 
1.8.2.3



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

* [PATCH 2/4] ARM: KVM: vgic: fix GICD_ICFGRn access
  2013-08-29 10:08 [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Marc Zyngier
  2013-08-29 10:08 ` [PATCH 1/4] ARM: KVM: vgic: simplify vgic_get_target_reg Marc Zyngier
@ 2013-08-29 10:08 ` Marc Zyngier
  2013-08-29 20:28   ` Christoffer Dall
  2013-08-29 10:08 ` [PATCH 3/4] ARM: KVM: Bugfix: vgic_bytemap_get_reg per cpu regs Marc Zyngier
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Marc Zyngier @ 2013-08-29 10:08 UTC (permalink / raw)
  To: pbonzini, gleb; +Cc: kvm, kvmarm, Zhaobo (Bob, ERC)

All the code in handle_mmio_cfg_reg() assumes the offset has
been shifted right to accomodate for the 2:1 bit compression,
but this is only done when getting the register addess.

Shift the offset early so the code works mostly unchanged.

Reported-by: Zhaobo (Bob, ERC) <zhaobo@huawei.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 virt/kvm/arm/vgic.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index a2d478a..902789f 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -541,8 +541,12 @@ static bool handle_mmio_cfg_reg(struct kvm_vcpu *vcpu,
 				struct kvm_exit_mmio *mmio, phys_addr_t offset)
 {
 	u32 val;
-	u32 *reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
-				       vcpu->vcpu_id, offset >> 1);
+	u32 *reg;
+
+	offset >>= 1;
+	reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
+				  vcpu->vcpu_id, offset);
+
 	if (offset & 2)
 		val = *reg >> 16;
 	else
-- 
1.8.2.3



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

* [PATCH 3/4] ARM: KVM: Bugfix: vgic_bytemap_get_reg per cpu regs
  2013-08-29 10:08 [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Marc Zyngier
  2013-08-29 10:08 ` [PATCH 1/4] ARM: KVM: vgic: simplify vgic_get_target_reg Marc Zyngier
  2013-08-29 10:08 ` [PATCH 2/4] ARM: KVM: vgic: fix GICD_ICFGRn access Marc Zyngier
@ 2013-08-29 10:08 ` Marc Zyngier
  2013-08-29 10:08 ` [PATCH 4/4] ARM: KVM: vgic: Bump VGIC_NR_IRQS to 256 Marc Zyngier
  2013-08-30 13:08 ` [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Gleb Natapov
  4 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2013-08-29 10:08 UTC (permalink / raw)
  To: pbonzini, gleb; +Cc: kvm, kvmarm, Christoffer Dall

From: Christoffer Dall <christoffer.dall@linaro.org>

For bytemaps each IRQ field is 1 byte wide, so we pack 4 irq fields in
one word and since there are 32 private (per cpu) irqs, we have 8
private u32 fields on the vgic_bytemap struct.  We shift the offset from
the base of the register group right by 2, giving us the word index
instead of the field index.  But then there are 8 private words, not 4,
which is also why we subtract 8 words from the offset of the shared
words.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 virt/kvm/arm/vgic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 902789f..685fc72 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -149,7 +149,7 @@ static u32 *vgic_bytemap_get_reg(struct vgic_bytemap *x, int cpuid, u32 offset)
 {
 	offset >>= 2;
 	BUG_ON(offset > (VGIC_NR_IRQS / 4));
-	if (offset < 4)
+	if (offset < 8)
 		return x->percpu[cpuid] + offset;
 	else
 		return x->shared + offset - 8;
-- 
1.8.2.3



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

* [PATCH 4/4] ARM: KVM: vgic: Bump VGIC_NR_IRQS to 256
  2013-08-29 10:08 [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Marc Zyngier
                   ` (2 preceding siblings ...)
  2013-08-29 10:08 ` [PATCH 3/4] ARM: KVM: Bugfix: vgic_bytemap_get_reg per cpu regs Marc Zyngier
@ 2013-08-29 10:08 ` Marc Zyngier
  2013-08-30 13:08 ` [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Gleb Natapov
  4 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2013-08-29 10:08 UTC (permalink / raw)
  To: pbonzini, gleb; +Cc: kvm, kvmarm, Christoffer Dall

From: Christoffer Dall <christoffer.dall@linaro.org>

The Versatile Express TC2 board, which we use as our main emulated
platform in QEMU, defines 160+32 == 192 interrupts, so limiting the
number of interrupts to 128 is not quite going to cut it for real board
emulation.

Note that this didn't use to be a problem because QEMU was buggy and
only defined 128 interrupts until recently.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 include/kvm/arm_vgic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index 343744e..7e2d158 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -26,7 +26,7 @@
 #include <linux/types.h>
 #include <linux/irqchip/arm-gic.h>
 
-#define VGIC_NR_IRQS		128
+#define VGIC_NR_IRQS		256
 #define VGIC_NR_SGIS		16
 #define VGIC_NR_PPIS		16
 #define VGIC_NR_PRIVATE_IRQS	(VGIC_NR_SGIS + VGIC_NR_PPIS)
-- 
1.8.2.3



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

* Re: [PATCH 2/4] ARM: KVM: vgic: fix GICD_ICFGRn access
  2013-08-29 10:08 ` [PATCH 2/4] ARM: KVM: vgic: fix GICD_ICFGRn access Marc Zyngier
@ 2013-08-29 20:28   ` Christoffer Dall
  0 siblings, 0 replies; 8+ messages in thread
From: Christoffer Dall @ 2013-08-29 20:28 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: pbonzini, gleb, Zhaobo (Bob, ERC), kvmarm, kvm

On Thu, Aug 29, 2013 at 11:08:23AM +0100, Marc Zyngier wrote:
> All the code in handle_mmio_cfg_reg() assumes the offset has
> been shifted right to accomodate for the 2:1 bit compression,
> but this is only done when getting the register addess.

address

> 
> Shift the offset early so the code works mostly unchanged.
> 
> Reported-by: Zhaobo (Bob, ERC) <zhaobo@huawei.com>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
>  virt/kvm/arm/vgic.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> index a2d478a..902789f 100644
> --- a/virt/kvm/arm/vgic.c
> +++ b/virt/kvm/arm/vgic.c
> @@ -541,8 +541,12 @@ static bool handle_mmio_cfg_reg(struct kvm_vcpu *vcpu,
>  				struct kvm_exit_mmio *mmio, phys_addr_t offset)
>  {
>  	u32 val;
> -	u32 *reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
> -				       vcpu->vcpu_id, offset >> 1);
> +	u32 *reg;
> +
> +	offset >>= 1;
> +	reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
> +				  vcpu->vcpu_id, offset);
> +
>  	if (offset & 2)
>  		val = *reg >> 16;
>  	else
> -- 
> 1.8.2.3
> 
> 
> 
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm

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

* Re: [GIT PULL] ARM: KVM: VGIC fixes for 3.12
  2013-08-29 10:08 [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Marc Zyngier
                   ` (3 preceding siblings ...)
  2013-08-29 10:08 ` [PATCH 4/4] ARM: KVM: vgic: Bump VGIC_NR_IRQS to 256 Marc Zyngier
@ 2013-08-30 13:08 ` Gleb Natapov
  2013-08-30 13:15   ` Marc Zyngier
  4 siblings, 1 reply; 8+ messages in thread
From: Gleb Natapov @ 2013-08-30 13:08 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: pbonzini, kvm, kvmarm

On Thu, Aug 29, 2013 at 11:08:21AM +0100, Marc Zyngier wrote:
> Gleb, Paolo,
> 
> Please pull the below tag for a few VGIC fixes to be merged in 3.12.
> 
> Thanks,
> 
> 	M.
> 
> The following changes since commit d8dfad3876e4386666b759da3c833d62fb8b2267:
> 
>   Linux 3.11-rc7 (2013-08-25 17:43:22 -0700)
> 
kvm.git next branch is based on Linux 3.11-rc1, so if I pull this it
will bring all the commit in between. I just applied 4 patches manually.

> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git tags/vgic-fixes-for-3.12
> 
> for you to fetch changes up to c375e1d55ee7987707622e3907f481ce2d9e6cc0:
> 
>   ARM: KVM: vgic: Bump VGIC_NR_IRQS to 256 (2013-08-29 10:27:19 +0100)
> 
> ----------------------------------------------------------------
> A few simple fixes for the in-kernel GIC emulation.
> 
> The only real change is the bump of the number of interrupts
> sources (128 was a bit tiny).
> 
> ----------------------------------------------------------------
> Christoffer Dall (2):
>   ARM: KVM: Bugfix: vgic_bytemap_get_reg per cpu regs
>   ARM: KVM: vgic: Bump VGIC_NR_IRQS to 256
> 
> Marc Zyngier (2):
>   ARM: KVM: vgic: simplify vgic_get_target_reg
>   ARM: KVM: vgic: fix GICD_ICFGRn access
> 
>  include/kvm/arm_vgic.h |  2 +-
>  virt/kvm/arm/vgic.c    | 22 ++++++++++------------
>  2 files changed, 11 insertions(+), 13 deletions(-)
> 
> -- 
> 1.8.2.3
> 

--
			Gleb.

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

* Re: [GIT PULL] ARM: KVM: VGIC fixes for 3.12
  2013-08-30 13:08 ` [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Gleb Natapov
@ 2013-08-30 13:15   ` Marc Zyngier
  0 siblings, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2013-08-30 13:15 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: pbonzini, kvmarm, kvm

On 2013-08-30 14:08, Gleb Natapov wrote:
> On Thu, Aug 29, 2013 at 11:08:21AM +0100, Marc Zyngier wrote:
>> Gleb, Paolo,
>>
>> Please pull the below tag for a few VGIC fixes to be merged in 3.12.
>>
>> Thanks,
>>
>> 	M.
>>
>> The following changes since commit 
>> d8dfad3876e4386666b759da3c833d62fb8b2267:
>>
>>   Linux 3.11-rc7 (2013-08-25 17:43:22 -0700)
>>
> kvm.git next branch is based on Linux 3.11-rc1, so if I pull this it
> will bring all the commit in between. I just applied 4 patches 
> manually.

Fair enough. Thanks.

         M.
-- 
Fast, cheap, reliable. Pick two.

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

end of thread, other threads:[~2013-08-30 13:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29 10:08 [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Marc Zyngier
2013-08-29 10:08 ` [PATCH 1/4] ARM: KVM: vgic: simplify vgic_get_target_reg Marc Zyngier
2013-08-29 10:08 ` [PATCH 2/4] ARM: KVM: vgic: fix GICD_ICFGRn access Marc Zyngier
2013-08-29 20:28   ` Christoffer Dall
2013-08-29 10:08 ` [PATCH 3/4] ARM: KVM: Bugfix: vgic_bytemap_get_reg per cpu regs Marc Zyngier
2013-08-29 10:08 ` [PATCH 4/4] ARM: KVM: vgic: Bump VGIC_NR_IRQS to 256 Marc Zyngier
2013-08-30 13:08 ` [GIT PULL] ARM: KVM: VGIC fixes for 3.12 Gleb Natapov
2013-08-30 13:15   ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox