Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-12 Thread David Gibson
On Fri, Aug 12, 2011 at 07:38:54AM +0200, Alexander Graf wrote:
 
 Am 12.08.2011 um 05:35 schrieb David Gibson da...@gibson.dropbear.id.au:
 
  On Tue, Aug 09, 2011 at 06:31:45PM +0200, Alexander Graf wrote:
  When running a PAPR guest, we need to handle a few hypercalls in kernel 
  space,
  most prominently the page table invalidation (to sync the shadows).
  
  So this patch adds handling for a few PAPR hypercalls to PR mode KVM. I 
  tried
  to share the code with HV mode, but it ended up being a lot easier this way
  around, as the two differ too much in those details.
  
  Are these strictly necessary, or just an optimization?  Because you're
  using the space allocated by qemu for the guest hash table, it seems
  to be you could just let h_enter fall through to qemu which will put
  the right thing into the guest hash table which you can then walk in
  the kernel translation code.
 
 Every time a PTE can be invalidated, we need to do so in kvm to keep
 the SPT in sync. IIRC h_enter can evict/overwrite a previous entry,
 so we need to handle it in kvm as well :). Removal definitely needs
 to happin in-kernel.

True.  I think you could actually delay this invalidation until the
guest issues the tlbie, but it's probably not worth it.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-12 Thread Alexander Graf

Am 12.08.2011 um 09:43 schrieb David Gibson da...@gibson.dropbear.id.au:

 On Fri, Aug 12, 2011 at 07:38:54AM +0200, Alexander Graf wrote:
 
 Am 12.08.2011 um 05:35 schrieb David Gibson da...@gibson.dropbear.id.au:
 
 On Tue, Aug 09, 2011 at 06:31:45PM +0200, Alexander Graf wrote:
 When running a PAPR guest, we need to handle a few hypercalls in kernel 
 space,
 most prominently the page table invalidation (to sync the shadows).
 
 So this patch adds handling for a few PAPR hypercalls to PR mode KVM. I 
 tried
 to share the code with HV mode, but it ended up being a lot easier this way
 around, as the two differ too much in those details.
 
 Are these strictly necessary, or just an optimization?  Because you're
 using the space allocated by qemu for the guest hash table, it seems
 to be you could just let h_enter fall through to qemu which will put
 the right thing into the guest hash table which you can then walk in
 the kernel translation code.
 
 Every time a PTE can be invalidated, we need to do so in kvm to keep
 the SPT in sync. IIRC h_enter can evict/overwrite a previous entry,
 so we need to handle it in kvm as well :). Removal definitely needs
 to happin in-kernel.
 
 True.  I think you could actually delay this invalidation until the
 guest issues the tlbie, but it's probably not worth it.

Well, since we need to have HTAB modification code in kvm for PR either way, 
I'd rather have all of it at the same place :)

Alex
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-11 Thread David Gibson
On Tue, Aug 09, 2011 at 06:31:45PM +0200, Alexander Graf wrote:
 When running a PAPR guest, we need to handle a few hypercalls in kernel space,
 most prominently the page table invalidation (to sync the shadows).
 
 So this patch adds handling for a few PAPR hypercalls to PR mode KVM. I tried
 to share the code with HV mode, but it ended up being a lot easier this way
 around, as the two differ too much in those details.

Are these strictly necessary, or just an optimization?  Because you're
using the space allocated by qemu for the guest hash table, it seems
to be you could just let h_enter fall through to qemu which will put
the right thing into the guest hash table which you can then walk in
the kernel translation code.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-11 Thread Alexander Graf

Am 12.08.2011 um 05:35 schrieb David Gibson da...@gibson.dropbear.id.au:

 On Tue, Aug 09, 2011 at 06:31:45PM +0200, Alexander Graf wrote:
 When running a PAPR guest, we need to handle a few hypercalls in kernel 
 space,
 most prominently the page table invalidation (to sync the shadows).
 
 So this patch adds handling for a few PAPR hypercalls to PR mode KVM. I tried
 to share the code with HV mode, but it ended up being a lot easier this way
 around, as the two differ too much in those details.
 
 Are these strictly necessary, or just an optimization?  Because you're
 using the space allocated by qemu for the guest hash table, it seems
 to be you could just let h_enter fall through to qemu which will put
 the right thing into the guest hash table which you can then walk in
 the kernel translation code.

Every time a PTE can be invalidated, we need to do so in kvm to keep the SPT in 
sync. IIRC h_enter can evict/overwrite a previous entry, so we need to handle 
it in kvm as well :). Removal definitely needs to happin in-kernel.


Alex

 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-09 Thread Avi Kivity

On 08/09/2011 07:31 PM, Alexander Graf wrote:

When running a PAPR guest, we need to handle a few hypercalls in kernel space,
most prominently the page table invalidation (to sync the shadows).

So this patch adds handling for a few PAPR hypercalls to PR mode KVM. I tried
to share the code with HV mode, but it ended up being a lot easier this way
around, as the two differ too much in those details.


+++ b/arch/powerpc/kvm/book3s_pr_papr.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2011. Freescale Inc. All rights reserved.
+ *
+ * Authors:
+ *Alexander Grafag...@suse.de
+ *Paul Mackerraspau...@samba.org
+ *
+ * Description:
+ *
+ * Hypercall handling for running PAPR guests in PR KVM on Book 3S
+ * processors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ */


Copyright freescale, authors Paul and yourself?


+
+static unsigned long get_pteg_addr(struct kvm_vcpu *vcpu, long pte_index)
+{
+   struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
+   unsigned long pteg_addr;
+
+   pte_index= 4;
+   pte_index= ((1  ((vcpu_book3s-sdr1  0x1f) + 11)) - 1)  7 | 0x70;
+pteg_addr = vcpu_book3s-sdr1  0xfffcULL;
+   pteg_addr |= pte_index;
+
+   return pteg_addr;
+}


Evil space crept in.


--
error compiling committee.c: too many arguments to function

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-09 Thread Alexander Graf

On 08/09/2011 06:40 PM, Avi Kivity wrote:

On 08/09/2011 07:31 PM, Alexander Graf wrote:
When running a PAPR guest, we need to handle a few hypercalls in 
kernel space,

most prominently the page table invalidation (to sync the shadows).

So this patch adds handling for a few PAPR hypercalls to PR mode KVM. 
I tried
to share the code with HV mode, but it ended up being a lot easier 
this way

around, as the two differ too much in those details.


+++ b/arch/powerpc/kvm/book3s_pr_papr.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2011. Freescale Inc. All rights reserved.
+ *
+ * Authors:
+ *Alexander Grafag...@suse.de
+ *Paul Mackerraspau...@samba.org
+ *
+ * Description:
+ *
+ * Hypercall handling for running PAPR guests in PR KVM on Book 3S
+ * processors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ */


Copyright freescale, authors Paul and yourself?


Yeah, I'm reasonably clueless when it comes to legal stuff. This code is 
inspired by Paul's, but is mostly rewritten since it's so tied into the 
virtual MMU. What would the copyright be in that case?





+
+static unsigned long get_pteg_addr(struct kvm_vcpu *vcpu, long 
pte_index)

+{
+struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
+unsigned long pteg_addr;
+
+pte_index= 4;
+pte_index= ((1  ((vcpu_book3s-sdr1  0x1f) + 11)) - 1)  7 
| 0x70;

+pteg_addr = vcpu_book3s-sdr1  0xfffcULL;
+pteg_addr |= pte_index;
+
+return pteg_addr;
+}


Evil space crept in.



Oh noez! Fixed it :)


Alex

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-09 Thread Avi Kivity

On 08/09/2011 07:46 PM, Alexander Graf wrote:

On 08/09/2011 06:40 PM, Avi Kivity wrote:

On 08/09/2011 07:31 PM, Alexander Graf wrote:
When running a PAPR guest, we need to handle a few hypercalls in 
kernel space,

most prominently the page table invalidation (to sync the shadows).

So this patch adds handling for a few PAPR hypercalls to PR mode 
KVM. I tried
to share the code with HV mode, but it ended up being a lot easier 
this way

around, as the two differ too much in those details.


+++ b/arch/powerpc/kvm/book3s_pr_papr.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2011. Freescale Inc. All rights reserved.
+ *
+ * Authors:
+ *Alexander Grafag...@suse.de
+ *Paul Mackerraspau...@samba.org
+ *
+ * Description:
+ *
+ * Hypercall handling for running PAPR guests in PR KVM on Book 3S
+ * processors.
+ *
+ * This program is free software; you can redistribute it and/or 
modify

+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ */


Copyright freescale, authors Paul and yourself?


Yeah, I'm reasonably clueless when it comes to legal stuff. This code 
is inspired by Paul's, but is mostly rewritten since it's so tied into 
the virtual MMU. What would the copyright be in that case?


Just put your own (or your employers').  If someone contributed to the 
code they can add their copyrights (or ask you do do it before inclusion).


It would be good to get Paul's or Ben's so that the unimportant 
characters between the whitespace get some braintime.


--
error compiling committee.c: too many arguments to function

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-09 Thread Alexander Graf

On 08/09/2011 06:49 PM, Avi Kivity wrote:

On 08/09/2011 07:46 PM, Alexander Graf wrote:

On 08/09/2011 06:40 PM, Avi Kivity wrote:

On 08/09/2011 07:31 PM, Alexander Graf wrote:
When running a PAPR guest, we need to handle a few hypercalls in 
kernel space,

most prominently the page table invalidation (to sync the shadows).

So this patch adds handling for a few PAPR hypercalls to PR mode 
KVM. I tried
to share the code with HV mode, but it ended up being a lot easier 
this way

around, as the two differ too much in those details.


+++ b/arch/powerpc/kvm/book3s_pr_papr.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2011. Freescale Inc. All rights reserved.
+ *
+ * Authors:
+ *Alexander Grafag...@suse.de
+ *Paul Mackerraspau...@samba.org
+ *
+ * Description:
+ *
+ * Hypercall handling for running PAPR guests in PR KVM on Book 3S
+ * processors.
+ *
+ * This program is free software; you can redistribute it and/or 
modify
+ * it under the terms of the GNU General Public License, version 
2, as

+ * published by the Free Software Foundation.
+ */


Copyright freescale, authors Paul and yourself?


Yeah, I'm reasonably clueless when it comes to legal stuff. This code 
is inspired by Paul's, but is mostly rewritten since it's so tied 
into the virtual MMU. What would the copyright be in that case?


Just put your own (or your employers').  If someone contributed to the 
code they can add their copyrights (or ask you do do it before 
inclusion).


It would be good to get Paul's or Ben's so that the unimportant 
characters between the whitespace get some braintime.


So you mean I just put both copyright statements there? That's a nice idea!


Alex

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-09 Thread Avi Kivity

On 08/09/2011 07:51 PM, Alexander Graf wrote:
Just put your own (or your employers').  If someone contributed to 
the code they can add their copyrights (or ask you do do it before 
inclusion).


It would be good to get Paul's or Ben's so that the unimportant 
characters between the whitespace get some braintime.



So you mean I just put both copyright statements there? That's a nice 
idea!





I meant Paul's or Ben's *review*.

--
error compiling committee.c: too many arguments to function

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 07/10] KVM: PPC: Add PAPR hypercall code for PR mode

2011-08-09 Thread Benjamin Herrenschmidt
On Tue, 2011-08-09 at 20:01 +0300, Avi Kivity wrote:
 On 08/09/2011 07:51 PM, Alexander Graf wrote:
  Just put your own (or your employers').  If someone contributed to 
  the code they can add their copyrights (or ask you do do it before 
  inclusion).
 
  It would be good to get Paul's or Ben's so that the unimportant 
  characters between the whitespace get some braintime.
 
 
  So you mean I just put both copyright statements there? That's a nice 
  idea!
 
 
 
 I meant Paul's or Ben's *review*.

Ben's currently travelling doing some bringup :-) I will try to have a
look but I can't promise anything for the next 2 weeks.

Cheers,
Ben.



___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev