diff mbox series

[PULL,23/44] target/ppc: Use vector variable shifts for VSL, VSR, VSRA

Message ID 20190529065017.15149-24-david@gibson.dropbear.id.au
State Accepted
Commit 571fbe6ccd7a159789e5d473e2837d45764197ec
Headers show
Series None | expand

Commit Message

David Gibson May 29, 2019, 6:49 a.m. UTC
From: Richard Henderson <richard.henderson@linaro.org>


The gvec expanders take care of masking the shift amount
against the element width.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Message-Id: <20190518191430.21686-2-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

---
 target/ppc/helper.h                 | 12 ----------
 target/ppc/int_helper.c             | 37 -----------------------------
 target/ppc/translate/vmx-impl.inc.c | 24 +++++++++----------
 3 files changed, 12 insertions(+), 61 deletions(-)

-- 
2.21.0

Comments

Laurent Vivier June 7, 2019, 9:29 a.m. UTC | #1
On 29/05/2019 08:49, David Gibson wrote:
> From: Richard Henderson <richard.henderson@linaro.org>

> 

> The gvec expanders take care of masking the shift amount

> against the element width.

> 

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> Message-Id: <20190518191430.21686-2-richard.henderson@linaro.org>

> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

> ---

>  target/ppc/helper.h                 | 12 ----------

>  target/ppc/int_helper.c             | 37 -----------------------------

>  target/ppc/translate/vmx-impl.inc.c | 24 +++++++++----------

>  3 files changed, 12 insertions(+), 61 deletions(-)


This patch introduces a regressions
 with Fedora 29 guest:

- during kernel boot:

[   40.397876] crypto_register_alg 'aes' = 0
[   40.577517] crypto_register_alg 'cbc(aes)' = 0
[   40.743576] crypto_register_alg 'ctr(aes)' = 0
[   41.061379] alg: skcipher: Test 1 failed (invalid result) on encryption for p8_aes_xts
[   41.062054] 00000000: 91 7c f6 9e bd 68 b2 ec 9b 9f e9 a3 ea dd a6 92
[   41.062163] 00000010: 98 10 35 57 5e dc 36 1e 9a f7 bc ba 39 f2 5c eb
[   41.062834] crypto_register_alg 'xts(aes)' = 0
[   41.077358] alg: hash: Test 2 failed for p8_ghash
[   41.077553] 00000000: 5f 89 ab f7 20 57 20 57 20 57 20 57 20 57 20 57

- with libssl:

# curl -o /dev/null https://www.google.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (35) error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac

[before, this one fails with:
curl: (35) error:04091068:rsa routines:int_rsa_verify:bad signature ]

If I revert this patch on top of 0d74f3b427 + "target/ppc: Fix lxvw4x, lxvh8x and lxvb16x", all works fine.

Thanks,
Laurent
Laurent Vivier June 7, 2019, 2:09 p.m. UTC | #2
On 07/06/2019 11:29, Laurent Vivier wrote:
> On 29/05/2019 08:49, David Gibson wrote:

>> From: Richard Henderson <richard.henderson@linaro.org>

>>

>> The gvec expanders take care of masking the shift amount

>> against the element width.

>>

>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

>> Message-Id: <20190518191430.21686-2-richard.henderson@linaro.org>

>> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

>> ---

>>  target/ppc/helper.h                 | 12 ----------

>>  target/ppc/int_helper.c             | 37 -----------------------------

>>  target/ppc/translate/vmx-impl.inc.c | 24 +++++++++----------

>>  3 files changed, 12 insertions(+), 61 deletions(-)

> 

> This patch introduces a regressions

>  with Fedora 29 guest:

> 

> - during kernel boot:

> 

> [   40.397876] crypto_register_alg 'aes' = 0

> [   40.577517] crypto_register_alg 'cbc(aes)' = 0

> [   40.743576] crypto_register_alg 'ctr(aes)' = 0

> [   41.061379] alg: skcipher: Test 1 failed (invalid result) on encryption for p8_aes_xts

> [   41.062054] 00000000: 91 7c f6 9e bd 68 b2 ec 9b 9f e9 a3 ea dd a6 92

> [   41.062163] 00000010: 98 10 35 57 5e dc 36 1e 9a f7 bc ba 39 f2 5c eb

> [   41.062834] crypto_register_alg 'xts(aes)' = 0

> [   41.077358] alg: hash: Test 2 failed for p8_ghash

> [   41.077553] 00000000: 5f 89 ab f7 20 57 20 57 20 57 20 57 20 57 20 57

> 

> - with libssl:

> 

> # curl -o /dev/null https://www.google.com

>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

>                                  Dload  Upload   Total   Spent    Left  Speed

>   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

> curl: (35) error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac

> 

> [before, this one fails with:

> curl: (35) error:04091068:rsa routines:int_rsa_verify:bad signature ]

> 

> If I revert this patch on top of 0d74f3b427 + "target/ppc: Fix lxvw4x, lxvh8x and lxvb16x", all works fine.

> 

> Thanks,

> Laurent

> 


This seems to fix the problem:

diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c
index 3b6052fe97..6f0709b307 100644
--- a/accel/tcg/tcg-runtime-gvec.c
+++ b/accel/tcg/tcg-runtime-gvec.c
@@ -874,7 +874,7 @@ void HELPER(gvec_sar8v)(void *d, void *a, void *b,
uint32_t desc)
     intptr_t oprsz = simd_oprsz(desc);
     intptr_t i;

-    for (i = 0; i < oprsz; i += sizeof(vec8)) {
+    for (i = 0; i < oprsz; i += sizeof(uint8_t)) {
         uint8_t sh = *(uint8_t *)(b + i) & 7;
         *(int8_t *)(d + i) = *(int8_t *)(a + i) >> sh;
     }

Thanks,
Laurent
Richard Henderson June 7, 2019, 2:28 p.m. UTC | #3
On 6/7/19 9:09 AM, Laurent Vivier wrote:
> On 07/06/2019 11:29, Laurent Vivier wrote:

>> On 29/05/2019 08:49, David Gibson wrote:

>>> From: Richard Henderson <richard.henderson@linaro.org>

>>>

>>> The gvec expanders take care of masking the shift amount

>>> against the element width.

>>>

>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

>>> Message-Id: <20190518191430.21686-2-richard.henderson@linaro.org>

>>> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

>>> ---

>>>  target/ppc/helper.h                 | 12 ----------

>>>  target/ppc/int_helper.c             | 37 -----------------------------

>>>  target/ppc/translate/vmx-impl.inc.c | 24 +++++++++----------

>>>  3 files changed, 12 insertions(+), 61 deletions(-)

>>

>> This patch introduces a regressions

>>  with Fedora 29 guest:

>>

>> - during kernel boot:

>>

>> [   40.397876] crypto_register_alg 'aes' = 0

>> [   40.577517] crypto_register_alg 'cbc(aes)' = 0

>> [   40.743576] crypto_register_alg 'ctr(aes)' = 0

>> [   41.061379] alg: skcipher: Test 1 failed (invalid result) on encryption for p8_aes_xts

>> [   41.062054] 00000000: 91 7c f6 9e bd 68 b2 ec 9b 9f e9 a3 ea dd a6 92

>> [   41.062163] 00000010: 98 10 35 57 5e dc 36 1e 9a f7 bc ba 39 f2 5c eb

>> [   41.062834] crypto_register_alg 'xts(aes)' = 0

>> [   41.077358] alg: hash: Test 2 failed for p8_ghash

>> [   41.077553] 00000000: 5f 89 ab f7 20 57 20 57 20 57 20 57 20 57 20 57

>>

>> - with libssl:

>>

>> # curl -o /dev/null https://www.google.com

>>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

>>                                  Dload  Upload   Total   Spent    Left  Speed

>>   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

>> curl: (35) error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac

>>

>> [before, this one fails with:

>> curl: (35) error:04091068:rsa routines:int_rsa_verify:bad signature ]

>>

>> If I revert this patch on top of 0d74f3b427 + "target/ppc: Fix lxvw4x, lxvh8x and lxvb16x", all works fine.

>>

>> Thanks,

>> Laurent

>>

> 

> This seems to fix the problem:

> 

> diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c

> index 3b6052fe97..6f0709b307 100644

> --- a/accel/tcg/tcg-runtime-gvec.c

> +++ b/accel/tcg/tcg-runtime-gvec.c

> @@ -874,7 +874,7 @@ void HELPER(gvec_sar8v)(void *d, void *a, void *b,

> uint32_t desc)

>      intptr_t oprsz = simd_oprsz(desc);

>      intptr_t i;

> 

> -    for (i = 0; i < oprsz; i += sizeof(vec8)) {

> +    for (i = 0; i < oprsz; i += sizeof(uint8_t)) {

>          uint8_t sh = *(uint8_t *)(b + i) & 7;

>          *(int8_t *)(d + i) = *(int8_t *)(a + i) >> sh;

>      }


Grr.  I really really need to come up with a solution for testing that allows
me to test paths that the host cpu would not ordinarily take.  This bug is
hidden on a host with AVX2.

Thanks for the digging.


r~
David Gibson June 11, 2019, 2:43 a.m. UTC | #4
On Fri, Jun 07, 2019 at 09:28:49AM -0500, Richard Henderson wrote:
> On 6/7/19 9:09 AM, Laurent Vivier wrote:

> > On 07/06/2019 11:29, Laurent Vivier wrote:

> >> On 29/05/2019 08:49, David Gibson wrote:

> >>> From: Richard Henderson <richard.henderson@linaro.org>

> >>>

> >>> The gvec expanders take care of masking the shift amount

> >>> against the element width.

> >>>

> >>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> >>> Message-Id: <20190518191430.21686-2-richard.henderson@linaro.org>

> >>> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

> >>> ---

> >>>  target/ppc/helper.h                 | 12 ----------

> >>>  target/ppc/int_helper.c             | 37 -----------------------------

> >>>  target/ppc/translate/vmx-impl.inc.c | 24 +++++++++----------

> >>>  3 files changed, 12 insertions(+), 61 deletions(-)

> >>

> >> This patch introduces a regressions

> >>  with Fedora 29 guest:

> >>

> >> - during kernel boot:

> >>

> >> [   40.397876] crypto_register_alg 'aes' = 0

> >> [   40.577517] crypto_register_alg 'cbc(aes)' = 0

> >> [   40.743576] crypto_register_alg 'ctr(aes)' = 0

> >> [   41.061379] alg: skcipher: Test 1 failed (invalid result) on encryption for p8_aes_xts

> >> [   41.062054] 00000000: 91 7c f6 9e bd 68 b2 ec 9b 9f e9 a3 ea dd a6 92

> >> [   41.062163] 00000010: 98 10 35 57 5e dc 36 1e 9a f7 bc ba 39 f2 5c eb

> >> [   41.062834] crypto_register_alg 'xts(aes)' = 0

> >> [   41.077358] alg: hash: Test 2 failed for p8_ghash

> >> [   41.077553] 00000000: 5f 89 ab f7 20 57 20 57 20 57 20 57 20 57 20 57

> >>

> >> - with libssl:

> >>

> >> # curl -o /dev/null https://www.google.com

> >>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

> >>                                  Dload  Upload   Total   Spent    Left  Speed

> >>   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

> >> curl: (35) error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac

> >>

> >> [before, this one fails with:

> >> curl: (35) error:04091068:rsa routines:int_rsa_verify:bad signature ]

> >>

> >> If I revert this patch on top of 0d74f3b427 + "target/ppc: Fix lxvw4x, lxvh8x and lxvb16x", all works fine.

> >>

> >> Thanks,

> >> Laurent

> >>

> > 

> > This seems to fix the problem:

> > 

> > diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c

> > index 3b6052fe97..6f0709b307 100644

> > --- a/accel/tcg/tcg-runtime-gvec.c

> > +++ b/accel/tcg/tcg-runtime-gvec.c

> > @@ -874,7 +874,7 @@ void HELPER(gvec_sar8v)(void *d, void *a, void *b,

> > uint32_t desc)

> >      intptr_t oprsz = simd_oprsz(desc);

> >      intptr_t i;

> > 

> > -    for (i = 0; i < oprsz; i += sizeof(vec8)) {

> > +    for (i = 0; i < oprsz; i += sizeof(uint8_t)) {

> >          uint8_t sh = *(uint8_t *)(b + i) & 7;

> >          *(int8_t *)(d + i) = *(int8_t *)(a + i) >> sh;

> >      }

> 

> Grr.  I really really need to come up with a solution for testing that allows

> me to test paths that the host cpu would not ordinarily take.  This bug is

> hidden on a host with AVX2.

> 

> Thanks for the digging.


Can one of you send this fix formally with a S-o-b and so forth?

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Laurent Vivier June 11, 2019, 7:05 a.m. UTC | #5
On 11/06/2019 04:43, David Gibson wrote:
> On Fri, Jun 07, 2019 at 09:28:49AM -0500, Richard Henderson wrote:

>> On 6/7/19 9:09 AM, Laurent Vivier wrote:

>>> On 07/06/2019 11:29, Laurent Vivier wrote:

>>>> On 29/05/2019 08:49, David Gibson wrote:

>>>>> From: Richard Henderson <richard.henderson@linaro.org>

>>>>>

>>>>> The gvec expanders take care of masking the shift amount

>>>>> against the element width.

>>>>>

>>>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

>>>>> Message-Id: <20190518191430.21686-2-richard.henderson@linaro.org>

>>>>> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

>>>>> ---

>>>>>  target/ppc/helper.h                 | 12 ----------

>>>>>  target/ppc/int_helper.c             | 37 -----------------------------

>>>>>  target/ppc/translate/vmx-impl.inc.c | 24 +++++++++----------

>>>>>  3 files changed, 12 insertions(+), 61 deletions(-)

>>>>

>>>> This patch introduces a regressions

>>>>  with Fedora 29 guest:

>>>>

>>>> - during kernel boot:

>>>>

>>>> [   40.397876] crypto_register_alg 'aes' = 0

>>>> [   40.577517] crypto_register_alg 'cbc(aes)' = 0

>>>> [   40.743576] crypto_register_alg 'ctr(aes)' = 0

>>>> [   41.061379] alg: skcipher: Test 1 failed (invalid result) on encryption for p8_aes_xts

>>>> [   41.062054] 00000000: 91 7c f6 9e bd 68 b2 ec 9b 9f e9 a3 ea dd a6 92

>>>> [   41.062163] 00000010: 98 10 35 57 5e dc 36 1e 9a f7 bc ba 39 f2 5c eb

>>>> [   41.062834] crypto_register_alg 'xts(aes)' = 0

>>>> [   41.077358] alg: hash: Test 2 failed for p8_ghash

>>>> [   41.077553] 00000000: 5f 89 ab f7 20 57 20 57 20 57 20 57 20 57 20 57

>>>>

>>>> - with libssl:

>>>>

>>>> # curl -o /dev/null https://www.google.com

>>>>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

>>>>                                  Dload  Upload   Total   Spent    Left  Speed

>>>>   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

>>>> curl: (35) error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac

>>>>

>>>> [before, this one fails with:

>>>> curl: (35) error:04091068:rsa routines:int_rsa_verify:bad signature ]

>>>>

>>>> If I revert this patch on top of 0d74f3b427 + "target/ppc: Fix lxvw4x, lxvh8x and lxvb16x", all works fine.

>>>>

>>>> Thanks,

>>>> Laurent

>>>>

>>>

>>> This seems to fix the problem:

>>>

>>> diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c

>>> index 3b6052fe97..6f0709b307 100644

>>> --- a/accel/tcg/tcg-runtime-gvec.c

>>> +++ b/accel/tcg/tcg-runtime-gvec.c

>>> @@ -874,7 +874,7 @@ void HELPER(gvec_sar8v)(void *d, void *a, void *b,

>>> uint32_t desc)

>>>      intptr_t oprsz = simd_oprsz(desc);

>>>      intptr_t i;

>>>

>>> -    for (i = 0; i < oprsz; i += sizeof(vec8)) {

>>> +    for (i = 0; i < oprsz; i += sizeof(uint8_t)) {

>>>          uint8_t sh = *(uint8_t *)(b + i) & 7;

>>>          *(int8_t *)(d + i) = *(int8_t *)(a + i) >> sh;

>>>      }

>>

>> Grr.  I really really need to come up with a solution for testing that allows

>> me to test paths that the host cpu would not ordinarily take.  This bug is

>> hidden on a host with AVX2.

>>

>> Thanks for the digging.

> 

> Can one of you send this fix formally with a S-o-b and so forth?


I'm going to send it.

Thanks,
Laurent
Laurent Vivier June 11, 2019, 7:35 a.m. UTC | #6
On 11/06/2019 09:05, Laurent Vivier wrote:
> On 11/06/2019 04:43, David Gibson wrote:

>> On Fri, Jun 07, 2019 at 09:28:49AM -0500, Richard Henderson wrote:

>>> On 6/7/19 9:09 AM, Laurent Vivier wrote:

>>>> On 07/06/2019 11:29, Laurent Vivier wrote:

>>>>> On 29/05/2019 08:49, David Gibson wrote:

>>>>>> From: Richard Henderson <richard.henderson@linaro.org>

>>>>>>

>>>>>> The gvec expanders take care of masking the shift amount

>>>>>> against the element width.

>>>>>>

>>>>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

>>>>>> Message-Id: <20190518191430.21686-2-richard.henderson@linaro.org>

>>>>>> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

>>>>>> ---

>>>>>>  target/ppc/helper.h                 | 12 ----------

>>>>>>  target/ppc/int_helper.c             | 37 -----------------------------

>>>>>>  target/ppc/translate/vmx-impl.inc.c | 24 +++++++++----------

>>>>>>  3 files changed, 12 insertions(+), 61 deletions(-)

>>>>>

>>>>> This patch introduces a regressions

>>>>>  with Fedora 29 guest:

>>>>>

>>>>> - during kernel boot:

>>>>>

>>>>> [   40.397876] crypto_register_alg 'aes' = 0

>>>>> [   40.577517] crypto_register_alg 'cbc(aes)' = 0

>>>>> [   40.743576] crypto_register_alg 'ctr(aes)' = 0

>>>>> [   41.061379] alg: skcipher: Test 1 failed (invalid result) on encryption for p8_aes_xts

>>>>> [   41.062054] 00000000: 91 7c f6 9e bd 68 b2 ec 9b 9f e9 a3 ea dd a6 92

>>>>> [   41.062163] 00000010: 98 10 35 57 5e dc 36 1e 9a f7 bc ba 39 f2 5c eb

>>>>> [   41.062834] crypto_register_alg 'xts(aes)' = 0

>>>>> [   41.077358] alg: hash: Test 2 failed for p8_ghash

>>>>> [   41.077553] 00000000: 5f 89 ab f7 20 57 20 57 20 57 20 57 20 57 20 57

>>>>>

>>>>> - with libssl:

>>>>>

>>>>> # curl -o /dev/null https://www.google.com

>>>>>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

>>>>>                                  Dload  Upload   Total   Spent    Left  Speed

>>>>>   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

>>>>> curl: (35) error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac

>>>>>

>>>>> [before, this one fails with:

>>>>> curl: (35) error:04091068:rsa routines:int_rsa_verify:bad signature ]

>>>>>

>>>>> If I revert this patch on top of 0d74f3b427 + "target/ppc: Fix lxvw4x, lxvh8x and lxvb16x", all works fine.

>>>>>

>>>>> Thanks,

>>>>> Laurent

>>>>>

>>>>

>>>> This seems to fix the problem:

>>>>

>>>> diff --git a/accel/tcg/tcg-runtime-gvec.c b/accel/tcg/tcg-runtime-gvec.c

>>>> index 3b6052fe97..6f0709b307 100644

>>>> --- a/accel/tcg/tcg-runtime-gvec.c

>>>> +++ b/accel/tcg/tcg-runtime-gvec.c

>>>> @@ -874,7 +874,7 @@ void HELPER(gvec_sar8v)(void *d, void *a, void *b,

>>>> uint32_t desc)

>>>>      intptr_t oprsz = simd_oprsz(desc);

>>>>      intptr_t i;

>>>>

>>>> -    for (i = 0; i < oprsz; i += sizeof(vec8)) {

>>>> +    for (i = 0; i < oprsz; i += sizeof(uint8_t)) {

>>>>          uint8_t sh = *(uint8_t *)(b + i) & 7;

>>>>          *(int8_t *)(d + i) = *(int8_t *)(a + i) >> sh;

>>>>      }

>>>

>>> Grr.  I really really need to come up with a solution for testing that allows

>>> me to test paths that the host cpu would not ordinarily take.  This bug is

>>> hidden on a host with AVX2.

>>>

>>> Thanks for the digging.

>>

>> Can one of you send this fix formally with a S-o-b and so forth?

> 

> I'm going to send it.


Richard already sent it:

  [PATCH] tcg: Fix typos in helper_gvec_sar{8,32,64}v
  <20190607183016.8285-1-richard.henderson@linaro.org>

Thanks,
Laurent
diff mbox series

Patch

diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 638a6e99c4..02b67a333e 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -180,18 +180,6 @@  DEF_HELPER_3(vmuloub, void, avr, avr, avr)
 DEF_HELPER_3(vmulouh, void, avr, avr, avr)
 DEF_HELPER_3(vmulouw, void, avr, avr, avr)
 DEF_HELPER_3(vmuluwm, void, avr, avr, avr)
-DEF_HELPER_3(vsrab, void, avr, avr, avr)
-DEF_HELPER_3(vsrah, void, avr, avr, avr)
-DEF_HELPER_3(vsraw, void, avr, avr, avr)
-DEF_HELPER_3(vsrad, void, avr, avr, avr)
-DEF_HELPER_3(vsrb, void, avr, avr, avr)
-DEF_HELPER_3(vsrh, void, avr, avr, avr)
-DEF_HELPER_3(vsrw, void, avr, avr, avr)
-DEF_HELPER_3(vsrd, void, avr, avr, avr)
-DEF_HELPER_3(vslb, void, avr, avr, avr)
-DEF_HELPER_3(vslh, void, avr, avr, avr)
-DEF_HELPER_3(vslw, void, avr, avr, avr)
-DEF_HELPER_3(vsld, void, avr, avr, avr)
 DEF_HELPER_3(vslo, void, avr, avr, avr)
 DEF_HELPER_3(vsro, void, avr, avr, avr)
 DEF_HELPER_3(vsrv, void, avr, avr, avr)
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index 093ef74b59..8ce89f2ad9 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -1791,23 +1791,6 @@  VSHIFT(l, 1)
 VSHIFT(r, 0)
 #undef VSHIFT
 
-#define VSL(suffix, element, mask)                                      \
-    void helper_vsl##suffix(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)   \
-    {                                                                   \
-        int i;                                                          \
-                                                                        \
-        for (i = 0; i < ARRAY_SIZE(r->element); i++) {                  \
-            unsigned int shift = b->element[i] & mask;                  \
-                                                                        \
-            r->element[i] = a->element[i] << shift;                     \
-        }                                                               \
-    }
-VSL(b, u8, 0x7)
-VSL(h, u16, 0x0F)
-VSL(w, u32, 0x1F)
-VSL(d, u64, 0x3F)
-#undef VSL
-
 void helper_vslv(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
 {
     int i;
@@ -1980,26 +1963,6 @@  VNEG(vnegw, s32)
 VNEG(vnegd, s64)
 #undef VNEG
 
-#define VSR(suffix, element, mask)                                      \
-    void helper_vsr##suffix(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)   \
-    {                                                                   \
-        int i;                                                          \
-                                                                        \
-        for (i = 0; i < ARRAY_SIZE(r->element); i++) {                  \
-            unsigned int shift = b->element[i] & mask;                  \
-            r->element[i] = a->element[i] >> shift;                     \
-        }                                                               \
-    }
-VSR(ab, s8, 0x7)
-VSR(ah, s16, 0xF)
-VSR(aw, s32, 0x1F)
-VSR(ad, s64, 0x3F)
-VSR(b, u8, 0x7)
-VSR(h, u16, 0xF)
-VSR(w, u32, 0x1F)
-VSR(d, u64, 0x3F)
-#undef VSR
-
 void helper_vsro(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
 {
     int sh = (b->VsrB(0xf) >> 3) & 0xf;
diff --git a/target/ppc/translate/vmx-impl.inc.c b/target/ppc/translate/vmx-impl.inc.c
index 6861f4c5b9..663275b729 100644
--- a/target/ppc/translate/vmx-impl.inc.c
+++ b/target/ppc/translate/vmx-impl.inc.c
@@ -530,21 +530,21 @@  GEN_VXFORM(vmuleuw, 4, 10);
 GEN_VXFORM(vmulesb, 4, 12);
 GEN_VXFORM(vmulesh, 4, 13);
 GEN_VXFORM(vmulesw, 4, 14);
-GEN_VXFORM(vslb, 2, 4);
-GEN_VXFORM(vslh, 2, 5);
-GEN_VXFORM(vslw, 2, 6);
+GEN_VXFORM_V(vslb, MO_8, tcg_gen_gvec_shlv, 2, 4);
+GEN_VXFORM_V(vslh, MO_16, tcg_gen_gvec_shlv, 2, 5);
+GEN_VXFORM_V(vslw, MO_32, tcg_gen_gvec_shlv, 2, 6);
 GEN_VXFORM(vrlwnm, 2, 6);
 GEN_VXFORM_DUAL(vslw, PPC_ALTIVEC, PPC_NONE, \
                 vrlwnm, PPC_NONE, PPC2_ISA300)
-GEN_VXFORM(vsld, 2, 23);
-GEN_VXFORM(vsrb, 2, 8);
-GEN_VXFORM(vsrh, 2, 9);
-GEN_VXFORM(vsrw, 2, 10);
-GEN_VXFORM(vsrd, 2, 27);
-GEN_VXFORM(vsrab, 2, 12);
-GEN_VXFORM(vsrah, 2, 13);
-GEN_VXFORM(vsraw, 2, 14);
-GEN_VXFORM(vsrad, 2, 15);
+GEN_VXFORM_V(vsld, MO_64, tcg_gen_gvec_shlv, 2, 23);
+GEN_VXFORM_V(vsrb, MO_8, tcg_gen_gvec_shrv, 2, 8);
+GEN_VXFORM_V(vsrh, MO_16, tcg_gen_gvec_shrv, 2, 9);
+GEN_VXFORM_V(vsrw, MO_32, tcg_gen_gvec_shrv, 2, 10);
+GEN_VXFORM_V(vsrd, MO_64, tcg_gen_gvec_shrv, 2, 27);
+GEN_VXFORM_V(vsrab, MO_8, tcg_gen_gvec_sarv, 2, 12);
+GEN_VXFORM_V(vsrah, MO_16, tcg_gen_gvec_sarv, 2, 13);
+GEN_VXFORM_V(vsraw, MO_32, tcg_gen_gvec_sarv, 2, 14);
+GEN_VXFORM_V(vsrad, MO_64, tcg_gen_gvec_sarv, 2, 15);
 GEN_VXFORM(vsrv, 2, 28);
 GEN_VXFORM(vslv, 2, 29);
 GEN_VXFORM(vslo, 6, 16);