diff mbox series

[v3,1/2] selftests/powerpc: Add MSR bits

Message ID 1546531862-11926-1-git-send-email-leitao@debian.org (mailing list archive)
State Superseded
Headers show
Series [v3,1/2] selftests/powerpc: Add MSR bits | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success next/apply_patch Successfully applied
snowpatch_ozlabs/checkpatch warning total: 0 errors, 0 warnings, 2 checks, 51 lines checked

Commit Message

Breno Leitao Jan. 3, 2019, 4:11 p.m. UTC
This patch simply adds definitions for the MSR bits and some macros to
test for MSR TM bits.

This was copied from arch/powerpc/include/asm/reg.h generic MSR part.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 tools/testing/selftests/powerpc/include/reg.h | 45 +++++++++++++++++++
 1 file changed, 45 insertions(+)

Comments

Christophe Leroy Jan. 3, 2019, 5:19 p.m. UTC | #1
Breno Leitao <leitao@debian.org> a écrit :

> This patch simply adds definitions for the MSR bits and some macros to
> test for MSR TM bits.
>
> This was copied from arch/powerpc/include/asm/reg.h generic MSR part.

Can't we find a way to avoid duplicating such defines ?

Christophe

>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>  tools/testing/selftests/powerpc/include/reg.h | 45 +++++++++++++++++++
>  1 file changed, 45 insertions(+)
>
> diff --git a/tools/testing/selftests/powerpc/include/reg.h  
> b/tools/testing/selftests/powerpc/include/reg.h
> index 52b4710469d2..b67a85404255 100644
> --- a/tools/testing/selftests/powerpc/include/reg.h
> +++ b/tools/testing/selftests/powerpc/include/reg.h
> @@ -77,6 +77,51 @@
>  #define TEXASR_TE	0x0000000004000000
>  #define TEXASR_ROT	0x0000000002000000
>
> +/* MSR register bits */
> +#define MSR_SF_LG       63              /* Enable 64 bit mode */
> +#define MSR_ISF_LG      61              /* Interrupt 64b mode valid  
> on 630 */
> +#define MSR_HV_LG       60              /* Hypervisor state */
> +#define MSR_TS_T_LG     34              /* Trans Mem state: Transactional */
> +#define MSR_TS_S_LG     33              /* Trans Mem state: Suspended */
> +#define MSR_TS_LG       33              /* Trans Mem state (2 bits) */
> +#define MSR_TM_LG       32              /* Trans Mem Available */
> +#define MSR_VEC_LG      25              /* Enable AltiVec */
> +#define MSR_VSX_LG      23              /* Enable VSX */
> +#define MSR_POW_LG      18              /* Enable Power Management */
> +#define MSR_WE_LG       18              /* Wait State Enable */
> +#define MSR_TGPR_LG     17              /* TLB Update registers in use */
> +#define MSR_CE_LG       17              /* Critical Interrupt Enable */
> +#define MSR_ILE_LG      16              /* Interrupt Little Endian */
> +#define MSR_EE_LG       15              /* External Interrupt Enable */
> +#define MSR_PR_LG       14              /* Problem State /  
> Privilege Level */
> +#define MSR_FP_LG       13              /* Floating Point enable */
> +#define MSR_ME_LG       12              /* Machine Check Enable */
> +#define MSR_FE0_LG      11              /* Floating Exception mode 0 */
> +#define MSR_SE_LG       10              /* Single Step */
> +#define MSR_BE_LG       9               /* Branch Trace */
> +#define MSR_DE_LG       9               /* Debug Exception Enable */
> +#define MSR_FE1_LG      8               /* Floating Exception mode 1 */
> +#define MSR_IP_LG       6               /* Exception prefix 0x000/0xFFF */
> +#define MSR_IR_LG       5               /* Instruction Relocate */
> +#define MSR_DR_LG       4               /* Data Relocate */
> +#define MSR_PE_LG       3               /* Protection Enable */
> +#define MSR_PX_LG       2               /* Protection Exclusive Mode */
> +#define MSR_PMM_LG      2               /* Performance monitor */
> +#define MSR_RI_LG       1               /* Recoverable Exception */
> +#define MSR_LE_LG       0               /* Little Endian */
> +
> +#ifdef __ASSEMBLY__
> +#define __MASK(X)       (1<<(X))
> +#else
> +#define __MASK(X)       (1UL<<(X))
> +#endif
> +
> +/* macros to check TM MSR bits */
> +#define MSR_TM          __MASK(MSR_TM_LG)     /* Transactional Mem  
> Available */
> +#define MSR_TS_S        __MASK(MSR_TS_S_LG)   /* Transaction Suspended */
> +#define MSR_TS_T        __MASK(MSR_TS_T_LG)   /* Transaction  
> Transactional */
> +#define MSR_TS_MASK     (MSR_TS_T | MSR_TS_S) /* Transaction State bits */
> +
>  /* Vector Instructions */
>  #define VSX_XX1(xs, ra, rb)	(((xs) & 0x1f) << 21 | ((ra) << 16) |  \
>  				 ((rb) << 11) | (((xs) >> 5)))
> --
> 2.19.0
Breno Leitao Jan. 7, 2019, 12:44 p.m. UTC | #2
hi Christophe,

On 1/3/19 3:19 PM, LEROY Christophe wrote:
> Breno Leitao <leitao@debian.org> a écrit :
> 
>> This patch simply adds definitions for the MSR bits and some macros to
>> test for MSR TM bits.
>>
>> This was copied from arch/powerpc/include/asm/reg.h generic MSR part.
> 
> Can't we find a way to avoid duplicating such defines ?

I think there are three possible ways, but none of them respect the premises
we are used too. These are the possible ways I can think of:

1) Including arch/powerpc/include/asm as part of the selftest compilation
process.
   Problem: This might break the selftest independence of the kbuild system.

2) Generate a temporary header file inside selftests/include which contains
these macros at compilation time.
   Problem: The problem as above.

3) Define MSR fields at userspace headers (/usr/include).
   Problem: I am not sure userspace should have MSR bits information.

Do you suggest me to investigate any other way?
Christophe Leroy Jan. 7, 2019, 12:47 p.m. UTC | #3
Hi Breno,

Le 07/01/2019 à 13:44, Breno Leitao a écrit :
> hi Christophe,
> 
> On 1/3/19 3:19 PM, LEROY Christophe wrote:
>> Breno Leitao <leitao@debian.org> a écrit :
>>
>>> This patch simply adds definitions for the MSR bits and some macros to
>>> test for MSR TM bits.
>>>
>>> This was copied from arch/powerpc/include/asm/reg.h generic MSR part.
>>
>> Can't we find a way to avoid duplicating such defines ?
> 
> I think there are three possible ways, but none of them respect the premises
> we are used too. These are the possible ways I can think of:
> 
> 1) Including arch/powerpc/include/asm as part of the selftest compilation
> process.
>     Problem: This might break the selftest independence of the kbuild system.
> 
> 2) Generate a temporary header file inside selftests/include which contains
> these macros at compilation time.
>     Problem: The problem as above.
> 
> 3) Define MSR fields at userspace headers (/usr/include).
>     Problem: I am not sure userspace should have MSR bits information.
> 
> Do you suggest me to investigate any other way?

Looking it other .h in selftests, it looks like they are limited to the 
only strictly necessary values.

Are all the values you have listed used ? If not, could you only include 
in the file the necessary ones ?

Christophe

>
Breno Leitao Jan. 7, 2019, 12:58 p.m. UTC | #4
hi Christophe,

On 1/7/19 10:47 AM, Christophe Leroy wrote:
> Hi Breno,
> 
> Le 07/01/2019 à 13:44, Breno Leitao a écrit :
>> hi Christophe,
>>
>> On 1/3/19 3:19 PM, LEROY Christophe wrote:
>>> Breno Leitao <leitao@debian.org> a écrit :
>>>
>>>> This patch simply adds definitions for the MSR bits and some macros to
>>>> test for MSR TM bits.
>>>>
>>>> This was copied from arch/powerpc/include/asm/reg.h generic MSR part.
>>>
>>> Can't we find a way to avoid duplicating such defines ?
>>
>> I think there are three possible ways, but none of them respect the premises
>> we are used too. These are the possible ways I can think of:
>>
>> 1) Including arch/powerpc/include/asm as part of the selftest compilation
>> process.
>>     Problem: This might break the selftest independence of the kbuild system.
>>
>> 2) Generate a temporary header file inside selftests/include which contains
>> these macros at compilation time.
>>     Problem: The problem as above.
>>
>> 3) Define MSR fields at userspace headers (/usr/include).
>>     Problem: I am not sure userspace should have MSR bits information.
>>
>> Do you suggest me to investigate any other way?
> 
> Looking it other .h in selftests, it looks like they are limited to the only
> strictly necessary values.
> 
> Are all the values you have listed used ? If not, could you only include in
> the file the necessary ones ?

Sure. That works also.  Let send a v4 patch.
Michael Ellerman Jan. 8, 2019, 9:20 a.m. UTC | #5
Breno Leitao <leitao@debian.org> writes:

> hi Christophe,
>
> On 1/3/19 3:19 PM, LEROY Christophe wrote:
>> Breno Leitao <leitao@debian.org> a écrit :
>> 
>>> This patch simply adds definitions for the MSR bits and some macros to
>>> test for MSR TM bits.
>>>
>>> This was copied from arch/powerpc/include/asm/reg.h generic MSR part.
>> 
>> Can't we find a way to avoid duplicating such defines ?
>
> I think there are three possible ways, but none of them respect the premises
> we are used too. These are the possible ways I can think of:
>
> 1) Including arch/powerpc/include/asm as part of the selftest compilation
> process.
>    Problem: This might break the selftest independence of the kbuild system.
>
> 2) Generate a temporary header file inside selftests/include which contains
> these macros at compilation time.
>    Problem: The problem as above.
>
> 3) Define MSR fields at userspace headers (/usr/include).
>    Problem: I am not sure userspace should have MSR bits information.
>
> Do you suggest me to investigate any other way?

In this case I think we can probably just copy the few #defines we need.

If we decide in future we need all or most of the MSR defines then I
would suggest we:
 - split *only* the MSR defines into arch/powerpc/include/asm/msr.h
 - include that file from reg.h
 - symlink that into the selftest code


cheers
Breno Leitao Jan. 8, 2019, 11:11 a.m. UTC | #6
Hi Michael,

On 1/8/19 7:20 AM, Michael Ellerman wrote:
> Breno Leitao <leitao@debian.org> writes:
> 
>> hi Christophe,
>>
>> On 1/3/19 3:19 PM, LEROY Christophe wrote:
>>> Breno Leitao <leitao@debian.org> a écrit :
>>>
>>>> This patch simply adds definitions for the MSR bits and some macros to
>>>> test for MSR TM bits.
>>>>
>>>> This was copied from arch/powerpc/include/asm/reg.h generic MSR part.
>>>
>>> Can't we find a way to avoid duplicating such defines ?
>>
>> I think there are three possible ways, but none of them respect the premises
>> we are used too. These are the possible ways I can think of:
>>
>> 1) Including arch/powerpc/include/asm as part of the selftest compilation
>> process.
>>    Problem: This might break the selftest independence of the kbuild system.
>>
>> 2) Generate a temporary header file inside selftests/include which contains
>> these macros at compilation time.
>>    Problem: The problem as above.
>>
>> 3) Define MSR fields at userspace headers (/usr/include).
>>    Problem: I am not sure userspace should have MSR bits information.
>>
>> Do you suggest me to investigate any other way?
> 
> In this case I think we can probably just copy the few #defines we need.

Cool. That is the very same thing as suggested by Christophe. I sent the v4
yesterday, with this change already.

Thanks for looking at it.
Christophe Leroy Jan. 8, 2019, 11:14 a.m. UTC | #7
Le 08/01/2019 à 12:11, Breno Leitao a écrit :
> Hi Michael,
> 
> On 1/8/19 7:20 AM, Michael Ellerman wrote:
>> Breno Leitao <leitao@debian.org> writes:
>>
>>> hi Christophe,
>>>
>>> On 1/3/19 3:19 PM, LEROY Christophe wrote:
>>>> Breno Leitao <leitao@debian.org> a écrit :
>>>>
>>>>> This patch simply adds definitions for the MSR bits and some macros to
>>>>> test for MSR TM bits.
>>>>>
>>>>> This was copied from arch/powerpc/include/asm/reg.h generic MSR part.
>>>>
>>>> Can't we find a way to avoid duplicating such defines ?
>>>
>>> I think there are three possible ways, but none of them respect the premises
>>> we are used too. These are the possible ways I can think of:
>>>
>>> 1) Including arch/powerpc/include/asm as part of the selftest compilation
>>> process.
>>>     Problem: This might break the selftest independence of the kbuild system.
>>>
>>> 2) Generate a temporary header file inside selftests/include which contains
>>> these macros at compilation time.
>>>     Problem: The problem as above.
>>>
>>> 3) Define MSR fields at userspace headers (/usr/include).
>>>     Problem: I am not sure userspace should have MSR bits information.
>>>
>>> Do you suggest me to investigate any other way?
>>
>> In this case I think we can probably just copy the few #defines we need.
> 
> Cool. That is the very same thing as suggested by Christophe. I sent the v4
> yesterday, with this change already.

It didn't get through. Latest is still v3 it seems, look 
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?submitter=71262

Christophe

> 
> Thanks for looking at it.
>
Breno Leitao Jan. 8, 2019, 11:31 a.m. UTC | #8
On 1/8/19 9:14 AM, Christophe Leroy wrote:
> Le 08/01/2019 à 12:11, Breno Leitao a écrit :
>> Hi Michael,
>>
>> On 1/8/19 7:20 AM, Michael Ellerman wrote:
>>> Breno Leitao <leitao@debian.org> writes:
>>>
>>>> hi Christophe,
>>>>
>>>> On 1/3/19 3:19 PM, LEROY Christophe wrote:
>>>>> Breno Leitao <leitao@debian.org> a écrit :
>>>>>
>>>>>> This patch simply adds definitions for the MSR bits and some macros to
>>>>>> test for MSR TM bits.
>>>>>>
>>>>>> This was copied from arch/powerpc/include/asm/reg.h generic MSR part.
>>>>>
>>>>> Can't we find a way to avoid duplicating such defines ?
>>>>
>>>> I think there are three possible ways, but none of them respect the premises
>>>> we are used too. These are the possible ways I can think of:
>>>>
>>>> 1) Including arch/powerpc/include/asm as part of the selftest compilation
>>>> process.
>>>>     Problem: This might break the selftest independence of the kbuild
>>>> system.
>>>>
>>>> 2) Generate a temporary header file inside selftests/include which contains
>>>> these macros at compilation time.
>>>>     Problem: The problem as above.
>>>>
>>>> 3) Define MSR fields at userspace headers (/usr/include).
>>>>     Problem: I am not sure userspace should have MSR bits information.
>>>>
>>>> Do you suggest me to investigate any other way?
>>>
>>> In this case I think we can probably just copy the few #defines we need.
>>
>> Cool. That is the very same thing as suggested by Christophe. I sent the v4
>> yesterday, with this change already.
> 
> It didn't get through. Latest is still v3 it seems, look
> https://patchwork.ozlabs.org/project/linuxppc-dev/list/?submitter=71262

Weird, I am not finding it as well, although I've just confirmed that I have,
in fact, sent it. Anyway, let me send it again.

Thanks!
diff mbox series

Patch

diff --git a/tools/testing/selftests/powerpc/include/reg.h b/tools/testing/selftests/powerpc/include/reg.h
index 52b4710469d2..b67a85404255 100644
--- a/tools/testing/selftests/powerpc/include/reg.h
+++ b/tools/testing/selftests/powerpc/include/reg.h
@@ -77,6 +77,51 @@ 
 #define TEXASR_TE	0x0000000004000000
 #define TEXASR_ROT	0x0000000002000000
 
+/* MSR register bits */
+#define MSR_SF_LG       63              /* Enable 64 bit mode */
+#define MSR_ISF_LG      61              /* Interrupt 64b mode valid on 630 */
+#define MSR_HV_LG       60              /* Hypervisor state */
+#define MSR_TS_T_LG     34              /* Trans Mem state: Transactional */
+#define MSR_TS_S_LG     33              /* Trans Mem state: Suspended */
+#define MSR_TS_LG       33              /* Trans Mem state (2 bits) */
+#define MSR_TM_LG       32              /* Trans Mem Available */
+#define MSR_VEC_LG      25              /* Enable AltiVec */
+#define MSR_VSX_LG      23              /* Enable VSX */
+#define MSR_POW_LG      18              /* Enable Power Management */
+#define MSR_WE_LG       18              /* Wait State Enable */
+#define MSR_TGPR_LG     17              /* TLB Update registers in use */
+#define MSR_CE_LG       17              /* Critical Interrupt Enable */
+#define MSR_ILE_LG      16              /* Interrupt Little Endian */
+#define MSR_EE_LG       15              /* External Interrupt Enable */
+#define MSR_PR_LG       14              /* Problem State / Privilege Level */
+#define MSR_FP_LG       13              /* Floating Point enable */
+#define MSR_ME_LG       12              /* Machine Check Enable */
+#define MSR_FE0_LG      11              /* Floating Exception mode 0 */
+#define MSR_SE_LG       10              /* Single Step */
+#define MSR_BE_LG       9               /* Branch Trace */
+#define MSR_DE_LG       9               /* Debug Exception Enable */
+#define MSR_FE1_LG      8               /* Floating Exception mode 1 */
+#define MSR_IP_LG       6               /* Exception prefix 0x000/0xFFF */
+#define MSR_IR_LG       5               /* Instruction Relocate */
+#define MSR_DR_LG       4               /* Data Relocate */
+#define MSR_PE_LG       3               /* Protection Enable */
+#define MSR_PX_LG       2               /* Protection Exclusive Mode */
+#define MSR_PMM_LG      2               /* Performance monitor */
+#define MSR_RI_LG       1               /* Recoverable Exception */
+#define MSR_LE_LG       0               /* Little Endian */
+
+#ifdef __ASSEMBLY__
+#define __MASK(X)       (1<<(X))
+#else
+#define __MASK(X)       (1UL<<(X))
+#endif
+
+/* macros to check TM MSR bits */
+#define MSR_TM          __MASK(MSR_TM_LG)     /* Transactional Mem Available */
+#define MSR_TS_S        __MASK(MSR_TS_S_LG)   /* Transaction Suspended */
+#define MSR_TS_T        __MASK(MSR_TS_T_LG)   /* Transaction Transactional */
+#define MSR_TS_MASK     (MSR_TS_T | MSR_TS_S) /* Transaction State bits */
+
 /* Vector Instructions */
 #define VSX_XX1(xs, ra, rb)	(((xs) & 0x1f) << 21 | ((ra) << 16) |  \
 				 ((rb) << 11) | (((xs) >> 5)))