Re: [PATCH] ARM: KVM: use kvm_skip_instr() instead of open-coded versions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 22, 2012 at 10:37 AM, Marc Zyngier <marc.zyngier@xxxxxxx> wrote:
> kvm_skip_instr() is a nice cleanup compared to the use of manual
> vcpu_pc correction and a call to kvm_adjust_itstate().
>
> Also make kvm_adjust_itstate() static.
>
> Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
> ---
>  arch/arm/include/asm/kvm_emulate.h | 1 -
>  arch/arm/kvm/coproc.c              | 4 +---
>  arch/arm/kvm/emulate.c             | 2 +-
>  arch/arm/kvm/mmu.c                 | 8 ++------
>  4 files changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h
> index d899fbb..f60c415 100644
> --- a/arch/arm/include/asm/kvm_emulate.h
> +++ b/arch/arm/include/asm/kvm_emulate.h
> @@ -54,7 +54,6 @@ static inline enum vcpu_mode vcpu_mode(struct kvm_vcpu *vcpu)
>  int kvm_handle_wfi(struct kvm_vcpu *vcpu, struct kvm_run *run);
>  int kvm_emulate_mmio_ls(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>                         unsigned long instr);
> -void kvm_adjust_itstate(struct kvm_vcpu *vcpu);
>  void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr);
>  void kvm_inject_undefined(struct kvm_vcpu *vcpu);
>
> diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c
> index e36826c..69dd947 100644
> --- a/arch/arm/kvm/coproc.c
> +++ b/arch/arm/kvm/coproc.c
> @@ -476,9 +476,7 @@ static int emulate_cp15(struct kvm_vcpu *vcpu,
>
>                 if (likely(r->access(vcpu, params, r))) {
>                         /* Skip instruction, since it was emulated */
> -                       int instr_len = ((vcpu->arch.hsr >> 25) & 1) ? 4 : 2;
> -                       *vcpu_pc(vcpu) += instr_len;
> -                       kvm_adjust_itstate(vcpu);
> +                       kvm_skip_instr(vcpu, (vcpu->arch.hsr >> 25) & 1);
>                         return 1;
>                 }
>                 /* If access function fails, it should complain. */
> diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c
> index 6cbdb08..1236a46 100644
> --- a/arch/arm/kvm/emulate.c
> +++ b/arch/arm/kvm/emulate.c
> @@ -431,7 +431,7 @@ int kvm_emulate_mmio_ls(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>   *
>   * IT[7:0] -> CPSR[26:25],CPSR[15:10]
>   */
> -void kvm_adjust_itstate(struct kvm_vcpu *vcpu)
> +static void kvm_adjust_itstate(struct kvm_vcpu *vcpu)
>  {
>         unsigned long itbits, cond;
>         unsigned long cpsr = *vcpu_cpsr(vcpu);
> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
> index 87e4a59..68d9da7 100644
> --- a/arch/arm/kvm/mmu.c
> +++ b/arch/arm/kvm/mmu.c
> @@ -628,7 +628,7 @@ static int invalid_io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa)
>  static int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
>                         phys_addr_t fault_ipa, struct kvm_memory_slot *memslot)
>  {
> -       unsigned long rd, len, instr_len;
> +       unsigned long rd, len;
>         bool is_write, sign_extend;
>
>         if (!(vcpu->arch.hsr & HSR_ISV))
> @@ -669,9 +669,6 @@ static int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
>                 return -EFAULT;
>         }
>
> -       /* Get instruction length in bytes */
> -       instr_len = (vcpu->arch.hsr & HSR_IL) ? 4 : 2;
> -
>         /* Export MMIO operations to user space */
>         run->mmio.is_write = is_write;
>         run->mmio.phys_addr = fault_ipa;
> @@ -690,8 +687,7 @@ static int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
>          * The MMIO instruction is emulated and should not be re-executed
>          * in the guest.
>          */
> -       *vcpu_pc(vcpu) += instr_len;
> -       kvm_adjust_itstate(vcpu);
> +       kvm_skip_instr(vcpu, (vcpu->arch.hsr >> 25) & 1);
>         run->exit_reason = KVM_EXIT_MMIO;
>         return 0;
>  }
> --
> 1.7.11.4
>
thanks for removing this one from my todo list :)

-Christoffer
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux