Skip to content

Commit 17a0005

Browse files
author
Marc Zyngier
committed
Merge branch kvm-arm64/visibility-cleanups into kvmarm-master/next
* kvm-arm64/visibility-cleanups: : . : Remove REG_HIDDEN_USER from the sysreg infrastructure, making things : a little more simple. From the cover letter: : : "Since 4d4f520 ("KVM: arm64: nv: Drop EL12 register traps that are : redirected to VNCR") and the admission that KVM would never be supporting : the original FEAT_NV, REG_HIDDEN_USER only had a few users, all of which : could either be replaced by a more ad-hoc mechanism, or removed altogether." : . KVM: arm64: Get rid of REG_HIDDEN_USER visibility qualifier KVM: arm64: Simplify visibility handling of AArch32 SPSR_* KVM: arm64: Simplify handling of CNTKCTL_EL12 Signed-off-by: Marc Zyngier <[email protected]>
2 parents f625469 + 0746096 commit 17a0005

File tree

2 files changed

+22
-44
lines changed

2 files changed

+22
-44
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,26 +2094,6 @@ static bool bad_redir_trap(struct kvm_vcpu *vcpu,
20942094
#define EL2_REG_VNCR(name, rst, v) EL2_REG(name, bad_vncr_trap, rst, v)
20952095
#define EL2_REG_REDIR(name, rst, v) EL2_REG(name, bad_redir_trap, rst, v)
20962096

2097-
/*
2098-
* EL{0,1}2 registers are the EL2 view on an EL0 or EL1 register when
2099-
* HCR_EL2.E2H==1, and only in the sysreg table for convenience of
2100-
* handling traps. Given that, they are always hidden from userspace.
2101-
*/
2102-
static unsigned int hidden_user_visibility(const struct kvm_vcpu *vcpu,
2103-
const struct sys_reg_desc *rd)
2104-
{
2105-
return REG_HIDDEN_USER;
2106-
}
2107-
2108-
#define EL12_REG(name, acc, rst, v) { \
2109-
SYS_DESC(SYS_##name##_EL12), \
2110-
.access = acc, \
2111-
.reset = rst, \
2112-
.reg = name##_EL1, \
2113-
.val = v, \
2114-
.visibility = hidden_user_visibility, \
2115-
}
2116-
21172097
/*
21182098
* Since reset() callback and field val are not used for idregs, they will be
21192099
* used for specific purposes for idregs.
@@ -2221,6 +2201,18 @@ static bool access_spsr(struct kvm_vcpu *vcpu,
22212201
return true;
22222202
}
22232203

2204+
static bool access_cntkctl_el12(struct kvm_vcpu *vcpu,
2205+
struct sys_reg_params *p,
2206+
const struct sys_reg_desc *r)
2207+
{
2208+
if (p->is_write)
2209+
__vcpu_sys_reg(vcpu, CNTKCTL_EL1) = p->regval;
2210+
else
2211+
p->regval = __vcpu_sys_reg(vcpu, CNTKCTL_EL1);
2212+
2213+
return true;
2214+
}
2215+
22242216
static u64 reset_hcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
22252217
{
22262218
u64 val = r->val;
@@ -2792,14 +2784,10 @@ static const struct sys_reg_desc sys_reg_descs[] = {
27922784
{ SYS_DESC(SYS_SP_EL1), access_sp_el1},
27932785

27942786
/* AArch32 SPSR_* are RES0 if trapped from a NV guest */
2795-
{ SYS_DESC(SYS_SPSR_irq), .access = trap_raz_wi,
2796-
.visibility = hidden_user_visibility },
2797-
{ SYS_DESC(SYS_SPSR_abt), .access = trap_raz_wi,
2798-
.visibility = hidden_user_visibility },
2799-
{ SYS_DESC(SYS_SPSR_und), .access = trap_raz_wi,
2800-
.visibility = hidden_user_visibility },
2801-
{ SYS_DESC(SYS_SPSR_fiq), .access = trap_raz_wi,
2802-
.visibility = hidden_user_visibility },
2787+
{ SYS_DESC(SYS_SPSR_irq), .access = trap_raz_wi },
2788+
{ SYS_DESC(SYS_SPSR_abt), .access = trap_raz_wi },
2789+
{ SYS_DESC(SYS_SPSR_und), .access = trap_raz_wi },
2790+
{ SYS_DESC(SYS_SPSR_fiq), .access = trap_raz_wi },
28032791

28042792
{ SYS_DESC(SYS_IFSR32_EL2), undef_access, reset_unknown, IFSR32_EL2 },
28052793
EL2_REG(AFSR0_EL2, access_rw, reset_val, 0),
@@ -2825,7 +2813,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
28252813
EL2_REG_VNCR(CNTVOFF_EL2, reset_val, 0),
28262814
EL2_REG(CNTHCTL_EL2, access_rw, reset_val, 0),
28272815

2828-
EL12_REG(CNTKCTL, access_rw, reset_val, 0),
2816+
{ SYS_DESC(SYS_CNTKCTL_EL12), access_cntkctl_el12 },
28292817

28302818
EL2_REG(SP_EL2, NULL, reset_unknown, 0),
28312819
};
@@ -4365,7 +4353,7 @@ int kvm_sys_reg_get_user(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg,
43654353
int ret;
43664354

43674355
r = id_to_sys_reg_desc(vcpu, reg->id, table, num);
4368-
if (!r || sysreg_hidden_user(vcpu, r))
4356+
if (!r || sysreg_hidden(vcpu, r))
43694357
return -ENOENT;
43704358

43714359
if (r->get_user) {
@@ -4409,7 +4397,7 @@ int kvm_sys_reg_set_user(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg,
44094397
return -EFAULT;
44104398

44114399
r = id_to_sys_reg_desc(vcpu, reg->id, table, num);
4412-
if (!r || sysreg_hidden_user(vcpu, r))
4400+
if (!r || sysreg_hidden(vcpu, r))
44134401
return -ENOENT;
44144402

44154403
if (sysreg_user_write_ignore(vcpu, r))
@@ -4495,7 +4483,7 @@ static int walk_one_sys_reg(const struct kvm_vcpu *vcpu,
44954483
if (!(rd->reg || rd->get_user))
44964484
return 0;
44974485

4498-
if (sysreg_hidden_user(vcpu, rd))
4486+
if (sysreg_hidden(vcpu, rd))
44994487
return 0;
45004488

45014489
if (!copy_reg_to_user(rd, uind))

arch/arm64/kvm/sys_regs.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ struct sys_reg_desc {
9595
};
9696

9797
#define REG_HIDDEN (1 << 0) /* hidden from userspace and guest */
98-
#define REG_HIDDEN_USER (1 << 1) /* hidden from userspace only */
99-
#define REG_RAZ (1 << 2) /* RAZ from userspace and guest */
100-
#define REG_USER_WI (1 << 3) /* WI from userspace only */
98+
#define REG_RAZ (1 << 1) /* RAZ from userspace and guest */
99+
#define REG_USER_WI (1 << 2) /* WI from userspace only */
101100

102101
static __printf(2, 3)
103102
inline void print_sys_reg_msg(const struct sys_reg_params *p,
@@ -165,15 +164,6 @@ static inline bool sysreg_hidden(const struct kvm_vcpu *vcpu,
165164
return sysreg_visibility(vcpu, r) & REG_HIDDEN;
166165
}
167166

168-
static inline bool sysreg_hidden_user(const struct kvm_vcpu *vcpu,
169-
const struct sys_reg_desc *r)
170-
{
171-
if (likely(!r->visibility))
172-
return false;
173-
174-
return r->visibility(vcpu, r) & (REG_HIDDEN | REG_HIDDEN_USER);
175-
}
176-
177167
static inline bool sysreg_visible_as_raz(const struct kvm_vcpu *vcpu,
178168
const struct sys_reg_desc *r)
179169
{

0 commit comments

Comments
 (0)