[PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea
Alexander Graf
agraf at suse.de
Sun Dec 2 00:32:35 EST 2012
On 01.12.2012, at 14:28, Alexander Graf wrote:
>
> On 11.10.2012, at 18:13, Mihai Caraman wrote:
>
>> Add emulation helper for getting instruction ea and refactor tlb instruction
>> emulation to use it.
>>
>> Signed-off-by: Mihai Caraman <mihai.caraman at freescale.com>
>> ---
>> v1: use _t_ype instead of _t_arget _r_egister in tlbilx emulation.
>>
>> arch/powerpc/include/asm/kvm_ppc.h | 11 +++++++++++
>> arch/powerpc/kvm/e500.h | 6 +++---
>> arch/powerpc/kvm/e500_emulate.c | 15 ++++++++++-----
>> arch/powerpc/kvm/e500_tlb.c | 33 +++++++++++----------------------
>> 4 files changed, 35 insertions(+), 30 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
>> index 609cca3..a08e756 100644
>> --- a/arch/powerpc/include/asm/kvm_ppc.h
>> +++ b/arch/powerpc/include/asm/kvm_ppc.h
>> @@ -293,4 +293,15 @@ static inline void kvmppc_lazy_ee_enable(void)
>> #endif
>> }
>>
>> +static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb)
>> +{
>> + ulong ea;
>> +
>> + ea = kvmppc_get_gpr(vcpu, rb);
>> + if (ra)
>> + ea += kvmppc_get_gpr(vcpu, ra);
>> +
>> + return ea;
>> +}
>> +
>> #endif /* __POWERPC_KVM_PPC_H__ */
>> diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h
>> index d162286..32e98a7 100644
>> --- a/arch/powerpc/kvm/e500.h
>> +++ b/arch/powerpc/kvm/e500.h
>> @@ -129,9 +129,9 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500,
>> ulong value);
>> int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu);
>> int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu);
>> -int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb);
>> -int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, int rb);
>> -int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb);
>> +int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea);
>> +int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int type, gva_t ea);
>> +int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, gva_t ea);
>> int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500);
>> void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500);
>>
>> diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c
>> index e04b0ef..3bf2486 100644
>> --- a/arch/powerpc/kvm/e500_emulate.c
>> +++ b/arch/powerpc/kvm/e500_emulate.c
>> @@ -88,7 +88,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
>> int emulated = EMULATE_DONE;
>> int ra = get_ra(inst);
>> int rb = get_rb(inst);
>> - int rt = get_rt(inst);
>
> The function scope rt variable shouldn't hurt, as the compiler will be smart enough to only calculate it when it's actually used.
>
>> + gva_t ea;
>>
>> switch (get_op(inst)) {
>> case 31:
>> @@ -113,15 +113,20 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
>> break;
>>
>> case XOP_TLBSX:
>> - emulated = kvmppc_e500_emul_tlbsx(vcpu,rb);
>> + ea = kvmppc_get_ea_indexed(vcpu, ra, rb);
>> + emulated = kvmppc_e500_emul_tlbsx(vcpu, ea);
>> break;
>>
>> - case XOP_TLBILX:
>> - emulated = kvmppc_e500_emul_tlbilx(vcpu, rt, ra, rb);
>> + case XOP_TLBILX: {
>> + int t = (inst >> 21) & 0x3;
>
> so we can remove this
>
>> + ea = kvmppc_get_ea_indexed(vcpu, ra, rb);
>> + emulated = kvmppc_e500_emul_tlbilx(vcpu, t, ea);
>
> and instead here pass rt & 3.
>
> The rest of the patch looks fine, so I'll do the change while applying it.
Reading my old comment on the previous version, I realized that I was slightly too fuzzy in my wording. I meant to make the parameter that gets passed into the functions a variable of a different type (like you did). Calculating that one from rt is fine.
Alex
More information about the Linuxppc-dev
mailing list