Skip to content

Commit 4de06e4

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Add a visibility bit to ignore user writes
We're about to ignore writes to AArch32 ID registers on AArch64-only systems. Add a bit to indicate a register is handled as write ignore when accessed from userspace. Signed-off-by: Oliver Upton <[email protected]> Reviewed-by: Reiji Watanabe <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5d9a718 commit 4de06e4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,6 +2775,9 @@ int kvm_sys_reg_set_user(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg,
27752775
if (!r)
27762776
return -ENOENT;
27772777

2778+
if (sysreg_user_write_ignore(vcpu, r))
2779+
return 0;
2780+
27782781
if (r->set_user) {
27792782
ret = (r->set_user)(vcpu, r, val);
27802783
} else {

arch/arm64/kvm/sys_regs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct sys_reg_desc {
8686

8787
#define REG_HIDDEN (1 << 0) /* hidden from userspace and guest */
8888
#define REG_RAZ (1 << 1) /* RAZ from userspace and guest */
89+
#define REG_USER_WI (1 << 2) /* WI from userspace only */
8990

9091
static __printf(2, 3)
9192
inline void print_sys_reg_msg(const struct sys_reg_params *p,
@@ -157,6 +158,12 @@ static inline bool sysreg_visible_as_raz(const struct kvm_vcpu *vcpu,
157158
return sysreg_visibility(vcpu, r) & REG_RAZ;
158159
}
159160

161+
static inline bool sysreg_user_write_ignore(const struct kvm_vcpu *vcpu,
162+
const struct sys_reg_desc *r)
163+
{
164+
return sysreg_visibility(vcpu, r) & REG_USER_WI;
165+
}
166+
160167
static inline int cmp_sys_reg(const struct sys_reg_desc *i1,
161168
const struct sys_reg_desc *i2)
162169
{

0 commit comments

Comments
 (0)