On Mon, May 14, 2012 at 9:04 AM, Marc Zyngier <marc.zyngier at arm.com> wrote: > The ACTLR is implementation dependant, and better left untouched > by the guest. > > Trap the access by ignoring writes, and let reads return the host > view of the ACTLR, adjusted to reflect whether the guest is SMP > or not. > > Signed-off-by: Marc Zyngier <marc.zyngier at arm.com> > --- > ?arch/arm/include/asm/kvm_arm.h | ? ?2 +- > ?arch/arm/kvm/emulate.c ? ? ? ? | ? 24 ++++++++++++++++++++++++ > ?2 files changed, 25 insertions(+), 1 deletions(-) > > diff --git a/arch/arm/include/asm/kvm_arm.h b/arch/arm/include/asm/kvm_arm.h > index 29f3a36..b9e4197 100644 > --- a/arch/arm/include/asm/kvm_arm.h > +++ b/arch/arm/include/asm/kvm_arm.h > @@ -49,7 +49,7 @@ > ?#define HCR_SWIO ? ? ? (1 << 1) > ?#define HCR_VM ? ? ? ? 1 > ?#define HCR_GUEST_MASK (HCR_TSC | HCR_TWI | HCR_VM | HCR_BSU_IS | HCR_FB | \ > - ? ? ? ? ? ? ? ? ? ? ? HCR_AMO | HCR_IMO | HCR_FMO | HCR_SWIO) > + ? ? ? ? ? ? ? ? ? ? ? HCR_TAC | HCR_AMO | HCR_IMO | HCR_FMO | HCR_SWIO) > ?#define HCR_VIRT_EXCP_MASK (HCR_VA | HCR_VI | HCR_VF) > > ?/* Hyp System Control Register (HSCTLR) bits */ > diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c > index e356d1c..6eaa97d 100644 > --- a/arch/arm/kvm/emulate.c > +++ b/arch/arm/kvm/emulate.c > @@ -238,6 +238,23 @@ static bool read_l2ctlr(struct kvm_vcpu *vcpu, > ? ? ? ?return true; > ?} > > +static bool read_actlr(struct kvm_vcpu *vcpu, > + ? ? ? ? ? ? ? ? ? ? ?const struct coproc_params *p, > + ? ? ? ? ? ? ? ? ? ? ?unsigned long arg) > +{ > + ? ? ? u32 actlr; > + > + ? ? ? asm volatile("mrc p15, 0, %0, c1, c0, 1\n" : "=r" (actlr)); > + ? ? ? /* Make the SMP bit consistent with the guest configuration */ > + ? ? ? if (atomic_read(&vcpu->kvm->online_vcpus) > 1) > + ? ? ? ? ? ? ? actlr |= 1U << 6; should we not check the MIDR here since it's implementation defined? (refer to Russel's "Check the cpuid we're being asked to emulate" patch) > + ? ? ? else > + ? ? ? ? ? ? ? actlr &= ~(1U << 6); > + ? ? ? *vcpu_reg(vcpu, p->Rt1) = actlr; > + > + ? ? ? return true; > +} > + > ?static bool access_cp15_reg(struct kvm_vcpu *vcpu, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?const struct coproc_params *p, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned long cp15_reg) > @@ -278,6 +295,13 @@ struct coproc_emulate { > > ?static const struct coproc_emulate coproc_emulate[] = { > ? ? ? ?/* > + ? ? ? ?* ACTRL access: > + ? ? ? ?* > + ? ? ? ?* Ignore writes, and read returns the host settings. > + ? ? ? ?*/ > + ? ? ? { CRn( 1), CRm( 0), Op1( 0), Op2( 1), is32, WRITE, ignore_write}, > + ? ? ? { CRn( 1), CRm( 0), Op1( 0), Op2( 1), is32, READ, ?read_actlr}, > + ? ? ? /* > ? ? ? ? * L2CTLR access: > ? ? ? ? * > ? ? ? ? * Ignore writes completely. > -- > 1.7.7.1 > > otherwise looks good to me. Thanks, Christoffer