mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 06:34:12 +08:00
KVM: arm64: Sanely ratelimit sysreg messages
Currently kvm_pr_unimpl() is ratelimited, so print_sys_reg_instr() won't spam the console. However, someof its callers try to print some contextual information with kvm_err(), which is not ratelimited. This means that in some cases the context may be printed without the sysreg encoding, which isn't all that useful. Let's ensure that both are consistently printed together and ratelimited, by refactoring print_sys_reg_instr() so that some callers can provide it with an arbitrary format string. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20191205180652.18671-2-mark.rutland@arm.com
This commit is contained in:
parent
72a610f32e
commit
bf4b96bb54
@ -2094,9 +2094,9 @@ static void unhandled_cp_access(struct kvm_vcpu *vcpu,
|
|||||||
WARN_ON(1);
|
WARN_ON(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
kvm_err("Unsupported guest CP%d access at: %08lx [%08lx]\n",
|
print_sys_reg_msg(params,
|
||||||
cp, *vcpu_pc(vcpu), *vcpu_cpsr(vcpu));
|
"Unsupported guest CP%d access at: %08lx [%08lx]\n",
|
||||||
print_sys_reg_instr(params);
|
cp, *vcpu_pc(vcpu), *vcpu_cpsr(vcpu));
|
||||||
kvm_inject_undefined(vcpu);
|
kvm_inject_undefined(vcpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2245,9 +2245,9 @@ static int emulate_sys_reg(struct kvm_vcpu *vcpu,
|
|||||||
if (likely(r)) {
|
if (likely(r)) {
|
||||||
perform_access(vcpu, params, r);
|
perform_access(vcpu, params, r);
|
||||||
} else {
|
} else {
|
||||||
kvm_err("Unsupported guest sys_reg access at: %lx [%08lx]\n",
|
print_sys_reg_msg(params,
|
||||||
*vcpu_pc(vcpu), *vcpu_cpsr(vcpu));
|
"Unsupported guest sys_reg access at: %lx [%08lx]\n",
|
||||||
print_sys_reg_instr(params);
|
*vcpu_pc(vcpu), *vcpu_cpsr(vcpu));
|
||||||
kvm_inject_undefined(vcpu);
|
kvm_inject_undefined(vcpu);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -62,11 +62,24 @@ struct sys_reg_desc {
|
|||||||
#define REG_HIDDEN_USER (1 << 0) /* hidden from userspace ioctls */
|
#define REG_HIDDEN_USER (1 << 0) /* hidden from userspace ioctls */
|
||||||
#define REG_HIDDEN_GUEST (1 << 1) /* hidden from guest */
|
#define REG_HIDDEN_GUEST (1 << 1) /* hidden from guest */
|
||||||
|
|
||||||
|
static __printf(2, 3)
|
||||||
|
inline void print_sys_reg_msg(const struct sys_reg_params *p,
|
||||||
|
char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list va;
|
||||||
|
|
||||||
|
va_start(va, fmt);
|
||||||
|
/* Look, we even formatted it for you to paste into the table! */
|
||||||
|
kvm_pr_unimpl("%pV { Op0(%2u), Op1(%2u), CRn(%2u), CRm(%2u), Op2(%2u), func_%s },\n",
|
||||||
|
&(struct va_format){ fmt, &va },
|
||||||
|
p->Op0, p->Op1, p->CRn, p->CRm, p->Op2, p->is_write ? "write" : "read");
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void print_sys_reg_instr(const struct sys_reg_params *p)
|
static inline void print_sys_reg_instr(const struct sys_reg_params *p)
|
||||||
{
|
{
|
||||||
/* Look, we even formatted it for you to paste into the table! */
|
/* GCC warns on an empty format string */
|
||||||
kvm_pr_unimpl(" { Op0(%2u), Op1(%2u), CRn(%2u), CRm(%2u), Op2(%2u), func_%s },\n",
|
print_sys_reg_msg(p, "%s", "");
|
||||||
p->Op0, p->Op1, p->CRn, p->CRm, p->Op2, p->is_write ? "write" : "read");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool ignore_write(struct kvm_vcpu *vcpu,
|
static inline bool ignore_write(struct kvm_vcpu *vcpu,
|
||||||
|
Loading…
Reference in New Issue
Block a user