All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: "Bharat.Bhushan@freescale.com" <Bharat.Bhushan@freescale.com>,
	"kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Scott Wood <scottwood@freescale.com>,
	Stuart Yoder <stuart.yoder@freescale.com>
Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest
Date: Thu, 17 Jul 2014 16:29:43 +0000	[thread overview]
Message-ID: <53C7F9F7.30800@suse.de> (raw)
In-Reply-To: <53C7F981.9080405@suse.de>


On 17.07.14 18:27, Alexander Graf wrote:
>
> On 17.07.14 18:24, Bharat.Bhushan@freescale.com wrote:
>>
>>> -----Original Message-----
>>> From: Alexander Graf [mailto:agraf@suse.de]
>>> Sent: Thursday, July 17, 2014 9:41 PM
>>> To: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org
>>> Cc: kvm@vger.kernel.org; Wood Scott-B07421; Yoder Stuart-B08248
>>> Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest
>>>
>>>
>>> On 16.07.14 08:02, Bharat Bhushan wrote:
>>>> SPRG3 is guest accessible and SPRG3 can be clobbered by host or
>>>> another guest, So this need to be restored when loading guest state.
>>>>
>>>> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
>>>> ---
>>>>    arch/powerpc/kvm/booke_interrupts.S | 2 ++
>>>>    1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/arch/powerpc/kvm/booke_interrupts.S
>>>> b/arch/powerpc/kvm/booke_interrupts.S
>>>> index 2c6deb5ef..0d3403f 100644
>>>> --- a/arch/powerpc/kvm/booke_interrupts.S
>>>> +++ b/arch/powerpc/kvm/booke_interrupts.S
>>>> @@ -459,6 +459,8 @@ lightweight_exit:
>>>>         * written directly to the shared area, so we
>>>>         * need to reload them here with the guest's values.
>>>>         */
>>>> +    PPC_LD(r3, VCPU_SHARED_SPRG3, r5)
>>>> +    mtspr    SPRN_SPRG3, r3
>>> We also need to restore it when resuming the host, no?
>> I do not think host expect some meaningful value when returning from 
>> guest, same true for SPRG4-7.
>> So there seems no reason to save host values and restore them.
>
> Hmm - arch/powerpc/include/asm/reg.h says:
>
>  * All 32-bit:
>  *      - SPRG3 current thread_info pointer
>  *        (virtual on BookE, physical on others)
>
> but I can indeed find no trace of usage anywhere. This at least needs 
> to go into the patch description.

Bah - it obviously is used. It's SPRN_SPRG_THREAD. And it's so 
incredibly important that I have no idea how we could possibly run 
without switching the host value back in very early. And even then our 
interrupt handlers wouldn't work anymore.

This is more complicated :).


Alex


WARNING: multiple messages have this Message-ID (diff)
From: Alexander Graf <agraf@suse.de>
To: "Bharat.Bhushan@freescale.com" <Bharat.Bhushan@freescale.com>,
	"kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Scott Wood <scottwood@freescale.com>,
	Stuart Yoder <stuart.yoder@freescale.com>
Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest
Date: Thu, 17 Jul 2014 18:29:43 +0200	[thread overview]
Message-ID: <53C7F9F7.30800@suse.de> (raw)
In-Reply-To: <53C7F981.9080405@suse.de>


On 17.07.14 18:27, Alexander Graf wrote:
>
> On 17.07.14 18:24, Bharat.Bhushan@freescale.com wrote:
>>
>>> -----Original Message-----
>>> From: Alexander Graf [mailto:agraf@suse.de]
>>> Sent: Thursday, July 17, 2014 9:41 PM
>>> To: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org
>>> Cc: kvm@vger.kernel.org; Wood Scott-B07421; Yoder Stuart-B08248
>>> Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest
>>>
>>>
>>> On 16.07.14 08:02, Bharat Bhushan wrote:
>>>> SPRG3 is guest accessible and SPRG3 can be clobbered by host or
>>>> another guest, So this need to be restored when loading guest state.
>>>>
>>>> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
>>>> ---
>>>>    arch/powerpc/kvm/booke_interrupts.S | 2 ++
>>>>    1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/arch/powerpc/kvm/booke_interrupts.S
>>>> b/arch/powerpc/kvm/booke_interrupts.S
>>>> index 2c6deb5ef..0d3403f 100644
>>>> --- a/arch/powerpc/kvm/booke_interrupts.S
>>>> +++ b/arch/powerpc/kvm/booke_interrupts.S
>>>> @@ -459,6 +459,8 @@ lightweight_exit:
>>>>         * written directly to the shared area, so we
>>>>         * need to reload them here with the guest's values.
>>>>         */
>>>> +    PPC_LD(r3, VCPU_SHARED_SPRG3, r5)
>>>> +    mtspr    SPRN_SPRG3, r3
>>> We also need to restore it when resuming the host, no?
>> I do not think host expect some meaningful value when returning from 
>> guest, same true for SPRG4-7.
>> So there seems no reason to save host values and restore them.
>
> Hmm - arch/powerpc/include/asm/reg.h says:
>
>  * All 32-bit:
>  *      - SPRG3 current thread_info pointer
>  *        (virtual on BookE, physical on others)
>
> but I can indeed find no trace of usage anywhere. This at least needs 
> to go into the patch description.

Bah - it obviously is used. It's SPRN_SPRG_THREAD. And it's so 
incredibly important that I have no idea how we could possibly run 
without switching the host value back in very early. And even then our 
interrupt handlers wouldn't work anymore.

This is more complicated :).


Alex

  reply	other threads:[~2014-07-17 16:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-16  6:02 [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest Bharat Bhushan
2014-07-16  6:14 ` Bharat Bhushan
2014-07-17 16:10 ` Alexander Graf
2014-07-17 16:10   ` Alexander Graf
2014-07-17 16:24   ` Bharat.Bhushan
2014-07-17 16:27     ` Alexander Graf
2014-07-17 16:27       ` Alexander Graf
2014-07-17 16:29       ` Alexander Graf [this message]
2014-07-17 16:29         ` Alexander Graf
2014-07-18  0:28         ` Scott Wood
2014-07-18  0:28           ` Scott Wood
2014-07-18  0:33           ` Alexander Graf
2014-07-18  0:33             ` Alexander Graf
2014-07-18  0:36             ` Scott Wood
2014-07-18  0:36               ` Scott Wood
2014-07-18  0:37               ` Alexander Graf
2014-07-18  0:37                 ` Alexander Graf
2014-07-18  0:49                 ` Scott Wood
2014-07-18  0:49                   ` Scott Wood
2014-07-18  9:57                   ` Bharat.Bhushan
2014-07-18  9:57                     ` Bharat.Bhushan
2014-07-18 10:55                     ` Alexander Graf
2014-07-18 10:55                       ` Alexander Graf
2014-07-18 13:42                       ` Bharat.Bhushan
2014-07-18 13:42                         ` Bharat.Bhushan
2014-07-18 14:01                       ` Bharat.Bhushan
2014-07-18 14:01                         ` Bharat.Bhushan
2014-07-18 11:14                   ` Alexander Graf
2014-07-18 11:14                     ` Alexander Graf
2014-07-17 16:32       ` Bharat.Bhushan

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=53C7F9F7.30800@suse.de \
    --to=agraf@suse.de \
    --cc=Bharat.Bhushan@freescale.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=scottwood@freescale.com \
    --cc=stuart.yoder@freescale.com \
    /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.