[PATCH v4 2/3] arm64: KVM: Enable Common Not Private translations
From: catalin.marinas@arm.com (Catalin Marinas)
Date: 2018-05-23 17:11:44
From: catalin.marinas@arm.com (Catalin Marinas)
Date: 2018-05-23 17:11:44
On Fri, May 18, 2018 at 11:07:01AM +0100, Vladimir Murzin wrote:
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index a4c1b76..9a651a2 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c@@ -472,7 +472,7 @@ static bool need_new_vmid_gen(struct kvm *kvm) static void update_vttbr(struct kvm *kvm) { phys_addr_t pgd_phys; - u64 vmid; + u64 vmid, cnp = kvm_cpu_has_cnp() ? 1 : 0;
Please define a VTTBR_CNP_BIT here instead of a hard-coded value.
bool new_gen; read_lock(&kvm_vmid_lock);@@ -522,7 +522,7 @@ static void update_vttbr(struct kvm *kvm) pgd_phys = virt_to_phys(kvm->arch.pgd); BUG_ON(pgd_phys & ~VTTBR_BADDR_MASK); vmid = ((u64)(kvm->arch.vmid) << VTTBR_VMID_SHIFT) & VTTBR_VMID_MASK(kvm_vmid_bits); - kvm->arch.vttbr = kvm_phys_to_vttbr(pgd_phys) | vmid; + kvm->arch.vttbr = kvm_phys_to_vttbr(pgd_phys) | vmid | cnp; write_unlock(&kvm_vmid_lock); }
-- Catalin