Patchwork [09/26] KVM: PPC: Add PV guest scratch registers

login
register
mail settings
Submitter Alexander Graf
Date June 25, 2010, 11:24 p.m.
Message ID <1277508314-915-10-git-send-email-agraf@suse.de>
Download mbox | patch
Permalink /patch/57016/
State Not Applicable
Headers show

Comments

Alexander Graf - June 25, 2010, 11:24 p.m.
While running in hooked code we need to store register contents out because
we must not clobber any registers.

So let's add some fields to the shared page we can just happily write to.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/include/asm/kvm_para.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Avi Kivity - June 27, 2010, 8:22 a.m.
On 06/26/2010 02:24 AM, Alexander Graf wrote:
> While running in hooked code we need to store register contents out because
> we must not clobber any registers.
>
> So let's add some fields to the shared page we can just happily write to.
>
>    

How are these protected during interrupts?
Alexander Graf - June 27, 2010, 9:41 a.m.
Am 27.06.2010 um 10:22 schrieb Avi Kivity <avi@redhat.com>:

> On 06/26/2010 02:24 AM, Alexander Graf wrote:
>> While running in hooked code we need to store register contents out  
>> because
>> we must not clobber any registers.
>>
>> So let's add some fields to the shared page we can just happily  
>> write to.
>>
>>
>
> How are these protected during interrupts?

By the 'critical section' bit. When in a critical section (read: using  
scratch registers), we don't issue interrupts.

Alex
Avi Kivity - June 27, 2010, 9:53 a.m.
On 06/27/2010 12:41 PM, Alexander Graf wrote:
>
> Am 27.06.2010 um 10:22 schrieb Avi Kivity <avi@redhat.com>:
>
>> On 06/26/2010 02:24 AM, Alexander Graf wrote:
>>> While running in hooked code we need to store register contents out 
>>> because
>>> we must not clobber any registers.
>>>
>>> So let's add some fields to the shared page we can just happily 
>>> write to.
>>>
>>>
>>
>> How are these protected during interrupts?
>
> By the 'critical section' bit. When in a critical section (read: using 
> scratch registers), we don't issue interrupts.

Ok.  I thought you needed scratch registers to set up the critical 
section, but you don't.  Neat stuff.

Patch

diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
index d1fe9ae..edf8f83 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -23,6 +23,9 @@ 
 #include <linux/types.h>
 
 struct kvm_vcpu_arch_shared {
+	__u64 scratch1;
+	__u64 scratch2;
+	__u64 scratch3;
 	__u64 critical;		/* Guest may not get interrupts if == r1 */
 	__u64 sprg0;
 	__u64 sprg1;