diff mbox series

[QEMU-PPC,RFC,1/2] target/ppc: Add one reg id for ptcr

Message ID 20180927065009.32154-2-sjitindarsingh@gmail.com (mailing list archive)
State New, archived
Headers show
Series ppc/spapr: Add support for nested kvm-hv | expand

Commit Message

Suraj Jitindar Singh Sept. 27, 2018, 6:50 a.m. UTC
The ptcr (partition table control register) is used to store the address
and size of the partition table. For nested kvm-hv we have a level 1
guest register the location of it's partition table with the hypervisor.
Thus to support migration we need to be able to read this out of kvm
and restore it post migration.

Add the one reg id for the ptcr.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
---
 linux-headers/asm-powerpc/kvm.h |  1 +
 target/ppc/translate_init.inc.c | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

Comments

David Gibson Sept. 28, 2018, 6:29 a.m. UTC | #1
On Thu, Sep 27, 2018 at 04:50:08PM +1000, Suraj Jitindar Singh wrote:
> The ptcr (partition table control register) is used to store the address
> and size of the partition table. For nested kvm-hv we have a level 1
> guest register the location of it's partition table with the hypervisor.
> Thus to support migration we need to be able to read this out of kvm
> and restore it post migration.
> 
> Add the one reg id for the ptcr.
> 
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> ---
>  linux-headers/asm-powerpc/kvm.h |  1 +
>  target/ppc/translate_init.inc.c | 10 +++++-----
>  2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kvm.h
> index 1b32b56a03..8c876c166e 100644
> --- a/linux-headers/asm-powerpc/kvm.h
> +++ b/linux-headers/asm-powerpc/kvm.h
> @@ -634,6 +634,7 @@ struct kvm_ppc_cpu_char {
>  
>  #define KVM_REG_PPC_DEC_EXPIRY	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe)
>  #define KVM_REG_PPC_ONLINE	(KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf)
> +#define KVM_REG_PPC_PTCR	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc0)
>  
>  /* Transactional Memory checkpointed state:
>   * This is all GPRs, all VSX regs and a subset of SPRs

The preferred procedure is to split linux-headers/ updates out into a
separate patch which just updates it to a specific kernel snapshot.
Obviously you can't quite do that until the necessary constats are in
the upstream kernel tree.  However, you can split the linux-headers/
changes out so it will be easy to update just that patch in the series
for the final version.

> diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
> index 263e63cb03..487196800b 100644
> --- a/target/ppc/translate_init.inc.c
> +++ b/target/ppc/translate_init.inc.c
> @@ -8197,11 +8197,11 @@ static void gen_spr_power9_mmu(CPUPPCState *env)
>  {
>  #if !defined(CONFIG_USER_ONLY)
>      /* Partition Table Control */
> -    spr_register_hv(env, SPR_PTCR, "PTCR",
> -                    SPR_NOACCESS, SPR_NOACCESS,
> -                    SPR_NOACCESS, SPR_NOACCESS,
> -                    &spr_read_generic, &spr_write_ptcr,
> -                    0x00000000);
> +    spr_register_kvm_hv(env, SPR_PTCR, "PTCR",
> +                        SPR_NOACCESS, SPR_NOACCESS,
> +                        SPR_NOACCESS, SPR_NOACCESS,
> +                        &spr_read_generic, &spr_write_ptcr,
> +                        KVM_REG_PPC_PTCR, 0x00000000);
>  #endif

Apart from that, this looks fine.

>  }
>
diff mbox series

Patch

diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kvm.h
index 1b32b56a03..8c876c166e 100644
--- a/linux-headers/asm-powerpc/kvm.h
+++ b/linux-headers/asm-powerpc/kvm.h
@@ -634,6 +634,7 @@  struct kvm_ppc_cpu_char {
 
 #define KVM_REG_PPC_DEC_EXPIRY	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe)
 #define KVM_REG_PPC_ONLINE	(KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf)
+#define KVM_REG_PPC_PTCR	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc0)
 
 /* Transactional Memory checkpointed state:
  * This is all GPRs, all VSX regs and a subset of SPRs
diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c
index 263e63cb03..487196800b 100644
--- a/target/ppc/translate_init.inc.c
+++ b/target/ppc/translate_init.inc.c
@@ -8197,11 +8197,11 @@  static void gen_spr_power9_mmu(CPUPPCState *env)
 {
 #if !defined(CONFIG_USER_ONLY)
     /* Partition Table Control */
-    spr_register_hv(env, SPR_PTCR, "PTCR",
-                    SPR_NOACCESS, SPR_NOACCESS,
-                    SPR_NOACCESS, SPR_NOACCESS,
-                    &spr_read_generic, &spr_write_ptcr,
-                    0x00000000);
+    spr_register_kvm_hv(env, SPR_PTCR, "PTCR",
+                        SPR_NOACCESS, SPR_NOACCESS,
+                        SPR_NOACCESS, SPR_NOACCESS,
+                        &spr_read_generic, &spr_write_ptcr,
+                        KVM_REG_PPC_PTCR, 0x00000000);
 #endif
 }