Subject: Re: [PATCH 36/37] KVM: PPC: booke: expose guest registers on irq reinject

From: Scott Wood <[email-masked]>
Date: Fri, 24 Feb 2012 17:40:17 -0600

On 02/24/2012 08:26 AM, Alexander Graf wrote:
> +static void kvmppc_fill_pt_regs(struct kvm_vcpu *vcpu, struct pt_regs *regs)
>  {
> -	int r = RESUME_HOST;
> +	int i;
>  
> -	/* update before a new last_exit_type is rewritten */
> -	kvmppc_update_timing_stats(vcpu);
> +	for (i = 0; i < 32; i++)
> +		regs->gpr[i] = kvmppc_get_gpr(vcpu, i);
> +	regs->nip = vcpu->arch.pc;
> +	regs->msr = vcpu->arch.shared->msr;
> +	regs->ctr = vcpu->arch.ctr;
> +	regs->link = vcpu->arch.lr;
> +	regs->xer = kvmppc_get_xer(vcpu);
> +	regs->ccr = kvmppc_get_cr(vcpu);
> +	regs->dar = get_guest_dear(vcpu);
> +	regs->dsisr = get_guest_esr(vcpu);
> +}

How much overhead does this add to every interrupt?  Can't we keep this
to the minimum that perf cares about?

> +
> +static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
> +				     unsigned int exit_nr)
> +{
> +	struct pt_regs regs = *current->thread.regs;
>  
> +	kvmppc_fill_pt_regs(vcpu, &regs);

Why are you copying out of current->thread.regs?  That's old junk data,
set by some previous exception and possibly overwritten since.

-Scott