Skip to content

Commit 7e7a7bf

Browse files
committed
Merge tag 'kvmarm-fixes-6.16-5' of https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.16, take # - Remove the last leftovers from the ill-fated FPSIMD host state mapping at EL2 stage-1 - Fix unexpected advertisement to the guest of unimplemented S2 base granule sizes
2 parents 8aed168 + 42ce432 commit 7e7a7bf

File tree

4 files changed

+23
-34
lines changed

4 files changed

+23
-34
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,6 @@ int kvm_vm_ioctl_get_reg_writable_masks(struct kvm *kvm,
14801480
struct reg_mask_range *range);
14811481

14821482
/* Guest/host FPSIMD coordination helpers */
1483-
int kvm_arch_vcpu_run_map_fp(struct kvm_vcpu *vcpu);
14841483
void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu);
14851484
void kvm_arch_vcpu_ctxflush_fp(struct kvm_vcpu *vcpu);
14861485
void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu);

arch/arm64/kvm/arm.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,10 +825,6 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
825825
if (!kvm_arm_vcpu_is_finalized(vcpu))
826826
return -EPERM;
827827

828-
ret = kvm_arch_vcpu_run_map_fp(vcpu);
829-
if (ret)
830-
return ret;
831-
832828
if (likely(vcpu_has_run_once(vcpu)))
833829
return 0;
834830

arch/arm64/kvm/fpsimd.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,6 @@
1414
#include <asm/kvm_mmu.h>
1515
#include <asm/sysreg.h>
1616

17-
/*
18-
* Called on entry to KVM_RUN unless this vcpu previously ran at least
19-
* once and the most recent prior KVM_RUN for this vcpu was called from
20-
* the same task as current (highly likely).
21-
*
22-
* This is guaranteed to execute before kvm_arch_vcpu_load_fp(vcpu),
23-
* such that on entering hyp the relevant parts of current are already
24-
* mapped.
25-
*/
26-
int kvm_arch_vcpu_run_map_fp(struct kvm_vcpu *vcpu)
27-
{
28-
struct user_fpsimd_state *fpsimd = &current->thread.uw.fpsimd_state;
29-
int ret;
30-
31-
/* pKVM has its own tracking of the host fpsimd state. */
32-
if (is_protected_kvm_enabled())
33-
return 0;
34-
35-
/* Make sure the host task fpsimd state is visible to hyp: */
36-
ret = kvm_share_hyp(fpsimd, fpsimd + 1);
37-
if (ret)
38-
return ret;
39-
40-
return 0;
41-
}
42-
4317
/*
4418
* Prepare vcpu for saving the host's FPSIMD state and loading the guest's.
4519
* The actual loading is done by the FPSIMD access trap taken to hyp.

arch/arm64/kvm/nested.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,21 @@ static void kvm_map_l1_vncr(struct kvm_vcpu *vcpu)
14021402
}
14031403
}
14041404

1405+
#define has_tgran_2(__r, __sz) \
1406+
({ \
1407+
u64 _s1, _s2, _mmfr0 = __r; \
1408+
\
1409+
_s2 = SYS_FIELD_GET(ID_AA64MMFR0_EL1, \
1410+
TGRAN##__sz##_2, _mmfr0); \
1411+
\
1412+
_s1 = SYS_FIELD_GET(ID_AA64MMFR0_EL1, \
1413+
TGRAN##__sz, _mmfr0); \
1414+
\
1415+
((_s2 != ID_AA64MMFR0_EL1_TGRAN##__sz##_2_NI && \
1416+
_s2 != ID_AA64MMFR0_EL1_TGRAN##__sz##_2_TGRAN##__sz) || \
1417+
(_s2 == ID_AA64MMFR0_EL1_TGRAN##__sz##_2_TGRAN##__sz && \
1418+
_s1 != ID_AA64MMFR0_EL1_TGRAN##__sz##_NI)); \
1419+
})
14051420
/*
14061421
* Our emulated CPU doesn't support all the possible features. For the
14071422
* sake of simplicity (and probably mental sanity), wipe out a number
@@ -1411,6 +1426,8 @@ static void kvm_map_l1_vncr(struct kvm_vcpu *vcpu)
14111426
*/
14121427
u64 limit_nv_id_reg(struct kvm *kvm, u32 reg, u64 val)
14131428
{
1429+
u64 orig_val = val;
1430+
14141431
switch (reg) {
14151432
case SYS_ID_AA64ISAR0_EL1:
14161433
/* Support everything but TME */
@@ -1480,13 +1497,16 @@ u64 limit_nv_id_reg(struct kvm *kvm, u32 reg, u64 val)
14801497
*/
14811498
switch (PAGE_SIZE) {
14821499
case SZ_4K:
1483-
val |= SYS_FIELD_PREP_ENUM(ID_AA64MMFR0_EL1, TGRAN4_2, IMP);
1500+
if (has_tgran_2(orig_val, 4))
1501+
val |= SYS_FIELD_PREP_ENUM(ID_AA64MMFR0_EL1, TGRAN4_2, IMP);
14841502
fallthrough;
14851503
case SZ_16K:
1486-
val |= SYS_FIELD_PREP_ENUM(ID_AA64MMFR0_EL1, TGRAN16_2, IMP);
1504+
if (has_tgran_2(orig_val, 16))
1505+
val |= SYS_FIELD_PREP_ENUM(ID_AA64MMFR0_EL1, TGRAN16_2, IMP);
14871506
fallthrough;
14881507
case SZ_64K:
1489-
val |= SYS_FIELD_PREP_ENUM(ID_AA64MMFR0_EL1, TGRAN64_2, IMP);
1508+
if (has_tgran_2(orig_val, 64))
1509+
val |= SYS_FIELD_PREP_ENUM(ID_AA64MMFR0_EL1, TGRAN64_2, IMP);
14901510
break;
14911511
}
14921512

0 commit comments

Comments
 (0)