Linux KVM/arm64 development list
 help / color / mirror / Atom feed
* [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3
@ 2018-01-12 12:33 Christoffer Dall
  2018-01-12 12:33 ` [PULL 1/2] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Christoffer Dall
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christoffer Dall @ 2018-01-12 12:33 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Marc Zyngier, linux-arm-kernel, kvmarm, kvm, Christoffer Dall

Hi Paolo and Radim,

This is the third round of fixes for KVM/ARM for v4.15, including two more
fixes for v4.15 fixing incorrect huge page mappings on systems using the
contiguous hint for hugetlbfs and supporting an alternative GICv4 init
sequence.

The following changes since commit 0eb7c33cadf6b2f1a94e58ded8b0eb89b4eba382:

  KVM: arm/arm64: Fix timer enable flow (2017-12-18 10:53:24 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvm-arm-fixes-for-v4.15-3

for you to fetch changes up to f8f85dc00b7427de6222ea3955c52512315d13cd:

  KVM: arm64: Fix GICv4 init when called from vgic_its_create (2018-01-12 11:40:21 +0100)

Thanks,
-Christoffer

Christoffer Dall (1):
      KVM: arm64: Fix GICv4 init when called from vgic_its_create

Punit Agrawal (1):
      KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2

 virt/kvm/arm/mmu.c            | 2 +-
 virt/kvm/arm/vgic/vgic-init.c | 8 +++++---
 virt/kvm/arm/vgic/vgic-v4.c   | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

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

* [PULL 1/2] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2
  2018-01-12 12:33 [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3 Christoffer Dall
@ 2018-01-12 12:33 ` Christoffer Dall
  2018-01-12 12:33 ` [PULL 2/2] KVM: arm64: Fix GICv4 init when called from vgic_its_create Christoffer Dall
  2018-01-12 12:59 ` [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3 Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Christoffer Dall @ 2018-01-12 12:33 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: kvm, Marc Zyngier, Punit Agrawal, stable, kvmarm,
	linux-arm-kernel

From: Punit Agrawal <punit.agrawal@arm.com>

KVM only supports PMD hugepages at stage 2 but doesn't actually check
that the provided hugepage memory pagesize is PMD_SIZE before populating
stage 2 entries.

In cases where the backing hugepage size is smaller than PMD_SIZE (such
as when using contiguous hugepages), KVM can end up creating stage 2
mappings that extend beyond the supplied memory.

Fix this by checking for the pagesize of userspace vma before creating
PMD hugepage at stage 2.

Fixes: 66b3923a1a0f77a ("arm64: hugetlb: add support for PTE contiguous bit")
Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: <stable@vger.kernel.org> # v4.5+
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index b4b69c2d1012..9dea96380339 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -1310,7 +1310,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
 		return -EFAULT;
 	}
 
-	if (is_vm_hugetlb_page(vma) && !logging_active) {
+	if (vma_kernel_pagesize(vma) == PMD_SIZE && !logging_active) {
 		hugetlb = true;
 		gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT;
 	} else {
-- 
2.14.2

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

* [PULL 2/2] KVM: arm64: Fix GICv4 init when called from vgic_its_create
  2018-01-12 12:33 [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3 Christoffer Dall
  2018-01-12 12:33 ` [PULL 1/2] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Christoffer Dall
@ 2018-01-12 12:33 ` Christoffer Dall
  2018-01-12 12:59 ` [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3 Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Christoffer Dall @ 2018-01-12 12:33 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Marc Zyngier, linux-arm-kernel, kvmarm, kvm, Christoffer Dall

Commit 3d1ad640f8c94 ("KVM: arm/arm64: Fix GICv4 ITS initialization
issues") moved the vgic_supports_direct_msis() check in vgic_v4_init().
However when vgic_v4_init is called from vgic_its_create(), the has_its
field is not yet set. Hence vgic_supports_direct_msis returns false and
vgic_v4_init does nothing.

The gic/its init sequence is a bit messy, so let's be specific about the
prerequisite checks in the various call paths instead of relying on a
common wrapper.

Fixes: 3d1ad640f8c94 ("KVM: arm/arm64: Fix GICv4 ITS initialization issues")
Reported-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/vgic/vgic-init.c | 8 +++++---
 virt/kvm/arm/vgic/vgic-v4.c   | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index 62310122ee78..743ca5cb05ef 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -285,9 +285,11 @@ int vgic_init(struct kvm *kvm)
 	if (ret)
 		goto out;
 
-	ret = vgic_v4_init(kvm);
-	if (ret)
-		goto out;
+	if (vgic_has_its(kvm)) {
+		ret = vgic_v4_init(kvm);
+		if (ret)
+			goto out;
+	}
 
 	kvm_for_each_vcpu(i, vcpu, kvm)
 		kvm_vgic_vcpu_enable(vcpu);
diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c
index 4a37292855bc..bc4265154bac 100644
--- a/virt/kvm/arm/vgic/vgic-v4.c
+++ b/virt/kvm/arm/vgic/vgic-v4.c
@@ -118,7 +118,7 @@ int vgic_v4_init(struct kvm *kvm)
 	struct kvm_vcpu *vcpu;
 	int i, nr_vcpus, ret;
 
-	if (!vgic_supports_direct_msis(kvm))
+	if (!kvm_vgic_global_state.has_gicv4)
 		return 0; /* Nothing to see here... move along. */
 
 	if (dist->its_vm.vpes)
-- 
2.14.2

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

* Re: [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3
  2018-01-12 12:33 [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3 Christoffer Dall
  2018-01-12 12:33 ` [PULL 1/2] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Christoffer Dall
  2018-01-12 12:33 ` [PULL 2/2] KVM: arm64: Fix GICv4 init when called from vgic_its_create Christoffer Dall
@ 2018-01-12 12:59 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2018-01-12 12:59 UTC (permalink / raw)
  To: Christoffer Dall, Radim Krčmář
  Cc: Marc Zyngier, linux-arm-kernel, kvmarm, kvm

On 12/01/2018 13:33, Christoffer Dall wrote:
> Hi Paolo and Radim,
> 
> This is the third round of fixes for KVM/ARM for v4.15, including two more
> fixes for v4.15 fixing incorrect huge page mappings on systems using the
> contiguous hint for hugetlbfs and supporting an alternative GICv4 init
> sequence.
> 
> The following changes since commit 0eb7c33cadf6b2f1a94e58ded8b0eb89b4eba382:
> 
>   KVM: arm/arm64: Fix timer enable flow (2017-12-18 10:53:24 +0100)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvm-arm-fixes-for-v4.15-3
> 
> for you to fetch changes up to f8f85dc00b7427de6222ea3955c52512315d13cd:
> 
>   KVM: arm64: Fix GICv4 init when called from vgic_its_create (2018-01-12 11:40:21 +0100)
> 
> Thanks,
> -Christoffer
> 
> Christoffer Dall (1):
>       KVM: arm64: Fix GICv4 init when called from vgic_its_create
> 
> Punit Agrawal (1):
>       KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2
> 
>  virt/kvm/arm/mmu.c            | 2 +-
>  virt/kvm/arm/vgic/vgic-init.c | 8 +++++---
>  virt/kvm/arm/vgic/vgic-v4.c   | 2 +-
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 

Oops, missed this by a few minutes. :(

We'll send it next week.

Paolo

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

end of thread, other threads:[~2018-01-12 12:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-12 12:33 [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3 Christoffer Dall
2018-01-12 12:33 ` [PULL 1/2] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Christoffer Dall
2018-01-12 12:33 ` [PULL 2/2] KVM: arm64: Fix GICv4 init when called from vgic_its_create Christoffer Dall
2018-01-12 12:59 ` [PULL 0/2] KVM/ARM Fixes for v4.15 - Round 3 Paolo Bonzini

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