[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 12/20] kvm: arm64: Add helper for loading the sta
From: |
Suzuki K Poulose |
Subject: |
[Qemu-devel] [PATCH v3 12/20] kvm: arm64: Add helper for loading the stage2 setting for a VM |
Date: |
Fri, 29 Jun 2018 12:15:32 +0100 |
We load the stage2 context of a guest for different operations,
including running the guest and tlb maintenance on behalf of the
guest. As of now only the vttbr is private to the guest, but this
is about to change with IPA per VM. Add a helper to load the stage2
configuration for a VM, which could do the right thing with the
future changes.
Cc: Christoffer Dall <address@hidden>
Cc: Marc Zyngier <address@hidden>
Signed-off-by: Suzuki K Poulose <address@hidden>
---
Changes since v2:
- New patch
---
arch/arm64/include/asm/kvm_hyp.h | 6 ++++++
arch/arm64/kvm/hyp/switch.c | 2 +-
arch/arm64/kvm/hyp/tlb.c | 4 ++--
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h
index 384c343..82f9994 100644
--- a/arch/arm64/include/asm/kvm_hyp.h
+++ b/arch/arm64/include/asm/kvm_hyp.h
@@ -155,5 +155,11 @@ void deactivate_traps_vhe_put(void);
u64 __guest_enter(struct kvm_vcpu *vcpu, struct kvm_cpu_context *host_ctxt);
void __noreturn __hyp_do_panic(unsigned long, ...);
+/* Must be called from hyp code running at EL2 */
+static __always_inline void __hyp_text __load_guest_stage2(struct kvm *kvm)
+{
+ write_sysreg(kvm->arch.vttbr, vttbr_el2);
+}
+
#endif /* __ARM64_KVM_HYP_H__ */
diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
index d496ef5..355fb25 100644
--- a/arch/arm64/kvm/hyp/switch.c
+++ b/arch/arm64/kvm/hyp/switch.c
@@ -195,7 +195,7 @@ void deactivate_traps_vhe_put(void)
static void __hyp_text __activate_vm(struct kvm *kvm)
{
- write_sysreg(kvm->arch.vttbr, vttbr_el2);
+ __load_guest_stage2(kvm);
}
static void __hyp_text __deactivate_vm(struct kvm_vcpu *vcpu)
diff --git a/arch/arm64/kvm/hyp/tlb.c b/arch/arm64/kvm/hyp/tlb.c
index 131c777..4dbd9c6 100644
--- a/arch/arm64/kvm/hyp/tlb.c
+++ b/arch/arm64/kvm/hyp/tlb.c
@@ -30,7 +30,7 @@ static void __hyp_text __tlb_switch_to_guest_vhe(struct kvm
*kvm)
* bits. Changing E2H is impossible (goodbye TTBR1_EL2), so
* let's flip TGE before executing the TLB operation.
*/
- write_sysreg(kvm->arch.vttbr, vttbr_el2);
+ __load_guest_stage2(kvm);
val = read_sysreg(hcr_el2);
val &= ~HCR_TGE;
write_sysreg(val, hcr_el2);
@@ -39,7 +39,7 @@ static void __hyp_text __tlb_switch_to_guest_vhe(struct kvm
*kvm)
static void __hyp_text __tlb_switch_to_guest_nvhe(struct kvm *kvm)
{
- write_sysreg(kvm->arch.vttbr, vttbr_el2);
+ __load_guest_stage2(kvm);
isb();
}
--
2.7.4
- [Qemu-devel] [PATCH v3 02/20] virtio: pci-legacy: Validate queue pfn, (continued)
- [Qemu-devel] [PATCH v3 02/20] virtio: pci-legacy: Validate queue pfn, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 03/20] arm64: Add a helper for PARange to physical shift conversion, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 04/20] kvm: arm64: Clean up VTCR_EL2 initialisation, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 05/20] kvm: arm/arm64: Fix stage2_flush_memslot for 4 level page table, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 06/20] kvm: arm/arm64: Remove spurious WARN_ON, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 07/20] kvm: arm/arm64: Prepare for VM specific stage2 translations, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 08/20] kvm: arm/arm64: Abstract stage2 pgd table allocation, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 10/20] kvm: arm64: Dynamic configuration of VTTBR mask, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 09/20] kvm: arm64: Make stage2 page table layout dynamic, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 11/20] kvm: arm64: Helper for computing VTCR_EL2.SL0, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 12/20] kvm: arm64: Add helper for loading the stage2 setting for a VM,
Suzuki K Poulose <=
- [Qemu-devel] [PATCH v3 14/20] kvm: arm/arm64: Expose supported physical address limit for VM, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 13/20] kvm: arm64: Configure VTCR per VM, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 15/20] kvm: arm/arm64: Allow tuning the physical address size for VM, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 16/20] kvm: arm64: Switch to per VM IPA limit, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 18/20] kvm: arm64: Add support for handling 52bit IPA, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 17/20] vgic: Add support for 52bit guest physical address, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 19/20] kvm: arm64: Allow IPA size supported by the system, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [kvmtool test PATCH 22/24] kvmtool: arm64: Add support for guest physical address size, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [PATCH v3 20/20] kvm: arm64: Fall back to normal stage2 entry level, Suzuki K Poulose, 2018/06/29
- [Qemu-devel] [kvmtool test PATCH 23/24] kvmtool: arm64: Switch memory layout, Suzuki K Poulose, 2018/06/29