stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PULL 03/19] KVM: arm/arm64: vgic-irqfd: Fix MSI entry allocation
       [not found] <20171204135637.21620-1-cdall@kernel.org>
@ 2017-12-04 14:03 ` Christoffer Dall
  2017-12-04 14:03 ` [PULL 04/19] KVM: arm/arm64: vgic: Preserve the revious read from the pending table Christoffer Dall
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2017-12-04 14:03 UTC (permalink / raw)
  To: kvmarm, Paolo Bonzini, Radim Krčmář
  Cc: linux-arm-kernel, kvm, Marc Zyngier, stable, Christoffer Dall

From: Marc Zyngier <marc.zyngier@arm.com>

Using the size of the structure we're allocating is a good idea
and avoids any surprise... In this case, we're happilly confusing
kvm_kernel_irq_routing_entry and kvm_irq_routing_entry...

Fixes: 95b110ab9a09 ("KVM: arm/arm64: Enable irqchip routing")
Cc: <stable@vger.kernel.org> # 4.8
Reported-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/vgic/vgic-irqfd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-irqfd.c b/virt/kvm/arm/vgic/vgic-irqfd.c
index b7baf581611a..99e026d2dade 100644
--- a/virt/kvm/arm/vgic/vgic-irqfd.c
+++ b/virt/kvm/arm/vgic/vgic-irqfd.c
@@ -112,8 +112,7 @@ int kvm_vgic_setup_default_irq_routing(struct kvm *kvm)
 	u32 nr = dist->nr_spis;
 	int i, ret;
 
-	entries = kcalloc(nr, sizeof(struct kvm_kernel_irq_routing_entry),
-			  GFP_KERNEL);
+	entries = kcalloc(nr, sizeof(*entries), GFP_KERNEL);
 	if (!entries)
 		return -ENOMEM;
 
-- 
2.14.2

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

* [PULL 04/19] KVM: arm/arm64: vgic: Preserve the revious read from the pending table
       [not found] <20171204135637.21620-1-cdall@kernel.org>
  2017-12-04 14:03 ` [PULL 03/19] KVM: arm/arm64: vgic-irqfd: Fix MSI entry allocation Christoffer Dall
@ 2017-12-04 14:03 ` Christoffer Dall
  2017-12-04 14:03 ` [PULL 05/19] KVM: arm/arm64: vgic-its: " Christoffer Dall
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2017-12-04 14:03 UTC (permalink / raw)
  To: kvmarm, Paolo Bonzini, Radim Krčmář
  Cc: linux-arm-kernel, kvm, Marc Zyngier, stable, Christoffer Dall

From: Marc Zyngier <marc.zyngier@arm.com>

The current pending table parsing code assumes that we keep the
previous read of the pending bits, but keep that variable in
the current block, making sure it is discarded on each loop.

We end-up using whatever is on the stack. Who knows, it might
just be the right thing...

Fixes: 280771252c1ba ("KVM: arm64: vgic-v3: KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES")
Cc: <stable@vger.kernel.org> # 4.12
Reported-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/vgic/vgic-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 2f05f732d3fd..f47e8481fa45 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -327,13 +327,13 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
 	int last_byte_offset = -1;
 	struct vgic_irq *irq;
 	int ret;
+	u8 val;
 
 	list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) {
 		int byte_offset, bit_nr;
 		struct kvm_vcpu *vcpu;
 		gpa_t pendbase, ptr;
 		bool stored;
-		u8 val;
 
 		vcpu = irq->target_vcpu;
 		if (!vcpu)
-- 
2.14.2

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

* [PULL 05/19] KVM: arm/arm64: vgic-its: Preserve the revious read from the pending table
       [not found] <20171204135637.21620-1-cdall@kernel.org>
  2017-12-04 14:03 ` [PULL 03/19] KVM: arm/arm64: vgic-irqfd: Fix MSI entry allocation Christoffer Dall
  2017-12-04 14:03 ` [PULL 04/19] KVM: arm/arm64: vgic: Preserve the revious read from the pending table Christoffer Dall
@ 2017-12-04 14:03 ` Christoffer Dall
  2017-12-04 14:03 ` [PULL 06/19] KVM: arm/arm64: vgic-its: Check result of allocation before use Christoffer Dall
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2017-12-04 14:03 UTC (permalink / raw)
  To: kvmarm, Paolo Bonzini, Radim Krčmář
  Cc: linux-arm-kernel, kvm, Marc Zyngier, stable, Christoffer Dall

From: Marc Zyngier <marc.zyngier@arm.com>

The current pending table parsing code assumes that we keep the
previous read of the pending bits, but keep that variable in
the current block, making sure it is discarded on each loop.

We end-up using whatever is on the stack. Who knows, it might
just be the right thing...

Fixes: 33d3bc9556a7d ("KVM: arm64: vgic-its: Read initial LPI pending table")
Cc: <stable@vger.kernel.org> # 4.8
Reported-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/vgic/vgic-its.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index 1f761a9991e7..cb2d0a2dbe5a 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -421,6 +421,7 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu)
 	u32 *intids;
 	int nr_irqs, i;
 	unsigned long flags;
+	u8 pendmask;
 
 	nr_irqs = vgic_copy_lpi_list(vcpu, &intids);
 	if (nr_irqs < 0)
@@ -428,7 +429,6 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu)
 
 	for (i = 0; i < nr_irqs; i++) {
 		int byte_offset, bit_nr;
-		u8 pendmask;
 
 		byte_offset = intids[i] / BITS_PER_BYTE;
 		bit_nr = intids[i] % BITS_PER_BYTE;
-- 
2.14.2

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

* [PULL 06/19] KVM: arm/arm64: vgic-its: Check result of allocation before use
       [not found] <20171204135637.21620-1-cdall@kernel.org>
                   ` (2 preceding siblings ...)
  2017-12-04 14:03 ` [PULL 05/19] KVM: arm/arm64: vgic-its: " Christoffer Dall
@ 2017-12-04 14:03 ` Christoffer Dall
  2017-12-04 14:03 ` [PULL 08/19] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one Christoffer Dall
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2017-12-04 14:03 UTC (permalink / raw)
  To: kvmarm, Paolo Bonzini, Radim Krčmář
  Cc: linux-arm-kernel, kvm, Marc Zyngier, stable, Christoffer Dall

From: Marc Zyngier <marc.zyngier@arm.com>

We miss a test against NULL after allocation.

Fixes: 6d03a68f8054 ("KVM: arm64: vgic-its: Turn device_id validation into generic ID validation")
Cc: <stable@vger.kernel.org> # 4.8
Reported-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/vgic/vgic-its.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index cb2d0a2dbe5a..8e633bd9cc1e 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -821,6 +821,8 @@ static int vgic_its_alloc_collection(struct vgic_its *its,
 		return E_ITS_MAPC_COLLECTION_OOR;
 
 	collection = kzalloc(sizeof(*collection), GFP_KERNEL);
+	if (!collection)
+		return -ENOMEM;
 
 	collection->collection_id = coll_id;
 	collection->target_addr = COLLECTION_NOT_MAPPED;
-- 
2.14.2

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

* [PULL 08/19] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one
       [not found] <20171204135637.21620-1-cdall@kernel.org>
                   ` (3 preceding siblings ...)
  2017-12-04 14:03 ` [PULL 06/19] KVM: arm/arm64: vgic-its: Check result of allocation before use Christoffer Dall
@ 2017-12-04 14:03 ` Christoffer Dall
  2017-12-04 14:03 ` [PULL 09/19] arm: KVM: Fix " Christoffer Dall
  2017-12-04 14:03 ` [PULL 19/19] KVM: arm/arm64: Fix broken GICH_ELRSR big endian conversion Christoffer Dall
  6 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2017-12-04 14:03 UTC (permalink / raw)
  To: kvmarm, Paolo Bonzini, Radim Krčmář
  Cc: linux-arm-kernel, kvm, Marc Zyngier, Kristina Martsenko, stable,
	Christoffer Dall

From: Kristina Martsenko <kristina.martsenko@arm.com>

VTTBR_BADDR_MASK is used to sanity check the size and alignment of the
VTTBR address. It seems to currently be off by one, thereby only
allowing up to 47-bit addresses (instead of 48-bit) and also
insufficiently checking the alignment. This patch fixes it.

As an example, with 4k pages, before this patch we have:

  PHYS_MASK_SHIFT = 48
  VTTBR_X = 37 - 24 = 13
  VTTBR_BADDR_SHIFT = 13 - 1 = 12
  VTTBR_BADDR_MASK = ((1 << 35) - 1) << 12 = 0x00007ffffffff000

Which is wrong, because the mask doesn't allow bit 47 of the VTTBR
address to be set, and only requires the address to be 12-bit (4k)
aligned, while it actually needs to be 13-bit (8k) aligned because we
concatenate two 4k tables.

With this patch, the mask becomes 0x0000ffffffffe000, which is what we
want.

Fixes: 0369f6a34b9f ("arm64: KVM: EL2 register definitions")
Cc: <stable@vger.kernel.org> # 3.11.x
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 arch/arm64/include/asm/kvm_arm.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
index 7f069ff37f06..715d395ef45b 100644
--- a/arch/arm64/include/asm/kvm_arm.h
+++ b/arch/arm64/include/asm/kvm_arm.h
@@ -170,8 +170,7 @@
 #define VTCR_EL2_FLAGS			(VTCR_EL2_COMMON_BITS | VTCR_EL2_TGRAN_FLAGS)
 #define VTTBR_X				(VTTBR_X_TGRAN_MAGIC - VTCR_EL2_T0SZ_IPA)
 
-#define VTTBR_BADDR_SHIFT (VTTBR_X - 1)
-#define VTTBR_BADDR_MASK  (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT)
+#define VTTBR_BADDR_MASK  (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_X)
 #define VTTBR_VMID_SHIFT  (UL(48))
 #define VTTBR_VMID_MASK(size) (_AT(u64, (1 << size) - 1) << VTTBR_VMID_SHIFT)
 
-- 
2.14.2

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

* [PULL 09/19] arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one
       [not found] <20171204135637.21620-1-cdall@kernel.org>
                   ` (4 preceding siblings ...)
  2017-12-04 14:03 ` [PULL 08/19] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one Christoffer Dall
@ 2017-12-04 14:03 ` Christoffer Dall
  2017-12-04 14:03 ` [PULL 19/19] KVM: arm/arm64: Fix broken GICH_ELRSR big endian conversion Christoffer Dall
  6 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2017-12-04 14:03 UTC (permalink / raw)
  To: kvmarm, Paolo Bonzini, Radim Krčmář
  Cc: linux-arm-kernel, kvm, Marc Zyngier, stable, Christoffer Dall

From: Marc Zyngier <marc.zyngier@arm.com>

VTTBR_BADDR_MASK is used to sanity check the size and alignment of the
VTTBR address. It seems to currently be off by one, thereby only
allowing up to 39-bit addresses (instead of 40-bit) and also
insufficiently checking the alignment. This patch fixes it.

This patch is the 32bit pendent of Kristina's arm64 fix, and
she deserves the actual kudos for pinpointing that one.

Fixes: f7ed45be3ba52 ("KVM: ARM: World-switch implementation")
Cc: <stable@vger.kernel.org> # 3.9
Reported-by: Kristina Martsenko <kristina.martsenko@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 arch/arm/include/asm/kvm_arm.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/kvm_arm.h b/arch/arm/include/asm/kvm_arm.h
index c8781450905b..3ab8b3781bfe 100644
--- a/arch/arm/include/asm/kvm_arm.h
+++ b/arch/arm/include/asm/kvm_arm.h
@@ -161,8 +161,7 @@
 #else
 #define VTTBR_X		(5 - KVM_T0SZ)
 #endif
-#define VTTBR_BADDR_SHIFT (VTTBR_X - 1)
-#define VTTBR_BADDR_MASK  (((_AC(1, ULL) << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT)
+#define VTTBR_BADDR_MASK  (((_AC(1, ULL) << (40 - VTTBR_X)) - 1) << VTTBR_X)
 #define VTTBR_VMID_SHIFT  _AC(48, ULL)
 #define VTTBR_VMID_MASK(size)	(_AT(u64, (1 << size) - 1) << VTTBR_VMID_SHIFT)
 
-- 
2.14.2

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

* [PULL 19/19] KVM: arm/arm64: Fix broken GICH_ELRSR big endian conversion
       [not found] <20171204135637.21620-1-cdall@kernel.org>
                   ` (5 preceding siblings ...)
  2017-12-04 14:03 ` [PULL 09/19] arm: KVM: Fix " Christoffer Dall
@ 2017-12-04 14:03 ` Christoffer Dall
  6 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2017-12-04 14:03 UTC (permalink / raw)
  To: kvmarm, Paolo Bonzini, Radim Krčmář
  Cc: linux-arm-kernel, kvm, Marc Zyngier, Christoffer Dall, stable

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

We are incorrectly rearranging 32-bit words inside a 64-bit typed value
for big endian systems, which would result in never marking a virtual
interrupt as inactive on big endian systems (assuming 32 or fewer LRs on
the hardware).  Fix this by not doing any word order manipulation for
the typed values.

Cc: <stable@vger.kernel.org>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/hyp/vgic-v2-sr.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/virt/kvm/arm/hyp/vgic-v2-sr.c b/virt/kvm/arm/hyp/vgic-v2-sr.c
index a3f18d362366..d7fd46fe9efb 100644
--- a/virt/kvm/arm/hyp/vgic-v2-sr.c
+++ b/virt/kvm/arm/hyp/vgic-v2-sr.c
@@ -34,11 +34,7 @@ static void __hyp_text save_elrsr(struct kvm_vcpu *vcpu, void __iomem *base)
 	else
 		elrsr1 = 0;
 
-#ifdef CONFIG_CPU_BIG_ENDIAN
-	cpu_if->vgic_elrsr = ((u64)elrsr0 << 32) | elrsr1;
-#else
 	cpu_if->vgic_elrsr = ((u64)elrsr1 << 32) | elrsr0;
-#endif
 }
 
 static void __hyp_text save_lrs(struct kvm_vcpu *vcpu, void __iomem *base)
-- 
2.14.2

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

end of thread, other threads:[~2017-12-04 14:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20171204135637.21620-1-cdall@kernel.org>
2017-12-04 14:03 ` [PULL 03/19] KVM: arm/arm64: vgic-irqfd: Fix MSI entry allocation Christoffer Dall
2017-12-04 14:03 ` [PULL 04/19] KVM: arm/arm64: vgic: Preserve the revious read from the pending table Christoffer Dall
2017-12-04 14:03 ` [PULL 05/19] KVM: arm/arm64: vgic-its: " Christoffer Dall
2017-12-04 14:03 ` [PULL 06/19] KVM: arm/arm64: vgic-its: Check result of allocation before use Christoffer Dall
2017-12-04 14:03 ` [PULL 08/19] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one Christoffer Dall
2017-12-04 14:03 ` [PULL 09/19] arm: KVM: Fix " Christoffer Dall
2017-12-04 14:03 ` [PULL 19/19] KVM: arm/arm64: Fix broken GICH_ELRSR big endian conversion Christoffer Dall

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