diff mbox

[1/6,v2] kvm: ppc: bookehv: Added wrapper macros for shadow registers

Message ID 1405596700-2699-2-git-send-email-Bharat.Bhushan@freescale.com
State New, archived
Headers show

Commit Message

Bharat Bhushan July 17, 2014, 11:31 a.m. UTC
There are shadow registers like, GSPRG[0-3], GSRR0, GSRR1 etc on
BOOKE-HV and these shadow registers are guest accessible.
So these shadow registers needs to be updated on BOOKE-HV.
This patch adds new macro for get/set helper of shadow register .

Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
---
v1->v2
 - Fix compilation for book3s (separate macro etc)

 arch/powerpc/include/asm/kvm_ppc.h | 44 +++++++++++++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 8 deletions(-)

Comments

Scott Wood July 18, 2014, 12:55 a.m. UTC | #1
On Thu, 2014-07-17 at 17:01 +0530, Bharat Bhushan wrote:
> There are shadow registers like, GSPRG[0-3], GSRR0, GSRR1 etc on
> BOOKE-HV and these shadow registers are guest accessible.
> So these shadow registers needs to be updated on BOOKE-HV.
> This patch adds new macro for get/set helper of shadow register .
> 
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
> ---
> v1->v2
>  - Fix compilation for book3s (separate macro etc)
> 
>  arch/powerpc/include/asm/kvm_ppc.h | 44 +++++++++++++++++++++++++++++++-------
>  1 file changed, 36 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
> index f3f7611..7646994 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -475,8 +475,20 @@ static inline bool kvmppc_shared_big_endian(struct kvm_vcpu *vcpu)
>  #endif
>  }
>  
> +#define SPRNG_WRAPPER_GET(reg, e500hv_spr)				\
> +static inline ulong kvmppc_get_##reg(struct kvm_vcpu *vcpu)		\
> +{									\
> +	return mfspr(e500hv_spr);					\
> +}									\
> +
> +#define SPRNG_WRAPPER_SET(reg, e500hv_spr)				\
> +static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, ulong val)	\
> +{									\
> +	mtspr(e500hv_spr, val);						\
> +}									\

Why "e500hv" rather than "bookehv"?

-Scott


--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf July 24, 2014, 3:04 p.m. UTC | #2
On 18.07.14 02:55, Scott Wood wrote:
> On Thu, 2014-07-17 at 17:01 +0530, Bharat Bhushan wrote:
>> There are shadow registers like, GSPRG[0-3], GSRR0, GSRR1 etc on
>> BOOKE-HV and these shadow registers are guest accessible.
>> So these shadow registers needs to be updated on BOOKE-HV.
>> This patch adds new macro for get/set helper of shadow register .
>>
>> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com>
>> ---
>> v1->v2
>>   - Fix compilation for book3s (separate macro etc)
>>
>>   arch/powerpc/include/asm/kvm_ppc.h | 44 +++++++++++++++++++++++++++++++-------
>>   1 file changed, 36 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
>> index f3f7611..7646994 100644
>> --- a/arch/powerpc/include/asm/kvm_ppc.h
>> +++ b/arch/powerpc/include/asm/kvm_ppc.h
>> @@ -475,8 +475,20 @@ static inline bool kvmppc_shared_big_endian(struct kvm_vcpu *vcpu)
>>   #endif
>>   }
>>   
>> +#define SPRNG_WRAPPER_GET(reg, e500hv_spr)				\
>> +static inline ulong kvmppc_get_##reg(struct kvm_vcpu *vcpu)		\
>> +{									\
>> +	return mfspr(e500hv_spr);					\
>> +}									\
>> +
>> +#define SPRNG_WRAPPER_SET(reg, e500hv_spr)				\
>> +static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, ulong val)	\
>> +{									\
>> +	mtspr(e500hv_spr, val);						\
>> +}									\
> Why "e500hv" rather than "bookehv"?

No good reason. Bharat, could you please send a quick patch to rename them?


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index f3f7611..7646994 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -475,8 +475,20 @@  static inline bool kvmppc_shared_big_endian(struct kvm_vcpu *vcpu)
 #endif
 }
 
+#define SPRNG_WRAPPER_GET(reg, e500hv_spr)				\
+static inline ulong kvmppc_get_##reg(struct kvm_vcpu *vcpu)		\
+{									\
+	return mfspr(e500hv_spr);					\
+}									\
+
+#define SPRNG_WRAPPER_SET(reg, e500hv_spr)				\
+static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, ulong val)	\
+{									\
+	mtspr(e500hv_spr, val);						\
+}									\
+
 #define SHARED_WRAPPER_GET(reg, size)					\
-static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu)	\
+static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu)		\
 {									\
 	if (kvmppc_shared_big_endian(vcpu))				\
 	       return be##size##_to_cpu(vcpu->arch.shared->reg);	\
@@ -497,14 +509,30 @@  static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, u##size val)	\
 	SHARED_WRAPPER_GET(reg, size)					\
 	SHARED_WRAPPER_SET(reg, size)					\
 
+#define SPRNG_WRAPPER(reg, e500hv_spr)					\
+	SPRNG_WRAPPER_GET(reg, e500hv_spr)				\
+	SPRNG_WRAPPER_SET(reg, e500hv_spr)				\
+
+#ifdef CONFIG_KVM_BOOKE_HV
+
+#define SHARED_SPRNG_WRAPPER(reg, size, e500hv_spr)			\
+	SPRNG_WRAPPER(reg, e500hv_spr)					\
+
+#else
+
+#define SHARED_SPRNG_WRAPPER(reg, size, e500hv_spr)			\
+	SHARED_WRAPPER(reg, size)					\
+
+#endif
+
 SHARED_WRAPPER(critical, 64)
-SHARED_WRAPPER(sprg0, 64)
-SHARED_WRAPPER(sprg1, 64)
-SHARED_WRAPPER(sprg2, 64)
-SHARED_WRAPPER(sprg3, 64)
-SHARED_WRAPPER(srr0, 64)
-SHARED_WRAPPER(srr1, 64)
-SHARED_WRAPPER(dar, 64)
+SHARED_SPRNG_WRAPPER(sprg0, 64, SPRN_GSPRG0)
+SHARED_SPRNG_WRAPPER(sprg1, 64, SPRN_GSPRG1)
+SHARED_SPRNG_WRAPPER(sprg2, 64, SPRN_GSPRG2)
+SHARED_SPRNG_WRAPPER(sprg3, 64, SPRN_GSPRG3)
+SHARED_SPRNG_WRAPPER(srr0, 64, SPRN_GSRR0)
+SHARED_SPRNG_WRAPPER(srr1, 64, SPRN_GSRR1)
+SHARED_SPRNG_WRAPPER(dar, 64, SPRN_GDEAR)
 SHARED_WRAPPER_GET(msr, 64)
 static inline void kvmppc_set_msr_fast(struct kvm_vcpu *vcpu, u64 val)
 {