lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202203201943.V8TSsqLr-lkp@intel.com>
Date:   Sun, 20 Mar 2022 19:28:43 +0800
From:   kernel test robot <lkp@...el.com>
To:     Bart Van Assche <bvanassche@....org>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: [bvanassche:ufs-for-next 317/317]
 drivers/scsi/ufs/ufshcd-crypto.c:24:30: error: 'struct ufs_hba' has no
 member named 'crypto_cfg_register'

tree:   https://github.com/bvanassche/linux ufs-for-next
head:   905917fe701f16ad2d895c3fef85ca92efd86a06
commit: 905917fe701f16ad2d895c3fef85ca92efd86a06 [317/317] scsi: ufs: Split struct ufs_hba
config: arm-randconfig-r021-20220320 (https://download.01.org/0day-ci/archive/20220320/202203201943.V8TSsqLr-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/bvanassche/linux/commit/905917fe701f16ad2d895c3fef85ca92efd86a06
        git remote add bvanassche https://github.com/bvanassche/linux
        git fetch --no-tags bvanassche ufs-for-next
        git checkout 905917fe701f16ad2d895c3fef85ca92efd86a06
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/scsi/ufs/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>

All errors (new ones prefixed by >>):

   drivers/scsi/ufs/ufshcd-crypto.c: In function 'ufshcd_program_key':
>> drivers/scsi/ufs/ufshcd-crypto.c:24:30: error: 'struct ufs_hba' has no member named 'crypto_cfg_register'
      24 |         u32 slot_offset = hba->crypto_cfg_register + slot * sizeof(*cfg);
         |                              ^~
   In file included from include/linux/container_of.h:5,
                    from include/linux/list.h:5,
                    from include/linux/module.h:12,
                    from drivers/scsi/ufs/ufshcd.h:15,
                    from drivers/scsi/ufs/ufshcd-crypto.c:6:
   drivers/scsi/ufs/ufshcd-crypto.c: In function 'ufshcd_crypto_keyslot_program':
>> include/linux/container_of.h:19:54: error: 'struct ufs_hba' has no member named 'crypto_profile'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |                                                      ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/container_of.h:19:9: note: in expansion of macro 'static_assert'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |         ^~~~~~~~~~~~~
   include/linux/container_of.h:19:23: note: in expansion of macro '__same_type'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |                       ^~~~~~~~~~~
   drivers/scsi/ufs/ufshcd-crypto.c:56:17: note: in expansion of macro 'container_of'
      56 |                 container_of(profile, struct ufs_hba, crypto_profile);
         |                 ^~~~~~~~~~~~
>> include/linux/compiler_types.h:287:27: error: expression in static assertion is not an integer
     287 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/container_of.h:19:9: note: in expansion of macro 'static_assert'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |         ^~~~~~~~~~~~~
   include/linux/container_of.h:19:23: note: in expansion of macro '__same_type'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |                       ^~~~~~~~~~~
   drivers/scsi/ufs/ufshcd-crypto.c:56:17: note: in expansion of macro 'container_of'
      56 |                 container_of(profile, struct ufs_hba, crypto_profile);
         |                 ^~~~~~~~~~~~
   In file included from <command-line>:
>> include/linux/compiler_types.h:140:41: error: 'struct ufs_hba' has no member named 'crypto_profile'
     140 | #define __compiler_offsetof(a, b)       __builtin_offsetof(a, b)
         |                                         ^~~~~~~~~~~~~~~~~~
   include/linux/stddef.h:17:33: note: in expansion of macro '__compiler_offsetof'
      17 | #define offsetof(TYPE, MEMBER)  __compiler_offsetof(TYPE, MEMBER)
         |                                 ^~~~~~~~~~~~~~~~~~~
   include/linux/container_of.h:22:28: note: in expansion of macro 'offsetof'
      22 |         ((type *)(__mptr - offsetof(type, member))); })
         |                            ^~~~~~~~
   drivers/scsi/ufs/ufshcd-crypto.c:56:17: note: in expansion of macro 'container_of'
      56 |                 container_of(profile, struct ufs_hba, crypto_profile);
         |                 ^~~~~~~~~~~~
>> drivers/scsi/ufs/ufshcd-crypto.c:57:59: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
      57 |         const union ufs_crypto_cap_entry *ccap_array = hba->crypto_cap_array;
         |                                                           ^~
>> drivers/scsi/ufs/ufshcd-crypto.c:67:30: error: 'struct ufs_hba' has no member named 'crypto_capabilities'; did you mean 'capabilities'?
      67 |         for (i = 0; i < hba->crypto_capabilities.num_crypto_cap; i++) {
         |                              ^~~~~~~~~~~~~~~~~~~
         |                              capabilities
   In file included from include/linux/container_of.h:5,
                    from include/linux/list.h:5,
                    from include/linux/module.h:12,
                    from drivers/scsi/ufs/ufshcd.h:15,
                    from drivers/scsi/ufs/ufshcd-crypto.c:6:
   drivers/scsi/ufs/ufshcd-crypto.c: In function 'ufshcd_crypto_keyslot_evict':
>> include/linux/container_of.h:19:54: error: 'struct ufs_hba' has no member named 'crypto_profile'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |                                                      ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/container_of.h:19:9: note: in expansion of macro 'static_assert'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |         ^~~~~~~~~~~~~
   include/linux/container_of.h:19:23: note: in expansion of macro '__same_type'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |                       ^~~~~~~~~~~
   drivers/scsi/ufs/ufshcd-crypto.c:114:17: note: in expansion of macro 'container_of'
     114 |                 container_of(profile, struct ufs_hba, crypto_profile);
         |                 ^~~~~~~~~~~~
>> include/linux/compiler_types.h:287:27: error: expression in static assertion is not an integer
     287 | #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/container_of.h:19:9: note: in expansion of macro 'static_assert'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |         ^~~~~~~~~~~~~
   include/linux/container_of.h:19:23: note: in expansion of macro '__same_type'
      19 |         static_assert(__same_type(*(ptr), ((type *)0)->member) ||       \
         |                       ^~~~~~~~~~~
   drivers/scsi/ufs/ufshcd-crypto.c:114:17: note: in expansion of macro 'container_of'
     114 |                 container_of(profile, struct ufs_hba, crypto_profile);
         |                 ^~~~~~~~~~~~
   In file included from <command-line>:
>> include/linux/compiler_types.h:140:41: error: 'struct ufs_hba' has no member named 'crypto_profile'
     140 | #define __compiler_offsetof(a, b)       __builtin_offsetof(a, b)
         |                                         ^~~~~~~~~~~~~~~~~~
   include/linux/stddef.h:17:33: note: in expansion of macro '__compiler_offsetof'
      17 | #define offsetof(TYPE, MEMBER)  __compiler_offsetof(TYPE, MEMBER)
         |                                 ^~~~~~~~~~~~~~~~~~~
   include/linux/container_of.h:22:28: note: in expansion of macro 'offsetof'
      22 |         ((type *)(__mptr - offsetof(type, member))); })
         |                            ^~~~~~~~
   drivers/scsi/ufs/ufshcd-crypto.c:114:17: note: in expansion of macro 'container_of'
     114 |                 container_of(profile, struct ufs_hba, crypto_profile);
         |                 ^~~~~~~~~~~~
   drivers/scsi/ufs/ufshcd-crypto.c: In function 'ufshcd_crypto_enable':
>> drivers/scsi/ufs/ufshcd-crypto.c:125:43: error: 'struct ufs_hba' has no member named 'crypto_profile'
     125 |         blk_crypto_reprogram_all_keys(&hba->crypto_profile);
         |                                           ^~
   drivers/scsi/ufs/ufshcd-crypto.c: In function 'ufshcd_hba_init_crypto_capabilities':
   drivers/scsi/ufs/ufshcd-crypto.c:171:14: error: 'struct ufs_hba' has no member named 'crypto_capabilities'; did you mean 'capabilities'?
     171 |         hba->crypto_capabilities.reg_val =
         |              ^~~~~~~~~~~~~~~~~~~
         |              capabilities
   drivers/scsi/ufs/ufshcd-crypto.c:173:12: error: 'struct ufs_hba' has no member named 'crypto_cfg_register'
     173 |         hba->crypto_cfg_register =
         |            ^~
   drivers/scsi/ufs/ufshcd-crypto.c:174:27: error: 'struct ufs_hba' has no member named 'crypto_capabilities'; did you mean 'capabilities'?
     174 |                 (u32)hba->crypto_capabilities.config_array_ptr * 0x100;
         |                           ^~~~~~~~~~~~~~~~~~~
         |                           capabilities
   drivers/scsi/ufs/ufshcd-crypto.c:175:12: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
     175 |         hba->crypto_cap_array =
         |            ^~
   drivers/scsi/ufs/ufshcd-crypto.c:176:45: error: 'struct ufs_hba' has no member named 'crypto_capabilities'; did you mean 'capabilities'?
     176 |                 devm_kcalloc(hba->dev, hba->crypto_capabilities.num_crypto_cap,
         |                                             ^~~~~~~~~~~~~~~~~~~
         |                                             capabilities
   drivers/scsi/ufs/ufshcd-crypto.c:177:40: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
     177 |                              sizeof(hba->crypto_cap_array[0]), GFP_KERNEL);
         |                                        ^~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/container_of.h:5,
                    from include/linux/list.h:5,
                    from include/linux/module.h:12,
                    from drivers/scsi/ufs/ufshcd.h:15,
                    from drivers/scsi/ufs/ufshcd-crypto.c:6:
   drivers/scsi/ufs/ufshcd-crypto.c:178:17: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
     178 |         if (!hba->crypto_cap_array) {
         |                 ^~
   include/linux/compiler.h:58:52: note: in definition of macro '__trace_if_var'
      58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
         |                                                    ^~~~
   drivers/scsi/ufs/ufshcd-crypto.c:178:9: note: in expansion of macro 'if'
     178 |         if (!hba->crypto_cap_array) {
         |         ^~
   drivers/scsi/ufs/ufshcd-crypto.c:178:17: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
     178 |         if (!hba->crypto_cap_array) {
         |                 ^~
   include/linux/compiler.h:58:61: note: in definition of macro '__trace_if_var'
      58 | #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
         |                                                             ^~~~
   drivers/scsi/ufs/ufshcd-crypto.c:178:9: note: in expansion of macro 'if'
     178 |         if (!hba->crypto_cap_array) {
         |         ^~
   drivers/scsi/ufs/ufshcd-crypto.c:178:17: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
     178 |         if (!hba->crypto_cap_array) {
         |                 ^~
   include/linux/compiler.h:69:10: note: in definition of macro '__trace_if_value'
      69 |         (cond) ?                                        \
         |          ^~~~
   include/linux/compiler.h:56:28: note: in expansion of macro '__trace_if_var'
      56 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
         |                            ^~~~~~~~~~~~~~
   drivers/scsi/ufs/ufshcd-crypto.c:178:9: note: in expansion of macro 'if'
     178 |         if (!hba->crypto_cap_array) {
         |         ^~
   drivers/scsi/ufs/ufshcd-crypto.c:185:39: error: 'struct ufs_hba' has no member named 'crypto_profile'
     185 |                         hba->dev, &hba->crypto_profile,
         |                                       ^~
   drivers/scsi/ufs/ufshcd-crypto.c:186:30: error: 'struct ufs_hba' has no member named 'crypto_capabilities'; did you mean 'capabilities'?
     186 |                         hba->crypto_capabilities.config_count + 1);
         |                              ^~~~~~~~~~~~~~~~~~~
         |                              capabilities
   drivers/scsi/ufs/ufshcd-crypto.c:190:12: error: 'struct ufs_hba' has no member named 'crypto_profile'
     190 |         hba->crypto_profile.ll_ops = ufshcd_crypto_ops;
         |            ^~
   drivers/scsi/ufs/ufshcd-crypto.c:192:12: error: 'struct ufs_hba' has no member named 'crypto_profile'
     192 |         hba->crypto_profile.max_dun_bytes_supported = 8;
         |            ^~
   drivers/scsi/ufs/ufshcd-crypto.c:193:12: error: 'struct ufs_hba' has no member named 'crypto_profile'
     193 |         hba->crypto_profile.dev = hba->dev;
         |            ^~
   drivers/scsi/ufs/ufshcd-crypto.c:199:42: error: 'struct ufs_hba' has no member named 'crypto_capabilities'; did you mean 'capabilities'?
     199 |         for (cap_idx = 0; cap_idx < hba->crypto_capabilities.num_crypto_cap;
         |                                          ^~~~~~~~~~~~~~~~~~~
         |                                          capabilities
   drivers/scsi/ufs/ufshcd-crypto.c:201:20: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
     201 |                 hba->crypto_cap_array[cap_idx].reg_val =
         |                    ^~
   drivers/scsi/ufs/ufshcd-crypto.c:206:52: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
     206 |                                                 hba->crypto_cap_array[cap_idx]);
         |                                                    ^~
   drivers/scsi/ufs/ufshcd-crypto.c:208:28: error: 'struct ufs_hba' has no member named 'crypto_profile'
     208 |                         hba->crypto_profile.modes_supported[blk_mode_num] |=
         |                            ^~
   drivers/scsi/ufs/ufshcd-crypto.c:209:36: error: 'struct ufs_hba' has no member named 'crypto_cap_array'
     209 |                                 hba->crypto_cap_array[cap_idx].sdus_mask * 512;
         |                                    ^~
   drivers/scsi/ufs/ufshcd-crypto.c: In function 'ufshcd_init_crypto':
   drivers/scsi/ufs/ufshcd-crypto.c:232:36: error: 'struct ufs_hba' has no member named 'crypto_capabilities'; did you mean 'capabilities'?
     232 |         for (slot = 0; slot < hba->crypto_capabilities.config_count + 1; slot++)
         |                                    ^~~~~~~~~~~~~~~~~~~
         |                                    capabilities
   drivers/scsi/ufs/ufshcd-crypto.c: In function 'ufshcd_crypto_register':
   drivers/scsi/ufs/ufshcd-crypto.c:239:41: error: 'struct ufs_hba' has no member named 'crypto_profile'
     239 |                 blk_crypto_register(&hba->crypto_profile, q);


vim +24 drivers/scsi/ufs/ufshcd-crypto.c

70297a8ac7a7a4 Satya Tangirala 2020-07-06   19  
1bc726e26ef317 Eric Biggers    2020-07-10   20  static int ufshcd_program_key(struct ufs_hba *hba,
1bc726e26ef317 Eric Biggers    2020-07-10   21  			      const union ufs_crypto_cfg_entry *cfg, int slot)
70297a8ac7a7a4 Satya Tangirala 2020-07-06   22  {
70297a8ac7a7a4 Satya Tangirala 2020-07-06   23  	int i;
70297a8ac7a7a4 Satya Tangirala 2020-07-06  @24  	u32 slot_offset = hba->crypto_cfg_register + slot * sizeof(*cfg);
1bc726e26ef317 Eric Biggers    2020-07-10   25  	int err = 0;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   26  
70297a8ac7a7a4 Satya Tangirala 2020-07-06   27  	ufshcd_hold(hba, false);
1bc726e26ef317 Eric Biggers    2020-07-10   28  
1bc726e26ef317 Eric Biggers    2020-07-10   29  	if (hba->vops && hba->vops->program_key) {
1bc726e26ef317 Eric Biggers    2020-07-10   30  		err = hba->vops->program_key(hba, cfg, slot);
1bc726e26ef317 Eric Biggers    2020-07-10   31  		goto out;
1bc726e26ef317 Eric Biggers    2020-07-10   32  	}
1bc726e26ef317 Eric Biggers    2020-07-10   33  
70297a8ac7a7a4 Satya Tangirala 2020-07-06   34  	/* Ensure that CFGE is cleared before programming the key */
70297a8ac7a7a4 Satya Tangirala 2020-07-06   35  	ufshcd_writel(hba, 0, slot_offset + 16 * sizeof(cfg->reg_val[0]));
70297a8ac7a7a4 Satya Tangirala 2020-07-06   36  	for (i = 0; i < 16; i++) {
70297a8ac7a7a4 Satya Tangirala 2020-07-06   37  		ufshcd_writel(hba, le32_to_cpu(cfg->reg_val[i]),
70297a8ac7a7a4 Satya Tangirala 2020-07-06   38  			      slot_offset + i * sizeof(cfg->reg_val[0]));
70297a8ac7a7a4 Satya Tangirala 2020-07-06   39  	}
70297a8ac7a7a4 Satya Tangirala 2020-07-06   40  	/* Write dword 17 */
70297a8ac7a7a4 Satya Tangirala 2020-07-06   41  	ufshcd_writel(hba, le32_to_cpu(cfg->reg_val[17]),
70297a8ac7a7a4 Satya Tangirala 2020-07-06   42  		      slot_offset + 17 * sizeof(cfg->reg_val[0]));
70297a8ac7a7a4 Satya Tangirala 2020-07-06   43  	/* Dword 16 must be written last */
70297a8ac7a7a4 Satya Tangirala 2020-07-06   44  	ufshcd_writel(hba, le32_to_cpu(cfg->reg_val[16]),
70297a8ac7a7a4 Satya Tangirala 2020-07-06   45  		      slot_offset + 16 * sizeof(cfg->reg_val[0]));
1bc726e26ef317 Eric Biggers    2020-07-10   46  out:
70297a8ac7a7a4 Satya Tangirala 2020-07-06   47  	ufshcd_release(hba);
1bc726e26ef317 Eric Biggers    2020-07-10   48  	return err;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   49  }
70297a8ac7a7a4 Satya Tangirala 2020-07-06   50  
cb77cb5abe1f4f Eric Biggers    2021-10-18   51  static int ufshcd_crypto_keyslot_program(struct blk_crypto_profile *profile,
70297a8ac7a7a4 Satya Tangirala 2020-07-06   52  					 const struct blk_crypto_key *key,
70297a8ac7a7a4 Satya Tangirala 2020-07-06   53  					 unsigned int slot)
70297a8ac7a7a4 Satya Tangirala 2020-07-06   54  {
cb77cb5abe1f4f Eric Biggers    2021-10-18   55  	struct ufs_hba *hba =
cb77cb5abe1f4f Eric Biggers    2021-10-18   56  		container_of(profile, struct ufs_hba, crypto_profile);
70297a8ac7a7a4 Satya Tangirala 2020-07-06  @57  	const union ufs_crypto_cap_entry *ccap_array = hba->crypto_cap_array;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   58  	const struct ufs_crypto_alg_entry *alg =
70297a8ac7a7a4 Satya Tangirala 2020-07-06   59  			&ufs_crypto_algs[key->crypto_cfg.crypto_mode];
70297a8ac7a7a4 Satya Tangirala 2020-07-06   60  	u8 data_unit_mask = key->crypto_cfg.data_unit_size / 512;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   61  	int i;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   62  	int cap_idx = -1;
6500251e590657 Pujin Shi       2020-10-02   63  	union ufs_crypto_cfg_entry cfg = {};
1bc726e26ef317 Eric Biggers    2020-07-10   64  	int err;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   65  
70297a8ac7a7a4 Satya Tangirala 2020-07-06   66  	BUILD_BUG_ON(UFS_CRYPTO_KEY_SIZE_INVALID != 0);
70297a8ac7a7a4 Satya Tangirala 2020-07-06  @67  	for (i = 0; i < hba->crypto_capabilities.num_crypto_cap; i++) {
70297a8ac7a7a4 Satya Tangirala 2020-07-06   68  		if (ccap_array[i].algorithm_id == alg->ufs_alg &&
70297a8ac7a7a4 Satya Tangirala 2020-07-06   69  		    ccap_array[i].key_size == alg->ufs_key_size &&
70297a8ac7a7a4 Satya Tangirala 2020-07-06   70  		    (ccap_array[i].sdus_mask & data_unit_mask)) {
70297a8ac7a7a4 Satya Tangirala 2020-07-06   71  			cap_idx = i;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   72  			break;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   73  		}
70297a8ac7a7a4 Satya Tangirala 2020-07-06   74  	}
70297a8ac7a7a4 Satya Tangirala 2020-07-06   75  
70297a8ac7a7a4 Satya Tangirala 2020-07-06   76  	if (WARN_ON(cap_idx < 0))
70297a8ac7a7a4 Satya Tangirala 2020-07-06   77  		return -EOPNOTSUPP;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   78  
70297a8ac7a7a4 Satya Tangirala 2020-07-06   79  	cfg.data_unit_size = data_unit_mask;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   80  	cfg.crypto_cap_idx = cap_idx;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   81  	cfg.config_enable = UFS_CRYPTO_CONFIGURATION_ENABLE;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   82  
70297a8ac7a7a4 Satya Tangirala 2020-07-06   83  	if (ccap_array[cap_idx].algorithm_id == UFS_CRYPTO_ALG_AES_XTS) {
70297a8ac7a7a4 Satya Tangirala 2020-07-06   84  		/* In XTS mode, the blk_crypto_key's size is already doubled */
70297a8ac7a7a4 Satya Tangirala 2020-07-06   85  		memcpy(cfg.crypto_key, key->raw, key->size/2);
70297a8ac7a7a4 Satya Tangirala 2020-07-06   86  		memcpy(cfg.crypto_key + UFS_CRYPTO_KEY_MAX_SIZE/2,
70297a8ac7a7a4 Satya Tangirala 2020-07-06   87  		       key->raw + key->size/2, key->size/2);
70297a8ac7a7a4 Satya Tangirala 2020-07-06   88  	} else {
70297a8ac7a7a4 Satya Tangirala 2020-07-06   89  		memcpy(cfg.crypto_key, key->raw, key->size);
70297a8ac7a7a4 Satya Tangirala 2020-07-06   90  	}
70297a8ac7a7a4 Satya Tangirala 2020-07-06   91  
1bc726e26ef317 Eric Biggers    2020-07-10   92  	err = ufshcd_program_key(hba, &cfg, slot);
70297a8ac7a7a4 Satya Tangirala 2020-07-06   93  
70297a8ac7a7a4 Satya Tangirala 2020-07-06   94  	memzero_explicit(&cfg, sizeof(cfg));
1bc726e26ef317 Eric Biggers    2020-07-10   95  	return err;
70297a8ac7a7a4 Satya Tangirala 2020-07-06   96  }
70297a8ac7a7a4 Satya Tangirala 2020-07-06   97  
1bc726e26ef317 Eric Biggers    2020-07-10   98  static int ufshcd_clear_keyslot(struct ufs_hba *hba, int slot)
70297a8ac7a7a4 Satya Tangirala 2020-07-06   99  {
70297a8ac7a7a4 Satya Tangirala 2020-07-06  100  	/*
70297a8ac7a7a4 Satya Tangirala 2020-07-06  101  	 * Clear the crypto cfg on the device. Clearing CFGE
70297a8ac7a7a4 Satya Tangirala 2020-07-06  102  	 * might not be sufficient, so just clear the entire cfg.
70297a8ac7a7a4 Satya Tangirala 2020-07-06  103  	 */
6500251e590657 Pujin Shi       2020-10-02  104  	union ufs_crypto_cfg_entry cfg = {};
70297a8ac7a7a4 Satya Tangirala 2020-07-06  105  
1bc726e26ef317 Eric Biggers    2020-07-10  106  	return ufshcd_program_key(hba, &cfg, slot);
70297a8ac7a7a4 Satya Tangirala 2020-07-06  107  }
70297a8ac7a7a4 Satya Tangirala 2020-07-06  108  
cb77cb5abe1f4f Eric Biggers    2021-10-18  109  static int ufshcd_crypto_keyslot_evict(struct blk_crypto_profile *profile,
70297a8ac7a7a4 Satya Tangirala 2020-07-06  110  				       const struct blk_crypto_key *key,
70297a8ac7a7a4 Satya Tangirala 2020-07-06  111  				       unsigned int slot)
70297a8ac7a7a4 Satya Tangirala 2020-07-06  112  {
cb77cb5abe1f4f Eric Biggers    2021-10-18  113  	struct ufs_hba *hba =
cb77cb5abe1f4f Eric Biggers    2021-10-18  114  		container_of(profile, struct ufs_hba, crypto_profile);
70297a8ac7a7a4 Satya Tangirala 2020-07-06  115  
1bc726e26ef317 Eric Biggers    2020-07-10  116  	return ufshcd_clear_keyslot(hba, slot);
70297a8ac7a7a4 Satya Tangirala 2020-07-06  117  }
70297a8ac7a7a4 Satya Tangirala 2020-07-06  118  
70297a8ac7a7a4 Satya Tangirala 2020-07-06  119  bool ufshcd_crypto_enable(struct ufs_hba *hba)
70297a8ac7a7a4 Satya Tangirala 2020-07-06  120  {
70297a8ac7a7a4 Satya Tangirala 2020-07-06  121  	if (!(hba->caps & UFSHCD_CAP_CRYPTO))
70297a8ac7a7a4 Satya Tangirala 2020-07-06  122  		return false;
70297a8ac7a7a4 Satya Tangirala 2020-07-06  123  
70297a8ac7a7a4 Satya Tangirala 2020-07-06  124  	/* Reset might clear all keys, so reprogram all the keys. */
cb77cb5abe1f4f Eric Biggers    2021-10-18 @125  	blk_crypto_reprogram_all_keys(&hba->crypto_profile);
70297a8ac7a7a4 Satya Tangirala 2020-07-06  126  	return true;
70297a8ac7a7a4 Satya Tangirala 2020-07-06  127  }
70297a8ac7a7a4 Satya Tangirala 2020-07-06  128  

:::::: The code at line 24 was first introduced by commit
:::::: 70297a8ac7a7a4a3284c2eb20fefefbe72dab338 scsi: ufs: UFS crypto API

:::::: TO: Satya Tangirala <satyat@...gle.com>
:::::: CC: Martin K. Petersen <martin.petersen@...cle.com>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ