summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMamone Tarsha <maamoun.tk@googlemail.com>2021-07-01 05:47:02 +0300
committerMamone Tarsha <maamoun.tk@googlemail.com>2021-07-01 05:47:02 +0300
commit33bfc509ba579c2f9aa87749ee774fbfad679f02 (patch)
tree4e465f151e110a969570c991dded1adbafcb681d
parent530e4c8d12de3e59c96b6955be07154a3a93b241 (diff)
downloadnettle-33bfc509ba579c2f9aa87749ee774fbfad679f02.tar.gz
[S390x] Use uppercase for macro names in machine.m4 and enhance the documentation for GHASH implementation
-rw-r--r--s390x/machine.m419
-rw-r--r--s390x/msa_x4/gcm-hash.asm11
2 files changed, 16 insertions, 14 deletions
diff --git a/s390x/machine.m4 b/s390x/machine.m4
index b10b3045..8626cec1 100644
--- a/s390x/machine.m4
+++ b/s390x/machine.m4
@@ -1,20 +1,21 @@
C Register usage:
-define(`RA', `%r14')
-define(`SP', `%r15')
+define(`RA', `%r14') C Return address
+define(`SP', `%r15') C Stack pointer
define(`STANDARD_STACK_FRAME',`160')
C Dynamic stack space allocation
-C the allocated space is assigned to 'AP' general register
-C the length of space must be a multiple of 8
-C free_stack can be used to free the allocated space
-C alloc_stack(AP, space_len)
-define(`alloc_stack',
+C AP is a general register to which the allocated space is assigned
+C SPACE_LEN is the length of space, must be a multiple of 8
+C FREE_STACK macro can be used to free the allocated space
+C ALLOC_STACK(AP, SPACE_LEN)
+define(`ALLOC_STACK',
`lgr $1,SP
aghi SP,-(STANDARD_STACK_FRAME+$2)
stg $1,0(SP)
la $1,STANDARD_STACK_FRAME (SP)')
-C free_stack(space_len)
-define(`free_stack',
+C Free allocated stack space
+C FREE_STACK(SPACE_LEN)
+define(`FREE_STACK',
`aghi SP,STANDARD_STACK_FRAME+$1')
diff --git a/s390x/msa_x4/gcm-hash.asm b/s390x/msa_x4/gcm-hash.asm
index b54debf2..73a50824 100644
--- a/s390x/msa_x4/gcm-hash.asm
+++ b/s390x/msa_x4/gcm-hash.asm
@@ -65,15 +65,16 @@ C void gcm_hash (const struct gcm_key *key, union gcm_block *x,
C size_t length, const uint8_t *data)
PROLOGUE(_nettle_gcm_hash)
- ldgr %f0,%r6
- alloc_stack(%r1,PB_SIZE+16) C parameter block (must be general register 1)
+ ldgr %f0,%r6 C load non-volatile general register 6 into volatile float-point register 0
+ C --- allocate a stack space for parameter block in addition to 16-byte buffer to handle leftover bytes ---
+ ALLOC_STACK(%r1,PB_SIZE+16) C parameter block (must be general register 1)
lgr %r6,%r3
mvc 0(16,%r1),0(%r3) C copy x Initial Chaining Value field
mvc 16(16,%r1),H_idx (%r2) C copy H to Hash Subkey field
lghi %r0,65 C GHASH function code (must be general register 0)
lgr %r2,%r5 C location of leftmost byte of data (must not be odd-numbered general register nor be general register 0)
C number of bytes (must be general register of data + 1). length must be a multiple of the data block size (16).
- risbg %r3,%r4,0,187,0 C Insert bit offsets 0-59, bit offset 0 of the fourth operant is set to clear the remaining bits.
+ risbg %r3,%r4,0,187,0 C Insert bit offsets 0-59, bit offset 0 of the fourth operand is set to clear the remaining bits.
1: .long 0xb93e0002 C kimd %r0,%r2
brc 1,1b C safely branch back in case of partial completion
C --- handle leftovers ---
@@ -91,7 +92,7 @@ PROLOGUE(_nettle_gcm_hash)
brc 1,3b C safely branch back in case of partial completion
4:
mvc 0(16,%r6),0(%r1) C store x
- free_stack(PB_SIZE+16)
- lgdr %r6,%f0
+ FREE_STACK(PB_SIZE+16)
+ lgdr %r6,%f0 C restore general register 6
br RA
EPILOGUE(_nettle_gcm_hash)