Skip to content

Commit d741dca

Browse files
committed
Merge tag 'kvmarm-fixes-5.8-4' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into kvm-master
KVM/arm64 fixes for Linux 5.8, take #3 - Fix a corner case of a new mapping inheriting exec permission without and yet bypassing invalidation of the I-cache - Make sure PtrAuth predicates oinly generate inline code for the non-VHE hypervisor code
2 parents 5e105c8 + b757b47 commit d741dca

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,14 @@ struct kvm_vcpu_arch {
380380
#define vcpu_has_sve(vcpu) (system_supports_sve() && \
381381
((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_SVE))
382382

383-
#define vcpu_has_ptrauth(vcpu) ((system_supports_address_auth() || \
384-
system_supports_generic_auth()) && \
385-
((vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_PTRAUTH))
383+
#ifdef CONFIG_ARM64_PTR_AUTH
384+
#define vcpu_has_ptrauth(vcpu) \
385+
((cpus_have_final_cap(ARM64_HAS_ADDRESS_AUTH) || \
386+
cpus_have_final_cap(ARM64_HAS_GENERIC_AUTH)) && \
387+
(vcpu)->arch.flags & KVM_ARM64_GUEST_HAS_PTRAUTH)
388+
#else
389+
#define vcpu_has_ptrauth(vcpu) false
390+
#endif
386391

387392
#define vcpu_gp_regs(v) (&(v)->arch.ctxt.gp_regs)
388393

arch/arm64/kvm/mmu.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ static bool stage2_get_leaf_entry(struct kvm *kvm, phys_addr_t addr,
13261326
return true;
13271327
}
13281328

1329-
static bool stage2_is_exec(struct kvm *kvm, phys_addr_t addr)
1329+
static bool stage2_is_exec(struct kvm *kvm, phys_addr_t addr, unsigned long sz)
13301330
{
13311331
pud_t *pudp;
13321332
pmd_t *pmdp;
@@ -1338,11 +1338,11 @@ static bool stage2_is_exec(struct kvm *kvm, phys_addr_t addr)
13381338
return false;
13391339

13401340
if (pudp)
1341-
return kvm_s2pud_exec(pudp);
1341+
return sz <= PUD_SIZE && kvm_s2pud_exec(pudp);
13421342
else if (pmdp)
1343-
return kvm_s2pmd_exec(pmdp);
1343+
return sz <= PMD_SIZE && kvm_s2pmd_exec(pmdp);
13441344
else
1345-
return kvm_s2pte_exec(ptep);
1345+
return sz == PAGE_SIZE && kvm_s2pte_exec(ptep);
13461346
}
13471347

13481348
static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
@@ -1958,7 +1958,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
19581958
* execute permissions, and we preserve whatever we have.
19591959
*/
19601960
needs_exec = exec_fault ||
1961-
(fault_status == FSC_PERM && stage2_is_exec(kvm, fault_ipa));
1961+
(fault_status == FSC_PERM &&
1962+
stage2_is_exec(kvm, fault_ipa, vma_pagesize));
19621963

19631964
if (vma_pagesize == PUD_SIZE) {
19641965
pud_t new_pud = kvm_pfn_pud(pfn, mem_type);

0 commit comments

Comments
 (0)