From d675b172548c96d6193b37b729039b4763b11d7a Mon Sep 17 00:00:00 2001 From: Peng Liang Date: Mon, 8 Feb 2021 17:16:33 +0800 Subject: [PATCH] kvm: arm64: make ID_AA64PFR0_EL1 configurable hulk inclusion category: feature bugzilla: 48052 CVE: NA ------------------------------ Since 23711a5e662c ("KVM: arm64: Allow setting of ID_AA64PFR0_EL1.CSV2 from userspace"), ID_AA64PFR0_EL1 uses a separate set_user callback. We should remove some check in the callback to make ID_AA64PFR0_EL1 configurable. Signed-off-by: Peng Liang Reviewed-by: Zhanghailiang Signed-off-by: Zheng Zengkai --- arch/arm64/kvm/sys_regs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 1b63c0a9494c..92671bab8a08 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1249,6 +1249,8 @@ static int set_id_aa64pfr0_el1(struct kvm_vcpu *vcpu, int err; u64 val; u8 csv2; + u32 reg_id = sys_reg((u32)rd->Op0, (u32)rd->Op1, (u32)rd->CRn, + (u32)rd->CRm, (u32)rd->Op2); err = reg_from_user(&val, uaddr, id); if (err) @@ -1264,13 +1266,8 @@ static int set_id_aa64pfr0_el1(struct kvm_vcpu *vcpu, (csv2 && arm64_get_spectre_v2_state() != SPECTRE_UNAFFECTED)) return -EINVAL; - /* We can only differ with CSV2, and anything else is an error */ - val ^= read_id_reg(vcpu, rd, false); - val &= ~(0xFUL << ID_AA64PFR0_CSV2_SHIFT); - if (val) - return -EINVAL; - vcpu->kvm->arch.pfr0_csv2 = csv2; + kvm_set_id_reg(vcpu, reg_id, val); return 0; } -- GitLab