Message ID | 20191113095144.2981-1-thomas_os@shipmail.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/vmwgfx: Use dma-coherent memory for high-bandwidth port messaging | expand |
On Wed, Nov 13, 2019 at 10:51:42AM +0100, Thomas Hellström (VMware) wrote: > From: Thomas Hellstrom <thellstrom@vmware.com> > > With AMD-SEV high-bandwidth port messaging runs into trouble since the > message content is encrypted using the vm-specific key, and the > hypervisor is unable to read it. > > So use unencrypted dma-coherent bounce buffers for temporary message > storage space. Allocating that memory is expensive so a future > optimization might include a static unencrypted memory area for messages. > > Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> > Reviewed-by: Brian Paul <brianp@vmware.com> Hi Thomas, The 0day team has been doing clang builds for us and sending the results to our mailing list for triage; this patch causes the following warning. Seems legitimate, mind taking a look at it and resolving it how you see fit? Cheers, Nathan On Thu, Nov 14, 2019 at 03:36:44AM +0800, kbuild test robot wrote: > CC: kbuild-all@lists.01.org > In-Reply-To: <20191113095144.2981-1-thomas_os@shipmail.org> > References: <20191113095144.2981-1-thomas_os@shipmail.org> > TO: "Thomas Hellström (VMware)" <thomas_os@shipmail.org> > CC: dri-devel@lists.freedesktop.org, Thomas Hellstrom <thellstrom@vmware.com>, Brian Paul <brianp@vmware.com>, Thomas Hellstrom <thellstrom@vmware.com>, Brian Paul <brianp@vmware.com> > CC: Thomas Hellstrom <thellstrom@vmware.com>, Brian Paul <brianp@vmware.com> > > Hi "Thomas, > > I love your patch! Perhaps something to improve: > > [auto build test WARNING on linus/master] > [also build test WARNING on v5.4-rc7 next-20191113] > [if your patch is applied to the wrong git tree, please drop us a note to help > improve the system. BTW, we also suggest to use '--base' option to specify the > base tree in git format-patch, please see https://stackoverflow.com/a/37406982] > > url: https://github.com/0day-ci/linux/commits/Thomas-Hellstr-m-VMware/drm-vmwgfx-Use-dma-coherent-memory-for-high-bandwidth-port-messaging/20191114-020818 > base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0e3f1ad80fc8cb0c517fd9a9afb22752b741fa76 > config: x86_64-rhel-7.6 (attached as .config) > compiler: clang version 10.0.0 (git://gitmirror/llvm_project 335ac2eb662ce5f1888e2a50310b01fba2d40d68) > reproduce: > # save the attached .config to linux build tree > make ARCH=x86_64 > > If you fix the issue, kindly add following tag > Reported-by: kbuild test robot <lkp@intel.com> > > All warnings (new ones prefixed by >>): > > >> drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:441:6: warning: variable 'reply_handle' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized] > if (vmw_send_msg(&channel, msg) || > ^~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:467:47: note: uninitialized use occurs here > dma_free_coherent(dev, reply_len + 1, reply, reply_handle); > ^~~~~~~~~~~~ > drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:441:6: note: remove the '||' if its condition is always false > if (vmw_send_msg(&channel, msg) || > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:421:37: note: initialize the variable 'reply_handle' to silence this warning > dma_addr_t req_handle, reply_handle; > ^ > = 0 > 1 warning generated. > > vim +441 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > > 89da76fde68de1 Sinclair Yeh 2016-04-27 400 > 89da76fde68de1 Sinclair Yeh 2016-04-27 401 > 89da76fde68de1 Sinclair Yeh 2016-04-27 402 /** > 89da76fde68de1 Sinclair Yeh 2016-04-27 403 * vmw_host_get_guestinfo: Gets a GuestInfo parameter > 89da76fde68de1 Sinclair Yeh 2016-04-27 404 * > 89da76fde68de1 Sinclair Yeh 2016-04-27 405 * Gets the value of a GuestInfo.* parameter. The value returned will be in > 89da76fde68de1 Sinclair Yeh 2016-04-27 406 * a string, and it is up to the caller to post-process. > 89da76fde68de1 Sinclair Yeh 2016-04-27 407 * > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 408 * @dev: Pointer to struct device used for coherent memory allocation > 89da76fde68de1 Sinclair Yeh 2016-04-27 409 * @guest_info_param: Parameter to get, e.g. GuestInfo.svga.gl3 > 89da76fde68de1 Sinclair Yeh 2016-04-27 410 * @buffer: if NULL, *reply_len will contain reply size. > 89da76fde68de1 Sinclair Yeh 2016-04-27 411 * @length: size of the reply_buf. Set to size of reply upon return > 89da76fde68de1 Sinclair Yeh 2016-04-27 412 * > 89da76fde68de1 Sinclair Yeh 2016-04-27 413 * Returns: 0 on success > 89da76fde68de1 Sinclair Yeh 2016-04-27 414 */ > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 415 int vmw_host_get_guestinfo(struct device *dev, const char *guest_info_param, > 89da76fde68de1 Sinclair Yeh 2016-04-27 416 char *buffer, size_t *length) > 89da76fde68de1 Sinclair Yeh 2016-04-27 417 { > 89da76fde68de1 Sinclair Yeh 2016-04-27 418 struct rpc_channel channel; > 89da76fde68de1 Sinclair Yeh 2016-04-27 419 char *msg, *reply = NULL; > 6073a09210e06f Himanshu Jha 2018-03-22 420 size_t reply_len = 0; > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 421 dma_addr_t req_handle, reply_handle; > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 422 int req_len = strlen("info-get ") + strlen(guest_info_param) + 1; > 89da76fde68de1 Sinclair Yeh 2016-04-27 423 > 89da76fde68de1 Sinclair Yeh 2016-04-27 424 if (!vmw_msg_enabled) > 89da76fde68de1 Sinclair Yeh 2016-04-27 425 return -ENODEV; > 89da76fde68de1 Sinclair Yeh 2016-04-27 426 > 89da76fde68de1 Sinclair Yeh 2016-04-27 427 if (!guest_info_param || !length) > 89da76fde68de1 Sinclair Yeh 2016-04-27 428 return -EINVAL; > 89da76fde68de1 Sinclair Yeh 2016-04-27 429 > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 430 msg = dma_alloc_coherent(dev, req_len, &req_handle, GFP_KERNEL); > 1a4adb05632e90 Ravikant B Sharma 2016-11-08 431 if (!msg) { > 3fbeccf8ceb165 Thomas Hellstrom 2018-06-20 432 DRM_ERROR("Cannot allocate memory to get guest info \"%s\".", > 3fbeccf8ceb165 Thomas Hellstrom 2018-06-20 433 guest_info_param); > 89da76fde68de1 Sinclair Yeh 2016-04-27 434 return -ENOMEM; > 89da76fde68de1 Sinclair Yeh 2016-04-27 435 } > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 436 snprintf(msg, req_len, "info-get %s", guest_info_param); > 89da76fde68de1 Sinclair Yeh 2016-04-27 437 > f37230c0ad4810 Thomas Hellstrom 2018-05-23 438 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM)) > f37230c0ad4810 Thomas Hellstrom 2018-05-23 439 goto out_open; > 89da76fde68de1 Sinclair Yeh 2016-04-27 440 > f37230c0ad4810 Thomas Hellstrom 2018-05-23 @441 if (vmw_send_msg(&channel, msg) || > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 442 vmw_recv_msg(dev, &channel, (void *) &reply, &reply_len, > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 443 &reply_handle)) > f37230c0ad4810 Thomas Hellstrom 2018-05-23 444 goto out_msg; > 89da76fde68de1 Sinclair Yeh 2016-04-27 445 > f37230c0ad4810 Thomas Hellstrom 2018-05-23 446 vmw_close_channel(&channel); > 89da76fde68de1 Sinclair Yeh 2016-04-27 447 if (buffer && reply && reply_len > 0) { > 89da76fde68de1 Sinclair Yeh 2016-04-27 448 /* Remove reply code, which are the first 2 characters of > 89da76fde68de1 Sinclair Yeh 2016-04-27 449 * the reply > 89da76fde68de1 Sinclair Yeh 2016-04-27 450 */ > 89da76fde68de1 Sinclair Yeh 2016-04-27 451 reply_len = max(reply_len - 2, (size_t) 0); > 89da76fde68de1 Sinclair Yeh 2016-04-27 452 reply_len = min(reply_len, *length); > 89da76fde68de1 Sinclair Yeh 2016-04-27 453 > 89da76fde68de1 Sinclair Yeh 2016-04-27 454 if (reply_len > 0) > 89da76fde68de1 Sinclair Yeh 2016-04-27 455 memcpy(buffer, reply + 2, reply_len); > 89da76fde68de1 Sinclair Yeh 2016-04-27 456 } > 89da76fde68de1 Sinclair Yeh 2016-04-27 457 > 89da76fde68de1 Sinclair Yeh 2016-04-27 458 *length = reply_len; > 89da76fde68de1 Sinclair Yeh 2016-04-27 459 > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 460 dma_free_coherent(dev, reply_len + 1, reply, reply_handle); > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 461 dma_free_coherent(dev, req_len, msg, req_handle); > 89da76fde68de1 Sinclair Yeh 2016-04-27 462 > f37230c0ad4810 Thomas Hellstrom 2018-05-23 463 return 0; > f37230c0ad4810 Thomas Hellstrom 2018-05-23 464 > f37230c0ad4810 Thomas Hellstrom 2018-05-23 465 out_msg: > f37230c0ad4810 Thomas Hellstrom 2018-05-23 466 vmw_close_channel(&channel); > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 467 dma_free_coherent(dev, reply_len + 1, reply, reply_handle); > f37230c0ad4810 Thomas Hellstrom 2018-05-23 468 out_open: > f37230c0ad4810 Thomas Hellstrom 2018-05-23 469 *length = 0; > f37230c0ad4810 Thomas Hellstrom 2018-05-23 470 > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 471 DRM_ERROR("Failed to get guest info \"%s\".", guest_info_param); > 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 472 dma_free_coherent(dev, req_len, msg, req_handle); > f37230c0ad4810 Thomas Hellstrom 2018-05-23 473 return -EINVAL; > 89da76fde68de1 Sinclair Yeh 2016-04-27 474 } > 89da76fde68de1 Sinclair Yeh 2016-04-27 475 > > :::::: The code at line 441 was first introduced by commit > :::::: f37230c0ad481091bc136788ff8b37dc86300c6d drm/vmwgfx: Fix host logging / guestinfo reading error paths > > :::::: TO: Thomas Hellstrom <thellstrom@vmware.com> > :::::: CC: Thomas Hellstrom <thellstrom@vmware.com> > > --- > 0-DAY kernel test infrastructure Open Source Technology Center > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
Hi, Nathan, On 11/13/19 9:01 PM, Nathan Chancellor wrote: > On Wed, Nov 13, 2019 at 10:51:42AM +0100, Thomas Hellström (VMware) wrote: >> From: Thomas Hellstrom <thellstrom@vmware.com> >> >> With AMD-SEV high-bandwidth port messaging runs into trouble since the >> message content is encrypted using the vm-specific key, and the >> hypervisor is unable to read it. >> >> So use unencrypted dma-coherent bounce buffers for temporary message >> storage space. Allocating that memory is expensive so a future >> optimization might include a static unencrypted memory area for messages. >> >> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> >> Reviewed-by: Brian Paul <brianp@vmware.com> > Hi Thomas, > > The 0day team has been doing clang builds for us and sending the results > to our mailing list for triage; this patch causes the following warning. > Seems legitimate, mind taking a look at it and resolving it how you see > fit? > > Cheers, > Nathan This should be harmless as dma_free_coherent() with reply == NULL is a nop, but anyway I'll respin to silence the warning. Thanks, Thomas > On Thu, Nov 14, 2019 at 03:36:44AM +0800, kbuild test robot wrote: >> CC: kbuild-all@lists.01.org >> In-Reply-To: <20191113095144.2981-1-thomas_os@shipmail.org> >> References: <20191113095144.2981-1-thomas_os@shipmail.org> >> TO: "Thomas Hellström (VMware)" <thomas_os@shipmail.org> >> CC: dri-devel@lists.freedesktop.org, Thomas Hellstrom <thellstrom@vmware.com>, Brian Paul <brianp@vmware.com>, Thomas Hellstrom <thellstrom@vmware.com>, Brian Paul <brianp@vmware.com> >> CC: Thomas Hellstrom <thellstrom@vmware.com>, Brian Paul <brianp@vmware.com> >> >> Hi "Thomas, >> >> I love your patch! Perhaps something to improve: >> >> [auto build test WARNING on linus/master] >> [also build test WARNING on v5.4-rc7 next-20191113] >> [if your patch is applied to the wrong git tree, please drop us a note to help >> improve the system. BTW, we also suggest to use '--base' option to specify the >> base tree in git format-patch, please see https://stackoverflow.com/a/37406982] >> >> url: https://github.com/0day-ci/linux/commits/Thomas-Hellstr-m-VMware/drm-vmwgfx-Use-dma-coherent-memory-for-high-bandwidth-port-messaging/20191114-020818 >> base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0e3f1ad80fc8cb0c517fd9a9afb22752b741fa76 >> config: x86_64-rhel-7.6 (attached as .config) >> compiler: clang version 10.0.0 (git://gitmirror/llvm_project 335ac2eb662ce5f1888e2a50310b01fba2d40d68) >> reproduce: >> # save the attached .config to linux build tree >> make ARCH=x86_64 >> >> If you fix the issue, kindly add following tag >> Reported-by: kbuild test robot <lkp@intel.com> >> >> All warnings (new ones prefixed by >>): >> >>>> drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:441:6: warning: variable 'reply_handle' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized] >> if (vmw_send_msg(&channel, msg) || >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:467:47: note: uninitialized use occurs here >> dma_free_coherent(dev, reply_len + 1, reply, reply_handle); >> ^~~~~~~~~~~~ >> drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:441:6: note: remove the '||' if its condition is always false >> if (vmw_send_msg(&channel, msg) || >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpu/drm/vmwgfx/vmwgfx_msg.c:421:37: note: initialize the variable 'reply_handle' to silence this warning >> dma_addr_t req_handle, reply_handle; >> ^ >> = 0 >> 1 warning generated. >> >> vim +441 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c >> >> 89da76fde68de1 Sinclair Yeh 2016-04-27 400 >> 89da76fde68de1 Sinclair Yeh 2016-04-27 401 >> 89da76fde68de1 Sinclair Yeh 2016-04-27 402 /** >> 89da76fde68de1 Sinclair Yeh 2016-04-27 403 * vmw_host_get_guestinfo: Gets a GuestInfo parameter >> 89da76fde68de1 Sinclair Yeh 2016-04-27 404 * >> 89da76fde68de1 Sinclair Yeh 2016-04-27 405 * Gets the value of a GuestInfo.* parameter. The value returned will be in >> 89da76fde68de1 Sinclair Yeh 2016-04-27 406 * a string, and it is up to the caller to post-process. >> 89da76fde68de1 Sinclair Yeh 2016-04-27 407 * >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 408 * @dev: Pointer to struct device used for coherent memory allocation >> 89da76fde68de1 Sinclair Yeh 2016-04-27 409 * @guest_info_param: Parameter to get, e.g. GuestInfo.svga.gl3 >> 89da76fde68de1 Sinclair Yeh 2016-04-27 410 * @buffer: if NULL, *reply_len will contain reply size. >> 89da76fde68de1 Sinclair Yeh 2016-04-27 411 * @length: size of the reply_buf. Set to size of reply upon return >> 89da76fde68de1 Sinclair Yeh 2016-04-27 412 * >> 89da76fde68de1 Sinclair Yeh 2016-04-27 413 * Returns: 0 on success >> 89da76fde68de1 Sinclair Yeh 2016-04-27 414 */ >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 415 int vmw_host_get_guestinfo(struct device *dev, const char *guest_info_param, >> 89da76fde68de1 Sinclair Yeh 2016-04-27 416 char *buffer, size_t *length) >> 89da76fde68de1 Sinclair Yeh 2016-04-27 417 { >> 89da76fde68de1 Sinclair Yeh 2016-04-27 418 struct rpc_channel channel; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 419 char *msg, *reply = NULL; >> 6073a09210e06f Himanshu Jha 2018-03-22 420 size_t reply_len = 0; >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 421 dma_addr_t req_handle, reply_handle; >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 422 int req_len = strlen("info-get ") + strlen(guest_info_param) + 1; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 423 >> 89da76fde68de1 Sinclair Yeh 2016-04-27 424 if (!vmw_msg_enabled) >> 89da76fde68de1 Sinclair Yeh 2016-04-27 425 return -ENODEV; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 426 >> 89da76fde68de1 Sinclair Yeh 2016-04-27 427 if (!guest_info_param || !length) >> 89da76fde68de1 Sinclair Yeh 2016-04-27 428 return -EINVAL; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 429 >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 430 msg = dma_alloc_coherent(dev, req_len, &req_handle, GFP_KERNEL); >> 1a4adb05632e90 Ravikant B Sharma 2016-11-08 431 if (!msg) { >> 3fbeccf8ceb165 Thomas Hellstrom 2018-06-20 432 DRM_ERROR("Cannot allocate memory to get guest info \"%s\".", >> 3fbeccf8ceb165 Thomas Hellstrom 2018-06-20 433 guest_info_param); >> 89da76fde68de1 Sinclair Yeh 2016-04-27 434 return -ENOMEM; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 435 } >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 436 snprintf(msg, req_len, "info-get %s", guest_info_param); >> 89da76fde68de1 Sinclair Yeh 2016-04-27 437 >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 438 if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM)) >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 439 goto out_open; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 440 >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 @441 if (vmw_send_msg(&channel, msg) || >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 442 vmw_recv_msg(dev, &channel, (void *) &reply, &reply_len, >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 443 &reply_handle)) >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 444 goto out_msg; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 445 >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 446 vmw_close_channel(&channel); >> 89da76fde68de1 Sinclair Yeh 2016-04-27 447 if (buffer && reply && reply_len > 0) { >> 89da76fde68de1 Sinclair Yeh 2016-04-27 448 /* Remove reply code, which are the first 2 characters of >> 89da76fde68de1 Sinclair Yeh 2016-04-27 449 * the reply >> 89da76fde68de1 Sinclair Yeh 2016-04-27 450 */ >> 89da76fde68de1 Sinclair Yeh 2016-04-27 451 reply_len = max(reply_len - 2, (size_t) 0); >> 89da76fde68de1 Sinclair Yeh 2016-04-27 452 reply_len = min(reply_len, *length); >> 89da76fde68de1 Sinclair Yeh 2016-04-27 453 >> 89da76fde68de1 Sinclair Yeh 2016-04-27 454 if (reply_len > 0) >> 89da76fde68de1 Sinclair Yeh 2016-04-27 455 memcpy(buffer, reply + 2, reply_len); >> 89da76fde68de1 Sinclair Yeh 2016-04-27 456 } >> 89da76fde68de1 Sinclair Yeh 2016-04-27 457 >> 89da76fde68de1 Sinclair Yeh 2016-04-27 458 *length = reply_len; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 459 >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 460 dma_free_coherent(dev, reply_len + 1, reply, reply_handle); >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 461 dma_free_coherent(dev, req_len, msg, req_handle); >> 89da76fde68de1 Sinclair Yeh 2016-04-27 462 >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 463 return 0; >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 464 >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 465 out_msg: >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 466 vmw_close_channel(&channel); >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 467 dma_free_coherent(dev, reply_len + 1, reply, reply_handle); >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 468 out_open: >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 469 *length = 0; >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 470 >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 471 DRM_ERROR("Failed to get guest info \"%s\".", guest_info_param); >> 6bdb21230a2a01 Thomas Hellstrom 2019-11-13 472 dma_free_coherent(dev, req_len, msg, req_handle); >> f37230c0ad4810 Thomas Hellstrom 2018-05-23 473 return -EINVAL; >> 89da76fde68de1 Sinclair Yeh 2016-04-27 474 } >> 89da76fde68de1 Sinclair Yeh 2016-04-27 475 >> >> :::::: The code at line 441 was first introduced by commit >> :::::: f37230c0ad481091bc136788ff8b37dc86300c6d drm/vmwgfx: Fix host logging / guestinfo reading error paths >> >> :::::: TO: Thomas Hellstrom <thellstrom@vmware.com> >> :::::: CC: Thomas Hellstrom <thellstrom@vmware.com> >> >> --- >> 0-DAY kernel test infrastructure Open Source Technology Center >> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 81a95651643f..fc0283659c41 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -908,13 +908,13 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) snprintf(host_log, sizeof(host_log), "vmwgfx: %s-%s", VMWGFX_REPO, VMWGFX_GIT_VERSION); - vmw_host_log(host_log); + vmw_host_log(dev->dev, host_log); memset(host_log, 0, sizeof(host_log)); snprintf(host_log, sizeof(host_log), "vmwgfx: Module Version: %d.%d.%d", VMWGFX_DRIVER_MAJOR, VMWGFX_DRIVER_MINOR, VMWGFX_DRIVER_PATCHLEVEL); - vmw_host_log(host_log); + vmw_host_log(dev->dev, host_log); if (dev_priv->enable_fb) { vmw_fifo_resource_inc(dev_priv); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index b18842f73081..a77bf72cb9ac 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -1389,9 +1389,9 @@ int vmw_bo_cpu_blit(struct ttm_buffer_object *dst, struct vmw_diff_cpy *diff); /* Host messaging -vmwgfx_msg.c: */ -int vmw_host_get_guestinfo(const char *guest_info_param, +int vmw_host_get_guestinfo(struct device *dev, const char *guest_info_param, char *buffer, size_t *length); -int vmw_host_log(const char *log); +int vmw_host_log(struct device *dev, const char *log); /* VMW logging */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c index b6c5e4c2ac3c..f439b7afa3a5 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c @@ -304,8 +304,8 @@ STACK_FRAME_NON_STANDARD(vmw_send_msg); * @msg: [OUT] message received from the host * @msg_len: message length */ -static int vmw_recv_msg(struct rpc_channel *channel, void **msg, - size_t *msg_len) +static int vmw_recv_msg(struct device *dev, struct rpc_channel *channel, + void **msg, size_t *msg_len, dma_addr_t *dma_handle) { unsigned long eax, ebx, ecx, edx, si, di; char *reply; @@ -339,7 +339,8 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, return 0; reply_len = ebx; - reply = kzalloc(reply_len + 1, GFP_KERNEL); + reply = dma_alloc_coherent(dev, reply_len + 1, dma_handle, + GFP_KERNEL); if (!reply) { DRM_ERROR("Cannot allocate memory for host message reply.\n"); return -ENOMEM; @@ -350,7 +351,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, ebx = vmw_port_hb_in(channel, reply, reply_len, !!(HIGH_WORD(ecx) & MESSAGE_STATUS_HB)); if ((HIGH_WORD(ebx) & MESSAGE_STATUS_SUCCESS) == 0) { - kfree(reply); + dma_free_coherent(dev, reply_len + 1, reply, *dma_handle); reply = NULL; if ((HIGH_WORD(ebx) & MESSAGE_STATUS_CPT) != 0) { /* A checkpoint occurred. Retry. */ @@ -374,7 +375,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, eax, ebx, ecx, edx, si, di); if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) { - kfree(reply); + dma_free_coherent(dev, reply_len + 1, reply, *dma_handle); reply = NULL; if ((HIGH_WORD(ecx) & MESSAGE_STATUS_CPT) != 0) { /* A checkpoint occurred. Retry. */ @@ -404,18 +405,21 @@ STACK_FRAME_NON_STANDARD(vmw_recv_msg); * Gets the value of a GuestInfo.* parameter. The value returned will be in * a string, and it is up to the caller to post-process. * + * @dev: Pointer to struct device used for coherent memory allocation * @guest_info_param: Parameter to get, e.g. GuestInfo.svga.gl3 * @buffer: if NULL, *reply_len will contain reply size. * @length: size of the reply_buf. Set to size of reply upon return * * Returns: 0 on success */ -int vmw_host_get_guestinfo(const char *guest_info_param, +int vmw_host_get_guestinfo(struct device *dev, const char *guest_info_param, char *buffer, size_t *length) { struct rpc_channel channel; char *msg, *reply = NULL; size_t reply_len = 0; + dma_addr_t req_handle, reply_handle; + int req_len = strlen("info-get ") + strlen(guest_info_param) + 1; if (!vmw_msg_enabled) return -ENODEV; @@ -423,18 +427,20 @@ int vmw_host_get_guestinfo(const char *guest_info_param, if (!guest_info_param || !length) return -EINVAL; - msg = kasprintf(GFP_KERNEL, "info-get %s", guest_info_param); + msg = dma_alloc_coherent(dev, req_len, &req_handle, GFP_KERNEL); if (!msg) { DRM_ERROR("Cannot allocate memory to get guest info \"%s\".", guest_info_param); return -ENOMEM; } + snprintf(msg, req_len, "info-get %s", guest_info_param); if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM)) goto out_open; if (vmw_send_msg(&channel, msg) || - vmw_recv_msg(&channel, (void *) &reply, &reply_len)) + vmw_recv_msg(dev, &channel, (void *) &reply, &reply_len, + &reply_handle)) goto out_msg; vmw_close_channel(&channel); @@ -451,19 +457,19 @@ int vmw_host_get_guestinfo(const char *guest_info_param, *length = reply_len; - kfree(reply); - kfree(msg); + dma_free_coherent(dev, reply_len + 1, reply, reply_handle); + dma_free_coherent(dev, req_len, msg, req_handle); return 0; out_msg: vmw_close_channel(&channel); - kfree(reply); + dma_free_coherent(dev, reply_len + 1, reply, reply_handle); out_open: *length = 0; - kfree(msg); - DRM_ERROR("Failed to get guest info \"%s\".", guest_info_param); + DRM_ERROR("Failed to get guest info \"%s\".", guest_info_param); + dma_free_coherent(dev, req_len, msg, req_handle); return -EINVAL; } @@ -472,16 +478,18 @@ int vmw_host_get_guestinfo(const char *guest_info_param, /** * vmw_host_log: Sends a log message to the host * + * @dev: Pointer to struct device used for coherent memory allocation * @log: NULL terminated string * * Returns: 0 on success */ -int vmw_host_log(const char *log) +int vmw_host_log(struct device *dev, const char *log) { struct rpc_channel channel; char *msg; int ret = 0; - + dma_addr_t log_handle; + int log_len = strlen("log ") + strlen(log) + 1; if (!vmw_msg_enabled) return -ENODEV; @@ -489,11 +497,12 @@ int vmw_host_log(const char *log) if (!log) return ret; - msg = kasprintf(GFP_KERNEL, "log %s", log); + msg = dma_alloc_coherent(dev, log_len, &log_handle, GFP_KERNEL); if (!msg) { DRM_ERROR("Cannot allocate memory for host log message.\n"); return -ENOMEM; } + snprintf(msg, log_len, "log %s", log); if (vmw_open_channel(&channel, RPCI_PROTOCOL_NUM)) goto out_open; @@ -502,14 +511,14 @@ int vmw_host_log(const char *log) goto out_msg; vmw_close_channel(&channel); - kfree(msg); + dma_free_coherent(dev, log_len, msg, log_handle); return 0; out_msg: vmw_close_channel(&channel); out_open: - kfree(msg); + dma_free_coherent(dev, log_len, msg, log_handle); DRM_ERROR("Failed to send host log message.\n"); return -EINVAL;