[Android-virt] [PATCH 5/8] ARM: KVM: make emulation functions return bool.

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

 



by the way, which are these Christoffer people that this mail is cc'ed
to? Could you have applied some greedy algorithm when selecting your
cc list? :)

On Fri, Mar 9, 2012 at 10:44 PM, Rusty Russell <rusty at rustcorp.com.au> wrote:
>
> From: Rusty Russell <rusty at rustcorp.com.au>
>
> Simplifies error handling into the parent: all errors mean
> "can't emulate".
>

also nicer, I was actually tired of abusing -EINVAL here.

thanks.

> Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
> ---
> ?arch/arm/kvm/emulate.c | ? 44 ++++++++++++++++++++++----------------------
> ?1 files changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c
> index 11ab0a9..8208297 100644
> --- a/arch/arm/kvm/emulate.c
> +++ b/arch/arm/kvm/emulate.c
> @@ -212,8 +212,8 @@ int kvm_handle_cp14_access(struct kvm_vcpu *vcpu, struct kvm_run *run)
> ?* @vcpu: The VCPU pointer
> ?* @p: ? ?The coprocessor parameters struct pointer holding trap inst. details
> ?*/
> -static int emulate_cp15_c9_access(struct kvm_vcpu *vcpu,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const struct coproc_params *p)
> +static bool emulate_cp15_c9_access(struct kvm_vcpu *vcpu,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const struct coproc_params *p)
> ?{
> ? ? ? ?BUG_ON(p->CRn != 9);
> ? ? ? ?BUG_ON(p->is_64bit);
> @@ -223,7 +223,7 @@ static int emulate_cp15_c9_access(struct kvm_vcpu *vcpu,
> ? ? ? ? ? ? ? ?u32 l2ctlr, ncores;
>
> ? ? ? ? ? ? ? ?if (p->is_write)
> - ? ? ? ? ? ? ? ? ? ? ? return 0;
> + ? ? ? ? ? ? ? ? ? ? ? return true;
>
> ? ? ? ? ? ? ? ?asm volatile("mrc p15, 1, %0, c9, c0, 2\n" : "=r" (l2ctlr));
> ? ? ? ? ? ? ? ?l2ctlr &= ~(3 << 24);
> @@ -231,13 +231,13 @@ static int emulate_cp15_c9_access(struct kvm_vcpu *vcpu,
> ? ? ? ? ? ? ? ?l2ctlr |= (ncores & 3) << 24;
> ? ? ? ? ? ? ? ?*vcpu_reg(vcpu, p->Rt1) = l2ctlr;
>
> - ? ? ? ? ? ? ? return 0;
> + ? ? ? ? ? ? ? return true;
> ? ? ? ?}
>
> ? ? ? ?/* hack alert!!! */
> ? ? ? ?if (!p->is_write)
> ? ? ? ? ? ? ? ?*vcpu_reg(vcpu, p->Rt1) = 0;
> - ? ? ? return 0;
> + ? ? ? return true;
> ?}
>
> ?/**
> @@ -250,8 +250,8 @@ static int emulate_cp15_c9_access(struct kvm_vcpu *vcpu,
> ?* host/guest PRRR and NMRR memory remap registers and allow guest direct access
> ?* to these registers.
> ?*/
> -static int emulate_cp15_c10_access(struct kvm_vcpu *vcpu,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const struct coproc_params *p)
> +static bool emulate_cp15_c10_access(struct kvm_vcpu *vcpu,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const struct coproc_params *p)
> ?{
> ? ? ? ?BUG_ON(p->CRn != 10);
> ? ? ? ?BUG_ON(p->is_64bit);
> @@ -259,7 +259,7 @@ static int emulate_cp15_c10_access(struct kvm_vcpu *vcpu,
> ? ? ? ?if ((p->CRm == 0 || p->CRm == 1 || p->CRm == 4 || p->CRm == 8) &&
> ? ? ? ? ? ?(p->Op2 <= 7)) {
> ? ? ? ? ? ? ? ?/* TLB Lockdown operations - ignored */
> - ? ? ? ? ? ? ? return 0;
> + ? ? ? ? ? ? ? return true;
> ? ? ? ?}
>
> ? ? ? ?/*
> @@ -270,15 +270,15 @@ static int emulate_cp15_c10_access(struct kvm_vcpu *vcpu,
>
> ? ? ? ?if (p->CRm == 2 && p->Op1 == 0 && p->Op2 == 0) {
> ? ? ? ? ? ? ? ?cp15_op(vcpu, p, c10_PRRR);
> - ? ? ? ? ? ? ? return 0;
> + ? ? ? ? ? ? ? return true;
> ? ? ? ?}
>
> ? ? ? ?if (p->CRm == 2 && p->Op1 == 0 && p->Op2 == 1) {
> ? ? ? ? ? ? ? ?cp15_op(vcpu, p, c10_NMRR);
> - ? ? ? ? ? ? ? return 0;
> + ? ? ? ? ? ? ? return true;
> ? ? ? ?}
>
> - ? ? ? return -EINVAL;
> + ? ? ? return false;
> ?}
>
> ?/**
> @@ -292,8 +292,8 @@ static int emulate_cp15_c10_access(struct kvm_vcpu *vcpu,
> ?*
> ?* This may need to be refined.
> ?*/
> -static int emulate_cp15_c15_access(struct kvm_vcpu *vcpu,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const struct coproc_params *p)
> +static bool emulate_cp15_c15_access(struct kvm_vcpu *vcpu,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const struct coproc_params *p)
> ?{
> ? ? ? ?trace_kvm_emulate_cp15_imp(p->Op1, p->Rt1, p->CRn, p->CRm,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? p->Op2, p->is_write);
> @@ -301,14 +301,14 @@ static int emulate_cp15_c15_access(struct kvm_vcpu *vcpu,
> ? ? ? ?if (!p->is_write)
> ? ? ? ? ? ? ? ?*vcpu_reg(vcpu, p->Rt1) = 0;
>
> - ? ? ? return 0;
> + ? ? ? return true;
> ?}
>
> ?static int emulate_cp15(struct kvm_vcpu *vcpu,
> ? ? ? ? ? ? ? ? ? ? ? ?const struct coproc_params *params)
> ?{
> ? ? ? ?unsigned long instr_len;
> - ? ? ? int ret;
> + ? ? ? bool ok;
>
> ? ? ? ?/* So far no mrrc/mcrr accesses are emulated */
> ? ? ? ?if (params->is_64bit)
> @@ -316,32 +316,32 @@ static int emulate_cp15(struct kvm_vcpu *vcpu,
>
> ? ? ? ?switch (params->CRn) {
> ? ? ? ?case 9:
> - ? ? ? ? ? ? ? ret = emulate_cp15_c9_access(vcpu, params);
> + ? ? ? ? ? ? ? ok = emulate_cp15_c9_access(vcpu, params);
> ? ? ? ? ? ? ? ?break;
> ? ? ? ?case 10:
> - ? ? ? ? ? ? ? ret = emulate_cp15_c10_access(vcpu, params);
> + ? ? ? ? ? ? ? ok = emulate_cp15_c10_access(vcpu, params);
> ? ? ? ? ? ? ? ?break;
> ? ? ? ?case 15:
> - ? ? ? ? ? ? ? ret = emulate_cp15_c15_access(vcpu, params);
> + ? ? ? ? ? ? ? ok = emulate_cp15_c15_access(vcpu, params);
> ? ? ? ? ? ? ? ?break;
> ? ? ? ?default:
> - ? ? ? ? ? ? ? ret = -EINVAL;
> + ? ? ? ? ? ? ? ok = false;
> ? ? ? ? ? ? ? ?break;
> ? ? ? ?}
>
> - ? ? ? if (ret)
> + ? ? ? if (!ok)
> ? ? ? ? ? ? ? ?goto unsupp_err_out;
>
> ? ? ? ?/* Skip instruction, since it was emulated */
> ? ? ? ?instr_len = ((vcpu->arch.hsr >> 25) & 1) ? 4 : 2;
> ? ? ? ?*vcpu_reg(vcpu, 15) += instr_len;
>
> - ? ? ? return ret;
> + ? ? ? return 0;
>
> ?unsupp_err_out:
> ? ? ? ?kvm_err("Unsupported guest CP15 access at: %08x\n", vcpu->arch.regs.pc);
> ? ? ? ?print_cp_instr(params);
> - ? ? ? return ret;
> + ? ? ? return -EINVAL;
> ?}
>
> ?/**
>
> _______________________________________________
> Android-virt mailing list
> Android-virt at lists.cs.columbia.edu
> https://lists.cs.columbia.edu/cucslists/listinfo/android-virt



[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