public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Stefan Liebler <stli@linux.ibm.com>
To: GNU C Library <libc-alpha@sourceware.org>
Cc: Stefan Liebler <stli@linux.ibm.com>
Subject: Re: [PATCH] S390: Also check vector support in memmove ifunc-selector [BZ #27511]
Date: Fri, 26 Mar 2021 11:07:38 +0100	[thread overview]
Message-ID: <17e2e772-9376-0b73-6d94-1e8e13f64c4b@linux.ibm.com> (raw)
In-Reply-To: <20210323162926.869418-1-stli@linux.ibm.com>

On 23/03/2021 17:29, Stefan Liebler wrote:
> The arch13 memmove variant is currently selected by the ifunc selector
> if the Miscellaneous-Instruction-Extensions Facility 3 facility bit
> is present, but the function is also using vector instructions.
> If the vector support is not present, one is receiving an operation
> exception.
> 
> Therefore this patch also checks for vector support in the ifunc
> selector and in ifunc-impl-list.c.
> 
> Just to be sure, the configure check is now also testing an arch13
> vector instruction and an arch13 Miscellaneous-Instruction-Extensions
> Facility 3 instruction.
> ---
>  sysdeps/s390/configure                   | 8 ++++++--
>  sysdeps/s390/configure.ac                | 8 ++++++--
>  sysdeps/s390/memmove.c                   | 2 +-
>  sysdeps/s390/multiarch/ifunc-impl-list.c | 3 ++-
>  4 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/sysdeps/s390/configure b/sysdeps/s390/configure
> index 5f98640d0f..7eaefbabcf 100644
> --- a/sysdeps/s390/configure
> +++ b/sysdeps/s390/configure
> @@ -123,7 +123,9 @@ void testinsn (char *buf)
>      __asm__ (".machine \"arch13\" \n\t"
>  	     ".machinemode \"zarch_nohighgprs\" \n\t"
>  	     "lghi %%r0,16 \n\t"
> -	     "mvcrl 0(%0),32(%0)" : : "a" (buf) : "memory", "r0");
> +	     "mvcrl 0(%0),32(%0) \n\t"
> +	     "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
> +	     : : "a" (buf) : "memory", "r0");
>  }
>  EOF
>  if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
> @@ -271,7 +273,9 @@ else
>  void testinsn (char *buf)
>  {
>      __asm__ ("lghi %%r0,16 \n\t"
> -	     "mvcrl 0(%0),32(%0)" : : "a" (buf) : "memory", "r0");
> +	     "mvcrl 0(%0),32(%0) \n\t"
> +	     "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
> +	     : : "a" (buf) : "memory", "r0");
>  }
>  EOF
>  if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS --shared conftest.c
> diff --git a/sysdeps/s390/configure.ac b/sysdeps/s390/configure.ac
> index dfe007a774..e6df624919 100644
> --- a/sysdeps/s390/configure.ac
> +++ b/sysdeps/s390/configure.ac
> @@ -88,7 +88,9 @@ void testinsn (char *buf)
>      __asm__ (".machine \"arch13\" \n\t"
>  	     ".machinemode \"zarch_nohighgprs\" \n\t"
>  	     "lghi %%r0,16 \n\t"
> -	     "mvcrl 0(%0),32(%0)" : : "a" (buf) : "memory", "r0");
> +	     "mvcrl 0(%0),32(%0) \n\t"
> +	     "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
> +	     : : "a" (buf) : "memory", "r0");
>  }
>  EOF
>  dnl test, if assembler supports S390 arch13 instructions
> @@ -195,7 +197,9 @@ cat > conftest.c <<\EOF
>  void testinsn (char *buf)
>  {
>      __asm__ ("lghi %%r0,16 \n\t"
> -	     "mvcrl 0(%0),32(%0)" : : "a" (buf) : "memory", "r0");
> +	     "mvcrl 0(%0),32(%0) \n\t"
> +	     "vstrs %%v20,%%v20,%%v20,%%v20,0,2"
> +	     : : "a" (buf) : "memory", "r0");
>  }
>  EOF
>  dnl test, if assembler supports S390 arch13 zarch instructions as default
> diff --git a/sysdeps/s390/memmove.c b/sysdeps/s390/memmove.c
> index f88ea79d97..1a7d3369f2 100644
> --- a/sysdeps/s390/memmove.c
> +++ b/sysdeps/s390/memmove.c
> @@ -43,7 +43,7 @@ extern __typeof (__redirect_memmove) MEMMOVE_ARCH13 attribute_hidden;
>  s390_libc_ifunc_expr (__redirect_memmove, memmove,
>  		      ({
>  			s390_libc_ifunc_expr_stfle_init ();
> -			(HAVE_MEMMOVE_ARCH13
> +			(HAVE_MEMMOVE_ARCH13 && (hwcap & HWCAP_S390_VXRS_EXT2)
>  			 && S390_IS_ARCH13_MIE3 (stfle_bits))
>  			  ? MEMMOVE_ARCH13
>  			  : (HAVE_MEMMOVE_Z13 && (hwcap & HWCAP_S390_VX))
> diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c
> index 4b170e4459..2ef38b72dd 100644
> --- a/sysdeps/s390/multiarch/ifunc-impl-list.c
> +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c
> @@ -171,7 +171,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
>      IFUNC_IMPL (i, name, memmove,
>  # if HAVE_MEMMOVE_ARCH13
>  		IFUNC_IMPL_ADD (array, i, memmove,
> -				S390_IS_ARCH13_MIE3 (stfle_bits),
> +				((dl_hwcap & HWCAP_S390_VXRS_EXT2)
> +				 && S390_IS_ARCH13_MIE3 (stfle_bits)),
>  				MEMMOVE_ARCH13)
>  # endif
>  # if HAVE_MEMMOVE_Z13
> 

I've just committed this patch after testing by booting with "novx"
kernel parameter which disables all vector related HWCAPs and the
enabling the vector part in the kernel.

Thanks,
Stefan

      reply	other threads:[~2021-03-26 10:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 16:29 Stefan Liebler
2021-03-26 10:07 ` Stefan Liebler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17e2e772-9376-0b73-6d94-1e8e13f64c4b@linux.ibm.com \
    --to=stli@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).