Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5137635pxb; Wed, 26 Jan 2022 05:44:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzMyHThLDb/OU3XlTuwwS55SR6xp637Ow7eK251bkWljFAXZeTN8dC07N8hfwnmMCoBTRZ X-Received: by 2002:a63:b544:: with SMTP id u4mr18900091pgo.160.1643204657494; Wed, 26 Jan 2022 05:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643204657; cv=none; d=google.com; s=arc-20160816; b=p7Xoclf4FXfbdNFieriHaq98AIarGocFjwK1qxk4Ge76WphAWgZlwP6e4p1kS23k+a MGVBVL8rTpZ9JN6wob5svowbmyZzUZFNlBq4UcvO5WcNnRonJh3wVVyf8XVcOjoaHTk5 sxsKkkvO58ztb1CGGBWXwqWsnDGhUaGgvcEVBGylwcGMxQMWFwSlIx0/D7T6RfXXdIbW i7IfrK25rzcO6nIg8m7/1yUUWVF7U7YgjLuItMgDOERqmwSH2d86C2CqJIJNBhU76g40 mSQ+k+e1X66c8aYLlaiJ18yULlX9aazFVaV9Qy/0kh+m96fwJHhFFtCXtt9pwJDP448q bI4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xXUuEZaufNJBt33NRKvYgrNCXefiiPKYWwx6RL+UM5Q=; b=VC4LiW+Kf3ZX0D5Oc8cbEP1S0ayU7Tf4H9seM907t67xoaszNvnjFKk+rIx1r5AiQf 5WUp4A1hVajWiPq3MsC2v6V4L/U0k8zU2aQdZCws03MwVBpvrnzHXUtHkZ5ywcLEmD/F U03K1jMlXv+GsvpFaB/0GDIwYRGWdlVj5FLlO589WK1gv74BoiXnzTCqatd6XQB3NbmO pME+JxSLSj7nXB8hS+u6qiQwgOsAllU9mIHw1346kOvjDx3+IrUcRhdUbF/DgWi7Kr68 punmSVC/du2/Qrdxv8BS1snvmrfMyZr8tWPXzYne2s4pa2rU6B3Txi0KL1hmI0ksMWbe 7bxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vBj0DhvU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si16622433pla.578.2022.01.26.05.44.05; Wed, 26 Jan 2022 05:44:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vBj0DhvU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235269AbiAZA2J (ORCPT + 99 others); Tue, 25 Jan 2022 19:28:09 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:46698 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235260AbiAZA2C (ORCPT ); Tue, 25 Jan 2022 19:28:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 22E7E61488; Wed, 26 Jan 2022 00:28:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99494C340E0; Wed, 26 Jan 2022 00:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643156880; bh=ksVjsac8pbiJiN9Quz36d8M4Pzg1QwigCdaIkcPJcwE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vBj0DhvU5ltRgnu7K8EeAnXUI9PFQwkcs3bFsL4jky4oz4ayDq5IsjRlLyCrZIHaL tY4DbmFk3HPotyWwXAV9YiSuEMxgr4HWW9z9GmNwNvYG9E34BToS8gy6UjNzXfVtpV Vb+InQ7tzz+WXbnEeZ3fTP35YehN/J/FnuCajoA7Z+TfbFMSFftoSWWmd63h8B/doo OzaC52ZAiAMI9lX08p3i/zLDZQFM/opDzWRXmIPPukGmbyA4oFIfkzKwXuvNl17kuL D0ZKkYtAs7WQkvCuE+n5p8x2idOWJYI6gSJXpCmrK5pF7fdxACELmU0m5dDOH1KvxR F0oMrObYuU1rw== Date: Tue, 25 Jan 2022 17:27:55 -0700 From: Nathan Chancellor To: Iouri Tarassov Cc: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, spronovo@microsoft.com, gregkh@linuxfoundation.org Subject: Re: [PATCH v1 0/9] drivers: hv: dxgkrnl: Driver overview Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Iouri, On Wed, Jan 12, 2022 at 03:39:13PM -0800, Iouri Tarassov wrote: > > On 1/12/2022 2:12 PM, Nathan Chancellor wrote: > > Hi Iouri, > > > > > We're looking forward additional feedback. > > > > I have been including this patch set into my downstream WSL2 kernel that > > I build with clang and I noticed an instance of -Wenum-conversion that > > is still present in this revision:Please consider cleaning this up in a future revision so that clang > > builds stay clean :) > > ... > > I happened to notice there was another function that looks very similar > > to command_vgpu_to_host_init0(), command_vm_to_host_init0(), which is > > also unused. This was hidden because it is marked as "static inline" in > > a .c file, which should generally be avoided; I would recommend > > replacing all instances of "static inline" with just "static". The > > compiler will still inline it if it feels it is worthwhile. Doing this > > reveals one other unused function, is_empty(): > > > > $ sed -i 's/static inline /static /g' drivers/hv/dxgkrnl/*.c > > > > $ make -skj"$(nproc)" LLVM=1 drivers/hv/dxgkrnl/ > > drivers/hv/dxgkrnl/hmgr.c:167:13: warning: unused function 'is_empty' [-Wunused-function] > > static bool is_empty(struct hmgrtable *table) > > ^ > > 1 warning generated. > > drivers/hv/dxgkrnl/dxgvmbus.c:234:13: warning: unused function 'command_vm_to_host_init0' [-Wunused-function] > > static void command_vm_to_host_init0(struct dxgkvmb_command_vm_to_host > > ^ > > 1 warning generated. > > Thanks a lot! We will get this fixed In addition to the warnings that I mentioned above, when I apply this patchset on top of next-20220125, which enables -Warray-bounds, I see the following warnings with GCC 11.2.1: drivers/hv/dxgkrnl/ioctl.c: In function ‘init_ioctls’: drivers/hv/dxgkrnl/ioctl.c:5315:15: warning: array subscript 69 is above array bounds of ‘struct ioctl_desc[69]’ [-Warray-bounds] 5315 | ioctls[_IOC_NR(v)].ioctl_callback = callback; \ | ~~~~~~^~~~~~~~~~~~ drivers/hv/dxgkrnl/ioctl.c:5456:9: note: in expansion of macro ‘SET_IOCTL’ 5456 | SET_IOCTL(/*0x45 */ dxgk_create_sync_file, | ^~~~~~~~~ drivers/hv/dxgkrnl/ioctl.c:34:26: note: while referencing ‘ioctls’ 34 | static struct ioctl_desc ioctls[LX_IO_MAX + 1]; | ^~~~~~ drivers/hv/dxgkrnl/ioctl.c:5316:15: warning: array subscript 69 is above array bounds of ‘struct ioctl_desc[69]’ [-Warray-bounds] 5316 | ioctls[_IOC_NR(v)].ioctl = v | ~~~~~~^~~~~~~~~~~~ drivers/hv/dxgkrnl/ioctl.c:5456:9: note: in expansion of macro ‘SET_IOCTL’ 5456 | SET_IOCTL(/*0x45 */ dxgk_create_sync_file, | ^~~~~~~~~ drivers/hv/dxgkrnl/ioctl.c:34:26: note: while referencing ‘ioctls’ 34 | static struct ioctl_desc ioctls[LX_IO_MAX + 1]; | ^~~~~~ drivers/hv/dxgkrnl/dxgvmbus.c: In function ‘dxgvmb_send_query_alloc_residency’: drivers/hv/dxgkrnl/dxgvmbus.c:147:16: warning: array subscript ‘struct dxgvmbusmsg[0]’ is partly outside array bounds of ‘struct dxgvmbusmsgres[1]’ [-Warray-bounds] 147 | if (msg->hdr && (char *)msg->hdr != msg->msg_on_stack) | ~~~^~~~~ drivers/hv/dxgkrnl/dxgvmbus.c:1882:31: note: while referencing ‘msg’ 1882 | struct dxgvmbusmsgres msg = {.hdr = NULL}; | ^~~ drivers/hv/dxgkrnl/dxgvmbus.c: In function ‘dxgvmb_send_open_resource’: drivers/hv/dxgkrnl/dxgvmbus.c:147:16: warning: array subscript ‘struct dxgvmbusmsg[0]’ is partly outside array bounds of ‘struct dxgvmbusmsgres[1]’ [-Warray-bounds] 147 | if (msg->hdr && (char *)msg->hdr != msg->msg_on_stack) | ~~~^~~~~ drivers/hv/dxgkrnl/dxgvmbus.c:2132:31: note: while referencing ‘msg’ 2132 | struct dxgvmbusmsgres msg = {.hdr = NULL}; | ^~~ drivers/hv/dxgkrnl/dxgvmbus.c: In function ‘dxgvmb_send_get_stdalloc_data’: drivers/hv/dxgkrnl/dxgvmbus.c:147:16: warning: array subscript ‘struct dxgvmbusmsg[0]’ is partly outside array bounds of ‘struct dxgvmbusmsgres[1]’ [-Warray-bounds] 147 | if (msg->hdr && (char *)msg->hdr != msg->msg_on_stack) | ~~~^~~~~ drivers/hv/dxgkrnl/dxgvmbus.c:2183:31: note: while referencing ‘msg’ 2183 | struct dxgvmbusmsgres msg = {.hdr = NULL}; | ^~~ drivers/hv/dxgkrnl/dxgvmbus.c: In function ‘dxgvmb_send_get_allocation_priority’: drivers/hv/dxgkrnl/dxgvmbus.c:147:16: warning: array subscript ‘struct dxgvmbusmsg[0]’ is partly outside array bounds of ‘struct dxgvmbusmsgres[1]’ [-Warray-bounds] 147 | if (msg->hdr && (char *)msg->hdr != msg->msg_on_stack) | ~~~^~~~~ drivers/hv/dxgkrnl/dxgvmbus.c:3106:31: note: while referencing ‘msg’ 3106 | struct dxgvmbusmsgres msg = {.hdr = NULL}; | ^~~ drivers/hv/dxgkrnl/dxgvmbus.c: In function ‘dxgvmb_send_reclaim_allocations’: drivers/hv/dxgkrnl/dxgvmbus.c:147:16: warning: array subscript ‘struct dxgvmbusmsg[0]’ is partly outside array bounds of ‘struct dxgvmbusmsgres[1]’ [-Warray-bounds] 147 | if (msg->hdr && (char *)msg->hdr != msg->msg_on_stack) | ~~~^~~~~ drivers/hv/dxgkrnl/dxgvmbus.c:3298:31: note: while referencing ‘msg’ 3298 | struct dxgvmbusmsgres msg = {.hdr = NULL}; | ^~~ drivers/hv/dxgkrnl/dxgvmbus.c: In function ‘dxgvmb_send_query_statistics’: drivers/hv/dxgkrnl/dxgvmbus.c:147:16: warning: array subscript ‘struct dxgvmbusmsg[0]’ is partly outside array bounds of ‘struct dxgvmbusmsgres[1]’ [-Warray-bounds] 147 | if (msg->hdr && (char *)msg->hdr != msg->msg_on_stack) | ~~~^~~~~ drivers/hv/dxgkrnl/dxgvmbus.c:3698:31: note: while referencing ‘msg’ 3698 | struct dxgvmbusmsgres msg = {.hdr = NULL}; | ^~~ The warning in ioctl.c is resolved with the following diff, which appears to be a forward port problem, since the WSL2 tree is fine. I don't see the warning in dxgvmbus.c with clang so I did not look into it. Cheers, Nathan diff --git a/include/uapi/misc/d3dkmthk.h b/include/uapi/misc/d3dkmthk.h index a7c9fdd95e2e..a32431e3df56 100644 --- a/include/uapi/misc/d3dkmthk.h +++ b/include/uapi/misc/d3dkmthk.h @@ -1949,6 +1949,6 @@ struct d3dkmt_createsyncfile { #define LX_DXCREATESYNCFILE \ _IOWR(0x47, 0x45, struct d3dkmt_createsyncfile) -#define LX_IO_MAX 0x44 +#define LX_IO_MAX 0x45 #endif /* _D3DKMTHK_H */