diff mbox series

[v2,1/2] lib: s390x: add PSW and PSW_CUR_MASK macros

Message ID 20221129094142.10141-2-imbrenda@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series lib: s390x: add PSW and PSW_CUR_MASK macros | expand

Commit Message

Claudio Imbrenda Nov. 29, 2022, 9:41 a.m. UTC
Since a lot of code starts new CPUs using the current PSW mask, add two
macros to streamline the creation of generic PSWs and PSWs with the
current program mask.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 lib/s390x/asm/arch_def.h | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Nico Boehr Nov. 29, 2022, 9:43 a.m. UTC | #1
Quoting Claudio Imbrenda (2022-11-29 10:41:41)
> Since a lot of code starts new CPUs using the current PSW mask, add two
> macros to streamline the creation of generic PSWs and PSWs with the
> current program mask.
> 
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Janis Schoetterl-Glausch Nov. 29, 2022, 10:45 a.m. UTC | #2
On Tue, 2022-11-29 at 10:41 +0100, Claudio Imbrenda wrote:
> Since a lot of code starts new CPUs using the current PSW mask, add two
> macros to streamline the creation of generic PSWs and PSWs with the
> current program mask.
> 
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

Reviewed-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>

> ---
>  lib/s390x/asm/arch_def.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> index 783a7eaa..43137d5f 100644
> --- a/lib/s390x/asm/arch_def.h
> +++ b/lib/s390x/asm/arch_def.h
> @@ -41,6 +41,8 @@ struct psw {
>  	uint64_t	addr;
>  };
>  
> +#define PSW(m, a) ((struct psw){ .mask = (m), .addr = (uint64_t)(a) })
> +
>  struct short_psw {
>  	uint32_t	mask;
>  	uint32_t	addr;
> @@ -321,6 +323,8 @@ static inline uint64_t extract_psw_mask(void)
>  	return (uint64_t) mask_upper << 32 | mask_lower;
>  }
>  
> +#define PSW_CUR_MASK(addr) PSW(extract_psw_mask(), (addr))
> +
>  static inline void load_psw_mask(uint64_t mask)
>  {
>  	struct psw psw = {
Janosch Frank Nov. 29, 2022, 2:17 p.m. UTC | #3
On 11/29/22 10:41, Claudio Imbrenda wrote:
> Since a lot of code starts new CPUs using the current PSW mask, add two
> macros to streamline the creation of generic PSWs and PSWs with the
> current program mask.
> 
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
>   lib/s390x/asm/arch_def.h | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> index 783a7eaa..43137d5f 100644
> --- a/lib/s390x/asm/arch_def.h
> +++ b/lib/s390x/asm/arch_def.h
> @@ -41,6 +41,8 @@ struct psw {
>   	uint64_t	addr;
>   };
>   
> +#define PSW(m, a) ((struct psw){ .mask = (m), .addr = (uint64_t)(a) })
> +
>   struct short_psw {
>   	uint32_t	mask;
>   	uint32_t	addr;
> @@ -321,6 +323,8 @@ static inline uint64_t extract_psw_mask(void)
>   	return (uint64_t) mask_upper << 32 | mask_lower;
>   }
>   
> +#define PSW_CUR_MASK(addr) PSW(extract_psw_mask(), (addr))

This sounds too much like what extract_psw_mask() does.
So we should agree on a name that states that we receive a PSW and not a 
PSW mask.

s/PSW_CUR_MASK/PSW_WITH_CUR_MASK/

Other than that the code looks fine.

> +
>   static inline void load_psw_mask(uint64_t mask)
>   {
>   	struct psw psw = {
Claudio Imbrenda Nov. 30, 2022, 11:29 a.m. UTC | #4
On Tue, 29 Nov 2022 15:17:51 +0100
Janosch Frank <frankja@linux.ibm.com> wrote:

> On 11/29/22 10:41, Claudio Imbrenda wrote:
> > Since a lot of code starts new CPUs using the current PSW mask, add two
> > macros to streamline the creation of generic PSWs and PSWs with the
> > current program mask.
> > 
> > Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > ---
> >   lib/s390x/asm/arch_def.h | 4 ++++
> >   1 file changed, 4 insertions(+)
> > 
> > diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> > index 783a7eaa..43137d5f 100644
> > --- a/lib/s390x/asm/arch_def.h
> > +++ b/lib/s390x/asm/arch_def.h
> > @@ -41,6 +41,8 @@ struct psw {
> >   	uint64_t	addr;
> >   };
> >   
> > +#define PSW(m, a) ((struct psw){ .mask = (m), .addr = (uint64_t)(a) })
> > +
> >   struct short_psw {
> >   	uint32_t	mask;
> >   	uint32_t	addr;
> > @@ -321,6 +323,8 @@ static inline uint64_t extract_psw_mask(void)
> >   	return (uint64_t) mask_upper << 32 | mask_lower;
> >   }
> >   
> > +#define PSW_CUR_MASK(addr) PSW(extract_psw_mask(), (addr))  
> 
> This sounds too much like what extract_psw_mask() does.
> So we should agree on a name that states that we receive a PSW and not a 
> PSW mask.
> 
> s/PSW_CUR_MASK/PSW_WITH_CUR_MASK/
> 
> Other than that the code looks fine.

will do

> 
> > +
> >   static inline void load_psw_mask(uint64_t mask)
> >   {
> >   	struct psw psw = {  
>
diff mbox series

Patch

diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
index 783a7eaa..43137d5f 100644
--- a/lib/s390x/asm/arch_def.h
+++ b/lib/s390x/asm/arch_def.h
@@ -41,6 +41,8 @@  struct psw {
 	uint64_t	addr;
 };
 
+#define PSW(m, a) ((struct psw){ .mask = (m), .addr = (uint64_t)(a) })
+
 struct short_psw {
 	uint32_t	mask;
 	uint32_t	addr;
@@ -321,6 +323,8 @@  static inline uint64_t extract_psw_mask(void)
 	return (uint64_t) mask_upper << 32 | mask_lower;
 }
 
+#define PSW_CUR_MASK(addr) PSW(extract_psw_mask(), (addr))
+
 static inline void load_psw_mask(uint64_t mask)
 {
 	struct psw psw = {