All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hollis Blanchard <hollisb@us.ibm.com>
To: kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 15/27] Add mfdec emulation
Date: Fri, 09 Oct 2009 20:45:34 +0000	[thread overview]
Message-ID: <1255121134.2546.139.camel@slab.beaverton.ibm.com> (raw)
In-Reply-To: <1254212303-8737-16-git-send-email-agraf@suse.de>

On Tue, 2009-09-29 at 10:18 +0200, Alexander Graf wrote:
> We support setting the DEC to a certain value right now. Doing that basically
> triggers the CPU local timer.
> 
> But there's also an mfdec command that enabled the OS to read the decrementor.
> 
> This is required at least by all desktop and server PowerPC Linux kernels. It
> can't really hurt to allow embedded ones to do it as well though.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  arch/powerpc/kvm/emulate.c |   13 ++++++++++++-
>  1 files changed, 12 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
> index 7737146..50d411d 100644
> --- a/arch/powerpc/kvm/emulate.c
> +++ b/arch/powerpc/kvm/emulate.c
> @@ -66,12 +66,14 @@
> 
>  void kvmppc_emulate_dec(struct kvm_vcpu *vcpu)
>  {
> +	unsigned long nr_jiffies;
> +
>  	if (vcpu->arch.tcr & TCR_DIE) {
>  		/* The decrementer ticks at the same rate as the timebase, so
>  		 * that's how we convert the guest DEC value to the number of
>  		 * host ticks. */
> -		unsigned long nr_jiffies;
> 
> +		vcpu->arch.dec_jiffies = mftb();
>  		nr_jiffies = vcpu->arch.dec / tb_ticks_per_jiffy;
>  		mod_timer(&vcpu->arch.dec_timer,
>  		          get_jiffies_64() + nr_jiffies);
> @@ -211,6 +213,15 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			/* Note: SPRG4-7 are user-readable, so we don't get
>  			 * a trap. */
> 
> +			case SPRN_DEC:
> +			{
> +				u64 jd = mftb() - vcpu->arch.dec_jiffies;
> +				vcpu->arch.gpr[rt] = vcpu->arch.dec - jd;
> +#ifdef DEBUG_EMUL
> +				printk(KERN_INFO "mfDEC: %x - %llx = %lx\n", vcpu->arch.dec, jd, vcpu->arch.gpr[rt]);
> +#endif
> +				break;
> +			}
>  			default:
>  				emulated = kvmppc_core_emulate_mfspr(vcpu, sprn, rt);
>  				if (emulated = EMULATE_FAIL) {

mftb() doesn't exist for ppc32, so we'll need to use the get_tb()
wrapper instead.

-- 
Hollis Blanchard
IBM Linux Technology Center


  reply	other threads:[~2009-10-09 20:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-29  8:18 [PATCH 15/27] Add mfdec emulation Alexander Graf
2009-10-09 20:45 ` Hollis Blanchard [this message]
2009-10-21 15:03 [PATCH 00/27] Add KVM support for Book3s_64 (PPC64) hosts v5 Alexander Graf
2009-10-21 15:03 ` [PATCH 01/27] Move dirty logging code to sub-arch Alexander Graf
2009-10-21 15:03   ` [PATCH 02/27] Pass PVR in sregs Alexander Graf
2009-10-21 15:03     ` [PATCH 03/27] Add Book3s definitions Alexander Graf
2009-10-21 15:03       ` [PATCH 04/27] Add Book3s fields to vcpu structs Alexander Graf
2009-10-21 15:03         ` [PATCH 05/27] Add asm/kvm_book3s.h Alexander Graf
2009-10-21 15:03           ` [PATCH 06/27] Add Book3s_64 intercept helpers Alexander Graf
2009-10-21 15:03             ` [PATCH 07/27] Add book3s_64 highmem asm code Alexander Graf
2009-10-21 15:03               ` [PATCH 08/27] Add SLB switching code for entry/exit Alexander Graf
2009-10-21 15:03                 ` [PATCH 09/27] Add interrupt handling code Alexander Graf
2009-10-21 15:03                   ` [PATCH 10/27] Add book3s.c Alexander Graf
2009-10-21 15:03                     ` [PATCH 11/27] Add book3s_64 Host MMU handling Alexander Graf
2009-10-21 15:03                       ` [PATCH 12/27] Add book3s_64 guest MMU Alexander Graf
2009-10-21 15:03                         ` [PATCH 13/27] Add book3s_32 " Alexander Graf
2009-10-21 15:03                           ` [PATCH 14/27] Add book3s_64 specific opcode emulation Alexander Graf
     [not found]                             ` <1256137413-15256-15-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
2009-10-21 15:03                               ` [PATCH 15/27] Add mfdec emulation Alexander Graf
2009-10-21 15:03                                 ` Alexander Graf
2009-10-30 15:47 [PATCH 00/27] Add KVM support for Book3s_64 (PPC64) hosts v6 Alexander Graf
     [not found] ` <1256917647-6200-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
2009-10-30 15:47   ` [PATCH 15/27] Add mfdec emulation Alexander Graf
2009-10-30 15:47     ` Alexander Graf
2009-10-30 15:47     ` Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255121134.2546.139.camel@slab.beaverton.ibm.com \
    --to=hollisb@us.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.