Hi Andra,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.8 next-20200805]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Andra-Paraschiv/Add-support-for-Nitro-Enclaves/20200805-171942
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git bcf876870b95592b52519ed4aafcf9d95999bc9c
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.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
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All errors (new ones prefixed by >>):
drivers/virt/nitro_enclaves/ne_misc_dev.c: In function 'ne_setup_cpu_pool':
245 | ne_cpu_pool.avail_cores_size = nr_cpu_ids / smp_num_siblings;drivers/virt/nitro_enclaves/ne_misc_dev.c:245:46: error: 'smp_num_siblings' undeclared (first use in this function); did you mean 'cpu_sibling'?
| ^~~~~~~~~~~~~~~~
| cpu_sibling
drivers/virt/nitro_enclaves/ne_misc_dev.c:245:46: note: each undeclared identifier is reported only once for each function it appears in
drivers/virt/nitro_enclaves/ne_misc_dev.c: In function 'ne_enclave_ioctl':
drivers/virt/nitro_enclaves/ne_misc_dev.c:928:54: error: 'smp_num_siblings' undeclared (first use in this function)
928 | if (vcpu_id >= (ne_enclave->avail_cpu_cores_size * smp_num_siblings)) {
| ^~~~~~~~~~~~~~~~
vim +245 drivers/virt/nitro_enclaves/ne_misc_dev.c
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 130
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 131 /**
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 132 * ne_setup_cpu_pool() - Set the NE CPU pool after handling sanity checks such
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 133 * as not sharing CPU cores with the primary / parent VM
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 134 * or not using CPU 0, which should remain available for
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 135 * the primary / parent VM. Offline the CPUs from the
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 136 * pool after the checks passed.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 137 * @ne_cpu_list: The CPU list used for setting NE CPU pool.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 138 *
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 139 * Context: Process context.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 140 * Return:
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 141 * * 0 on success.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 142 * * Negative return value on failure.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 143 */
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 144 static int ne_setup_cpu_pool(const char *ne_cpu_list)
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 145 {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 146 int core_id = -1;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 147 unsigned int cpu = 0;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 148 cpumask_var_t cpu_pool = NULL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 149 unsigned int cpu_sibling = 0;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 150 unsigned int i = 0;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 151 int numa_node = -1;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 152 int rc = -EINVAL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 153
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 154 if (!ne_cpu_list)
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 155 return 0;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 156
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 157 if (!zalloc_cpumask_var(&cpu_pool, GFP_KERNEL))
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 158 return -ENOMEM;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 159
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 160 mutex_lock(&ne_cpu_pool.mutex);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 161
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 162 rc = cpulist_parse(ne_cpu_list, cpu_pool);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 163 if (rc < 0) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 164 pr_err("%s: Error in cpulist parse [rc=%d]\n", ne_misc_dev.name, rc);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 165
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 166 goto free_pool_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 167 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 168
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 169 cpu = cpumask_any(cpu_pool);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 170 if (cpu >= nr_cpu_ids) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 171 pr_err("%s: No CPUs available in CPU pool\n", ne_misc_dev.name);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 172
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 173 rc = -EINVAL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 174
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 175 goto free_pool_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 176 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 177
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 178 /*
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 179 * Check if the CPUs from the NE CPU pool are from the same NUMA node.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 180 */
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 181 for_each_cpu(cpu, cpu_pool) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 182 if (numa_node < 0) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 183 numa_node = cpu_to_node(cpu);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 184 if (numa_node < 0) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 185 pr_err("%s: Invalid NUMA node %d\n",
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 186 ne_misc_dev.name, numa_node);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 187
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 188 rc = -EINVAL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 189
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 190 goto free_pool_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 191 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 192 } else {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 193 if (numa_node != cpu_to_node(cpu)) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 194 pr_err("%s: CPUs with different NUMA nodes\n",
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 195 ne_misc_dev.name);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 196
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 197 rc = -EINVAL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 198
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 199 goto free_pool_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 200 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 201 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 202 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 203
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 204 /*
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 205 * Check if CPU 0 and its siblings are included in the provided CPU pool
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 206 * They should remain available for the primary / parent VM.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 207 */
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 208 if (cpumask_test_cpu(0, cpu_pool)) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 209 pr_err("%s: CPU 0 has to remain available\n", ne_misc_dev.name);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 210
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 211 rc = -EINVAL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 212
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 213 goto free_pool_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 214 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 215
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 216 for_each_cpu(cpu_sibling, topology_sibling_cpumask(0)) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 217 if (cpumask_test_cpu(cpu_sibling, cpu_pool)) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 218 pr_err("%s: CPU sibling %d for CPU 0 is in CPU pool\n",
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 219 ne_misc_dev.name, cpu_sibling);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 220
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 221 rc = -EINVAL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 222
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 223 goto free_pool_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 224 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 225 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 226
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 227 /*
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 228 * Check if CPU siblings are included in the provided CPU pool. The
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 229 * expectation is that CPU cores are made available in the CPU pool for
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 230 * enclaves.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 231 */
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 232 for_each_cpu(cpu, cpu_pool) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 233 for_each_cpu(cpu_sibling, topology_sibling_cpumask(cpu)) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 234 if (!cpumask_test_cpu(cpu_sibling, cpu_pool)) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 235 pr_err("%s: CPU %d is not in CPU pool\n",
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 236 ne_misc_dev.name, cpu_sibling);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 237
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 238 rc = -EINVAL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 239
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 240 goto free_pool_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 241 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 242 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 243 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 244
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 @245 ne_cpu_pool.avail_cores_size = nr_cpu_ids / smp_num_siblings;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 246
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 247 ne_cpu_pool.avail_cores = kcalloc(ne_cpu_pool.avail_cores_size,
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 248 sizeof(*ne_cpu_pool.avail_cores),
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 249 GFP_KERNEL);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 250 if (!ne_cpu_pool.avail_cores) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 251 rc = -ENOMEM;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 252
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 253 goto free_pool_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 254 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 255
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 256 for (i = 0; i < ne_cpu_pool.avail_cores_size; i++)
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 257 if (!zalloc_cpumask_var(&ne_cpu_pool.avail_cores[i], GFP_KERNEL)) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 258 rc = -ENOMEM;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 259
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 260 goto free_cores_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 261 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 262
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 263 /* Split the NE CPU pool in CPU cores. */
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 264 for_each_cpu(cpu, cpu_pool) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 265 core_id = topology_core_id(cpu);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 266 if (core_id < 0 || core_id >= ne_cpu_pool.avail_cores_size) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 267 pr_err("%s: Invalid core id %d\n",
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 268 ne_misc_dev.name, core_id);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 269
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 270 rc = -EINVAL;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 271
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 272 goto clear_cpumask;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 273 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 274
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 275 cpumask_set_cpu(cpu, ne_cpu_pool.avail_cores[core_id]);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 276 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 277
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 278 /*
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 279 * CPUs that are given to enclave(s) should not be considered online
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 280 * by Linux anymore, as the hypervisor will degrade them to floating.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 281 * The physical CPUs (full cores) are carved out of the primary / parent
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 282 * VM and given to the enclave VM. The same number of vCPUs would run
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 283 * on less pCPUs for the primary / parent VM.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 284 *
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 285 * We offline them here, to not degrade performance and expose correct
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 286 * topology to Linux and user space.
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 287 */
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 288 for_each_cpu(cpu, cpu_pool) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 289 rc = remove_cpu(cpu);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 290 if (rc != 0) {
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 291 pr_err("%s: CPU %d is not offlined [rc=%d]\n",
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 292 ne_misc_dev.name, cpu, rc);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 293
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 294 goto online_cpus;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 295 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 296 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 297
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 298 free_cpumask_var(cpu_pool);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 299
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 300 ne_cpu_pool.numa_node = numa_node;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 301
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 302 mutex_unlock(&ne_cpu_pool.mutex);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 303
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 304 return 0;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 305
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 306 online_cpus:
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 307 for_each_cpu(cpu, cpu_pool)
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 308 add_cpu(cpu);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 309 clear_cpumask:
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 310 for (i = 0; i < ne_cpu_pool.avail_cores_size; i++)
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 311 cpumask_clear(ne_cpu_pool.avail_cores[i]);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 312 free_cores_cpumask:
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 313 for (i = 0; i < ne_cpu_pool.avail_cores_size; i++)
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 314 free_cpumask_var(ne_cpu_pool.avail_cores[i]);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 315 kfree(ne_cpu_pool.avail_cores);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 316 ne_cpu_pool.avail_cores_size = 0;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 317 free_pool_cpumask:
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 318 free_cpumask_var(cpu_pool);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 319 mutex_unlock(&ne_cpu_pool.mutex);
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 320
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 321 return rc;
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 322 }
7d5c9a7dfa51e60 Andra Paraschiv 2020-08-05 323
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx