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

TOMOYO Linux Cross Reference
Linux/arch/riscv/crypto/sha256-riscv64-glue.c

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/sha256-riscv64-glue.c (Version linux-6.12-rc7) and /arch/sparc64/crypto/sha256-riscv64-glue.c (Version linux-4.9.337)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 
  2 /*                                                
  3  * SHA-256 and SHA-224 using the RISC-V vector    
  4  *                                                
  5  * Copyright (C) 2022 VRULL GmbH                  
  6  * Author: Heiko Stuebner <heiko.stuebner@vrul    
  7  *                                                
  8  * Copyright (C) 2023 SiFive, Inc.                
  9  * Author: Jerry Shih <jerry.shih@sifive.com>     
 10  */                                               
 11                                                   
 12 #include <asm/simd.h>                             
 13 #include <asm/vector.h>                           
 14 #include <crypto/internal/hash.h>                 
 15 #include <crypto/internal/simd.h>                 
 16 #include <crypto/sha256_base.h>                   
 17 #include <linux/linkage.h>                        
 18 #include <linux/module.h>                         
 19                                                   
 20 /*                                                
 21  * Note: the asm function only uses the 'state    
 22  * It is assumed to be the first field.           
 23  */                                               
 24 asmlinkage void sha256_transform_zvknha_or_zvk    
 25         struct sha256_state *state, const u8 *    
 26                                                   
 27 static int riscv64_sha256_update(struct shash_    
 28                                  unsigned int     
 29 {                                                 
 30         /*                                        
 31          * Ensure struct sha256_state begins d    
 32          * 256-bit internal state, as this is     
 33          */                                       
 34         BUILD_BUG_ON(offsetof(struct sha256_st    
 35                                                   
 36         if (crypto_simd_usable()) {               
 37                 kernel_vector_begin();            
 38                 sha256_base_do_update(desc, da    
 39                                       sha256_t    
 40                 kernel_vector_end();              
 41         } else {                                  
 42                 crypto_sha256_update(desc, dat    
 43         }                                         
 44         return 0;                                 
 45 }                                                 
 46                                                   
 47 static int riscv64_sha256_finup(struct shash_d    
 48                                 unsigned int l    
 49 {                                                 
 50         if (crypto_simd_usable()) {               
 51                 kernel_vector_begin();            
 52                 if (len)                          
 53                         sha256_base_do_update(    
 54                                 desc, data, le    
 55                                 sha256_transfo    
 56                 sha256_base_do_finalize(          
 57                         desc, sha256_transform    
 58                 kernel_vector_end();              
 59                                                   
 60                 return sha256_base_finish(desc    
 61         }                                         
 62                                                   
 63         return crypto_sha256_finup(desc, data,    
 64 }                                                 
 65                                                   
 66 static int riscv64_sha256_final(struct shash_d    
 67 {                                                 
 68         return riscv64_sha256_finup(desc, NULL    
 69 }                                                 
 70                                                   
 71 static int riscv64_sha256_digest(struct shash_    
 72                                  unsigned int     
 73 {                                                 
 74         return sha256_base_init(desc) ?:          
 75                riscv64_sha256_finup(desc, data    
 76 }                                                 
 77                                                   
 78 static struct shash_alg riscv64_sha256_algs[]     
 79         {                                         
 80                 .init = sha256_base_init,         
 81                 .update = riscv64_sha256_updat    
 82                 .final = riscv64_sha256_final,    
 83                 .finup = riscv64_sha256_finup,    
 84                 .digest = riscv64_sha256_diges    
 85                 .descsize = sizeof(struct sha2    
 86                 .digestsize = SHA256_DIGEST_SI    
 87                 .base = {                         
 88                         .cra_blocksize = SHA25    
 89                         .cra_priority = 300,      
 90                         .cra_name = "sha256",     
 91                         .cra_driver_name = "sh    
 92                         .cra_module = THIS_MOD    
 93                 },                                
 94         }, {                                      
 95                 .init = sha224_base_init,         
 96                 .update = riscv64_sha256_updat    
 97                 .final = riscv64_sha256_final,    
 98                 .finup = riscv64_sha256_finup,    
 99                 .descsize = sizeof(struct sha2    
100                 .digestsize = SHA224_DIGEST_SI    
101                 .base = {                         
102                         .cra_blocksize = SHA22    
103                         .cra_priority = 300,      
104                         .cra_name = "sha224",     
105                         .cra_driver_name = "sh    
106                         .cra_module = THIS_MOD    
107                 },                                
108         },                                        
109 };                                                
110                                                   
111 static int __init riscv64_sha256_mod_init(void    
112 {                                                 
113         /* Both zvknha and zvknhb provide the     
114         if ((riscv_isa_extension_available(NUL    
115              riscv_isa_extension_available(NUL    
116             riscv_isa_extension_available(NULL    
117             riscv_vector_vlen() >= 128)           
118                 return crypto_register_shashes    
119                                                   
120                                                   
121         return -ENODEV;                           
122 }                                                 
123                                                   
124 static void __exit riscv64_sha256_mod_exit(voi    
125 {                                                 
126         crypto_unregister_shashes(riscv64_sha2    
127                                   ARRAY_SIZE(r    
128 }                                                 
129                                                   
130 module_init(riscv64_sha256_mod_init);             
131 module_exit(riscv64_sha256_mod_exit);             
132                                                   
133 MODULE_DESCRIPTION("SHA-256 (RISC-V accelerate    
134 MODULE_AUTHOR("Heiko Stuebner <heiko.stuebner@    
135 MODULE_LICENSE("GPL");                            
136 MODULE_ALIAS_CRYPTO("sha256");                    
137 MODULE_ALIAS_CRYPTO("sha224");                    
138                                                   

~ [ 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