From: Thomas Huth <thuth@redhat.com>
To: Aurelien Jarno <aurelien@aurel32.net>, qemu-devel@nongnu.org
Cc: Tom Musta <tommusta@gmail.com>,
David Gibson <david@gibson.dropbear.id.au>,
qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>,
qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] target-ppc: fix vcipher, vcipherlast, vncipherlast and vpermxor
Date: Tue, 22 Sep 2015 12:11:41 +0200 [thread overview]
Message-ID: <5601295D.7060702@redhat.com> (raw)
In-Reply-To: <1442178225-26780-2-git-send-email-aurelien@aurel32.net>
On 13/09/15 23:03, Aurelien Jarno wrote:
> For vector instructions, the helpers get pointers to the vector register
> in arguments. Some operands might point to the same register, including
> the operand holding the result.
>
> When emulating instructions which access the vector elements in a
> non-linear way, we need to store the result in an temporary variable.
>
> This fixes openssl when emulating a POWER8 CPU.
>
> Cc: Tom Musta <tommusta@gmail.com>
> Cc: Alexander Graf <agraf@suse.de>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
> target-ppc/int_helper.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
> index 0a55d5e..b122868 100644
> --- a/target-ppc/int_helper.c
> +++ b/target-ppc/int_helper.c
> @@ -2327,24 +2327,28 @@ void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a)
>
> void helper_vcipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> {
> + ppc_avr_t result;
> int i;
>
> VECTOR_FOR_INORDER_I(i, u32) {
> - r->AVRW(i) = b->AVRW(i) ^
> + result.AVRW(i) = b->AVRW(i) ^
> (AES_Te0[a->AVRB(AES_shifts[4*i + 0])] ^
> AES_Te1[a->AVRB(AES_shifts[4*i + 1])] ^
> AES_Te2[a->AVRB(AES_shifts[4*i + 2])] ^
> AES_Te3[a->AVRB(AES_shifts[4*i + 3])]);
> }
> + *r = result;
> }
>
> void helper_vcipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> {
> + ppc_avr_t result;
> int i;
>
> VECTOR_FOR_INORDER_I(i, u8) {
> - r->AVRB(i) = b->AVRB(i) ^ (AES_sbox[a->AVRB(AES_shifts[i])]);
> + result.AVRB(i) = b->AVRB(i) ^ (AES_sbox[a->AVRB(AES_shifts[i])]);
> }
> + *r = result;
> }
>
> void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> @@ -2369,11 +2373,13 @@ void helper_vncipher(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
>
> void helper_vncipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
> {
> + ppc_avr_t result;
> int i;
>
> VECTOR_FOR_INORDER_I(i, u8) {
> - r->AVRB(i) = b->AVRB(i) ^ (AES_isbox[a->AVRB(AES_ishifts[i])]);
> + result.AVRB(i) = b->AVRB(i) ^ (AES_isbox[a->AVRB(AES_ishifts[i])]);
> }
> + *r = result;
> }
>
> #define ROTRu32(v, n) (((v) >> (n)) | ((v) << (32-n)))
> @@ -2460,16 +2466,19 @@ void helper_vshasigmad(ppc_avr_t *r, ppc_avr_t *a, uint32_t st_six)
>
> void helper_vpermxor(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c)
> {
> + ppc_avr_t result;
> int i;
> +
> VECTOR_FOR_INORDER_I(i, u8) {
> int indexA = c->u8[i] >> 4;
> int indexB = c->u8[i] & 0xF;
> #if defined(HOST_WORDS_BIGENDIAN)
> - r->u8[i] = a->u8[indexA] ^ b->u8[indexB];
> + result.u8[i] = a->u8[indexA] ^ b->u8[indexB];
> #else
> - r->u8[i] = a->u8[15-indexA] ^ b->u8[15-indexB];
> + result.u8[i] = a->u8[15-indexA] ^ b->u8[15-indexB];
> #endif
> }
> + *r = result;
> }
>
> #undef VECTOR_FOR_INORDER_I
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2015-09-22 10:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-13 21:03 [Qemu-devel] [PATCH 0/2] target-ppc: vector instruction fixes Aurelien Jarno
2015-09-13 21:03 ` [Qemu-devel] [PATCH 1/2] target-ppc: fix vcipher, vcipherlast, vncipherlast and vpermxor Aurelien Jarno
2015-09-22 10:11 ` Thomas Huth [this message]
2015-09-13 21:03 ` [Qemu-devel] [PATCH 2/2] target-ppc: fix xscmpodp and xscmpudp decoding Aurelien Jarno
2015-09-20 14:46 ` Richard W.M. Jones
2015-09-22 10:26 ` Thomas Huth
2015-09-22 21:28 ` Aurelien Jarno
2015-09-23 11:12 ` Tom Musta
2015-09-17 4:58 ` [Qemu-devel] [PATCH 0/2] target-ppc: vector instruction fixes Richard Henderson
2015-09-20 20:29 ` Alexander Graf
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=5601295D.7060702@redhat.com \
--to=thuth@redhat.com \
--cc=agraf@suse.de \
--cc=aurelien@aurel32.net \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=tommusta@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.