* [PATCH 1/5] ARM: KVM: disable KVM in Kconfig on big-endian systems
2014-04-30 11:15 [GIT PULL] KVM/ARM Fixes for 3.15-rc4 Christoffer Dall
@ 2014-04-30 11:15 ` Christoffer Dall
2014-04-30 11:15 ` [PATCH 2/5] arm: KVM: fix possible misalignment of PGDs and bounce page Christoffer Dall
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2014-04-30 11:15 UTC (permalink / raw)
To: linux-arm-kernel
From: Will Deacon <will.deacon@arm.com>
KVM currently crashes and burns on big-endian hosts, so don't allow it
to be selected until we've got that fixed.
Cc: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
arch/arm/kvm/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index 466bd29..4be5bb1 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -23,7 +23,7 @@ config KVM
select HAVE_KVM_CPU_RELAX_INTERCEPT
select KVM_MMIO
select KVM_ARM_HOST
- depends on ARM_VIRT_EXT && ARM_LPAE
+ depends on ARM_VIRT_EXT && ARM_LPAE && !CPU_BIG_ENDIAN
---help---
Support hosting virtualized guest machines. You will also
need to select one or more of the processor modules below.
--
1.8.5.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/5] arm: KVM: fix possible misalignment of PGDs and bounce page
2014-04-30 11:15 [GIT PULL] KVM/ARM Fixes for 3.15-rc4 Christoffer Dall
2014-04-30 11:15 ` [PATCH 1/5] ARM: KVM: disable KVM in Kconfig on big-endian systems Christoffer Dall
@ 2014-04-30 11:15 ` Christoffer Dall
2014-04-30 11:15 ` [PATCH 3/5] KVM: ARM: vgic: Fix sgi dispatch problem Christoffer Dall
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2014-04-30 11:15 UTC (permalink / raw)
To: linux-arm-kernel
From: Mark Salter <msalter@redhat.com>
The kvm/mmu code shared by arm and arm64 uses kalloc() to allocate
a bounce page (if hypervisor init code crosses page boundary) and
hypervisor PGDs. The problem is that kalloc() does not guarantee
the proper alignment. In the case of the bounce page, the page sized
buffer allocated may also cross a page boundary negating the purpose
and leading to a hang during kvm initialization. Likewise the PGDs
allocated may not meet the minimum alignment requirements of the
underlying MMU. This patch uses __get_free_page() to guarantee the
worst case alignment needs of the bounce page and PGDs on both arm
and arm64.
Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Mark Salter <msalter@redhat.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
arch/arm/kvm/mmu.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 80bb1e6..16f8049 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -42,6 +42,8 @@ static unsigned long hyp_idmap_start;
static unsigned long hyp_idmap_end;
static phys_addr_t hyp_idmap_vector;
+#define pgd_order get_order(PTRS_PER_PGD * sizeof(pgd_t))
+
#define kvm_pmd_huge(_x) (pmd_huge(_x) || pmd_trans_huge(_x))
static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
@@ -293,14 +295,14 @@ void free_boot_hyp_pgd(void)
if (boot_hyp_pgd) {
unmap_range(NULL, boot_hyp_pgd, hyp_idmap_start, PAGE_SIZE);
unmap_range(NULL, boot_hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE);
- kfree(boot_hyp_pgd);
+ free_pages((unsigned long)boot_hyp_pgd, pgd_order);
boot_hyp_pgd = NULL;
}
if (hyp_pgd)
unmap_range(NULL, hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE);
- kfree(init_bounce_page);
+ free_page((unsigned long)init_bounce_page);
init_bounce_page = NULL;
mutex_unlock(&kvm_hyp_pgd_mutex);
@@ -330,7 +332,7 @@ void free_hyp_pgds(void)
for (addr = VMALLOC_START; is_vmalloc_addr((void*)addr); addr += PGDIR_SIZE)
unmap_range(NULL, hyp_pgd, KERN_TO_HYP(addr), PGDIR_SIZE);
- kfree(hyp_pgd);
+ free_pages((unsigned long)hyp_pgd, pgd_order);
hyp_pgd = NULL;
}
@@ -1024,7 +1026,7 @@ int kvm_mmu_init(void)
size_t len = __hyp_idmap_text_end - __hyp_idmap_text_start;
phys_addr_t phys_base;
- init_bounce_page = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ init_bounce_page = (void *)__get_free_page(GFP_KERNEL);
if (!init_bounce_page) {
kvm_err("Couldn't allocate HYP init bounce page\n");
err = -ENOMEM;
@@ -1050,8 +1052,9 @@ int kvm_mmu_init(void)
(unsigned long)phys_base);
}
- hyp_pgd = kzalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL);
- boot_hyp_pgd = kzalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL);
+ hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, pgd_order);
+ boot_hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, pgd_order);
+
if (!hyp_pgd || !boot_hyp_pgd) {
kvm_err("Hyp mode PGD not allocated\n");
err = -ENOMEM;
--
1.8.5.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/5] KVM: ARM: vgic: Fix sgi dispatch problem
2014-04-30 11:15 [GIT PULL] KVM/ARM Fixes for 3.15-rc4 Christoffer Dall
2014-04-30 11:15 ` [PATCH 1/5] ARM: KVM: disable KVM in Kconfig on big-endian systems Christoffer Dall
2014-04-30 11:15 ` [PATCH 2/5] arm: KVM: fix possible misalignment of PGDs and bounce page Christoffer Dall
@ 2014-04-30 11:15 ` Christoffer Dall
2014-04-30 11:15 ` [PATCH 4/5] KVM: arm/arm64: vgic: fix GICD_ICFGR register accesses Christoffer Dall
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2014-04-30 11:15 UTC (permalink / raw)
To: linux-arm-kernel
From: Haibin Wang <wanghaibin.wang@huawei.com>
When dispatch SGI(mode == 0), that is the vcpu of VM should send
sgi to the cpu which the target_cpus list.
So, there must add the "break" to branch of case 0.
Cc: <stable@vger.kernel.org> # 3.10+
Signed-off-by: Haibin Wang <wanghaibin.wang@huawei.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
virt/kvm/arm/vgic.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 47b2983..7e8b44e 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -916,6 +916,7 @@ static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg)
case 0:
if (!target_cpus)
return;
+ break;
case 1:
target_cpus = ((1 << nrcpus) - 1) & ~(1 << vcpu_id) & 0xff;
--
1.8.5.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/5] KVM: arm/arm64: vgic: fix GICD_ICFGR register accesses
2014-04-30 11:15 [GIT PULL] KVM/ARM Fixes for 3.15-rc4 Christoffer Dall
` (2 preceding siblings ...)
2014-04-30 11:15 ` [PATCH 3/5] KVM: ARM: vgic: Fix sgi dispatch problem Christoffer Dall
@ 2014-04-30 11:15 ` Christoffer Dall
2014-04-30 11:15 ` [PATCH 5/5] KVM: ARM: vgic: Fix the overlap check action about setting the GICD & GICC base address Christoffer Dall
2014-04-30 19:26 ` [GIT PULL] KVM/ARM Fixes for 3.15-rc4 Paolo Bonzini
5 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2014-04-30 11:15 UTC (permalink / raw)
To: linux-arm-kernel
From: Andre Przywara <andre.przywara@arm.com>
Since KVM internally represents the ICFGR registers by stuffing two
of them into one word, the offset for accessing the internal
representation and the one for the MMIO based access are different.
So keep the original offset around, but adjust the internal array
offset by one bit.
Reported-by: Haibin Wang <wanghaibin.wang@huawei.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
virt/kvm/arm/vgic.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 7e8b44e..f9af48c 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -548,11 +548,10 @@ static bool handle_mmio_cfg_reg(struct kvm_vcpu *vcpu,
u32 val;
u32 *reg;
- offset >>= 1;
reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
- vcpu->vcpu_id, offset);
+ vcpu->vcpu_id, offset >> 1);
- if (offset & 2)
+ if (offset & 4)
val = *reg >> 16;
else
val = *reg & 0xffff;
@@ -561,13 +560,13 @@ static bool handle_mmio_cfg_reg(struct kvm_vcpu *vcpu,
vgic_reg_access(mmio, &val, offset,
ACCESS_READ_VALUE | ACCESS_WRITE_VALUE);
if (mmio->is_write) {
- if (offset < 4) {
+ if (offset < 8) {
*reg = ~0U; /* Force PPIs/SGIs to 1 */
return false;
}
val = vgic_cfg_compress(val);
- if (offset & 2) {
+ if (offset & 4) {
*reg &= 0xffff;
*reg |= val << 16;
} else {
--
1.8.5.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/5] KVM: ARM: vgic: Fix the overlap check action about setting the GICD & GICC base address.
2014-04-30 11:15 [GIT PULL] KVM/ARM Fixes for 3.15-rc4 Christoffer Dall
` (3 preceding siblings ...)
2014-04-30 11:15 ` [PATCH 4/5] KVM: arm/arm64: vgic: fix GICD_ICFGR register accesses Christoffer Dall
@ 2014-04-30 11:15 ` Christoffer Dall
2014-04-30 19:26 ` [GIT PULL] KVM/ARM Fixes for 3.15-rc4 Paolo Bonzini
5 siblings, 0 replies; 7+ messages in thread
From: Christoffer Dall @ 2014-04-30 11:15 UTC (permalink / raw)
To: linux-arm-kernel
From: Haibin Wang <wanghaibin.wang@huawei.com>
Currently below check in vgic_ioaddr_overlap will always succeed,
because the vgic dist base and vgic cpu base are still kept UNDEF
after initialization. The code as follows will be return forever.
if (IS_VGIC_ADDR_UNDEF(dist) || IS_VGIC_ADDR_UNDEF(cpu))
return 0;
So, before invoking the vgic_ioaddr_overlap, it needs to set the
corresponding base address firstly.
Signed-off-by: Haibin Wang <wanghaibin.wang@huawei.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
virt/kvm/arm/vgic.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index f9af48c..56ff9be 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1667,10 +1667,11 @@ static int vgic_ioaddr_assign(struct kvm *kvm, phys_addr_t *ioaddr,
if (addr + size < addr)
return -EINVAL;
+ *ioaddr = addr;
ret = vgic_ioaddr_overlap(kvm);
if (ret)
- return ret;
- *ioaddr = addr;
+ *ioaddr = VGIC_ADDR_UNDEF;
+
return ret;
}
--
1.8.5.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* [GIT PULL] KVM/ARM Fixes for 3.15-rc4
2014-04-30 11:15 [GIT PULL] KVM/ARM Fixes for 3.15-rc4 Christoffer Dall
` (4 preceding siblings ...)
2014-04-30 11:15 ` [PATCH 5/5] KVM: ARM: vgic: Fix the overlap check action about setting the GICD & GICC base address Christoffer Dall
@ 2014-04-30 19:26 ` Paolo Bonzini
5 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2014-04-30 19:26 UTC (permalink / raw)
To: linux-arm-kernel
Il 30/04/2014 13:15, Christoffer Dall ha scritto:
> The following changes since commit 0f689a33ad17845363acdc6d52783befd6ad116c:
>
> Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux (2014-04-16 11:28:25 -0700)
>
> are available in the git repository at:
>
>
> git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvm-arm-for-3.15-rc4
>
> for you to fetch changes up to 30c2117085bc4e05d091cee6eba79f069b41a9cd:
>
> KVM: ARM: vgic: Fix the overlap check action about setting the GICD & GICC base address. (2014-04-29 02:01:43 -0700)
>
> ----------------------------------------------------------------
> First round of KVM/ARM Fixes for 3.15
>
> Includes vgic fixes, a possible kernel corruption bug due to
> misalignment of pages and disabling of KVM in KConfig on big-endian
> systems, because the last one breaks the build.
>
> ----------------------------------------------------------------
> Andre Przywara (1):
> KVM: arm/arm64: vgic: fix GICD_ICFGR register accesses
>
> Haibin Wang (2):
> KVM: ARM: vgic: Fix sgi dispatch problem
> KVM: ARM: vgic: Fix the overlap check action about setting the GICD & GICC base address.
>
> Mark Salter (1):
> arm: KVM: fix possible misalignment of PGDs and bounce page
>
> Will Deacon (1):
> ARM: KVM: disable KVM in Kconfig on big-endian systems
>
> arch/arm/kvm/Kconfig | 2 +-
> arch/arm/kvm/mmu.c | 15 +++++++++------
> virt/kvm/arm/vgic.c | 15 ++++++++-------
> 3 files changed, 18 insertions(+), 14 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Pulled, thanks. I'll send the pull request out on Friday, because
tomorrow is a public holiday here.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread