* [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-16 6:14 ` Bharat Bhushan 0 siblings, 0 replies; 30+ messages in thread From: Bharat Bhushan @ 2014-07-16 6:02 UTC (permalink / raw) To: agraf, kvm-ppc; +Cc: kvm, scottwood, stuart.yoder, Bharat Bhushan 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 PPC_LD(r3, VCPU_SHARED_SPRG4, r5) mtspr SPRN_SPRG4W, r3 PPC_LD(r3, VCPU_SHARED_SPRG5, r5) -- 1.9.3 ^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-16 6:14 ` Bharat Bhushan 0 siblings, 0 replies; 30+ messages in thread From: Bharat Bhushan @ 2014-07-16 6:14 UTC (permalink / raw) To: agraf, kvm-ppc; +Cc: kvm, scottwood, stuart.yoder, Bharat Bhushan 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 PPC_LD(r3, VCPU_SHARED_SPRG4, r5) mtspr SPRN_SPRG4W, r3 PPC_LD(r3, VCPU_SHARED_SPRG5, r5) -- 1.9.3 ^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-16 6:14 ` Bharat Bhushan @ 2014-07-17 16:10 ` Alexander Graf -1 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-17 16:10 UTC (permalink / raw) To: Bharat Bhushan, kvm-ppc; +Cc: kvm, scottwood, stuart.yoder 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? Alex > PPC_LD(r3, VCPU_SHARED_SPRG4, r5) > mtspr SPRN_SPRG4W, r3 > PPC_LD(r3, VCPU_SHARED_SPRG5, r5) ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-17 16:10 ` Alexander Graf 0 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-17 16:10 UTC (permalink / raw) To: Bharat Bhushan, kvm-ppc; +Cc: kvm, scottwood, stuart.yoder 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? Alex > PPC_LD(r3, VCPU_SHARED_SPRG4, r5) > mtspr SPRN_SPRG4W, r3 > PPC_LD(r3, VCPU_SHARED_SPRG5, r5) ^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-17 16:10 ` Alexander Graf (?) @ 2014-07-17 16:24 ` Bharat.Bhushan 2014-07-17 16:27 ` Alexander Graf -1 siblings, 1 reply; 30+ messages in thread From: Bharat.Bhushan @ 2014-07-17 16:24 UTC (permalink / raw) To: Alexander Graf, kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, Scott Wood, Stuart Yoder > -----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. Thanks -Bharat > > > Alex > > > PPC_LD(r3, VCPU_SHARED_SPRG4, r5) > > mtspr SPRN_SPRG4W, r3 > > PPC_LD(r3, VCPU_SHARED_SPRG5, r5) ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-17 16:24 ` Bharat.Bhushan @ 2014-07-17 16:27 ` Alexander Graf 0 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-17 16:27 UTC (permalink / raw) To: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, Scott Wood, Stuart Yoder 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. Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-17 16:27 ` Alexander Graf 0 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-17 16:27 UTC (permalink / raw) To: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, Scott Wood, Stuart Yoder 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. Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-17 16:27 ` Alexander Graf @ 2014-07-17 16:29 ` Alexander Graf -1 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-17 16:29 UTC (permalink / raw) To: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, Scott Wood, Stuart Yoder 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 ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-17 16:29 ` Alexander Graf 0 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-17 16:29 UTC (permalink / raw) To: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, Scott Wood, Stuart Yoder 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 ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-17 16:29 ` Alexander Graf @ 2014-07-18 0:28 ` Scott Wood -1 siblings, 0 replies; 30+ messages in thread From: Scott Wood @ 2014-07-18 0:28 UTC (permalink / raw) To: Alexander Graf Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > 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. SPRG3 is not guest writeable. We should be doing this so that guest reads of SPRG3 through the alternative read-only SPR work, not because "SPRG3 can be clobbered by host or another guest". > >>>> > >>>> 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. Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as Alex points out. > > 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 :). To make this work we need to avoid SPRG3 as well, or at least avoid using it for something needed prior to DO_KVM. We also need to update the documentation in reg.h to reflect the fact that we don't use SPRG4-7 anymore on e500. -Scott ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 0:28 ` Scott Wood 0 siblings, 0 replies; 30+ messages in thread From: Scott Wood @ 2014-07-18 0:28 UTC (permalink / raw) To: Alexander Graf Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > 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. SPRG3 is not guest writeable. We should be doing this so that guest reads of SPRG3 through the alternative read-only SPR work, not because "SPRG3 can be clobbered by host or another guest". > >>>> > >>>> 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. Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as Alex points out. > > 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 :). To make this work we need to avoid SPRG3 as well, or at least avoid using it for something needed prior to DO_KVM. We also need to update the documentation in reg.h to reflect the fact that we don't use SPRG4-7 anymore on e500. -Scott ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 0:28 ` Scott Wood @ 2014-07-18 0:33 ` Alexander Graf -1 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-18 0:33 UTC (permalink / raw) To: Scott Wood Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On 18.07.14 02:28, Scott Wood wrote: > On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: >> 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. > SPRG3 is not guest writeable. We should be doing this so that guest > reads of SPRG3 through the alternative read-only SPR work, not because > "SPRG3 can be clobbered by host or another guest". > >>>>>> 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. > Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as > Alex points out. > >>> 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 :). > To make this work we need to avoid SPRG3 as well, or at least avoid > using it for something needed prior to DO_KVM. > > We also need to update the documentation in reg.h to reflect the fact > that we don't use SPRG4-7 anymore on e500. I would personally prefer if we claim SPRG3R as unsupported on e500v2 until we find someone who actually uses it. There's a good chance we'd start jumping through a lot of hoops and reduce overall performance for no real-world gain today. Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 0:33 ` Alexander Graf 0 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-18 0:33 UTC (permalink / raw) To: Scott Wood Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On 18.07.14 02:28, Scott Wood wrote: > On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: >> 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. > SPRG3 is not guest writeable. We should be doing this so that guest > reads of SPRG3 through the alternative read-only SPR work, not because > "SPRG3 can be clobbered by host or another guest". > >>>>>> 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. > Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as > Alex points out. > >>> 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 :). > To make this work we need to avoid SPRG3 as well, or at least avoid > using it for something needed prior to DO_KVM. > > We also need to update the documentation in reg.h to reflect the fact > that we don't use SPRG4-7 anymore on e500. I would personally prefer if we claim SPRG3R as unsupported on e500v2 until we find someone who actually uses it. There's a good chance we'd start jumping through a lot of hoops and reduce overall performance for no real-world gain today. Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 0:33 ` Alexander Graf @ 2014-07-18 0:36 ` Scott Wood -1 siblings, 0 replies; 30+ messages in thread From: Scott Wood @ 2014-07-18 0:36 UTC (permalink / raw) To: Alexander Graf Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: > On 18.07.14 02:28, Scott Wood wrote: > > On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > >> 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. > > SPRG3 is not guest writeable. We should be doing this so that guest > > reads of SPRG3 through the alternative read-only SPR work, not because > > "SPRG3 can be clobbered by host or another guest". > > > >>>>>> 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. > > Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as > > Alex points out. > > > >>> 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 :). > > To make this work we need to avoid SPRG3 as well, or at least avoid > > using it for something needed prior to DO_KVM. > > > > We also need to update the documentation in reg.h to reflect the fact > > that we don't use SPRG4-7 anymore on e500. > > I would personally prefer if we claim SPRG3R as unsupported on e500v2 > until we find someone who actually uses it. There's a good chance we'd > start jumping through a lot of hoops and reduce overall performance for > no real-world gain today. The same problem applies to e500mc. -Scott ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 0:36 ` Scott Wood 0 siblings, 0 replies; 30+ messages in thread From: Scott Wood @ 2014-07-18 0:36 UTC (permalink / raw) To: Alexander Graf Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: > On 18.07.14 02:28, Scott Wood wrote: > > On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > >> 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. > > SPRG3 is not guest writeable. We should be doing this so that guest > > reads of SPRG3 through the alternative read-only SPR work, not because > > "SPRG3 can be clobbered by host or another guest". > > > >>>>>> 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. > > Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as > > Alex points out. > > > >>> 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 :). > > To make this work we need to avoid SPRG3 as well, or at least avoid > > using it for something needed prior to DO_KVM. > > > > We also need to update the documentation in reg.h to reflect the fact > > that we don't use SPRG4-7 anymore on e500. > > I would personally prefer if we claim SPRG3R as unsupported on e500v2 > until we find someone who actually uses it. There's a good chance we'd > start jumping through a lot of hoops and reduce overall performance for > no real-world gain today. The same problem applies to e500mc. -Scott ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 0:36 ` Scott Wood @ 2014-07-18 0:37 ` Alexander Graf -1 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-18 0:37 UTC (permalink / raw) To: Scott Wood Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On 18.07.14 02:36, Scott Wood wrote: > On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: >> On 18.07.14 02:28, Scott Wood wrote: >>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: >>>> 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. >>> SPRG3 is not guest writeable. We should be doing this so that guest >>> reads of SPRG3 through the alternative read-only SPR work, not because >>> "SPRG3 can be clobbered by host or another guest". >>> >>>>>>>> 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. >>> Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as >>> Alex points out. >>> >>>>> 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 :). >>> To make this work we need to avoid SPRG3 as well, or at least avoid >>> using it for something needed prior to DO_KVM. >>> >>> We also need to update the documentation in reg.h to reflect the fact >>> that we don't use SPRG4-7 anymore on e500. >> I would personally prefer if we claim SPRG3R as unsupported on e500v2 >> until we find someone who actually uses it. There's a good chance we'd >> start jumping through a lot of hoops and reduce overall performance for >> no real-world gain today. > The same problem applies to e500mc. There we have SPRN_GSPRG3, no? Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 0:37 ` Alexander Graf 0 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-18 0:37 UTC (permalink / raw) To: Scott Wood Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On 18.07.14 02:36, Scott Wood wrote: > On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: >> On 18.07.14 02:28, Scott Wood wrote: >>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: >>>> 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. >>> SPRG3 is not guest writeable. We should be doing this so that guest >>> reads of SPRG3 through the alternative read-only SPR work, not because >>> "SPRG3 can be clobbered by host or another guest". >>> >>>>>>>> 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. >>> Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as >>> Alex points out. >>> >>>>> 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 :). >>> To make this work we need to avoid SPRG3 as well, or at least avoid >>> using it for something needed prior to DO_KVM. >>> >>> We also need to update the documentation in reg.h to reflect the fact >>> that we don't use SPRG4-7 anymore on e500. >> I would personally prefer if we claim SPRG3R as unsupported on e500v2 >> until we find someone who actually uses it. There's a good chance we'd >> start jumping through a lot of hoops and reduce overall performance for >> no real-world gain today. > The same problem applies to e500mc. There we have SPRN_GSPRG3, no? Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 0:37 ` Alexander Graf @ 2014-07-18 0:49 ` Scott Wood -1 siblings, 0 replies; 30+ messages in thread From: Scott Wood @ 2014-07-18 0:49 UTC (permalink / raw) To: Alexander Graf Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: > On 18.07.14 02:36, Scott Wood wrote: > > On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: > >> On 18.07.14 02:28, Scott Wood wrote: > >>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > >>>> 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. > >>> SPRG3 is not guest writeable. We should be doing this so that guest > >>> reads of SPRG3 through the alternative read-only SPR work, not because > >>> "SPRG3 can be clobbered by host or another guest". > >>> > >>>>>>>> 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. > >>> Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as > >>> Alex points out. > >>> > >>>>> 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 :). > >>> To make this work we need to avoid SPRG3 as well, or at least avoid > >>> using it for something needed prior to DO_KVM. > >>> > >>> We also need to update the documentation in reg.h to reflect the fact > >>> that we don't use SPRG4-7 anymore on e500. > >> I would personally prefer if we claim SPRG3R as unsupported on e500v2 > >> until we find someone who actually uses it. There's a good chance we'd > >> start jumping through a lot of hoops and reduce overall performance for > >> no real-world gain today. > > The same problem applies to e500mc. > > There we have SPRN_GSPRG3, no? Oh, right. Since it's only a problem for PR-mode, it can be fixed without needing to avoid SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only need to avoid using SPRG_THREAD in __KVM_HANDLER (i.e. revert commit ffe129ecd79779221fdb03305049ec8b5a8beb0f). And if we decide it's not worthwhile and don't revert that commit, we should at least remove the comment that "Under KVM, the host SPRG1 is used to point to the current VCPU data structure"... -Scott ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 0:49 ` Scott Wood 0 siblings, 0 replies; 30+ messages in thread From: Scott Wood @ 2014-07-18 0:49 UTC (permalink / raw) To: Alexander Graf Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: > On 18.07.14 02:36, Scott Wood wrote: > > On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: > >> On 18.07.14 02:28, Scott Wood wrote: > >>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > >>>> 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. > >>> SPRG3 is not guest writeable. We should be doing this so that guest > >>> reads of SPRG3 through the alternative read-only SPR work, not because > >>> "SPRG3 can be clobbered by host or another guest". > >>> > >>>>>>>> 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. > >>> Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as > >>> Alex points out. > >>> > >>>>> 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 :). > >>> To make this work we need to avoid SPRG3 as well, or at least avoid > >>> using it for something needed prior to DO_KVM. > >>> > >>> We also need to update the documentation in reg.h to reflect the fact > >>> that we don't use SPRG4-7 anymore on e500. > >> I would personally prefer if we claim SPRG3R as unsupported on e500v2 > >> until we find someone who actually uses it. There's a good chance we'd > >> start jumping through a lot of hoops and reduce overall performance for > >> no real-world gain today. > > The same problem applies to e500mc. > > There we have SPRN_GSPRG3, no? Oh, right. Since it's only a problem for PR-mode, it can be fixed without needing to avoid SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only need to avoid using SPRG_THREAD in __KVM_HANDLER (i.e. revert commit ffe129ecd79779221fdb03305049ec8b5a8beb0f). And if we decide it's not worthwhile and don't revert that commit, we should at least remove the comment that "Under KVM, the host SPRG1 is used to point to the current VCPU data structure"... -Scott ^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 0:49 ` Scott Wood @ 2014-07-18 9:57 ` Bharat.Bhushan -1 siblings, 0 replies; 30+ messages in thread From: Bharat.Bhushan @ 2014-07-18 9:57 UTC (permalink / raw) To: Scott Wood, Alexander Graf Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogV29vZCBTY290dC1CMDc0 MjENCj4gU2VudDogRnJpZGF5LCBKdWx5IDE4LCAyMDE0IDY6MTkgQU0NCj4gVG86IEFsZXhhbmRl ciBHcmFmDQo+IENjOiBCaHVzaGFuIEJoYXJhdC1SNjU3Nzc7IGt2bS1wcGNAdmdlci5rZXJuZWwu b3JnOyBrdm1Admdlci5rZXJuZWwub3JnOyBZb2Rlcg0KPiBTdHVhcnQtQjA4MjQ4DQo+IFN1Ympl Y3Q6IFJlOiBbUEFUQ0hdIGt2bTogcHBjOiBib29rZTogUmVzdG9yZSBTUFJHMyB3aGVuIGVudGVy aW5nIGd1ZXN0DQo+IA0KPiBPbiBGcmksIDIwMTQtMDctMTggYXQgMDI6MzcgKzAyMDAsIEFsZXhh bmRlciBHcmFmIHdyb3RlOg0KPiA+IE9uIDE4LjA3LjE0IDAyOjM2LCBTY290dCBXb29kIHdyb3Rl Og0KPiA+ID4gT24gRnJpLCAyMDE0LTA3LTE4IGF0IDAyOjMzICswMjAwLCBBbGV4YW5kZXIgR3Jh ZiB3cm90ZToNCj4gPiA+PiBPbiAxOC4wNy4xNCAwMjoyOCwgU2NvdHQgV29vZCB3cm90ZToNCj4g PiA+Pj4gT24gVGh1LCAyMDE0LTA3LTE3IGF0IDE4OjI5ICswMjAwLCBBbGV4YW5kZXIgR3JhZiB3 cm90ZToNCj4gPiA+Pj4+IE9uIDE3LjA3LjE0IDE4OjI3LCBBbGV4YW5kZXIgR3JhZiB3cm90ZToN Cj4gPiA+Pj4+PiBPbiAxNy4wNy4xNCAxODoyNCwgQmhhcmF0LkJodXNoYW5AZnJlZXNjYWxlLmNv bSB3cm90ZToNC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b25seSBuZWVkIHRvIGF2b2lkIHVzaW5nDQo+IFNQUkdfVEhS RUFEIGluIF9fS1ZNX0hBTkRMRVIgKGkuZS4gcmV2ZXJ0IGNvbW1pdA0KPiBmZmUxMjllY2Q3OTc3 OTIyMWZkYjAzMzA1MDQ5ZWM4YjVhOGJlYjBmKS4NCg0KRGlkIG5vdCBnZXQgd2h5IHVzaW5nIFNQ UkdfVEhSRUFEIGhlcmUgaXMgYSBwcm9ibGVtPyBJcyBub3QgdGhpcyB3aWxsIGFsd2F5cyBhY2Nl c3MgaG9zdCBTUFJHMyBhbmQgZ3Vlc3QgcmVhZCB3cml0ZSB3aWxsIGFsd2F5cyB0cmFwIChtYWlu dGFpbmVkIGluIHZjcHUtPmFyY2gtPnNoYXJlZC0+cmVnLT5zcHJnMykNCg0KWWVzIHdlIGFyZSBu b3QgY29uc2lzdGVudCB3aXRoICJLVk0sIHRoZSBob3N0IFNQUkcxIGlzIHVzZWQgdG8gcG9pbnQg dG8gdGhlIGN1cnJlbnQgVkNQVSBkYXRhIHN0cnVjdHVyZSIgLCB3aGljaCBuZWVkIHRvIGJlIGNv cnJlY3RlZA0KDQpUaGFua3MNCi1CaGFyYXQNCg0KPiANCj4gQW5kIGlmIHdlIGRlY2lkZSBpdCdz IG5vdCB3b3J0aHdoaWxlIGFuZCBkb24ndCByZXZlcnQgdGhhdCBjb21taXQsIHdlIHNob3VsZCBh dA0KPiBsZWFzdCByZW1vdmUgdGhlIGNvbW1lbnQgdGhhdCAiVW5kZXIgS1ZNLCB0aGUgaG9zdCBT UFJHMSBpcyB1c2VkIHRvIHBvaW50IHRvIHRoZQ0KPiBjdXJyZW50IFZDUFUgZGF0YSBzdHJ1Y3R1 cmUiLi4uDQo+IA0KPiAtU2NvdHQNCj4gDQoNCg= ^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 9:57 ` Bharat.Bhushan 0 siblings, 0 replies; 30+ messages in thread From: Bharat.Bhushan @ 2014-07-18 9:57 UTC (permalink / raw) To: Scott Wood, Alexander Graf Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder > -----Original Message----- > From: Wood Scott-B07421 > Sent: Friday, July 18, 2014 6:19 AM > To: Alexander Graf > Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Yoder > Stuart-B08248 > Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest > > On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: > > On 18.07.14 02:36, Scott Wood wrote: > > > On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: > > >> On 18.07.14 02:28, Scott Wood wrote: > > >>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > > >>>> 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. > > >>> SPRG3 is not guest writeable. We should be doing this so that > > >>> guest reads of SPRG3 through the alternative read-only SPR work, > > >>> not because > > >>> "SPRG3 can be clobbered by host or another guest". > > >>> > > >>>>>>>> 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. > > >>> Linux no longer uses SPRG4-7 for itself. That is not true of > > >>> SPRG3, as Alex points out. > > >>> > > >>>>> 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 :). > > >>> To make this work we need to avoid SPRG3 as well, or at least > > >>> avoid using it for something needed prior to DO_KVM. > > >>> > > >>> We also need to update the documentation in reg.h to reflect the > > >>> fact that we don't use SPRG4-7 anymore on e500. > > >> I would personally prefer if we claim SPRG3R as unsupported on > > >> e500v2 until we find someone who actually uses it. There's a good > > >> chance we'd start jumping through a lot of hoops and reduce overall > > >> performance for no real-world gain today. > > > The same problem applies to e500mc. We have two SPRG3 registers 1) SPRN_SPRG3 -- All read/write access to this register in guest will trap and emulate, So no need to save/restore. 2) SPRN_SPRG3R -- This is guest read only and We do not see any user of this register, so can leave this for now > > > > There we have SPRN_GSPRG3, no? > > Oh, right. > > Since it's only a problem for PR-mode, it can be fixed without needing to avoid > SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only need to avoid using > SPRG_THREAD in __KVM_HANDLER (i.e. revert commit > ffe129ecd79779221fdb03305049ec8b5a8beb0f). Did not get why using SPRG_THREAD here is a problem? Is not this will always access host SPRG3 and guest read write will always trap (maintained in vcpu->arch->shared->reg->sprg3) Yes we are not consistent with "KVM, the host SPRG1 is used to point to the current VCPU data structure" , which need to be corrected Thanks -Bharat > > And if we decide it's not worthwhile and don't revert that commit, we should at > least remove the comment that "Under KVM, the host SPRG1 is used to point to the > current VCPU data structure"... > > -Scott > ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 9:57 ` Bharat.Bhushan @ 2014-07-18 10:55 ` Alexander Graf -1 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-18 10:55 UTC (permalink / raw) To: Bharat.Bhushan@freescale.com, Scott Wood Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On 18.07.14 11:57, Bharat.Bhushan@freescale.com wrote: > >> -----Original Message----- >> From: Wood Scott-B07421 >> Sent: Friday, July 18, 2014 6:19 AM >> To: Alexander Graf >> Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Yoder >> Stuart-B08248 >> Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest >> >> On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: >>> On 18.07.14 02:36, Scott Wood wrote: >>>> On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: >>>>> On 18.07.14 02:28, Scott Wood wrote: >>>>>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: >>>>>>> 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. >>>>>> SPRG3 is not guest writeable. We should be doing this so that >>>>>> guest reads of SPRG3 through the alternative read-only SPR work, >>>>>> not because >>>>>> "SPRG3 can be clobbered by host or another guest". >>>>>> >>>>>>>>>>> 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. >>>>>> Linux no longer uses SPRG4-7 for itself. That is not true of >>>>>> SPRG3, as Alex points out. >>>>>> >>>>>>>> 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 :). >>>>>> To make this work we need to avoid SPRG3 as well, or at least >>>>>> avoid using it for something needed prior to DO_KVM. >>>>>> >>>>>> We also need to update the documentation in reg.h to reflect the >>>>>> fact that we don't use SPRG4-7 anymore on e500. >>>>> I would personally prefer if we claim SPRG3R as unsupported on >>>>> e500v2 until we find someone who actually uses it. There's a good >>>>> chance we'd start jumping through a lot of hoops and reduce overall >>>>> performance for no real-world gain today. >>>> The same problem applies to e500mc. > We have two SPRG3 registers > 1) SPRN_SPRG3 -- All read/write access to this register in guest will trap and emulate, So no need to save/restore. > 2) SPRN_SPRG3R -- This is guest read only and We do not see any user of this register, so can leave this for now > >>> There we have SPRN_GSPRG3, no? >> Oh, right. >> >> Since it's only a problem for PR-mode, it can be fixed without needing to avoid >> SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only need to avoid using >> SPRG_THREAD in __KVM_HANDLER (i.e. revert commit >> ffe129ecd79779221fdb03305049ec8b5a8beb0f). > Did not get why using SPRG_THREAD here is a problem? Is not this will always access host SPRG3 and guest read write will always trap (maintained in vcpu->arch->shared->reg->sprg3) Guest reads via SPRG3R will access the real SPRG3 register. Guest reads via SPRG3 will trap :). Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 10:55 ` Alexander Graf 0 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-18 10:55 UTC (permalink / raw) To: Bharat.Bhushan@freescale.com, Scott Wood Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On 18.07.14 11:57, Bharat.Bhushan@freescale.com wrote: > >> -----Original Message----- >> From: Wood Scott-B07421 >> Sent: Friday, July 18, 2014 6:19 AM >> To: Alexander Graf >> Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Yoder >> Stuart-B08248 >> Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest >> >> On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: >>> On 18.07.14 02:36, Scott Wood wrote: >>>> On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: >>>>> On 18.07.14 02:28, Scott Wood wrote: >>>>>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: >>>>>>> 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. >>>>>> SPRG3 is not guest writeable. We should be doing this so that >>>>>> guest reads of SPRG3 through the alternative read-only SPR work, >>>>>> not because >>>>>> "SPRG3 can be clobbered by host or another guest". >>>>>> >>>>>>>>>>> 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. >>>>>> Linux no longer uses SPRG4-7 for itself. That is not true of >>>>>> SPRG3, as Alex points out. >>>>>> >>>>>>>> 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 :). >>>>>> To make this work we need to avoid SPRG3 as well, or at least >>>>>> avoid using it for something needed prior to DO_KVM. >>>>>> >>>>>> We also need to update the documentation in reg.h to reflect the >>>>>> fact that we don't use SPRG4-7 anymore on e500. >>>>> I would personally prefer if we claim SPRG3R as unsupported on >>>>> e500v2 until we find someone who actually uses it. There's a good >>>>> chance we'd start jumping through a lot of hoops and reduce overall >>>>> performance for no real-world gain today. >>>> The same problem applies to e500mc. > We have two SPRG3 registers > 1) SPRN_SPRG3 -- All read/write access to this register in guest will trap and emulate, So no need to save/restore. > 2) SPRN_SPRG3R -- This is guest read only and We do not see any user of this register, so can leave this for now > >>> There we have SPRN_GSPRG3, no? >> Oh, right. >> >> Since it's only a problem for PR-mode, it can be fixed without needing to avoid >> SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only need to avoid using >> SPRG_THREAD in __KVM_HANDLER (i.e. revert commit >> ffe129ecd79779221fdb03305049ec8b5a8beb0f). > Did not get why using SPRG_THREAD here is a problem? Is not this will always access host SPRG3 and guest read write will always trap (maintained in vcpu->arch->shared->reg->sprg3) Guest reads via SPRG3R will access the real SPRG3 register. Guest reads via SPRG3 will trap :). Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 10:55 ` Alexander Graf @ 2014-07-18 13:42 ` Bharat.Bhushan -1 siblings, 0 replies; 30+ messages in thread From: Bharat.Bhushan @ 2014-07-18 13:42 UTC (permalink / raw) To: Alexander Graf, Scott Wood Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQWxleGFuZGVyIEdyYWYg W21haWx0bzphZ3JhZkBzdXNlLmRlXQ0KPiBTZW50OiBGcmlkYXksIEp1bHkgMTgsIDIwMTQgNDoy NSBQTQ0KPiBUbzogQmh1c2hhbiBCaGFyYXQt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KDQpBZ3JlZSwgQWxzbyB3ZSBkbyBub3Qg c2VlIExpbnV4IGFzIGd1ZXN0IGlzIGFjY2Vzc2luZyBTUFJHM1IuIEJ1dCB3aGF0IEkgZGlkIG5v dCBnZXQgd2hhdCB0aGUgbWVudGlvbmVkIHBhdGNoIGhhdmUgdG8gZG8gd2l0aCB0aGF0Pw0KDQoN Cj4gDQo+IA0KPiBBbGV4DQoNCg= ^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 13:42 ` Bharat.Bhushan 0 siblings, 0 replies; 30+ messages in thread From: Bharat.Bhushan @ 2014-07-18 13:42 UTC (permalink / raw) To: Alexander Graf, Scott Wood Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder > -----Original Message----- > From: Alexander Graf [mailto:agraf@suse.de] > Sent: Friday, July 18, 2014 4:25 PM > To: Bhushan Bharat-R65777; Wood Scott-B07421 > Cc: kvm-ppc@vger.kernel.org; kvm@vger.kernel.org; Yoder Stuart-B08248 > Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest > > > On 18.07.14 11:57, Bharat.Bhushan@freescale.com wrote: > > > >> -----Original Message----- > >> From: Wood Scott-B07421 > >> Sent: Friday, July 18, 2014 6:19 AM > >> To: Alexander Graf > >> Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; > >> kvm@vger.kernel.org; Yoder > >> Stuart-B08248 > >> Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering > >> guest > >> > >> On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: > >>> On 18.07.14 02:36, Scott Wood wrote: > >>>> On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: > >>>>> On 18.07.14 02:28, Scott Wood wrote: > >>>>>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > >>>>>>> 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. > >>>>>> SPRG3 is not guest writeable. We should be doing this so that > >>>>>> guest reads of SPRG3 through the alternative read-only SPR work, > >>>>>> not because > >>>>>> "SPRG3 can be clobbered by host or another guest". > >>>>>> > >>>>>>>>>>> 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. > >>>>>> Linux no longer uses SPRG4-7 for itself. That is not true of > >>>>>> SPRG3, as Alex points out. > >>>>>> > >>>>>>>> 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 :). > >>>>>> To make this work we need to avoid SPRG3 as well, or at least > >>>>>> avoid using it for something needed prior to DO_KVM. > >>>>>> > >>>>>> We also need to update the documentation in reg.h to reflect the > >>>>>> fact that we don't use SPRG4-7 anymore on e500. > >>>>> I would personally prefer if we claim SPRG3R as unsupported on > >>>>> e500v2 until we find someone who actually uses it. There's a good > >>>>> chance we'd start jumping through a lot of hoops and reduce > >>>>> overall performance for no real-world gain today. > >>>> The same problem applies to e500mc. > > We have two SPRG3 registers > > 1) SPRN_SPRG3 -- All read/write access to this register in guest > will trap and emulate, So no need to save/restore. > > 2) SPRN_SPRG3R -- This is guest read only and We do not see any user > of this register, so can leave this for now > > > >>> There we have SPRN_GSPRG3, no? > >> Oh, right. > >> > >> Since it's only a problem for PR-mode, it can be fixed without > >> needing to avoid > >> SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only need to > >> avoid using SPRG_THREAD in __KVM_HANDLER (i.e. revert commit > >> ffe129ecd79779221fdb03305049ec8b5a8beb0f). > > Did not get why using SPRG_THREAD here is a problem? Is not this will > > always access host SPRG3 and guest read write will always trap > > (maintained in vcpu->arch->shared->reg->sprg3) > > Guest reads via SPRG3R will access the real SPRG3 register. Guest reads via > SPRG3 will trap :). Agree, Also we do not see Linux as guest is accessing SPRG3R. But what I did not get what the mentioned patch have to do with that? > > > Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 10:55 ` Alexander Graf @ 2014-07-18 14:01 ` Bharat.Bhushan -1 siblings, 0 replies; 30+ messages in thread From: Bharat.Bhushan @ 2014-07-18 14:01 UTC (permalink / raw) To: Bharat.Bhushan@freescale.com, Alexander Graf, Scott Wood Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder PiA+DQo+ID4gT24gMTguMDcuMTQgMTE6NTcsIEJoYXJhdC5CaHVzaGFuQGZyZWVzY2FsZS5jb20g d3JvdGU6DQo+ID4gPg0KPiA+ID4+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+ID4gPj4g RnJvbTogV29vZCBTY290dC1CMDc0MjENCj4gPiA+PiBTZW50OiBGcmlkYXksIEp1bHkgMTgsIDIw MTQgNjoxOSBBTQ0KPiA+ID4+IFRvOiBBbGV4YW5kZXIgR3JhZg0KPiA+ID4+IENjOiBCaHVzaGFu IEJoYXJhdC1SNjU3Nzc7IGt2bS1wcGNAdmdlci5rZXJuZWwub3JnOw0KPiA+ID4+IGt2bUB2Z2Vy Lmtlcm5lbC5vcmc7IFlvZGVyDQo+ID4gPj4gU3R1YXJ0LUIwODI0OA0KPiA+ID4+IFN1YmplY3Q6 IFJlOiBbUEFUQ0hdIGt2bTogcHBjOiBib29rZTogUmVzdG9yZSBTUFJHMyB3aGVuIGVudGVyaW5n DQo+ID4gPj4gZ3Vlc3QNCj4gPiA+Pg0KPiA+ID4+IE9uIEZyaSwgMjAxNC0wNy0xOCBhdCAwMjoz NyArMDIwMCwgQWxleGFuZGVyIEdyYWYgd3JvdGU6DQo+ID4gPj4+IE9uID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NkNzk3 NzkyMjFmZGIwMzMwNTA0OWVjOGI1YThiZWIwZikuDQo+ID4gPiBEaWQgbm90IGdldCB3aHkgdXNp bmcgU1BSR19USFJFQUQgaGVyZSBpcyBhIHByb2JsZW0/IElzIG5vdCB0aGlzDQo+ID4gPiB3aWxs IGFsd2F5cyBhY2Nlc3MgaG9zdCBTUFJHMyBhbmQgZ3Vlc3QgcmVhZCB3cml0ZSB3aWxsIGFsd2F5 cyB0cmFwDQo+ID4gPiAobWFpbnRhaW5lZCBpbiB2Y3B1LT5hcmNoLT5zaGFyZWQtPnJlZy0+c3By ZzMpDQo+ID4NCj4gPiBHdWVzdCByZWFkcyB2aWEgU1BSRzNSIHdpbGwgYWNjZXNzIHRoZSByZWFs IFNQUkczIHJlZ2lzdGVyLiBHdWVzdA0KPiA+IHJlYWRzIHZpYQ0KPiA+IFNQUkczIHdpbGwgdHJh cCA6KS4NCj4gDQo+IEFncmVlLCBBbHNvIHdlIGRvIG5vdCBzZWUgTGludXggYXMgZ3Vlc3QgaXMg YWNjZXNzaW5nIFNQUkczUi4gQnV0IHdoYXQgSSBkaWQgbm90DQo+IGdldCB3aGF0IHRoZSBtZW50 aW9uZWQgcGF0Y2ggaGF2ZSB0byBkbyB3aXRoIHRoYXQ/DQoNCkdvdCBpdCBhZnRlciBkaXNjdXNz aW9uIG9uIElSQywgSWYgd2UgbmVlZCB0byBjYXJlIGFib3V0IFNQUk5HM1IgZW11bGF0aW9uIHRo ZW4gd2Ugc2hvdWxkIG5vdCB1c2UgU1BSR19USFJFQUQgLg0KDQpUaGFua3MNCi1CaGFyYXQNCj4g DQo+IA0KPiA+DQo+ID4NCj4gPiBBbGV4DQoNCg= ^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 14:01 ` Bharat.Bhushan 0 siblings, 0 replies; 30+ messages in thread From: Bharat.Bhushan @ 2014-07-18 14:01 UTC (permalink / raw) To: Bharat.Bhushan@freescale.com, Alexander Graf, Scott Wood Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder > > > > On 18.07.14 11:57, Bharat.Bhushan@freescale.com wrote: > > > > > >> -----Original Message----- > > >> From: Wood Scott-B07421 > > >> Sent: Friday, July 18, 2014 6:19 AM > > >> To: Alexander Graf > > >> Cc: Bhushan Bharat-R65777; kvm-ppc@vger.kernel.org; > > >> kvm@vger.kernel.org; Yoder > > >> Stuart-B08248 > > >> Subject: Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering > > >> guest > > >> > > >> On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: > > >>> On 18.07.14 02:36, Scott Wood wrote: > > >>>> On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: > > >>>>> On 18.07.14 02:28, Scott Wood wrote: > > >>>>>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: > > >>>>>>> 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. > > >>>>>> SPRG3 is not guest writeable. We should be doing this so that > > >>>>>> guest reads of SPRG3 through the alternative read-only SPR > > >>>>>> work, not because > > >>>>>> "SPRG3 can be clobbered by host or another guest". > > >>>>>> > > >>>>>>>>>>> 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. > > >>>>>> Linux no longer uses SPRG4-7 for itself. That is not true of > > >>>>>> SPRG3, as Alex points out. > > >>>>>> > > >>>>>>>> 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 :). > > >>>>>> To make this work we need to avoid SPRG3 as well, or at least > > >>>>>> avoid using it for something needed prior to DO_KVM. > > >>>>>> > > >>>>>> We also need to update the documentation in reg.h to reflect > > >>>>>> the fact that we don't use SPRG4-7 anymore on e500. > > >>>>> I would personally prefer if we claim SPRG3R as unsupported on > > >>>>> e500v2 until we find someone who actually uses it. There's a > > >>>>> good chance we'd start jumping through a lot of hoops and reduce > > >>>>> overall performance for no real-world gain today. > > >>>> The same problem applies to e500mc. > > > We have two SPRG3 registers > > > 1) SPRN_SPRG3 -- All read/write access to this register in guest > > will trap and emulate, So no need to save/restore. > > > 2) SPRN_SPRG3R -- This is guest read only and We do not see any > user > > of this register, so can leave this for now > > > > > >>> There we have SPRN_GSPRG3, no? > > >> Oh, right. > > >> > > >> Since it's only a problem for PR-mode, it can be fixed without > > >> needing to avoid > > >> SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only need > > >> to avoid using SPRG_THREAD in __KVM_HANDLER (i.e. revert commit > > >> ffe129ecd79779221fdb03305049ec8b5a8beb0f). > > > Did not get why using SPRG_THREAD here is a problem? Is not this > > > will always access host SPRG3 and guest read write will always trap > > > (maintained in vcpu->arch->shared->reg->sprg3) > > > > Guest reads via SPRG3R will access the real SPRG3 register. Guest > > reads via > > SPRG3 will trap :). > > Agree, Also we do not see Linux as guest is accessing SPRG3R. But what I did not > get what the mentioned patch have to do with that? Got it after discussion on IRC, If we need to care about SPRNG3R emulation then we should not use SPRG_THREAD . Thanks -Bharat > > > > > > > > Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-18 0:49 ` Scott Wood @ 2014-07-18 11:14 ` Alexander Graf -1 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-18 11:14 UTC (permalink / raw) To: Scott Wood Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On 18.07.14 02:49, Scott Wood wrote: > On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: >> On 18.07.14 02:36, Scott Wood wrote: >>> On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: >>>> On 18.07.14 02:28, Scott Wood wrote: >>>>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: >>>>>> 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. >>>>> SPRG3 is not guest writeable. We should be doing this so that guest >>>>> reads of SPRG3 through the alternative read-only SPR work, not because >>>>> "SPRG3 can be clobbered by host or another guest". >>>>> >>>>>>>>>> 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. >>>>> Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as >>>>> Alex points out. >>>>> >>>>>>> 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 :). >>>>> To make this work we need to avoid SPRG3 as well, or at least avoid >>>>> using it for something needed prior to DO_KVM. >>>>> >>>>> We also need to update the documentation in reg.h to reflect the fact >>>>> that we don't use SPRG4-7 anymore on e500. >>>> I would personally prefer if we claim SPRG3R as unsupported on e500v2 >>>> until we find someone who actually uses it. There's a good chance we'd >>>> start jumping through a lot of hoops and reduce overall performance for >>>> no real-world gain today. >>> The same problem applies to e500mc. >> There we have SPRN_GSPRG3, no? > Oh, right. > > Since it's only a problem for PR-mode, it can be fixed without needing > to avoid SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only > need to avoid using SPRG_THREAD in __KVM_HANDLER (i.e. revert commit > ffe129ecd79779221fdb03305049ec8b5a8beb0f). > > And if we decide it's not worthwhile and don't revert that commit, we > should at least remove the comment that "Under KVM, the host SPRG1 is > used to point to the current VCPU data structure"... Agreed, please send a patch :). Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest @ 2014-07-18 11:14 ` Alexander Graf 0 siblings, 0 replies; 30+ messages in thread From: Alexander Graf @ 2014-07-18 11:14 UTC (permalink / raw) To: Scott Wood Cc: Bharat.Bhushan@freescale.com, kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Stuart Yoder On 18.07.14 02:49, Scott Wood wrote: > On Fri, 2014-07-18 at 02:37 +0200, Alexander Graf wrote: >> On 18.07.14 02:36, Scott Wood wrote: >>> On Fri, 2014-07-18 at 02:33 +0200, Alexander Graf wrote: >>>> On 18.07.14 02:28, Scott Wood wrote: >>>>> On Thu, 2014-07-17 at 18:29 +0200, Alexander Graf wrote: >>>>>> 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. >>>>> SPRG3 is not guest writeable. We should be doing this so that guest >>>>> reads of SPRG3 through the alternative read-only SPR work, not because >>>>> "SPRG3 can be clobbered by host or another guest". >>>>> >>>>>>>>>> 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. >>>>> Linux no longer uses SPRG4-7 for itself. That is not true of SPRG3, as >>>>> Alex points out. >>>>> >>>>>>> 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 :). >>>>> To make this work we need to avoid SPRG3 as well, or at least avoid >>>>> using it for something needed prior to DO_KVM. >>>>> >>>>> We also need to update the documentation in reg.h to reflect the fact >>>>> that we don't use SPRG4-7 anymore on e500. >>>> I would personally prefer if we claim SPRG3R as unsupported on e500v2 >>>> until we find someone who actually uses it. There's a good chance we'd >>>> start jumping through a lot of hoops and reduce overall performance for >>>> no real-world gain today. >>> The same problem applies to e500mc. >> There we have SPRN_GSPRG3, no? > Oh, right. > > Since it's only a problem for PR-mode, it can be fixed without needing > to avoid SPRG3 entirely, since PR-mode doesn't use DO_KVM. We'd only > need to avoid using SPRG_THREAD in __KVM_HANDLER (i.e. revert commit > ffe129ecd79779221fdb03305049ec8b5a8beb0f). > > And if we decide it's not worthwhile and don't revert that commit, we > should at least remove the comment that "Under KVM, the host SPRG1 is > used to point to the current VCPU data structure"... Agreed, please send a patch :). Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
* RE: [PATCH] kvm: ppc: booke: Restore SPRG3 when entering guest 2014-07-17 16:27 ` Alexander Graf (?) (?) @ 2014-07-17 16:32 ` Bharat.Bhushan -1 siblings, 0 replies; 30+ messages in thread From: Bharat.Bhushan @ 2014-07-17 16:32 UTC (permalink / raw) To: Alexander Graf, kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, Scott Wood, Stuart Yoder > -----Original Message----- > From: Alexander Graf [mailto:agraf@suse.de] > Sent: Thursday, July 17, 2014 9:58 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 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. I will add a comment in code as well. Thanks -Bharat > > > Alex ^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2014-07-18 14:01 UTC | newest] Thread overview: 30+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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.