linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3
@ 2014-08-29  9:59 Christoffer Dall
  2014-08-29  9:59 ` [GIT PULL 1/2] ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU Christoffer Dall
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christoffer Dall @ 2014-08-29  9:59 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Paolo and Gleb,

The following changes since commit 30d1e0e806e5b2fadc297ba78f2d7afd6ba309cf:

  virt/kvm/assigned-dev.c: Set 'dev->irq_source_id' to '-1' after free it (2014-08-19 15:12:28 +0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvm-arm-for-v3.17-rc3

for you to fetch changes up to 05e0127f9e362b36aa35f17b1a3d52bca9322a3a:

  arm/arm64: KVM: Complete WFI/WFE instructions (2014-08-29 11:53:53 +0200)

Thanks,
-Christoffer

----------------------------------------------------------------
These fixes fix two issues in KVM for arm/arm64:
 - hyp mode initialization issues on certian boards/bootloader combos.
 - incorrect return address from trapped WFI/WFE instrucitons, which
   breaks non-linux guests.

----------------------------------------------------------------
Christoffer Dall (1):
      arm/arm64: KVM: Complete WFI/WFE instructions

Pranavkumar Sawargaonkar (1):
      ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU

 arch/arm/kvm/handle_exit.c   | 2 ++
 arch/arm/kvm/init.S          | 4 ++++
 arch/arm64/kvm/handle_exit.c | 2 ++
 arch/arm64/kvm/hyp-init.S    | 4 ++++
 4 files changed, 12 insertions(+)

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

* [GIT PULL 1/2] ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU
  2014-08-29  9:59 [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3 Christoffer Dall
@ 2014-08-29  9:59 ` Christoffer Dall
  2014-08-29  9:59 ` [GIT PULL 2/2] arm/arm64: KVM: Complete WFI/WFE instructions Christoffer Dall
  2014-08-29 10:26 ` [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3 Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Christoffer Dall @ 2014-08-29  9:59 UTC (permalink / raw)
  To: linux-arm-kernel

From: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>

X-Gene u-boot runs in EL2 mode with MMU enabled hence we might
have stale EL2 tlb enteris when we enable EL2 MMU on each host CPU.

This can happen on any ARM/ARM64 board running bootloader in
Hyp-mode (or EL2-mode) with MMU enabled.

This patch ensures that we flush all Hyp-mode (or EL2-mode) TLBs
on each host CPU before enabling Hyp-mode (or EL2-mode) MMU.

Cc: <stable@vger.kernel.org>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 arch/arm/kvm/init.S       | 4 ++++
 arch/arm64/kvm/hyp-init.S | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S
index 991415d..3988e72 100644
--- a/arch/arm/kvm/init.S
+++ b/arch/arm/kvm/init.S
@@ -99,6 +99,10 @@ __do_hyp_init:
 	mrc	p15, 0, r0, c10, c2, 1
 	mcr	p15, 4, r0, c10, c2, 1
 
+	@ Invalidate the stale TLBs from Bootloader
+	mcr	p15, 4, r0, c8, c7, 0	@ TLBIALLH
+	dsb	ish
+
 	@ Set the HSCTLR to:
 	@  - ARM/THUMB exceptions: Kernel config (Thumb-2 kernel)
 	@  - Endianness: Kernel config
diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S
index d968796..c319116 100644
--- a/arch/arm64/kvm/hyp-init.S
+++ b/arch/arm64/kvm/hyp-init.S
@@ -80,6 +80,10 @@ __do_hyp_init:
 	msr	mair_el2, x4
 	isb
 
+	/* Invalidate the stale TLBs from Bootloader */
+	tlbi	alle2
+	dsb	sy
+
 	mrs	x4, sctlr_el2
 	and	x4, x4, #SCTLR_EL2_EE	// preserve endianness of EL2
 	ldr	x5, =SCTLR_EL2_FLAGS
-- 
2.0.0

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

* [GIT PULL 2/2] arm/arm64: KVM: Complete WFI/WFE instructions
  2014-08-29  9:59 [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3 Christoffer Dall
  2014-08-29  9:59 ` [GIT PULL 1/2] ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU Christoffer Dall
@ 2014-08-29  9:59 ` Christoffer Dall
  2014-08-29 10:26 ` [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3 Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Christoffer Dall @ 2014-08-29  9:59 UTC (permalink / raw)
  To: linux-arm-kernel

The architecture specifies that when the processor wakes up from a WFE
or WFI instruction, the instruction is considered complete, however we
currrently return to EL1 (or EL0) at the WFI/WFE instruction itself.

While most guests may not be affected by this because their local
exception handler performs an exception returning setting the event bit
or with an interrupt pending, some guests like UEFI will get wedged due
this little mishap.

Simply skip the instruction when we have completed the emulation.

Cc: <stable@vger.kernel.org>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 arch/arm/kvm/handle_exit.c   | 2 ++
 arch/arm64/kvm/handle_exit.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c
index 4c979d4..a96a804 100644
--- a/arch/arm/kvm/handle_exit.c
+++ b/arch/arm/kvm/handle_exit.c
@@ -93,6 +93,8 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
 	else
 		kvm_vcpu_block(vcpu);
 
+	kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
+
 	return 1;
 }
 
diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index e28be51..34b8bd0 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -66,6 +66,8 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
 	else
 		kvm_vcpu_block(vcpu);
 
+	kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
+
 	return 1;
 }
 
-- 
2.0.0

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

* [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3
  2014-08-29  9:59 [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3 Christoffer Dall
  2014-08-29  9:59 ` [GIT PULL 1/2] ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU Christoffer Dall
  2014-08-29  9:59 ` [GIT PULL 2/2] arm/arm64: KVM: Complete WFI/WFE instructions Christoffer Dall
@ 2014-08-29 10:26 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2014-08-29 10:26 UTC (permalink / raw)
  To: linux-arm-kernel

Il 29/08/2014 11:59, Christoffer Dall ha scritto:
> Hi Paolo and Gleb,
> 
> The following changes since commit 30d1e0e806e5b2fadc297ba78f2d7afd6ba309cf:
> 
>   virt/kvm/assigned-dev.c: Set 'dev->irq_source_id' to '-1' after free it (2014-08-19 15:12:28 +0200)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvm-arm-for-v3.17-rc3
> 
> for you to fetch changes up to 05e0127f9e362b36aa35f17b1a3d52bca9322a3a:
> 
>   arm/arm64: KVM: Complete WFI/WFE instructions (2014-08-29 11:53:53 +0200)
> 
> Thanks,
> -Christoffer
> 
> ----------------------------------------------------------------
> These fixes fix two issues in KVM for arm/arm64:
>  - hyp mode initialization issues on certian boards/bootloader combos.
>  - incorrect return address from trapped WFI/WFE instrucitons, which
>    breaks non-linux guests.
> 
> ----------------------------------------------------------------
> Christoffer Dall (1):
>       arm/arm64: KVM: Complete WFI/WFE instructions
> 
> Pranavkumar Sawargaonkar (1):
>       ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU
> 
>  arch/arm/kvm/handle_exit.c   | 2 ++
>  arch/arm/kvm/init.S          | 4 ++++
>  arch/arm64/kvm/handle_exit.c | 2 ++
>  arch/arm64/kvm/hyp-init.S    | 4 ++++
>  4 files changed, 12 insertions(+)
> --
> 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
> 

Thanks, picked this up.

Paolo

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

end of thread, other threads:[~2014-08-29 10:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-29  9:59 [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3 Christoffer Dall
2014-08-29  9:59 ` [GIT PULL 1/2] ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU Christoffer Dall
2014-08-29  9:59 ` [GIT PULL 2/2] arm/arm64: KVM: Complete WFI/WFE instructions Christoffer Dall
2014-08-29 10:26 ` [GIT PULL 0/2] KVM/ARM Fixes for v3.17-rc3 Paolo Bonzini

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