arch/powerpc/platforms/pseries/plpks_sed_ops.c:89:15: sparse: sparse: cast to restricted __be32

From: kernel test robot
Date: Sat Nov 18 2023 - 23:11:07 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b8f1fa2419c19c81bc386a6b350879ba54a573e1
commit: ec8cf230ceccfcc2bd29990c2902be168a92dee4 powerpc/pseries: PLPKS SED Opal keystore support
date: 5 weeks ago
config: powerpc64-randconfig-r131-20231119 (https://download.01.org/0day-ci/archive/20231119/202311191142.ZOdOE2vT-lkp@xxxxxxxxx/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231119/202311191142.ZOdOE2vT-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311191142.ZOdOE2vT-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:89:15: sparse: sparse: cast to restricted __be32
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:89:15: sparse: sparse: cast to restricted __be32
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:89:15: sparse: sparse: cast to restricted __be32
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:89:15: sparse: sparse: cast to restricted __be32
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:89:15: sparse: sparse: cast to restricted __be32
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:89:15: sparse: sparse: cast to restricted __be32
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:116:24: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long [addressable] [assigned] [usertype] authority @@ got restricted __be64 [usertype] @@
arch/powerpc/platforms/pseries/plpks_sed_ops.c:116:24: sparse: expected unsigned long [addressable] [assigned] [usertype] authority
arch/powerpc/platforms/pseries/plpks_sed_ops.c:116:24: sparse: got restricted __be64 [usertype]
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:117:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long [addressable] [assigned] [usertype] range @@ got restricted __be64 [usertype] @@
arch/powerpc/platforms/pseries/plpks_sed_ops.c:117:20: sparse: expected unsigned long [addressable] [assigned] [usertype] range
arch/powerpc/platforms/pseries/plpks_sed_ops.c:117:20: sparse: got restricted __be64 [usertype]
>> arch/powerpc/platforms/pseries/plpks_sed_ops.c:119:22: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [addressable] [assigned] [usertype] key_len @@ got restricted __be32 [usertype] @@
arch/powerpc/platforms/pseries/plpks_sed_ops.c:119:22: sparse: expected unsigned int [addressable] [assigned] [usertype] key_len
arch/powerpc/platforms/pseries/plpks_sed_ops.c:119:22: sparse: got restricted __be32 [usertype]

vim +89 arch/powerpc/platforms/pseries/plpks_sed_ops.c

66
67 /*
68 * Read the SED Opal key from PLPKS given the label
69 */
70 int sed_read_key(char *keyname, char *key, u_int *keylen)
71 {
72 struct plpks_var var;
73 struct plpks_sed_object_data data;
74 int ret;
75 u_int len;
76
77 plpks_init_var(&var, keyname);
78
79 if (!plpks_sed_available)
80 return -EOPNOTSUPP;
81
82 var.data = (u8 *)&data;
83 var.datalen = sizeof(data);
84
85 ret = plpks_read_os_var(&var);
86 if (ret != 0)
87 return ret;
88
> 89 len = min_t(u16, be32_to_cpu(data.key_len), var.datalen);
90 memcpy(key, data.key, len);
91 key[len] = '\0';
92 *keylen = len;
93
94 return 0;
95 }
96
97 /*
98 * Write the SED Opal key to PLPKS given the label
99 */
100 int sed_write_key(char *keyname, char *key, u_int keylen)
101 {
102 struct plpks_var var;
103 struct plpks_sed_object_data data;
104 struct plpks_var_name vname;
105
106 plpks_init_var(&var, keyname);
107
108 if (!plpks_sed_available)
109 return -EOPNOTSUPP;
110
111 var.datalen = sizeof(struct plpks_sed_object_data);
112 var.data = (u8 *)&data;
113
114 /* initialize SED object */
115 data.version = PLPKS_SED_OBJECT_DATA_V0;
> 116 data.authority = cpu_to_be64(PLPKS_SED_AUTHORITY);
> 117 data.range = cpu_to_be64(PLPKS_SED_RANGE);
118 memset(&data.pad1, '\0', sizeof(data.pad1));
> 119 data.key_len = cpu_to_be32(keylen);

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki