public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Hao Ge <hao.ge@linux.dev>
To: Greg KH <gregkh@linuxfoundation.org>,
	Yufeng Wang <wangyufeng@kylinos.cn>
Cc: Kees Cook <kees@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Petr Pavlu <petr.pavlu@suse.com>,
	Yafang Shao <laoar.shao@gmail.com>,
	Jan Hendrik Farr <kernel@jfarr.cc>,
	Tony Ambardar <tony.ambardar@gmail.com>,
	Alexander Potapenko <glider@google.com>,
	Uros Bizjak <ubizjak@gmail.com>, Shunsuke Mie <mie@igel.co.jp>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] tools: fixed compile tools/virtio error "__user" redefined [-Werror]
Date: Mon, 13 Jan 2025 10:34:41 +0800	[thread overview]
Message-ID: <0e5ab96b-2a2a-4e64-b0e0-2fdf6ce39810@linux.dev> (raw)
In-Reply-To: <2025010943-chess-affluent-1bb5@gregkh>

Hi Greg and Yufeng


On 2025/1/9 17:14, Greg KH wrote:
> On Thu, Jan 09, 2025 at 04:43:41PM +0800, Yufeng Wang wrote:
>> we use -Werror now, and warnings break the build so let's fixed it.
>>
>> from virtio_test.c:17:
>> ./linux/../../../include/linux/compiler_types.h:48: error: "__user" redefined [-Werror]
>> 48 | # define __user BTF_TYPE_TAG(user)
>> |
>> In file included from ../../usr/include/linux/stat.h:5,
>> from /usr/include/x86_64-linux-gnu/bits/statx.h:31,
>> from /usr/include/x86_64-linux-gnu/sys/stat.h:465,
>> from virtio_test.c:12:
>> ../include/linux/types.h:56: note: this is the location of the previous definition
>> 56 | #define __user
>>
>> Cc: stable@vger.kernel.org
>>
>> Signed-off-by: Yufeng Wang <wangyufeng@kylinos.cn>
>> ---
>>   include/linux/compiler_types.h | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
>> index 5d6544545658..3316e56140d6 100644
>> --- a/include/linux/compiler_types.h
>> +++ b/include/linux/compiler_types.h
>> @@ -54,6 +54,7 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
>>   # ifdef STRUCTLEAK_PLUGIN
>>   #  define __user	__attribute__((user))
>>   # else
>> +#  undef __user
>>   #  define __user	BTF_TYPE_TAG(user)
>>   # endif
>>   # define __iomem
>> -- 
>> 2.34.1
> What commit does this fix?  Why is this suddenly showing up now?
>
> thanks,
>
> greg k-h


This may be an issue caused by an upgrade in the GCC version.

Using GCC version 9.3.0, it can happily pass the build process.

However, when using GCC version 12.3.1, issues arise.

The initial build error stack is as follows:

cc -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I 
../../usr/include/ -Wno-pointer-sign -fno-strict-overflow 
-fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include 
../../include/linux/kconfig.h -mfunction-return=thunk 
-fcf-protection=none -mindirect-branch-register -pthread   -c -o 
virtio_test.o virtio_test.c
In file included from ./linux/compiler.h:5,
                  from ./linux/kernel.h:12,
                  from ./linux/scatterlist.h:4,
                  from ./linux/virtio.h:4,
                  from ./linux/virtio_config.h:5,
                  from ../../usr/include/linux/vhost_types.h:14,
                  from ../../usr/include/linux/vhost.h:14,
                  from virtio_test.c:17:
./linux/../../../include/linux/compiler_types.h:57: error: "__user" 
redefined [-Werror]

    57 | #  define __user        BTF_TYPE_TAG(user)
       |
In file included from ../../usr/include/linux/stat.h:5,
                  from /usr/include/bits/statx.h:31,
                  from /usr/include/sys/stat.h:465,
                  from virtio_test.c:12:

../include/linux/types.h:56: note: this is the location of the previous 
definition

    56 | #define __user

It should have first encountered the following #ifndef

https://elixir.bootlin.com/linux/v6.12.5/source/tools/include/linux/types.h#L52

So I think the  modification should be as follows(Adjust the position of 
the header file),

What do you think?


diff --git a/tools/virtio/linux/virtio_config.h 
b/tools/virtio/linux/virtio_config.h
index 42a564f22f2d..3d32211d2d23 100644
--- a/tools/virtio/linux/virtio_config.h
+++ b/tools/virtio/linux/virtio_config.h
@@ -1,8 +1,8 @@
  /* SPDX-License-Identifier: GPL-2.0 */
  #ifndef LINUX_VIRTIO_CONFIG_H
  #define LINUX_VIRTIO_CONFIG_H
-#include <linux/virtio_byteorder.h>
  #include <linux/virtio.h>
+#include <linux/virtio_byteorder.h>
  #include <uapi/linux/virtio_config.h>

  struct virtio_config_ops {
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index 028f54e6854a..8cbe632e98b0 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -9,13 +9,13 @@
  #include <assert.h>
  #include <unistd.h>
  #include <sys/ioctl.h>
+#include <linux/virtio.h>
  #include <sys/stat.h>
  #include <sys/types.h>
  #include <fcntl.h>
  #include <stdbool.h>
  #include <linux/virtio_types.h>
  #include <linux/vhost.h>
-#include <linux/virtio.h>
  #include <linux/virtio_ring.h>
  #include "../../drivers/vhost/test.h"

Thanks

Best Regards

Hao


      reply	other threads:[~2025-01-13  2:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09  8:43 [PATCH] tools: fixed compile tools/virtio error "__user" redefined [-Werror] Yufeng Wang
2025-01-09  9:14 ` Greg KH
2025-01-13  2:34   ` Hao Ge [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0e5ab96b-2a2a-4e64-b0e0-2fdf6ce39810@linux.dev \
    --to=hao.ge@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kees@kernel.org \
    --cc=kernel@jfarr.cc \
    --cc=kuba@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mie@igel.co.jp \
    --cc=nathan@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=stable@vger.kernel.org \
    --cc=tony.ambardar@gmail.com \
    --cc=ubizjak@gmail.com \
    --cc=wangyufeng@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox