Re: [PATCH v6 07/16] x86/sev: Move and reorganize sev guest request api

kernel test robot
2023-11-29T02:42:05Z

Hi Nikunj,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/x86/mm]
[also build test WARNING on linus/master v6.7-rc3 next-20231128]
[cannot apply to tip/x86/core kvm/queue kvm/linux-next]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Nikunj-A-Dadhania/virt-sev-guest-Move-mutex-to-SNP-guest-device-structure/20231128-220026
base: tip/x86/mm
patch link: https://lore.kernel.org/r/20231128125959.1810039-8-nikunj%40amd.com
patch subject: [PATCH v6 07/16] x86/sev: Move and reorganize sev guest request api
config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20231129/202311290851.yrAyZYIl-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231129/202311290851.yrAyZYIl-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311290851.yrAyZYIl-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/x86/kernel/sev.c:2404:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!pdata->layout) {
^~~~~~~~~~~~~~
arch/x86/kernel/sev.c:2446:9: note: uninitialized use occurs here
return ret;
^~~
arch/x86/kernel/sev.c:2404:2: note: remove the 'if' if its condition is always false
if (!pdata->layout) {
^~~~~~~~~~~~~~~~~~~~~
arch/x86/kernel/sev.c:2380:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
1 warning generated.

vim +2404 arch/x86/kernel/sev.c

2376
2377 int snp_setup_psp_messaging(struct snp_guest_dev *snp_dev)
2378 {
2379 struct sev_guest_platform_data *pdata;
2380 int ret;
2381
2382 if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) {
2383 pr_err("SNP not supported\n");
2384 return 0;
2385 }
2386
2387 if (platform_data) {
2388 pr_debug("SNP platform data already initialized.\n");
2389 goto create_ctx;
2390 }
2391
2392 if (!secrets_pa) {
2393 pr_err("SNP secrets page not found\n");
2394 return -ENODEV;
2395 }
2396
2397 pdata = kzalloc(sizeof(struct sev_guest_platform_data), GFP_KERNEL);
2398 if (!pdata) {
2399 pr_err("Allocation of SNP guest platform data failed\n");
2400 return -ENOMEM;
2401 }
2402
2403 pdata->layout = (__force void *)ioremap_encrypted(secrets_pa, PAGE_SIZE);
> 2404 if (!pdata->layout) {
2405 pr_err("Failed to map SNP secrets page.\n");
2406 goto e_free_pdata;
2407 }
2408
2409 ret = -ENOMEM;
2410 /* Allocate the shared page used for the request and response message. */
2411 pdata->request = alloc_shared_pages(sizeof(struct snp_guest_msg));
2412 if (!pdata->request)
2413 goto e_unmap;
2414
2415 pdata->response = alloc_shared_pages(sizeof(struct snp_guest_msg));
2416 if (!pdata->response)
2417 goto e_free_request;
2418
2419 /* initial the input address for guest request */
2420 pdata->input.req_gpa = __pa(pdata->request);
2421 pdata->input.resp_gpa = __pa(pdata->response);
2422 platform_data = pdata;
2423
2424 create_ctx:
2425 ret = -EIO;
2426 snp_dev->ctx = snp_init_crypto(snp_dev->vmpck_id);
2427 if (!snp_dev->ctx) {
2428 pr_err("SNP crypto context initialization failed\n");
2429 platform_data = NULL;
2430 goto e_free_response;
2431 }
2432
2433 snp_dev->pdata = platform_data;
2434
2435 return 0;
2436
2437 e_free_response:
2438 free_shared_pages(pdata->response, sizeof(struct snp_guest_msg));
2439 e_free_request:
2440 free_shared_pages(pdata->request, sizeof(struct snp_guest_msg));
2441 e_unmap:
2442 iounmap(pdata->layout);
2443 e_free_pdata:
2444 kfree(pdata);
2445
2446 return ret;
2447 }
2448 EXPORT_SYMBOL_GPL(snp_setup_psp_messaging);
2449

--
0-DAY CI Kernel Test Service