Skip to content

Commit 564ad0a

Browse files
committed
Merge tag 'kvm-arm-fixes-for-v4.19-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm
Fixes for KVM/ARM for Linux v4.19 v2: - Fix a VFP corruption in 32-bit guest - Add missing cache invalidation for CoW pages - Two small cleanups
2 parents ed2ef29 + df3190e commit 564ad0a

File tree

9 files changed

+15
-52
lines changed

9 files changed

+15
-52
lines changed

arch/arm/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
223223
struct kvm_vcpu_events *events);
224224

225225
#define KVM_ARCH_WANT_MMU_NOTIFIER
226-
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
227226
int kvm_unmap_hva_range(struct kvm *kvm,
228227
unsigned long start, unsigned long end);
229228
void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ struct kvm_arch {
6161
u64 vmid_gen;
6262
u32 vmid;
6363

64-
/* 1-level 2nd stage table and lock */
65-
spinlock_t pgd_lock;
64+
/* 1-level 2nd stage table, protected by kvm->mmu_lock */
6665
pgd_t *pgd;
6766

6867
/* VTTBR value associated with above pgd and vmid */
@@ -357,7 +356,6 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
357356
struct kvm_vcpu_events *events);
358357

359358
#define KVM_ARCH_WANT_MMU_NOTIFIER
360-
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
361359
int kvm_unmap_hva_range(struct kvm *kvm,
362360
unsigned long start, unsigned long end);
363361
void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);

arch/arm64/kvm/hyp/switch.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ static void activate_traps_vhe(struct kvm_vcpu *vcpu)
9898
val = read_sysreg(cpacr_el1);
9999
val |= CPACR_EL1_TTA;
100100
val &= ~CPACR_EL1_ZEN;
101-
if (!update_fp_enabled(vcpu))
101+
if (!update_fp_enabled(vcpu)) {
102102
val &= ~CPACR_EL1_FPEN;
103+
__activate_traps_fpsimd32(vcpu);
104+
}
103105

104106
write_sysreg(val, cpacr_el1);
105107

@@ -114,8 +116,10 @@ static void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu)
114116

115117
val = CPTR_EL2_DEFAULT;
116118
val |= CPTR_EL2_TTA | CPTR_EL2_TZ;
117-
if (!update_fp_enabled(vcpu))
119+
if (!update_fp_enabled(vcpu)) {
118120
val |= CPTR_EL2_TFP;
121+
__activate_traps_fpsimd32(vcpu);
122+
}
119123

120124
write_sysreg(val, cptr_el2);
121125
}
@@ -129,7 +133,6 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
129133
if (cpus_have_const_cap(ARM64_HAS_RAS_EXTN) && (hcr & HCR_VSE))
130134
write_sysreg_s(vcpu->arch.vsesr_el2, SYS_VSESR_EL2);
131135

132-
__activate_traps_fpsimd32(vcpu);
133136
if (has_vhe())
134137
activate_traps_vhe(vcpu);
135138
else

arch/mips/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,6 @@ enum kvm_mips_fault_result kvm_trap_emul_gva_fault(struct kvm_vcpu *vcpu,
931931
bool write);
932932

933933
#define KVM_ARCH_WANT_MMU_NOTIFIER
934-
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
935934
int kvm_unmap_hva_range(struct kvm *kvm,
936935
unsigned long start, unsigned long end);
937936
void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);

arch/mips/kvm/mmu.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -512,16 +512,6 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gfn_t gfn, gfn_t gfn_end,
512512
return 1;
513513
}
514514

515-
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
516-
{
517-
unsigned long end = hva + PAGE_SIZE;
518-
519-
handle_hva_to_gpa(kvm, hva, end, &kvm_unmap_hva_handler, NULL);
520-
521-
kvm_mips_callbacks->flush_shadow_all(kvm);
522-
return 0;
523-
}
524-
525515
int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
526516
{
527517
handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL);

arch/x86/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,6 @@ asmlinkage void kvm_spurious_fault(void);
14431443
____kvm_handle_fault_on_reboot(insn, "")
14441444

14451445
#define KVM_ARCH_WANT_MMU_NOTIFIER
1446-
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
14471446
int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end);
14481447
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
14491448
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);

arch/x86/kvm/mmu.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,11 +1853,6 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
18531853
return kvm_handle_hva_range(kvm, hva, hva + 1, data, handler);
18541854
}
18551855

1856-
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
1857-
{
1858-
return kvm_handle_hva(kvm, hva, 0, kvm_unmap_rmapp);
1859-
}
1860-
18611856
int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
18621857
{
18631858
return kvm_handle_hva_range(kvm, start, end, 0, kvm_unmap_rmapp);

virt/kvm/arm/mmu.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,18 +1817,6 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *dat
18171817
return 0;
18181818
}
18191819

1820-
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
1821-
{
1822-
unsigned long end = hva + PAGE_SIZE;
1823-
1824-
if (!kvm->arch.pgd)
1825-
return 0;
1826-
1827-
trace_kvm_unmap_hva(hva);
1828-
handle_hva_to_gpa(kvm, hva, end, &kvm_unmap_hva_handler, NULL);
1829-
return 0;
1830-
}
1831-
18321820
int kvm_unmap_hva_range(struct kvm *kvm,
18331821
unsigned long start, unsigned long end)
18341822
{
@@ -1860,13 +1848,20 @@ static int kvm_set_spte_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data
18601848
void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
18611849
{
18621850
unsigned long end = hva + PAGE_SIZE;
1851+
kvm_pfn_t pfn = pte_pfn(pte);
18631852
pte_t stage2_pte;
18641853

18651854
if (!kvm->arch.pgd)
18661855
return;
18671856

18681857
trace_kvm_set_spte_hva(hva);
1869-
stage2_pte = pfn_pte(pte_pfn(pte), PAGE_S2);
1858+
1859+
/*
1860+
* We've moved a page around, probably through CoW, so let's treat it
1861+
* just like a translation fault and clean the cache to the PoC.
1862+
*/
1863+
clean_dcache_guest_page(pfn, PAGE_SIZE);
1864+
stage2_pte = pfn_pte(pfn, PAGE_S2);
18701865
handle_hva_to_gpa(kvm, hva, end, &kvm_set_spte_handler, &stage2_pte);
18711866
}
18721867

virt/kvm/arm/trace.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,6 @@ TRACE_EVENT(kvm_mmio_emulate,
134134
__entry->vcpu_pc, __entry->instr, __entry->cpsr)
135135
);
136136

137-
TRACE_EVENT(kvm_unmap_hva,
138-
TP_PROTO(unsigned long hva),
139-
TP_ARGS(hva),
140-
141-
TP_STRUCT__entry(
142-
__field( unsigned long, hva )
143-
),
144-
145-
TP_fast_assign(
146-
__entry->hva = hva;
147-
),
148-
149-
TP_printk("mmu notifier unmap hva: %#08lx", __entry->hva)
150-
);
151-
152137
TRACE_EVENT(kvm_unmap_hva_range,
153138
TP_PROTO(unsigned long start, unsigned long end),
154139
TP_ARGS(start, end),

0 commit comments

Comments
 (0)