Kernel KVM-PPC virtualization development
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: kvm-ppc@vger.kernel.org
Subject: Re: kvm BookE and SPRGs
Date: Fri, 10 Jul 2009 08:10:49 +0000	[thread overview]
Message-ID: <1247213449.15530.31.camel@pasglop> (raw)
In-Reply-To: <1247207486.15530.23.camel@pasglop>

On Fri, 2009-07-10 at 16:31 +1000, Benjamin Herrenschmidt wrote:
> 
> I was roaming through kernel usage of SPRGs and noticed a small detail
> in kvmppc for BookE ... any reason why in OP_31_XOP_MTSPR, you
> open coded the emulation of SPRG0..3, but 4...7 are handled
> in kvmppc_core_emulate_mtspr() ?
> 
> It occurs to me that in fact for both MTSPR and MFSPR, the code should
> be moved into kvmppc_core_emulate_mtspr() and
> kvmppc_core_emulate_mfspr() for consistency.
> 
> Also, from looking at the FSL BookE code, it seems that there is such a
> thing as SPRG9 (and so I suppose there must be an SPRG8 somewhere too),
> shouldn't we handle it too ?

BTW. That leads me to another question (CC'ing Avi there too), which is
what is the policy vs. para-virtualization ? IE. Are we ok with adding
paravirt tricks to speed things up ?

A prime example I have in mind that could possibly help a lot here is
to have a shared page mapped at -4K (at the top of the address space)
when the guest is in supervisor mode only that hosts part of the current
VCPU supervisor register state.

That way, we could, either using our existing "alternate" instruction
patching mechanism, or maybe lazily patching them as we trap on them,
replace instructions such as mtsprg and mfsprg with la/sta (load
absolute/store absolute) from/to this page (absolute addresses on ppc
are 16 bits signed so can reach either the top of the bottom of the
address space).

We could also access the guest MSR read only that way, the guest SRR0
and SRR1, and a few more things. I also have ideas to do soft irq
disabling that way as well which would eventually remove most if not all
the spurrious emulation traps in the exception entry/exit of the guest
kernel.

(Note: this is paravirt even if we patch instructions on traps, in part
because if we use that instead of SPRGs, then the values will not be
reflected in the user readable SPRG aliases, so the guest kernel needs
to be aware of that, typically, the current BookE code -does- use the
user readable variants of SPRG4..7 so we must be careful here).

The cost of course is an additional TLB entry for mapping that -4K page
(but only when running guest kernel code).

(Note: this technique would apply to KVM ppc64 from Alex as well)

Cheers,
Ben.



  reply	other threads:[~2009-07-10  8:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-10  6:31 kvm BookE and SPRGs Benjamin Herrenschmidt
2009-07-10  8:10 ` Benjamin Herrenschmidt [this message]
2009-07-10  8:42 ` Alexander Graf
2009-07-10  9:09 ` Benjamin Herrenschmidt
2009-07-10  9:15 ` Liu Yu-B13201
2009-07-10  9:17 ` Benjamin Herrenschmidt
2009-07-10  9:25 ` Benjamin Herrenschmidt
2009-07-10  9:39 ` Benjamin Herrenschmidt
2009-07-10  9:42 ` Benjamin Herrenschmidt
2009-07-10  9:43 ` Alexander Graf
2009-07-10 10:50 ` Benjamin Herrenschmidt
2009-07-10 16:31 ` Hollis Blanchard
2009-07-10 16:40 ` Hollis Blanchard

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=1247213449.15530.31.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox