~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/riscv/crypto/sha512-riscv64-zvknhb-zvkb.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/riscv/crypto/sha512-riscv64-zvknhb-zvkb.S (Architecture ppc) and /arch/sparc/crypto/sha512-riscv64-zvknhb-zvkb.S (Architecture sparc)


  1 /* SPDX-License-Identifier: Apache-2.0 OR BSD-    
  2 //                                                
  3 // This file is dual-licensed, meaning that yo    
  4 // choice of either of the following two licen    
  5 //                                                
  6 // Copyright 2023 The OpenSSL Project Authors.    
  7 //                                                
  8 // Licensed under the Apache License 2.0 (the     
  9 // a copy in the file LICENSE in the source di    
 10 // https://www.openssl.org/source/license.html    
 11 //                                                
 12 // or                                             
 13 //                                                
 14 // Copyright (c) 2023, Christoph Müllner <chri    
 15 // Copyright (c) 2023, Phoebe Chen <phoebe.chen    
 16 // Copyright 2024 Google LLC                      
 17 // All rights reserved.                           
 18 //                                                
 19 // Redistribution and use in source and binary    
 20 // modification, are permitted provided that t    
 21 // are met:                                       
 22 // 1. Redistributions of source code must reta    
 23 //    notice, this list of conditions and the     
 24 // 2. Redistributions in binary form must repr    
 25 //    notice, this list of conditions and the     
 26 //    documentation and/or other materials pro    
 27 //                                                
 28 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT     
 29 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTI    
 30 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCH    
 31 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO     
 32 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIR    
 33 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGE    
 34 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS    
 35 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION)    
 36 // THEORY OF LIABILITY, WHETHER IN CONTRACT, S    
 37 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING    
 38 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE PO    
 39                                                   
 40 // The generated code of this file depends on     
 41 // - RV64I                                        
 42 // - RISC-V Vector ('V') with VLEN >= 128         
 43 // - RISC-V Vector SHA-2 Secure Hash extension    
 44 // - RISC-V Vector Cryptography Bit-manipulati    
 45                                                   
 46 #include <linux/cfi_types.h>                      
 47                                                   
 48 .text                                             
 49 .option arch, +zvknhb, +zvkb                      
 50                                                   
 51 #define STATEP          a0                        
 52 #define DATA            a1                        
 53 #define NUM_BLOCKS      a2                        
 54                                                   
 55 #define STATEP_C        a3                        
 56 #define K               a4                        
 57                                                   
 58 #define MASK            v0                        
 59 #define INDICES         v1                        
 60 #define W0              v10     // LMUL=2         
 61 #define W1              v12     // LMUL=2         
 62 #define W2              v14     // LMUL=2         
 63 #define W3              v16     // LMUL=2         
 64 #define VTMP            v20     // LMUL=2         
 65 #define FEBA            v22     // LMUL=2         
 66 #define HGDC            v24     // LMUL=2         
 67 #define PREV_FEBA       v26     // LMUL=2         
 68 #define PREV_HGDC       v28     // LMUL=2         
 69                                                   
 70 // Do 4 rounds of SHA-512.  w0 contains the cu    
 71 //                                                
 72 // If not all the message schedule words have     
 73 // computes 4 more message schedule words.  w1    
 74 // message schedule words; this macro computes    
 75 // to w0.  This means that the next (w0, w1, w    
 76 // w0), so the caller must cycle through the r    
 77 .macro  sha512_4rounds  last, w0, w1, w2, w3      
 78         vle64.v         VTMP, (K)                 
 79         addi            K, K, 32                  
 80         vadd.vv         VTMP, VTMP, \w0           
 81         vsha2cl.vv      HGDC, FEBA, VTMP          
 82         vsha2ch.vv      FEBA, HGDC, VTMP          
 83 .if !\last                                        
 84         vmerge.vvm      VTMP, \w2, \w1, MASK      
 85         vsha2ms.vv      \w0, VTMP, \w3            
 86 .endif                                            
 87 .endm                                             
 88                                                   
 89 .macro  sha512_16rounds last                      
 90         sha512_4rounds  \last, W0, W1, W2, W3     
 91         sha512_4rounds  \last, W1, W2, W3, W0     
 92         sha512_4rounds  \last, W2, W3, W0, W1     
 93         sha512_4rounds  \last, W3, W0, W1, W2     
 94 .endm                                             
 95                                                   
 96 // void sha512_transform_zvknhb_zvkb(u64 state    
 97 //                                   int num_b    
 98 SYM_TYPED_FUNC_START(sha512_transform_zvknhb_z    
 99                                                   
100         // Setup mask for the vmerge to replac    
101         // message scheduling.  There are 4 wo    
102         vsetivli        zero, 1, e8, m1, ta, m    
103         vmv.v.i         MASK, 0x01                
104                                                   
105         // Load the state.  The state is store    
106         // need {f,e,b,a},{h,g,d,c}.  The dst     
107         // is e8mf4.  We use index-load with t    
108         // loaded using the 32-bit little endi    
109         li              t0, 0x00082028            
110         vsetivli        zero, 1, e32, m1, ta,     
111         vmv.v.x         INDICES, t0               
112         addi            STATEP_C, STATEP, 16      
113         vsetivli        zero, 4, e64, m2, ta,     
114         vluxei8.v       FEBA, (STATEP), INDICE    
115         vluxei8.v       HGDC, (STATEP_C), INDI    
116                                                   
117 .Lnext_block:                                     
118         la              K, K512                   
119         addi            NUM_BLOCKS, NUM_BLOCKS    
120                                                   
121         // Save the previous state, as it's ne    
122         vmv.v.v         PREV_FEBA, FEBA           
123         vmv.v.v         PREV_HGDC, HGDC           
124                                                   
125         // Load the next 1024-bit message bloc    
126         vle64.v         W0, (DATA)                
127         vrev8.v         W0, W0                    
128         addi            DATA, DATA, 32            
129         vle64.v         W1, (DATA)                
130         vrev8.v         W1, W1                    
131         addi            DATA, DATA, 32            
132         vle64.v         W2, (DATA)                
133         vrev8.v         W2, W2                    
134         addi            DATA, DATA, 32            
135         vle64.v         W3, (DATA)                
136         vrev8.v         W3, W3                    
137         addi            DATA, DATA, 32            
138                                                   
139         // Do the 80 rounds of SHA-512.           
140         sha512_16rounds 0                         
141         sha512_16rounds 0                         
142         sha512_16rounds 0                         
143         sha512_16rounds 0                         
144         sha512_16rounds 1                         
145                                                   
146         // Add the previous state.                
147         vadd.vv         FEBA, FEBA, PREV_FEBA     
148         vadd.vv         HGDC, HGDC, PREV_HGDC     
149                                                   
150         // Repeat if more blocks remain.          
151         bnez            NUM_BLOCKS, .Lnext_blo    
152                                                   
153         // Store the new state and return.        
154         vsuxei8.v       FEBA, (STATEP), INDICE    
155         vsuxei8.v       HGDC, (STATEP_C), INDI    
156         ret                                       
157 SYM_FUNC_END(sha512_transform_zvknhb_zvkb)        
158                                                   
159 .section ".rodata"                                
160 .p2align 3                                        
161 .type K512, @object                               
162 K512:                                             
163         .dword          0x428a2f98d728ae22, 0x    
164         .dword          0xb5c0fbcfec4d3b2f, 0x    
165         .dword          0x3956c25bf348b538, 0x    
166         .dword          0x923f82a4af194f9b, 0x    
167         .dword          0xd807aa98a3030242, 0x    
168         .dword          0x243185be4ee4b28c, 0x    
169         .dword          0x72be5d74f27b896f, 0x    
170         .dword          0x9bdc06a725c71235, 0x    
171         .dword          0xe49b69c19ef14ad2, 0x    
172         .dword          0x0fc19dc68b8cd5b5, 0x    
173         .dword          0x2de92c6f592b0275, 0x    
174         .dword          0x5cb0a9dcbd41fbd4, 0x    
175         .dword          0x983e5152ee66dfab, 0x    
176         .dword          0xb00327c898fb213f, 0x    
177         .dword          0xc6e00bf33da88fc2, 0x    
178         .dword          0x06ca6351e003826f, 0x    
179         .dword          0x27b70a8546d22ffc, 0x    
180         .dword          0x4d2c6dfc5ac42aed, 0x    
181         .dword          0x650a73548baf63de, 0x    
182         .dword          0x81c2c92e47edaee6, 0x    
183         .dword          0xa2bfe8a14cf10364, 0x    
184         .dword          0xc24b8b70d0f89791, 0x    
185         .dword          0xd192e819d6ef5218, 0x    
186         .dword          0xf40e35855771202a, 0x    
187         .dword          0x19a4c116b8d2d0c8, 0x    
188         .dword          0x2748774cdf8eeb99, 0x    
189         .dword          0x391c0cb3c5c95a63, 0x    
190         .dword          0x5b9cca4f7763e373, 0x    
191         .dword          0x748f82ee5defb2fc, 0x    
192         .dword          0x84c87814a1f0ab72, 0x    
193         .dword          0x90befffa23631e28, 0x    
194         .dword          0xbef9a3f7b2c67915, 0x    
195         .dword          0xca273eceea26619c, 0x    
196         .dword          0xeada7dd6cde0eb1e, 0x    
197         .dword          0x06f067aa72176fba, 0x    
198         .dword          0x113f9804bef90dae, 0x    
199         .dword          0x28db77f523047d84, 0x    
200         .dword          0x3c9ebe0a15c9bebc, 0x    
201         .dword          0x4cc5d4becb3e42b6, 0x    
202         .dword          0x5fcb6fab3ad6faec, 0x    
203 .size K512, . - K512                              
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php