Message ID | 20191205180652.18671-3-mark.rutland@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | kvm/arm64: unimplemented sysreg improvements | expand |
On Thu, 05 Dec 2019 18:06:52 +0000, Mark Rutland <mark.rutland@arm.com> wrote: > > We don't intend to support IMPLEMENATION DEFINED system registers, but > have to trap them (and emulate them as UNDEFINED). These traps aren't > interesting to the system administrator or to the KVM developers, so > let's not bother logging when we do so. > > Signed-off-by: Mark Rutland <mark.rutland@arm.com> > Cc: Alexandru Elisei <alexandru.elisei@arm.com> > Cc: James Morse <james.morse@arm.com> > Cc: Julien Thierry <julien.thierry.kdev@gmail.com> > Cc: Marc Zyngier <maz@kernel.org> > Cc: Suzuki K Poulose <suzuki.poulose@arm.com> > Cc: kvmarm@lists.cs.columbia.edu > --- > arch/arm64/kvm/sys_regs.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index d128abd38656..61f019104841 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -2233,6 +2233,12 @@ int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run) > NULL, 0); > } > > +static bool is_imp_def_sys_reg(struct sys_reg_params *params) > +{ > + // See ARM DDI 0487E.a, section D12.3.2 > + return params->Op0 == 3 && (params->CRn & 0b1011) == 0b1011; > +} > + > static int emulate_sys_reg(struct kvm_vcpu *vcpu, > struct sys_reg_params *params) > { > @@ -2248,6 +2254,8 @@ static int emulate_sys_reg(struct kvm_vcpu *vcpu, > > if (likely(r)) { > perform_access(vcpu, params, r); > + } else if (is_imp_def_sysreg(params)) { Meh. Doesn't compile... :-( Fixing it locally. M.
On Fri, Dec 06, 2019 at 07:35:56PM +0000, Marc Zyngier wrote: > On Thu, 05 Dec 2019 18:06:52 +0000, > Mark Rutland <mark.rutland@arm.com> wrote: > > > > We don't intend to support IMPLEMENATION DEFINED system registers, but > > have to trap them (and emulate them as UNDEFINED). These traps aren't > > interesting to the system administrator or to the KVM developers, so > > let's not bother logging when we do so. > > > > Signed-off-by: Mark Rutland <mark.rutland@arm.com> > > Cc: Alexandru Elisei <alexandru.elisei@arm.com> > > Cc: James Morse <james.morse@arm.com> > > Cc: Julien Thierry <julien.thierry.kdev@gmail.com> > > Cc: Marc Zyngier <maz@kernel.org> > > Cc: Suzuki K Poulose <suzuki.poulose@arm.com> > > Cc: kvmarm@lists.cs.columbia.edu > > --- > > arch/arm64/kvm/sys_regs.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index d128abd38656..61f019104841 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -2233,6 +2233,12 @@ int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run) > > NULL, 0); > > } > > > > +static bool is_imp_def_sys_reg(struct sys_reg_params *params) > > +{ > > + // See ARM DDI 0487E.a, section D12.3.2 > > + return params->Op0 == 3 && (params->CRn & 0b1011) == 0b1011; > > +} > > + > > static int emulate_sys_reg(struct kvm_vcpu *vcpu, > > struct sys_reg_params *params) > > { > > @@ -2248,6 +2254,8 @@ static int emulate_sys_reg(struct kvm_vcpu *vcpu, > > > > if (likely(r)) { > > perform_access(vcpu, params, r); > > + } else if (is_imp_def_sysreg(params)) { > > Meh. Doesn't compile... :-( > Fixing it locally. Whoops, sorry about that. I "fixed" this at the last moment to match emulate_sys_reg(), but evidently failed to rebuild. I had tested the patch before the rename on my machine, at least. Mark.
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index d128abd38656..61f019104841 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2233,6 +2233,12 @@ int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run) NULL, 0); } +static bool is_imp_def_sys_reg(struct sys_reg_params *params) +{ + // See ARM DDI 0487E.a, section D12.3.2 + return params->Op0 == 3 && (params->CRn & 0b1011) == 0b1011; +} + static int emulate_sys_reg(struct kvm_vcpu *vcpu, struct sys_reg_params *params) { @@ -2248,6 +2254,8 @@ static int emulate_sys_reg(struct kvm_vcpu *vcpu, if (likely(r)) { perform_access(vcpu, params, r); + } else if (is_imp_def_sysreg(params)) { + kvm_inject_undefined(vcpu); } else { print_sys_reg_msg(params, "Unsupported guest sys_reg access at: %lx [%08lx]\n",
We don't intend to support IMPLEMENATION DEFINED system registers, but have to trap them (and emulate them as UNDEFINED). These traps aren't interesting to the system administrator or to the KVM developers, so let's not bother logging when we do so. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Alexandru Elisei <alexandru.elisei@arm.com> Cc: James Morse <james.morse@arm.com> Cc: Julien Thierry <julien.thierry.kdev@gmail.com> Cc: Marc Zyngier <maz@kernel.org> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: kvmarm@lists.cs.columbia.edu --- arch/arm64/kvm/sys_regs.c | 8 ++++++++ 1 file changed, 8 insertions(+)