Skip to content

Commit 959d6c4

Browse files
committed
Merge tag 'kvmarm-fixes-6.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.0, take #1 - Fix unexpected sign extension of KVM_ARM_DEVICE_ID_MASK - Tidy-up handling of AArch32 on asymmetric systems
2 parents eceb6e1 + b10d86f commit 959d6c4

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

arch/arm64/include/asm/kvm_host.h

+4
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,10 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu);
929929
(system_supports_mte() && \
930930
test_bit(KVM_ARCH_FLAG_MTE_ENABLED, &(kvm)->arch.flags))
931931

932+
#define kvm_supports_32bit_el0() \
933+
(system_supports_32bit_el0() && \
934+
!static_branch_unlikely(&arm64_mismatched_32bit_el0))
935+
932936
int kvm_trng_call(struct kvm_vcpu *vcpu);
933937
#ifdef CONFIG_KVM
934938
extern phys_addr_t hyp_mem_base;

arch/arm64/include/uapi/asm/kvm.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ struct kvm_regs {
7575

7676
/* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
7777
#define KVM_ARM_DEVICE_TYPE_SHIFT 0
78-
#define KVM_ARM_DEVICE_TYPE_MASK (0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
78+
#define KVM_ARM_DEVICE_TYPE_MASK GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
79+
KVM_ARM_DEVICE_TYPE_SHIFT)
7980
#define KVM_ARM_DEVICE_ID_SHIFT 16
80-
#define KVM_ARM_DEVICE_ID_MASK (0xffff << KVM_ARM_DEVICE_ID_SHIFT)
81+
#define KVM_ARM_DEVICE_ID_MASK GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
82+
KVM_ARM_DEVICE_ID_SHIFT)
8183

8284
/* Supported device IDs */
8385
#define KVM_ARM_DEVICE_VGIC_V2 0

arch/arm64/kvm/arm.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,7 @@ static bool vcpu_mode_is_bad_32bit(struct kvm_vcpu *vcpu)
757757
if (likely(!vcpu_mode_is_32bit(vcpu)))
758758
return false;
759759

760-
return !system_supports_32bit_el0() ||
761-
static_branch_unlikely(&arm64_mismatched_32bit_el0);
760+
return !kvm_supports_32bit_el0();
762761
}
763762

764763
/**

arch/arm64/kvm/guest.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
242242
u64 mode = (*(u64 *)valp) & PSR_AA32_MODE_MASK;
243243
switch (mode) {
244244
case PSR_AA32_MODE_USR:
245-
if (!system_supports_32bit_el0())
245+
if (!kvm_supports_32bit_el0())
246246
return -EINVAL;
247247
break;
248248
case PSR_AA32_MODE_FIQ:

arch/arm64/kvm/sys_regs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
652652
*/
653653
val = ((pmcr & ~ARMV8_PMU_PMCR_MASK)
654654
| (ARMV8_PMU_PMCR_MASK & 0xdecafbad)) & (~ARMV8_PMU_PMCR_E);
655-
if (!system_supports_32bit_el0())
655+
if (!kvm_supports_32bit_el0())
656656
val |= ARMV8_PMU_PMCR_LC;
657657
__vcpu_sys_reg(vcpu, r->reg) = val;
658658
}
@@ -701,7 +701,7 @@ static bool access_pmcr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
701701
val = __vcpu_sys_reg(vcpu, PMCR_EL0);
702702
val &= ~ARMV8_PMU_PMCR_MASK;
703703
val |= p->regval & ARMV8_PMU_PMCR_MASK;
704-
if (!system_supports_32bit_el0())
704+
if (!kvm_supports_32bit_el0())
705705
val |= ARMV8_PMU_PMCR_LC;
706706
__vcpu_sys_reg(vcpu, PMCR_EL0) = val;
707707
kvm_pmu_handle_pmcr(vcpu, val);

0 commit comments

Comments
 (0)