Skip to content

Commit 1eb07f4

Browse files
author
Marc Zyngier
committed
Merge branch kvm-arm64/raz-sysregs into kvmarm-master/next
* kvm-arm64/raz-sysregs: : . : Simplify the handling of RAZ register, removing pointless indirections. : . KVM: arm64: Replace get_raz_id_reg() with get_raz_reg() KVM: arm64: Use get_raz_reg() for userspace reads of PMSWINC_EL0 KVM: arm64: Return early from read_id_reg() if register is RAZ Signed-off-by: Marc Zyngier <[email protected]>
2 parents a049cf7 + ebf6aa8 commit 1eb07f4

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,12 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu,
10641064
struct sys_reg_desc const *r, bool raz)
10651065
{
10661066
u32 id = reg_to_encoding(r);
1067-
u64 val = raz ? 0 : read_sanitised_ftr_reg(id);
1067+
u64 val;
1068+
1069+
if (raz)
1070+
return 0;
1071+
1072+
val = read_sanitised_ftr_reg(id);
10681073

10691074
switch (id) {
10701075
case SYS_ID_AA64PFR0_EL1:
@@ -1268,16 +1273,19 @@ static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
12681273
return __set_id_reg(vcpu, rd, uaddr, raz);
12691274
}
12701275

1271-
static int get_raz_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
1276+
static int set_raz_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
12721277
const struct kvm_one_reg *reg, void __user *uaddr)
12731278
{
1274-
return __get_id_reg(vcpu, rd, uaddr, true);
1279+
return __set_id_reg(vcpu, rd, uaddr, true);
12751280
}
12761281

1277-
static int set_raz_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
1278-
const struct kvm_one_reg *reg, void __user *uaddr)
1282+
static int get_raz_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
1283+
const struct kvm_one_reg *reg, void __user *uaddr)
12791284
{
1280-
return __set_id_reg(vcpu, rd, uaddr, true);
1285+
const u64 id = sys_reg_to_index(rd);
1286+
const u64 val = 0;
1287+
1288+
return reg_to_user(uaddr, &val, id);
12811289
}
12821290

12831291
static int set_wi_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
@@ -1388,7 +1396,7 @@ static unsigned int mte_visibility(const struct kvm_vcpu *vcpu,
13881396
#define ID_UNALLOCATED(crm, op2) { \
13891397
Op0(3), Op1(0), CRn(0), CRm(crm), Op2(op2), \
13901398
.access = access_raz_id_reg, \
1391-
.get_user = get_raz_id_reg, \
1399+
.get_user = get_raz_reg, \
13921400
.set_user = set_raz_id_reg, \
13931401
}
13941402

@@ -1400,7 +1408,7 @@ static unsigned int mte_visibility(const struct kvm_vcpu *vcpu,
14001408
#define ID_HIDDEN(name) { \
14011409
SYS_DESC(SYS_##name), \
14021410
.access = access_raz_id_reg, \
1403-
.get_user = get_raz_id_reg, \
1411+
.get_user = get_raz_reg, \
14041412
.set_user = set_raz_id_reg, \
14051413
}
14061414

@@ -1642,7 +1650,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
16421650
* previously (and pointlessly) advertised in the past...
16431651
*/
16441652
{ PMU_SYS_REG(SYS_PMSWINC_EL0),
1645-
.get_user = get_raz_id_reg, .set_user = set_wi_reg,
1653+
.get_user = get_raz_reg, .set_user = set_wi_reg,
16461654
.access = access_pmswinc, .reset = NULL },
16471655
{ PMU_SYS_REG(SYS_PMSELR_EL0),
16481656
.access = access_pmselr, .reset = reset_pmselr, .reg = PMSELR_EL0 },

0 commit comments

Comments
 (0)