Skip to content

Commit 2733dd1

Browse files
author
Marc Zyngier
committed
KVM: arm64: Introduce a bad_trap() primitive for unexpected trap handling
In order to ease the debugging of NV, it is helpful to have the kernel shout at you when an unexpected trap is handled. We already have this in a couple of cases. Make this a more generic infrastructure that we will make use of very shortly. Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 60ce16c commit 2733dd1

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

arch/arm64/kvm/sys_regs.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,31 @@ static u64 sys_reg_to_index(const struct sys_reg_desc *reg);
4545
static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
4646
u64 val);
4747

48-
static bool read_from_write_only(struct kvm_vcpu *vcpu,
49-
struct sys_reg_params *params,
50-
const struct sys_reg_desc *r)
48+
static bool bad_trap(struct kvm_vcpu *vcpu,
49+
struct sys_reg_params *params,
50+
const struct sys_reg_desc *r,
51+
const char *msg)
5152
{
52-
WARN_ONCE(1, "Unexpected sys_reg read to write-only register\n");
53+
WARN_ONCE(1, "Unexpected %s\n", msg);
5354
print_sys_reg_instr(params);
5455
kvm_inject_undefined(vcpu);
5556
return false;
5657
}
5758

59+
static bool read_from_write_only(struct kvm_vcpu *vcpu,
60+
struct sys_reg_params *params,
61+
const struct sys_reg_desc *r)
62+
{
63+
return bad_trap(vcpu, params, r,
64+
"sys_reg read to write-only register");
65+
}
66+
5867
static bool write_to_read_only(struct kvm_vcpu *vcpu,
5968
struct sys_reg_params *params,
6069
const struct sys_reg_desc *r)
6170
{
62-
WARN_ONCE(1, "Unexpected sys_reg write to read-only register\n");
63-
print_sys_reg_instr(params);
64-
kvm_inject_undefined(vcpu);
65-
return false;
71+
return bad_trap(vcpu, params, r,
72+
"sys_reg write to read-only register");
6673
}
6774

6875
u64 vcpu_read_sys_reg(const struct kvm_vcpu *vcpu, int reg)

0 commit comments

Comments
 (0)