* Re: [PATCH v2 01/12] can: Add LIN bus as CAN abstraction
From: Christoph Fritz @ 2024-05-08 8:37 UTC (permalink / raw)
To: Simon Horman
Cc: Oliver Hartkopp, Marc Kleine-Budde, Vincent Mailhol,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jiri Kosina,
Benjamin Tissoires, Greg Kroah-Hartman, Jiri Slaby,
Sebastian Reichel, Linus Walleij, Andreas Lauser, Jonathan Corbet,
Pavel Pisa, linux-can, netdev, devicetree, linux-input,
linux-serial
In-Reply-To: <20240504124904.GJ3167983@kernel.org>
On Sat, 2024-05-04 at 13:49 +0100, Simon Horman wrote:
> On Thu, May 02, 2024 at 09:55:23AM +0200, Christoph Fritz wrote:
> > This patch adds a LIN (local interconnect network) bus abstraction on
> > top of CAN. It is a glue driver adapting CAN on one side while offering
> > LIN abstraction on the other side. So that upcoming LIN device drivers
> > can make use of it.
> >
> > Tested-by: Andreas Lauser <andreas.lauser@mercedes-benz.com>
> > Signed-off-by: Christoph Fritz <christoph.fritz@hexdev.de>
>
> ...
>
> > diff --git a/drivers/net/can/lin.c b/drivers/net/can/lin.c
>
> ...
>
> > +struct lin_device *register_lin(struct device *dev,
> > + const struct lin_device_ops *ldops)
> > +{
> > + struct net_device *ndev;
> > + struct lin_device *ldev;
> > + int ret;
> > +
> > + if (!ldops || !ldops->ldo_tx || !ldops->update_bitrate ||
> > + !ldops->ldo_open || !ldops->ldo_stop) {
> > + netdev_err(ndev, "missing mandatory lin_device_ops\n");
>
> Hi Christoph,
Hi Simon
> The line above uses ndev, but ndev is not initialised
> until a few lines further down.
>
> Flagged by Smatch.
Despite netdev_err() checks validity of ndev, I agree with Smatch: In
upcoming v4 I'll use dev_err() here instead.
> > + return ERR_PTR(-EINVAL);
> > + }
> > +
> > + ndev = alloc_candev(sizeof(struct lin_device), 1);
> > + if (!ndev)
> > + return ERR_PTR(-ENOMEM);
> > +
> > + ldev = netdev_priv(ndev);
> > +
> > + ldev->ldev_ops = ldops;
> > + ndev->netdev_ops = &lin_netdev_ops;
> > + ndev->flags |= IFF_ECHO;
> > + ndev->mtu = CANFD_MTU;
> > + ldev->can.bittiming.bitrate = LIN_DEFAULT_BAUDRATE;
> > + ldev->can.ctrlmode = CAN_CTRLMODE_LIN;
> > + ldev->can.ctrlmode_supported = 0;
> > + ldev->can.bitrate_const = lin_bitrate;
> > + ldev->can.bitrate_const_cnt = ARRAY_SIZE(lin_bitrate);
> > + ldev->can.do_set_bittiming = lin_set_bittiming;
> > + ldev->ndev = ndev;
> > + ldev->dev = dev;
> > +
> > + SET_NETDEV_DEV(ndev, dev);
> > +
> > + ret = lin_set_bittiming(ndev);
> > + if (ret) {
> > + netdev_err(ndev, "set bittiming failed\n");
> > + goto exit_candev;
> > + }
> > +
> > + ret = register_candev(ndev);
> > + if (ret)
> > + goto exit_candev;
> > +
> > + ldev->lin_ids_kobj = kobject_create_and_add("lin_ids", &ndev->dev.kobj);
> > + if (!ldev->lin_ids_kobj) {
> > + netdev_err(ndev, "Failed to create sysfs directory\n");
> > + ret = -ENOMEM;
> > + goto exit_unreg;
> > + }
> > +
> > + ret = lin_create_sysfs_id_files(ndev);
> > + if (ret) {
> > + netdev_err(ndev, "Failed to create sysfs entry: %d\n", ret);
> > + goto exit_kobj_put;
> > + }
> > +
> > + /* Using workqueue as tx over USB/SPI/... may sleep */
> > + ldev->wq = alloc_workqueue(dev_name(dev), WQ_FREEZABLE | WQ_MEM_RECLAIM,
> > + 0);
> > + if (!ldev->wq)
> > + goto exit_rm_files;
>
> The goto above will result in: return ERR_PTR(ret)
> But ret is 0 here. Should it be set to a negative error value?
>
> Also flagged by Smatch.
OK, will get an
ret = -ENOMEM;
>
> > +
> > + INIT_WORK(&ldev->tx_work, lin_tx_work_handler);
> > +
> > + netdev_info(ndev, "LIN initialized.\n");
> > +
> > + return ldev;
> > +
> > +exit_rm_files:
> > + lin_remove_sysfs_id_files(ndev);
> > +exit_kobj_put:
> > + kobject_put(ldev->lin_ids_kobj);
> > +exit_unreg:
> > + unregister_candev(ndev);
> > +exit_candev:
> > + free_candev(ndev);
> > + return ERR_PTR(ret);
> > +}
> > +EXPORT_SYMBOL_GPL(register_lin);
>
> ...
Thanks
-- Christoph
^ permalink raw reply
* Re: [PATCH v2 02/12] HID: hexLIN: Add support for USB LIN bus adapter
From: Christoph Fritz @ 2024-05-08 8:37 UTC (permalink / raw)
To: Simon Horman
Cc: Oliver Hartkopp, Marc Kleine-Budde, Vincent Mailhol,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jiri Kosina,
Benjamin Tissoires, Greg Kroah-Hartman, Jiri Slaby,
Sebastian Reichel, Linus Walleij, Andreas Lauser, Jonathan Corbet,
Pavel Pisa, linux-can, netdev, devicetree, linux-input,
linux-serial
In-Reply-To: <20240504125828.GK3167983@kernel.org>
On Sat, 2024-05-04 at 13:58 +0100, Simon Horman wrote:
> On Thu, May 02, 2024 at 09:55:24AM +0200, Christoph Fritz wrote:
> > This patch introduces driver support for the hexLIN USB LIN bus adapter,
> > enabling LIN communication over USB for both controller and responder
> > modes. The driver interfaces with the CAN_LIN framework for userland
> > connectivity.
> >
> > For more details on the adapter, visit: https://hexdev.de/hexlin/
> >
> > Tested-by: Andreas Lauser <andreas.lauser@mercedes-benz.com>
> > Signed-off-by: Christoph Fritz <christoph.fritz@hexdev.de>
>
> Hi Christoph,
>
> Some minor feedback from my side.
>
> ...
>
> > diff --git a/drivers/hid/hid-hexdev-hexlin.c b/drivers/hid/hid-hexdev-hexlin.c
>
> ...
>
> > +static int hexlin_queue_frames_insert(struct hexlin_priv_data *priv,
> > + const u8 *raw_data, int sz)
> > +{
> > + struct hid_device *hdev = priv->hid_dev;
> > + struct hexlin_frame hxf;
> > + struct lin_frame lf;
> > +
> > + if (sz != sizeof(struct hexlin_frame))
> > + return -EREMOTEIO;
> > +
> > + memcpy(&hxf, raw_data, sz);
> > + le32_to_cpus(hxf.flags);
> > +
> > + lf.len = hxf.len;
> > + lf.lin_id = hxf.lin_id;
> > + memcpy(lf.data, hxf.data, LIN_MAX_DLEN);
> > + lf.checksum = hxf.checksum;
> > + lf.checksum_mode = hxf.checksum_mode;
> > +
> > + hid_dbg(hdev, "id:%02x, len:%u, data:%*ph, checksum:%02x (%s)\n",
> > + lf.lin_id, lf.len, lf.len, lf.data, lf.checksum,
> > + lf.checksum_mode ? "enhanced" : "classic");
>
> nit: The indentation above is not quite right.
> It should align to inside the opening '(' like this.
>
> hid_dbg(hdev, "id:%02x, len:%u, data:%*ph, checksum:%02x (%s)\n",
> lf.lin_id, lf.len, lf.len, lf.data, lf.checksum,
> lf.checksum_mode ? "enhanced" : "classic");
>
> Flagged by checkpatch.
OK
>
> ...
>
> > +static int hexlin_set_baudrate(struct hexlin_priv_data *priv, u16 baudrate)
> > +{
> > + struct hexlin_baudrate_req req;
> > + int ret;
> > +
> > + if (baudrate < LIN_MIN_BAUDRATE || baudrate > LIN_MAX_BAUDRATE)
> > + return -EINVAL;
> > +
> > + req.cmd = HEXLIN_SET_BAUDRATE;
> > + req.baudrate = cpu_to_le16(baudrate);
>
> The type of req.baudrate is u16, a host byte-order type.
> But it is being assigned a little endian value.
> This does not seem right.
>
> Flagged by Smatch.
In upcoming v4 I'll use __le16
>
> > +
> > + ret = hexlin_tx_req_status(priv, &req,
> > + sizeof(struct hexlin_baudrate_req));
> > + if (ret)
> > + hid_err(priv->hid_dev, "%s failed with %d\n", __func__, ret);
> > +
> > + return ret;
> > +}
>
> ...
>
> > +static int hexlin_probe(struct hid_device *hdev,
> > + const struct hid_device_id *id)
> > +{
> > + struct hexlin_priv_data *priv;
> > + int ret;
> > +
> > + priv = devm_kzalloc(&hdev->dev, sizeof(*priv), GFP_KERNEL);
> > + if (!priv)
> > + return -ENOMEM;
> > +
> > + priv->hid_dev = hdev;
> > + hid_set_drvdata(hdev, priv);
> > +
> > + mutex_init(&priv->tx_lock);
> > +
> > + ret = hid_parse(hdev);
> > + if (ret) {
> > + hid_err(hdev, "hid parse failed with %d\n", ret);
> > + goto fail_and_free;
> > + }
> > +
> > + ret = hid_hw_start(hdev, HID_CONNECT_DRIVER);
> > + if (ret) {
> > + hid_err(hdev, "hid hw start failed with %d\n", ret);
> > + goto fail_and_stop;
> > + }
> > +
> > + ret = hid_hw_open(hdev);
> > + if (ret) {
> > + hid_err(hdev, "hid hw open failed with %d\n", ret);
> > + goto fail_and_close;
> > + }
> > +
> > + init_completion(&priv->wait_in_report);
> > +
> > + hid_device_io_start(hdev);
> > +
> > + ret = init_hw(priv);
> > + if (ret)
> > + goto fail_and_close;
> > +
> > + priv->ldev = register_lin(&hdev->dev, &hexlin_ldo);
> > + if (IS_ERR_OR_NULL(priv->ldev)) {
> > + ret = PTR_ERR(priv->ldev);
> > + goto fail_and_close;
>
> Is it intentional that when priv->ldev is NULL here,
> the function will return 0?
>
> Flagged by Smatch.
IS_ERR_OR_NULL() gets IS_ERR() in upcoming v4
>
> > + }
> > +
> > + hid_hw_close(hdev);
> > +
> > + hid_info(hdev, "hexLIN (fw-version: %u) probed\n", priv->fw_version);
> > +
> > + return 0;
> > +
> > +fail_and_close:
> > + hid_hw_close(hdev);
> > +fail_and_stop:
> > + hid_hw_stop(hdev);
> > +fail_and_free:
> > + mutex_destroy(&priv->tx_lock);
> > + return ret;
> > +}
>
> ...
Thanks
-- Christoph
^ permalink raw reply
* Re: [PATCH v2 5/5] selftests: Drop duplicate -D_GNU_SOURCE
From: Muhammad Usama Anjum @ 2024-05-08 7:58 UTC (permalink / raw)
To: Edward Liaw, shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Catalin Marinas, Will Deacon, Nhat Pham, Johannes Weiner,
Christian Brauner, Eric Biederman, Kees Cook, OGAWA Hirofumi,
Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
Davidlohr Bueso, André Almeida, Jiri Kosina,
Benjamin Tissoires, Jason Gunthorpe, Kevin Tian, Andy Lutomirski,
Will Drewry, Marc Zyngier, Oliver Upton, James Morse,
Suzuki K Poulose, Zenghui Yu, Paolo Bonzini, Sean Christopherson,
Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen
Cc: Muhammad Usama Anjum, linux-kernel, linux-kselftest, kernel-team,
linux-sound, linux-arm-kernel, linux-mm, linux-input, iommu,
kvmarm, kvm, kvm-riscv, linux-riscv, linux-security-module,
linux-fsdevel, netdev, linux-actions, mptcp, linux-rtc, linux-sgx,
bpf
In-Reply-To: <20240507214254.2787305-6-edliaw@google.com>
On 5/8/24 2:38 AM, Edward Liaw wrote:
> -D_GNU_SOURCE can be de-duplicated here, as it is added by
> KHDR_INCLUDES.
>
> Signed-off-by: Edward Liaw <edliaw@google.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> tools/testing/selftests/futex/functional/Makefile | 2 +-
> tools/testing/selftests/iommu/Makefile | 2 --
> tools/testing/selftests/net/tcp_ao/Makefile | 2 +-
> tools/testing/selftests/resctrl/Makefile | 2 +-
> 4 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
> index a392d0917b4e..f79f9bac7918 100644
> --- a/tools/testing/selftests/futex/functional/Makefile
> +++ b/tools/testing/selftests/futex/functional/Makefile
> @@ -1,6 +1,6 @@
> # SPDX-License-Identifier: GPL-2.0
> INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
> -CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) $(KHDR_INCLUDES)
> +CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES)
> LDLIBS := -lpthread -lrt
>
> LOCAL_HDRS := \
> diff --git a/tools/testing/selftests/iommu/Makefile b/tools/testing/selftests/iommu/Makefile
> index 32c5fdfd0eef..fd6477911f24 100644
> --- a/tools/testing/selftests/iommu/Makefile
> +++ b/tools/testing/selftests/iommu/Makefile
> @@ -2,8 +2,6 @@
> CFLAGS += -Wall -O2 -Wno-unused-function
> CFLAGS += $(KHDR_INCLUDES)
>
> -CFLAGS += -D_GNU_SOURCE
> -
> TEST_GEN_PROGS :=
> TEST_GEN_PROGS += iommufd
> TEST_GEN_PROGS += iommufd_fail_nth
> diff --git a/tools/testing/selftests/net/tcp_ao/Makefile b/tools/testing/selftests/net/tcp_ao/Makefile
> index 522d991e310e..c608b1ec02e6 100644
> --- a/tools/testing/selftests/net/tcp_ao/Makefile
> +++ b/tools/testing/selftests/net/tcp_ao/Makefile
> @@ -26,7 +26,7 @@ LIB := $(LIBDIR)/libaotst.a
> LDLIBS += $(LIB) -pthread
> LIBDEPS := lib/aolib.h Makefile
>
> -CFLAGS := -Wall -O2 -g -D_GNU_SOURCE -fno-strict-aliasing
> +CFLAGS := -Wall -O2 -g -fno-strict-aliasing
> CFLAGS += $(KHDR_INCLUDES)
> CFLAGS += -iquote ./lib/ -I ../../../../include/
>
> diff --git a/tools/testing/selftests/resctrl/Makefile b/tools/testing/selftests/resctrl/Makefile
> index 2deac2031de9..5073dbc96125 100644
> --- a/tools/testing/selftests/resctrl/Makefile
> +++ b/tools/testing/selftests/resctrl/Makefile
> @@ -1,6 +1,6 @@
> # SPDX-License-Identifier: GPL-2.0
>
> -CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
> +CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2
> CFLAGS += $(KHDR_INCLUDES)
>
> TEST_GEN_PROGS := resctrl_tests
--
BR,
Muhammad Usama Anjum
^ permalink raw reply
* Re: [PATCH v2 3/5] selftests: Include KHDR_INCLUDES in Makefile
From: Muhammad Usama Anjum @ 2024-05-08 7:49 UTC (permalink / raw)
To: Edward Liaw, shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Catalin Marinas, Will Deacon, Nhat Pham, Johannes Weiner,
Christian Brauner, Eric Biederman, Kees Cook, OGAWA Hirofumi,
Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
Davidlohr Bueso, André Almeida, Jiri Kosina,
Benjamin Tissoires, Jason Gunthorpe, Kevin Tian, Andy Lutomirski,
Will Drewry, Marc Zyngier, Oliver Upton, James Morse,
Suzuki K Poulose, Zenghui Yu, Paolo Bonzini, Sean Christopherson,
Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen
Cc: Muhammad Usama Anjum, linux-kernel, linux-kselftest, kernel-team,
linux-sound, linux-arm-kernel, linux-mm, linux-input, iommu,
kvmarm, kvm, kvm-riscv, linux-riscv, linux-security-module,
linux-fsdevel, netdev, linux-actions, mptcp, linux-rtc, linux-sgx,
bpf
In-Reply-To: <20240507214254.2787305-4-edliaw@google.com>
On 5/8/24 2:38 AM, Edward Liaw wrote:
> Add KHDR_INCLUDES to CFLAGS to pull in the kselftest harness
> dependencies (-D_GNU_SOURCE).
>
> Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
> Signed-off-by: Edward Liaw <edliaw@google.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> tools/testing/selftests/alsa/Makefile | 2 +-
> tools/testing/selftests/arm64/signal/Makefile | 2 +-
> tools/testing/selftests/exec/Makefile | 2 +-
> tools/testing/selftests/filesystems/overlayfs/Makefile | 2 +-
> tools/testing/selftests/hid/Makefile | 2 +-
> tools/testing/selftests/nci/Makefile | 2 +-
> tools/testing/selftests/prctl/Makefile | 2 ++
> tools/testing/selftests/proc/Makefile | 2 +-
> tools/testing/selftests/riscv/mm/Makefile | 2 +-
> tools/testing/selftests/rtc/Makefile | 2 +-
> tools/testing/selftests/tmpfs/Makefile | 2 +-
> 11 files changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/tools/testing/selftests/alsa/Makefile b/tools/testing/selftests/alsa/Makefile
> index 5af9ba8a4645..9a0ef194522c 100644
> --- a/tools/testing/selftests/alsa/Makefile
> +++ b/tools/testing/selftests/alsa/Makefile
> @@ -6,7 +6,7 @@ LDLIBS += $(shell pkg-config --libs alsa)
> ifeq ($(LDLIBS),)
> LDLIBS += -lasound
> endif
> -CFLAGS += -L$(OUTPUT) -Wl,-rpath=./
> +CFLAGS += $(KHDR_INCLUDES) -L$(OUTPUT) -Wl,-rpath=./
>
> LDLIBS+=-lpthread
>
> diff --git a/tools/testing/selftests/arm64/signal/Makefile b/tools/testing/selftests/arm64/signal/Makefile
> index 8f5febaf1a9a..ae682ade615d 100644
> --- a/tools/testing/selftests/arm64/signal/Makefile
> +++ b/tools/testing/selftests/arm64/signal/Makefile
> @@ -2,7 +2,7 @@
> # Copyright (C) 2019 ARM Limited
>
> # Additional include paths needed by kselftest.h and local headers
> -CFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
> +CFLAGS += $(KHDR_INCLUDES) -std=gnu99 -I.
>
> SRCS := $(filter-out testcases/testcases.c,$(wildcard testcases/*.c))
> PROGS := $(patsubst %.c,%,$(SRCS))
> diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
> index fb4472ddffd8..15e78ec7c55e 100644
> --- a/tools/testing/selftests/exec/Makefile
> +++ b/tools/testing/selftests/exec/Makefile
> @@ -1,7 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0
> CFLAGS = -Wall
> CFLAGS += -Wno-nonnull
> -CFLAGS += -D_GNU_SOURCE
> +CFLAGS += $(KHDR_INCLUDES)
>
> TEST_PROGS := binfmt_script.py
> TEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 load_address_16777216 non-regular
> diff --git a/tools/testing/selftests/filesystems/overlayfs/Makefile b/tools/testing/selftests/filesystems/overlayfs/Makefile
> index 56b2b48a765b..6c29c963c7a8 100644
> --- a/tools/testing/selftests/filesystems/overlayfs/Makefile
> +++ b/tools/testing/selftests/filesystems/overlayfs/Makefile
> @@ -2,6 +2,6 @@
>
> TEST_GEN_PROGS := dev_in_maps
>
> -CFLAGS := -Wall -Werror
> +CFLAGS := -Wall -Werror $(KHDR_INCLUDES)
>
> include ../../lib.mk
> diff --git a/tools/testing/selftests/hid/Makefile b/tools/testing/selftests/hid/Makefile
> index 2b5ea18bde38..0661b34488ef 100644
> --- a/tools/testing/selftests/hid/Makefile
> +++ b/tools/testing/selftests/hid/Makefile
> @@ -21,7 +21,7 @@ CXX ?= $(CROSS_COMPILE)g++
>
> HOSTPKG_CONFIG := pkg-config
>
> -CFLAGS += -g -O0 -rdynamic -Wall -Werror -I$(OUTPUT)
> +CFLAGS += -g -O0 -rdynamic -Wall -Werror $(KHDR_INCLUDES) -I$(OUTPUT)
> CFLAGS += -I$(OUTPUT)/tools/include
>
> LDLIBS += -lelf -lz -lrt -lpthread
> diff --git a/tools/testing/selftests/nci/Makefile b/tools/testing/selftests/nci/Makefile
> index 47669a1d6a59..bbc5b8ec3b17 100644
> --- a/tools/testing/selftests/nci/Makefile
> +++ b/tools/testing/selftests/nci/Makefile
> @@ -1,5 +1,5 @@
> # SPDX-License-Identifier: GPL-2.0
> -CFLAGS += -Wl,-no-as-needed -Wall
> +CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
> LDFLAGS += -lpthread
>
> TEST_GEN_PROGS := nci_dev
> diff --git a/tools/testing/selftests/prctl/Makefile b/tools/testing/selftests/prctl/Makefile
> index 01dc90fbb509..1a0aefec9d6f 100644
> --- a/tools/testing/selftests/prctl/Makefile
> +++ b/tools/testing/selftests/prctl/Makefile
> @@ -6,6 +6,8 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
> ifeq ($(ARCH),x86)
> TEST_PROGS := disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test \
> disable-tsc-test set-anon-vma-name-test set-process-name
> +
> +CFLAGS += $(KHDR_INCLUDES)
> all: $(TEST_PROGS)
>
> include ../lib.mk
> diff --git a/tools/testing/selftests/proc/Makefile b/tools/testing/selftests/proc/Makefile
> index cd95369254c0..9596014c10a0 100644
> --- a/tools/testing/selftests/proc/Makefile
> +++ b/tools/testing/selftests/proc/Makefile
> @@ -1,6 +1,6 @@
> # SPDX-License-Identifier: GPL-2.0-only
> CFLAGS += -Wall -O2 -Wno-unused-function
> -CFLAGS += -D_GNU_SOURCE
> +CFLAGS += $(KHDR_INCLUDES)
> LDFLAGS += -pthread
>
> TEST_GEN_PROGS :=
> diff --git a/tools/testing/selftests/riscv/mm/Makefile b/tools/testing/selftests/riscv/mm/Makefile
> index c333263f2b27..715a21241113 100644
> --- a/tools/testing/selftests/riscv/mm/Makefile
> +++ b/tools/testing/selftests/riscv/mm/Makefile
> @@ -3,7 +3,7 @@
> # Originally tools/testing/arm64/abi/Makefile
>
> # Additional include paths needed by kselftest.h and local headers
> -CFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
> +CFLAGS += $(KHDR_INCLUDES) -std=gnu99 -I.
>
> TEST_GEN_FILES := mmap_default mmap_bottomup
>
> diff --git a/tools/testing/selftests/rtc/Makefile b/tools/testing/selftests/rtc/Makefile
> index 55198ecc04db..654f9d58da3c 100644
> --- a/tools/testing/selftests/rtc/Makefile
> +++ b/tools/testing/selftests/rtc/Makefile
> @@ -1,5 +1,5 @@
> # SPDX-License-Identifier: GPL-2.0
> -CFLAGS += -O3 -Wl,-no-as-needed -Wall
> +CFLAGS += -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
> LDLIBS += -lrt -lpthread -lm
>
> TEST_GEN_PROGS = rtctest
> diff --git a/tools/testing/selftests/tmpfs/Makefile b/tools/testing/selftests/tmpfs/Makefile
> index aa11ccc92e5b..bcdc1bb6d2e6 100644
> --- a/tools/testing/selftests/tmpfs/Makefile
> +++ b/tools/testing/selftests/tmpfs/Makefile
> @@ -1,6 +1,6 @@
> # SPDX-License-Identifier: GPL-2.0-only
> CFLAGS += -Wall -O2
> -CFLAGS += -D_GNU_SOURCE
> +CFLAGS += $(KHDR_INCLUDES)
>
> TEST_GEN_PROGS :=
> TEST_GEN_PROGS += bug-link-o-tmpfile
--
BR,
Muhammad Usama Anjum
^ permalink raw reply
* Re: [PATCH v2 4/5] selftests: Drop define _GNU_SOURCE
From: Muhammad Usama Anjum @ 2024-05-08 7:50 UTC (permalink / raw)
To: Edward Liaw, shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Catalin Marinas, Will Deacon, Nhat Pham, Johannes Weiner,
Christian Brauner, Eric Biederman, Kees Cook, OGAWA Hirofumi,
Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
Davidlohr Bueso, André Almeida, Jiri Kosina,
Benjamin Tissoires, Jason Gunthorpe, Kevin Tian, Andy Lutomirski,
Will Drewry, Marc Zyngier, Oliver Upton, James Morse,
Suzuki K Poulose, Zenghui Yu, Paolo Bonzini, Sean Christopherson,
Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen
Cc: Muhammad Usama Anjum, linux-kernel, linux-kselftest, kernel-team,
linux-sound, linux-arm-kernel, linux-mm, linux-input, iommu,
kvmarm, kvm, kvm-riscv, linux-riscv, linux-security-module,
linux-fsdevel, netdev, linux-actions, mptcp, linux-rtc, linux-sgx,
bpf
In-Reply-To: <20240507214254.2787305-5-edliaw@google.com>
On 5/8/24 2:38 AM, Edward Liaw wrote:
> _GNU_SOURCE is provided by KHDR_INCLUDES, so it should be dropped to
> prevent _GNU_SOURCE redefined warnings.
>
> Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
> Signed-off-by: Edward Liaw <edliaw@google.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> tools/testing/selftests/cachestat/test_cachestat.c | 2 --
> tools/testing/selftests/capabilities/test_execve.c | 2 --
> tools/testing/selftests/clone3/clone3.c | 2 --
> .../testing/selftests/clone3/clone3_cap_checkpoint_restore.c | 2 --
> tools/testing/selftests/clone3/clone3_clear_sighand.c | 2 --
> tools/testing/selftests/clone3/clone3_selftests.h | 1 -
> tools/testing/selftests/clone3/clone3_set_tid.c | 2 --
> tools/testing/selftests/core/close_range_test.c | 2 --
> tools/testing/selftests/drivers/dma-buf/udmabuf.c | 1 -
> tools/testing/selftests/fchmodat2/fchmodat2_test.c | 2 --
> tools/testing/selftests/filesystems/binderfs/binderfs_test.c | 2 --
> tools/testing/selftests/filesystems/devpts_pts.c | 1 -
> tools/testing/selftests/filesystems/dnotify_test.c | 1 -
> tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c | 2 --
> tools/testing/selftests/filesystems/eventfd/eventfd_test.c | 2 --
> tools/testing/selftests/filesystems/fat/rename_exchange.c | 2 --
> tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 --
> .../testing/selftests/filesystems/statmount/statmount_test.c | 3 ---
> tools/testing/selftests/futex/functional/futex_requeue_pi.c | 3 ---
> tools/testing/selftests/ipc/msgque.c | 1 -
> tools/testing/selftests/kcmp/kcmp_test.c | 2 --
> tools/testing/selftests/kvm/aarch64/arch_timer.c | 2 --
> tools/testing/selftests/kvm/aarch64/page_fault_test.c | 1 -
> tools/testing/selftests/kvm/aarch64/psci_test.c | 3 ---
> tools/testing/selftests/kvm/aarch64/vgic_init.c | 1 -
> tools/testing/selftests/kvm/arch_timer.c | 3 ---
> tools/testing/selftests/kvm/demand_paging_test.c | 3 ---
> tools/testing/selftests/kvm/dirty_log_test.c | 3 ---
> tools/testing/selftests/kvm/guest_memfd_test.c | 2 --
> tools/testing/selftests/kvm/hardware_disable_test.c | 3 ---
> tools/testing/selftests/kvm/include/userfaultfd_util.h | 3 ---
> tools/testing/selftests/kvm/kvm_binary_stats_test.c | 2 --
> tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 2 --
> tools/testing/selftests/kvm/kvm_page_table_test.c | 3 ---
> tools/testing/selftests/kvm/lib/assert.c | 3 ---
> tools/testing/selftests/kvm/lib/kvm_util.c | 2 --
> tools/testing/selftests/kvm/lib/memstress.c | 2 --
> tools/testing/selftests/kvm/lib/test_util.c | 2 --
> tools/testing/selftests/kvm/lib/userfaultfd_util.c | 3 ---
> tools/testing/selftests/kvm/lib/x86_64/sev.c | 1 -
> tools/testing/selftests/kvm/max_guest_memory_test.c | 2 --
> .../testing/selftests/kvm/memslot_modification_stress_test.c | 3 ---
> tools/testing/selftests/kvm/riscv/arch_timer.c | 3 ---
> tools/testing/selftests/kvm/rseq_test.c | 1 -
> tools/testing/selftests/kvm/s390x/cmma_test.c | 2 --
> tools/testing/selftests/kvm/s390x/sync_regs_test.c | 2 --
> tools/testing/selftests/kvm/set_memory_region_test.c | 1 -
> tools/testing/selftests/kvm/steal_time.c | 1 -
> tools/testing/selftests/kvm/x86_64/amx_test.c | 2 --
> .../selftests/kvm/x86_64/exit_on_emulation_failure_test.c | 3 ---
> tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c | 2 --
> tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 2 --
> tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c | 1 -
> tools/testing/selftests/kvm/x86_64/hyperv_ipi.c | 2 --
> tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c | 1 -
> tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c | 2 --
> tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c | 2 --
> tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 3 ---
> tools/testing/selftests/kvm/x86_64/platform_info_test.c | 2 --
> tools/testing/selftests/kvm/x86_64/pmu_counters_test.c | 2 --
> tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c | 3 ---
> .../selftests/kvm/x86_64/private_mem_conversions_test.c | 1 -
> tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c | 1 -
> tools/testing/selftests/kvm/x86_64/set_sregs_test.c | 1 -
> .../selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c | 3 ---
> tools/testing/selftests/kvm/x86_64/smm_test.c | 1 -
> tools/testing/selftests/kvm/x86_64/state_test.c | 1 -
> tools/testing/selftests/kvm/x86_64/sync_regs_test.c | 2 --
> tools/testing/selftests/kvm/x86_64/ucna_injection_test.c | 2 --
> tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c | 2 --
> tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c | 3 ---
> tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c | 1 -
> .../testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c | 1 -
> tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c | 2 --
> tools/testing/selftests/kvm/x86_64/xapic_state_test.c | 1 -
> tools/testing/selftests/kvm/x86_64/xss_msr_test.c | 2 --
> tools/testing/selftests/landlock/base_test.c | 2 --
> tools/testing/selftests/landlock/fs_test.c | 2 --
> tools/testing/selftests/landlock/net_test.c | 2 --
> tools/testing/selftests/landlock/ptrace_test.c | 2 --
> tools/testing/selftests/lsm/common.c | 2 --
> tools/testing/selftests/lsm/lsm_get_self_attr_test.c | 2 --
> tools/testing/selftests/lsm/lsm_list_modules_test.c | 2 --
> tools/testing/selftests/lsm/lsm_set_self_attr_test.c | 2 --
> tools/testing/selftests/membarrier/membarrier_test_impl.h | 1 -
> .../selftests/membarrier/membarrier_test_multi_thread.c | 1 -
> .../selftests/membarrier/membarrier_test_single_thread.c | 1 -
> tools/testing/selftests/memfd/common.c | 1 -
> tools/testing/selftests/memfd/fuse_test.c | 2 --
> tools/testing/selftests/memfd/memfd_test.c | 1 -
> tools/testing/selftests/mm/cow.c | 1 -
> tools/testing/selftests/mm/gup_longterm.c | 1 -
> tools/testing/selftests/mm/hugepage-mmap.c | 1 -
> tools/testing/selftests/mm/hugepage-mremap.c | 2 --
> tools/testing/selftests/mm/hugetlb-madvise.c | 2 --
> tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 2 --
> tools/testing/selftests/mm/khugepaged.c | 1 -
> tools/testing/selftests/mm/ksm_functional_tests.c | 1 -
> tools/testing/selftests/mm/madv_populate.c | 1 -
> tools/testing/selftests/mm/map_populate.c | 2 --
> tools/testing/selftests/mm/mdwe_test.c | 1 -
> tools/testing/selftests/mm/memfd_secret.c | 2 --
> tools/testing/selftests/mm/mlock2-tests.c | 1 -
> tools/testing/selftests/mm/mrelease_test.c | 1 -
> tools/testing/selftests/mm/mremap_dontunmap.c | 1 -
> tools/testing/selftests/mm/mremap_test.c | 2 --
> tools/testing/selftests/mm/pagemap_ioctl.c | 1 -
> tools/testing/selftests/mm/pkey-helpers.h | 1 -
> tools/testing/selftests/mm/protection_keys.c | 1 -
> tools/testing/selftests/mm/split_huge_page_test.c | 2 --
> tools/testing/selftests/mm/thuge-gen.c | 2 --
> tools/testing/selftests/mm/uffd-common.h | 1 -
> tools/testing/selftests/mount_setattr/mount_setattr_test.c | 1 -
> .../move_mount_set_group/move_mount_set_group_test.c | 1 -
> tools/testing/selftests/net/af_unix/diag_uid.c | 2 --
> tools/testing/selftests/net/af_unix/scm_pidfd.c | 1 -
> tools/testing/selftests/net/af_unix/unix_connect.c | 2 --
> tools/testing/selftests/net/csum.c | 3 ---
> tools/testing/selftests/net/gro.c | 3 ---
> tools/testing/selftests/net/ip_defrag.c | 3 ---
> tools/testing/selftests/net/ipsec.c | 3 ---
> tools/testing/selftests/net/ipv6_flowlabel.c | 3 ---
> tools/testing/selftests/net/ipv6_flowlabel_mgr.c | 3 ---
> tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 ---
> tools/testing/selftests/net/mptcp/mptcp_inq.c | 3 ---
> tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 3 ---
> tools/testing/selftests/net/msg_zerocopy.c | 3 ---
> tools/testing/selftests/net/nettest.c | 2 --
> tools/testing/selftests/net/psock_fanout.c | 3 ---
> tools/testing/selftests/net/psock_snd.c | 3 ---
> tools/testing/selftests/net/reuseport_addr_any.c | 3 ---
> tools/testing/selftests/net/reuseport_bpf_cpu.c | 3 ---
> tools/testing/selftests/net/reuseport_bpf_numa.c | 3 ---
> tools/testing/selftests/net/reuseport_dualstack.c | 3 ---
> tools/testing/selftests/net/so_incoming_cpu.c | 1 -
> tools/testing/selftests/net/so_netns_cookie.c | 1 -
> tools/testing/selftests/net/so_txtime.c | 3 ---
> tools/testing/selftests/net/tap.c | 3 ---
> tools/testing/selftests/net/tcp_fastopen_backup_key.c | 1 -
> tools/testing/selftests/net/tcp_inq.c | 2 --
> tools/testing/selftests/net/tcp_mmap.c | 1 -
> tools/testing/selftests/net/tls.c | 3 ---
> tools/testing/selftests/net/toeplitz.c | 3 ---
> tools/testing/selftests/net/tun.c | 3 ---
> tools/testing/selftests/net/txring_overwrite.c | 3 ---
> tools/testing/selftests/net/txtimestamp.c | 3 ---
> tools/testing/selftests/net/udpgso.c | 3 ---
> tools/testing/selftests/net/udpgso_bench_rx.c | 3 ---
> tools/testing/selftests/net/udpgso_bench_tx.c | 3 ---
> tools/testing/selftests/perf_events/remove_on_exec.c | 2 --
> tools/testing/selftests/perf_events/sigtrap_threads.c | 2 --
> tools/testing/selftests/pid_namespace/regression_enomem.c | 1 -
> tools/testing/selftests/pidfd/pidfd.h | 1 -
> tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 2 --
> tools/testing/selftests/pidfd/pidfd_getfd_test.c | 2 --
> tools/testing/selftests/pidfd/pidfd_open_test.c | 2 --
> tools/testing/selftests/pidfd/pidfd_poll_test.c | 2 --
> tools/testing/selftests/pidfd/pidfd_setns_test.c | 2 --
> tools/testing/selftests/pidfd/pidfd_test.c | 2 --
> tools/testing/selftests/pidfd/pidfd_wait.c | 2 --
> tools/testing/selftests/ptrace/get_set_sud.c | 1 -
> tools/testing/selftests/ptrace/peeksiginfo.c | 1 -
> tools/testing/selftests/rseq/basic_percpu_ops_test.c | 1 -
> tools/testing/selftests/rseq/basic_test.c | 2 --
> tools/testing/selftests/rseq/param_test.c | 1 -
> tools/testing/selftests/rseq/rseq.c | 2 --
> tools/testing/selftests/seccomp/seccomp_benchmark.c | 1 -
> tools/testing/selftests/seccomp/seccomp_bpf.c | 2 --
> tools/testing/selftests/user_events/abi_test.c | 2 --
> tools/testing/selftests/x86/amx.c | 2 --
> tools/testing/selftests/x86/check_initial_reg_state.c | 3 ---
> tools/testing/selftests/x86/corrupt_xstate_header.c | 3 ---
> tools/testing/selftests/x86/entry_from_vm86.c | 3 ---
> tools/testing/selftests/x86/fsgsbase.c | 2 --
> tools/testing/selftests/x86/fsgsbase_restore.c | 2 --
> tools/testing/selftests/x86/ioperm.c | 2 --
> tools/testing/selftests/x86/iopl.c | 2 --
> tools/testing/selftests/x86/lam.c | 1 -
> tools/testing/selftests/x86/ldt_gdt.c | 2 --
> tools/testing/selftests/x86/mov_ss_trap.c | 2 --
> tools/testing/selftests/x86/nx_stack.c | 2 --
> tools/testing/selftests/x86/ptrace_syscall.c | 2 --
> tools/testing/selftests/x86/sigaltstack.c | 2 --
> tools/testing/selftests/x86/sigreturn.c | 3 ---
> tools/testing/selftests/x86/single_step_syscall.c | 3 ---
> tools/testing/selftests/x86/syscall_arg_fault.c | 3 ---
> tools/testing/selftests/x86/syscall_numbering.c | 3 ---
> tools/testing/selftests/x86/sysret_rip.c | 3 ---
> tools/testing/selftests/x86/sysret_ss_attrs.c | 3 ---
> tools/testing/selftests/x86/test_FCMOV.c | 4 ----
> tools/testing/selftests/x86/test_FCOMI.c | 4 ----
> tools/testing/selftests/x86/test_FISTTP.c | 4 ----
> tools/testing/selftests/x86/test_mremap_vdso.c | 1 -
> tools/testing/selftests/x86/test_shadow_stack.c | 3 ---
> tools/testing/selftests/x86/test_syscall_vdso.c | 4 ----
> tools/testing/selftests/x86/test_vsyscall.c | 3 ---
> tools/testing/selftests/x86/unwind_vdso.c | 3 ---
> tools/testing/selftests/x86/vdso_restorer.c | 3 ---
> 198 files changed, 405 deletions(-)
>
> diff --git a/tools/testing/selftests/cachestat/test_cachestat.c b/tools/testing/selftests/cachestat/test_cachestat.c
> index b171fd53b004..c1a6ce7b0912 100644
> --- a/tools/testing/selftests/cachestat/test_cachestat.c
> +++ b/tools/testing/selftests/cachestat/test_cachestat.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> -
> #include <stdio.h>
> #include <stdbool.h>
> #include <linux/kernel.h>
> diff --git a/tools/testing/selftests/capabilities/test_execve.c b/tools/testing/selftests/capabilities/test_execve.c
> index 7cde07a5df78..e3954b88c3ee 100644
> --- a/tools/testing/selftests/capabilities/test_execve.c
> +++ b/tools/testing/selftests/capabilities/test_execve.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> -
> #include <cap-ng.h>
> #include <linux/capability.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
> index 3c9bf0cd82a8..3c5e45dae617 100644
> --- a/tools/testing/selftests/clone3/clone3.c
> +++ b/tools/testing/selftests/clone3/clone3.c
> @@ -1,8 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0
>
> /* Based on Christian Brauner's clone3() example */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <inttypes.h>
> #include <linux/types.h>
> diff --git a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
> index 31b56d625655..bb99ea20f7d5 100644
> --- a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
> +++ b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
> @@ -7,8 +7,6 @@
> */
>
> /* capabilities related code based on selftests/bpf/test_verifier.c */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <linux/types.h>
> #include <linux/sched.h>
> diff --git a/tools/testing/selftests/clone3/clone3_clear_sighand.c b/tools/testing/selftests/clone3/clone3_clear_sighand.c
> index 54a8b2445be9..50336d56db6b 100644
> --- a/tools/testing/selftests/clone3/clone3_clear_sighand.c
> +++ b/tools/testing/selftests/clone3/clone3_clear_sighand.c
> @@ -1,6 +1,4 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <sched.h>
> #include <signal.h>
> diff --git a/tools/testing/selftests/clone3/clone3_selftests.h b/tools/testing/selftests/clone3/clone3_selftests.h
> index 3d2663fe50ba..172e19d5515f 100644
> --- a/tools/testing/selftests/clone3/clone3_selftests.h
> +++ b/tools/testing/selftests/clone3/clone3_selftests.h
> @@ -3,7 +3,6 @@
> #ifndef _CLONE3_SELFTESTS_H
> #define _CLONE3_SELFTESTS_H
>
> -#define _GNU_SOURCE
> #include <sched.h>
> #include <linux/sched.h>
> #include <linux/types.h>
> diff --git a/tools/testing/selftests/clone3/clone3_set_tid.c b/tools/testing/selftests/clone3/clone3_set_tid.c
> index ed785afb6077..8b5ed4484ee6 100644
> --- a/tools/testing/selftests/clone3/clone3_set_tid.c
> +++ b/tools/testing/selftests/clone3/clone3_set_tid.c
> @@ -5,8 +5,6 @@
> * These tests are assuming to be running in the host's
> * PID namespace.
> */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <linux/types.h>
> #include <linux/sched.h>
> diff --git a/tools/testing/selftests/core/close_range_test.c b/tools/testing/selftests/core/close_range_test.c
> index c59e4adb905d..1c2902bcc913 100644
> --- a/tools/testing/selftests/core/close_range_test.c
> +++ b/tools/testing/selftests/core/close_range_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <linux/kernel.h>
> diff --git a/tools/testing/selftests/drivers/dma-buf/udmabuf.c b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
> index c812080e304e..7c8dbab8ac44 100644
> --- a/tools/testing/selftests/drivers/dma-buf/udmabuf.c
> +++ b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #define __EXPORTED_HEADERS__
>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/fchmodat2/fchmodat2_test.c b/tools/testing/selftests/fchmodat2/fchmodat2_test.c
> index e0319417124d..6b411859c2cd 100644
> --- a/tools/testing/selftests/fchmodat2/fchmodat2_test.c
> +++ b/tools/testing/selftests/fchmodat2/fchmodat2_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0-or-later
> -
> -#define _GNU_SOURCE
> #include <fcntl.h>
> #include <sys/stat.h>
> #include <sys/types.h>
> diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
> index 5f362c0fd890..fca693db1b09 100644
> --- a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
> +++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/filesystems/devpts_pts.c b/tools/testing/selftests/filesystems/devpts_pts.c
> index b1fc9b916ace..73766447eeb0 100644
> --- a/tools/testing/selftests/filesystems/devpts_pts.c
> +++ b/tools/testing/selftests/filesystems/devpts_pts.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <sched.h>
> diff --git a/tools/testing/selftests/filesystems/dnotify_test.c b/tools/testing/selftests/filesystems/dnotify_test.c
> index c0a9b2d3302d..05367a70b963 100644
> --- a/tools/testing/selftests/filesystems/dnotify_test.c
> +++ b/tools/testing/selftests/filesystems/dnotify_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE /* needed to get the defines */
> #include <fcntl.h> /* in glibc 2.2 this has the needed
> values defined */
> #include <signal.h>
> diff --git a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
> index 65ede506305c..9bc2ddad7e92 100644
> --- a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
> +++ b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <asm/unistd.h>
> #include <linux/time_types.h>
> #include <poll.h>
> diff --git a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
> index f142a137526c..17935f42fbc9 100644
> --- a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
> +++ b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <asm/unistd.h>
> diff --git a/tools/testing/selftests/filesystems/fat/rename_exchange.c b/tools/testing/selftests/filesystems/fat/rename_exchange.c
> index e488ad354fce..56cf3ad8640d 100644
> --- a/tools/testing/selftests/filesystems/fat/rename_exchange.c
> +++ b/tools/testing/selftests/filesystems/fat/rename_exchange.c
> @@ -6,8 +6,6 @@
> * Copyright 2022 Red Hat Inc.
> * Author: Javier Martinez Canillas <javierm@redhat.com>
> */
> -
> -#define _GNU_SOURCE
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
> index 759f86e7d263..b58a80bde95a 100644
> --- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
> +++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> -
> #include <inttypes.h>
> #include <unistd.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test.c b/tools/testing/selftests/filesystems/statmount/statmount_test.c
> index 3eafd7da58e2..d1cefd1b7d16 100644
> --- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
> +++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0-or-later
> -
> -#define _GNU_SOURCE
> -
> #include <assert.h>
> #include <stdint.h>
> #include <sched.h>
> diff --git a/tools/testing/selftests/futex/functional/futex_requeue_pi.c b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
> index 7f3ca5c78df1..8e41f9fe784c 100644
> --- a/tools/testing/selftests/futex/functional/futex_requeue_pi.c
> +++ b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
> @@ -16,9 +16,6 @@
> * 2009-Nov-6: futex test adaptation by Darren Hart <dvhart@linux.intel.com>
> *
> *****************************************************************************/
> -
> -#define _GNU_SOURCE
> -
> #include <errno.h>
> #include <limits.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c
> index 656c43c24044..291c81d59a9d 100644
> --- a/tools/testing/selftests/ipc/msgque.c
> +++ b/tools/testing/selftests/ipc/msgque.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/kcmp/kcmp_test.c b/tools/testing/selftests/kcmp/kcmp_test.c
> index 25110c7c0b3e..885c9e943cee 100644
> --- a/tools/testing/selftests/kcmp/kcmp_test.c
> +++ b/tools/testing/selftests/kcmp/kcmp_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <signal.h>
> diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/testing/selftests/kvm/aarch64/arch_timer.c
> index 4eaba83cdcf3..5369959e9fc2 100644
> --- a/tools/testing/selftests/kvm/aarch64/arch_timer.c
> +++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c
> @@ -5,8 +5,6 @@
> *
> * Copyright (c) 2021, Google LLC.
> */
> -#define _GNU_SOURCE
> -
> #include "arch_timer.h"
> #include "delay.h"
> #include "gic.h"
> diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftests/kvm/aarch64/page_fault_test.c
> index 5972905275cf..79e99f47a9fe 100644
> --- a/tools/testing/selftests/kvm/aarch64/page_fault_test.c
> +++ b/tools/testing/selftests/kvm/aarch64/page_fault_test.c
> @@ -7,7 +7,6 @@
> * hugetlbfs with a hole). It checks that the expected handling method is
> * called (e.g., uffd faults with the right address and write/read flag).
> */
> -#define _GNU_SOURCE
> #include <linux/bitmap.h>
> #include <fcntl.h>
> #include <test_util.h>
> diff --git a/tools/testing/selftests/kvm/aarch64/psci_test.c b/tools/testing/selftests/kvm/aarch64/psci_test.c
> index 9b004905d1d3..1c8c6f0c1ca3 100644
> --- a/tools/testing/selftests/kvm/aarch64/psci_test.c
> +++ b/tools/testing/selftests/kvm/aarch64/psci_test.c
> @@ -10,9 +10,6 @@
> * - A test for KVM's handling of PSCI SYSTEM_SUSPEND and the associated
> * KVM_SYSTEM_EVENT_SUSPEND UAPI.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <linux/psci.h>
>
> #include "kvm_util.h"
> diff --git a/tools/testing/selftests/kvm/aarch64/vgic_init.c b/tools/testing/selftests/kvm/aarch64/vgic_init.c
> index ca917c71ff60..b3b5fb0ff0a9 100644
> --- a/tools/testing/selftests/kvm/aarch64/vgic_init.c
> +++ b/tools/testing/selftests/kvm/aarch64/vgic_init.c
> @@ -4,7 +4,6 @@
> *
> * Copyright (C) 2020, Red Hat, Inc.
> */
> -#define _GNU_SOURCE
> #include <linux/kernel.h>
> #include <sys/syscall.h>
> #include <asm/kvm.h>
> diff --git a/tools/testing/selftests/kvm/arch_timer.c b/tools/testing/selftests/kvm/arch_timer.c
> index ae1f1a6d8312..fcebd8d81ce4 100644
> --- a/tools/testing/selftests/kvm/arch_timer.c
> +++ b/tools/testing/selftests/kvm/arch_timer.c
> @@ -19,9 +19,6 @@
> *
> * Copyright (c) 2021, Google LLC.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <stdlib.h>
> #include <pthread.h>
> #include <linux/sizes.h>
> diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
> index bf3609f71854..0c4d3b6afbf8 100644
> --- a/tools/testing/selftests/kvm/demand_paging_test.c
> +++ b/tools/testing/selftests/kvm/demand_paging_test.c
> @@ -6,9 +6,6 @@
> * Copyright (C) 2018, Red Hat, Inc.
> * Copyright (C) 2019, Google, Inc.
> */
> -
> -#define _GNU_SOURCE /* for pipe2 */
> -
> #include <inttypes.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
> index eaad5b20854c..bf1ebc29f22a 100644
> --- a/tools/testing/selftests/kvm/dirty_log_test.c
> +++ b/tools/testing/selftests/kvm/dirty_log_test.c
> @@ -4,9 +4,6 @@
> *
> * Copyright (C) 2018, Red Hat, Inc.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_name */
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
> index 92eae206baa6..309fe84b84ad 100644
> --- a/tools/testing/selftests/kvm/guest_memfd_test.c
> +++ b/tools/testing/selftests/kvm/guest_memfd_test.c
> @@ -4,8 +4,6 @@
> *
> * Author: Chao Peng <chao.p.peng@linux.intel.com>
> */
> -
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/kvm/hardware_disable_test.c b/tools/testing/selftests/kvm/hardware_disable_test.c
> index decc521fc760..bce73bcb973c 100644
> --- a/tools/testing/selftests/kvm/hardware_disable_test.c
> +++ b/tools/testing/selftests/kvm/hardware_disable_test.c
> @@ -4,9 +4,6 @@
> * kvm_arch_hardware_disable is called and it attempts to unregister the user
> * return notifiers.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <fcntl.h>
> #include <pthread.h>
> #include <semaphore.h>
> diff --git a/tools/testing/selftests/kvm/include/userfaultfd_util.h b/tools/testing/selftests/kvm/include/userfaultfd_util.h
> index 877449c34592..a9d97c213584 100644
> --- a/tools/testing/selftests/kvm/include/userfaultfd_util.h
> +++ b/tools/testing/selftests/kvm/include/userfaultfd_util.h
> @@ -5,9 +5,6 @@
> * Copyright (C) 2018, Red Hat, Inc.
> * Copyright (C) 2019-2022 Google LLC
> */
> -
> -#define _GNU_SOURCE /* for pipe2 */
> -
> #include <inttypes.h>
> #include <time.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
> index 698c1cfa3111..f02355c3c4c2 100644
> --- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c
> +++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
> @@ -6,8 +6,6 @@
> *
> * Test the fd-based interface for KVM statistics.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
> index b9e23265e4b3..c78f34699f73 100644
> --- a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
> +++ b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
> @@ -6,8 +6,6 @@
> *
> * Test for KVM_CAP_MAX_VCPUS and KVM_CAP_MAX_VCPU_ID.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
> index e0ba97ac1c56..7759c685086b 100644
> --- a/tools/testing/selftests/kvm/kvm_page_table_test.c
> +++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
> @@ -8,9 +8,6 @@
> * page size have been pre-allocated on your system, if you are planning to
> * use hugepages to back the guest memory for testing.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_name */
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
> diff --git a/tools/testing/selftests/kvm/lib/assert.c b/tools/testing/selftests/kvm/lib/assert.c
> index 2bd25b191d15..b49690658c60 100644
> --- a/tools/testing/selftests/kvm/lib/assert.c
> +++ b/tools/testing/selftests/kvm/lib/assert.c
> @@ -4,9 +4,6 @@
> *
> * Copyright (C) 2018, Google LLC.
> */
> -
> -#define _GNU_SOURCE /* for getline(3) and strchrnul(3)*/
> -
> #include "test_util.h"
>
> #include <execinfo.h>
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
> index b2262b5fad9e..1eaf001d0ad4 100644
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -4,8 +4,6 @@
> *
> * Copyright (C) 2018, Google LLC.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_name */
> #include "test_util.h"
> #include "kvm_util.h"
> #include "processor.h"
> diff --git a/tools/testing/selftests/kvm/lib/memstress.c b/tools/testing/selftests/kvm/lib/memstress.c
> index cf2c73971308..555e3932e529 100644
> --- a/tools/testing/selftests/kvm/lib/memstress.c
> +++ b/tools/testing/selftests/kvm/lib/memstress.c
> @@ -2,8 +2,6 @@
> /*
> * Copyright (C) 2020, Google LLC.
> */
> -#define _GNU_SOURCE
> -
> #include <inttypes.h>
> #include <linux/bitmap.h>
>
> diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c
> index 5a8f8becb129..8ed0b74ae837 100644
> --- a/tools/testing/selftests/kvm/lib/test_util.c
> +++ b/tools/testing/selftests/kvm/lib/test_util.c
> @@ -4,8 +4,6 @@
> *
> * Copyright (C) 2020, Google LLC.
> */
> -
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <stdarg.h>
> #include <assert.h>
> diff --git a/tools/testing/selftests/kvm/lib/userfaultfd_util.c b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
> index f4eef6eb2dc2..bd07568a5240 100644
> --- a/tools/testing/selftests/kvm/lib/userfaultfd_util.c
> +++ b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
> @@ -6,9 +6,6 @@
> * Copyright (C) 2018, Red Hat, Inc.
> * Copyright (C) 2019-2022 Google LLC
> */
> -
> -#define _GNU_SOURCE /* for pipe2 */
> -
> #include <inttypes.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/lib/x86_64/sev.c b/tools/testing/selftests/kvm/lib/x86_64/sev.c
> index e248d3364b9c..e83809febae1 100644
> --- a/tools/testing/selftests/kvm/lib/x86_64/sev.c
> +++ b/tools/testing/selftests/kvm/lib/x86_64/sev.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0-only
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <stdint.h>
> #include <stdbool.h>
>
> diff --git a/tools/testing/selftests/kvm/max_guest_memory_test.c b/tools/testing/selftests/kvm/max_guest_memory_test.c
> index 1a6da7389bf1..0b9678858b6d 100644
> --- a/tools/testing/selftests/kvm/max_guest_memory_test.c
> +++ b/tools/testing/selftests/kvm/max_guest_memory_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c
> index 156361966612..05fcf902e067 100644
> --- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c
> +++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c
> @@ -6,9 +6,6 @@
> * Copyright (C) 2018, Red Hat, Inc.
> * Copyright (C) 2020, Google, Inc.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_name */
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/syscall.h>
> diff --git a/tools/testing/selftests/kvm/riscv/arch_timer.c b/tools/testing/selftests/kvm/riscv/arch_timer.c
> index 0f9cabd99fd4..4b5004ef9c6b 100644
> --- a/tools/testing/selftests/kvm/riscv/arch_timer.c
> +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c
> @@ -7,9 +7,6 @@
> *
> * Copyright (c) 2024, Intel Corporation.
> */
> -
> -#define _GNU_SOURCE
> -
> #include "arch_timer.h"
> #include "kvm_util.h"
> #include "processor.h"
> diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
> index 28f97fb52044..b3536400f9ac 100644
> --- a/tools/testing/selftests/kvm/rseq_test.c
> +++ b/tools/testing/selftests/kvm/rseq_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0-only
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <errno.h>
> #include <fcntl.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/kvm/s390x/cmma_test.c b/tools/testing/selftests/kvm/s390x/cmma_test.c
> index 626a2b8a2037..84ba79c42ab1 100644
> --- a/tools/testing/selftests/kvm/s390x/cmma_test.c
> +++ b/tools/testing/selftests/kvm/s390x/cmma_test.c
> @@ -7,8 +7,6 @@
> * Authors:
> * Nico Boehr <nrb@linux.ibm.com>
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/s390x/sync_regs_test.c b/tools/testing/selftests/kvm/s390x/sync_regs_test.c
> index 43fb25ddc3ec..53def355ccba 100644
> --- a/tools/testing/selftests/kvm/s390x/sync_regs_test.c
> +++ b/tools/testing/selftests/kvm/s390x/sync_regs_test.c
> @@ -10,8 +10,6 @@
> *
> * Test expected behavior of the KVM_CAP_SYNC_REGS functionality.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c
> index bd57d991e27d..214ff84f6fdb 100644
> --- a/tools/testing/selftests/kvm/set_memory_region_test.c
> +++ b/tools/testing/selftests/kvm/set_memory_region_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <pthread.h>
> #include <sched.h>
> diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
> index bae0c5026f82..e9231387c589 100644
> --- a/tools/testing/selftests/kvm/steal_time.c
> +++ b/tools/testing/selftests/kvm/steal_time.c
> @@ -4,7 +4,6 @@
> *
> * Copyright (C) 2020, Red Hat, Inc.
> */
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <time.h>
> #include <sched.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
> index eae521f050e0..8e5713e36d4b 100644
> --- a/tools/testing/selftests/kvm/x86_64/amx_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
> @@ -6,8 +6,6 @@
> *
> * Tests for amx #NM exception and save/restore.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/exit_on_emulation_failure_test.c b/tools/testing/selftests/kvm/x86_64/exit_on_emulation_failure_test.c
> index 6c2e5e0ceb1f..9c21b6bccc38 100644
> --- a/tools/testing/selftests/kvm/x86_64/exit_on_emulation_failure_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/exit_on_emulation_failure_test.c
> @@ -4,9 +4,6 @@
> *
> * Test for KVM_CAP_EXIT_ON_EMULATION_FAILURE.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> -
> #include "flds_emulation.h"
>
> #include "test_util.h"
> diff --git a/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c b/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c
> index df351ae17029..10b1b0ba374e 100644
> --- a/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c
> @@ -2,8 +2,6 @@
> /*
> * Copyright (C) 2023, Google LLC.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <sys/ioctl.h>
>
> #include "test_util.h"
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> index 5c27efbf405e..4f5881d4ef66 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
> @@ -7,8 +7,6 @@
> * This work is licensed under the terms of the GNU GPL, version 2.
> *
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c b/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
> index 4c7257ecd2a6..4f3f3a9b038b 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
> @@ -4,7 +4,6 @@
> *
> * Tests for Enlightened VMCS, including nested guest state.
> */
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c b/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
> index f1617762c22f..8206f5ef42dd 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
> @@ -5,8 +5,6 @@
> * Copyright (C) 2022, Red Hat, Inc.
> *
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <pthread.h>
> #include <inttypes.h>
>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
> index c9b18707edc0..b987a3d79715 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
> @@ -4,7 +4,6 @@
> *
> * Tests for Hyper-V extensions to SVM.
> */
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c b/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
> index 05b56095cf76..077cd0ec3040 100644
> --- a/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
> +++ b/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
> @@ -5,8 +5,6 @@
> * Copyright (C) 2022, Red Hat, Inc.
> *
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <asm/barrier.h>
> #include <pthread.h>
> #include <inttypes.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c b/tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c
> index 3670331adf21..3eb0313ffa39 100644
> --- a/tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0-only
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> -
> #include "test_util.h"
> #include "kvm_util.h"
> #include "processor.h"
> diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> index 17bbb96fc4df..e7efb2b35f8b 100644
> --- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> @@ -5,9 +5,6 @@
> *
> * Copyright (C) 2022, Google LLC.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <fcntl.h>
> #include <stdint.h>
> #include <time.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/platform_info_test.c b/tools/testing/selftests/kvm/x86_64/platform_info_test.c
> index 87011965dc41..2165b1ad8b38 100644
> --- a/tools/testing/selftests/kvm/x86_64/platform_info_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/platform_info_test.c
> @@ -9,8 +9,6 @@
> * Verifies expected behavior of controlling guest access to
> * MSR_PLATFORM_INFO.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c
> index 26c85815f7e9..77f14138594e 100644
> --- a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c
> @@ -2,8 +2,6 @@
> /*
> * Copyright (C) 2023, Tencent, Inc.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <x86intrin.h>
>
> #include "pmu.h"
> diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> index 3c85d1ae9893..5ce53b8c46e0 100644
> --- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> @@ -9,9 +9,6 @@
> * Verifies the expected behavior of allow lists and deny lists for
> * virtual PMU events.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> -
> #include "kvm_util.h"
> #include "pmu.h"
> #include "processor.h"
> diff --git a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
> index e0f642d2a3c4..82a8d88b5338 100644
> --- a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
> @@ -2,7 +2,6 @@
> /*
> * Copyright (C) 2022, Google LLC.
> */
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <limits.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c b/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
> index 366cf18600bc..d691d86e5bc3 100644
> --- a/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
> +++ b/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
> @@ -4,7 +4,6 @@
> *
> * Copyright (C) 2020, Red Hat, Inc.
> */
> -#define _GNU_SOURCE /* for program_invocation_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/set_sregs_test.c b/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
> index 3610981d9162..c021c0795a96 100644
> --- a/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
> @@ -10,7 +10,6 @@
> * That bug allowed a user-mode program that called the KVM_SET_SREGS
> * ioctl to put a VCPU's local APIC into an invalid state.
> */
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c b/tools/testing/selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c
> index 416207c38a17..362be40fc00d 100644
> --- a/tools/testing/selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c
> @@ -5,9 +5,6 @@
> * Test that KVM emulates instructions in response to EPT violations when
> * allow_smaller_maxphyaddr is enabled and guest.MAXPHYADDR < host.MAXPHYADDR.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> -
> #include "flds_emulation.h"
>
> #include "test_util.h"
> diff --git a/tools/testing/selftests/kvm/x86_64/smm_test.c b/tools/testing/selftests/kvm/x86_64/smm_test.c
> index e18b86666e1f..55c88d664a94 100644
> --- a/tools/testing/selftests/kvm/x86_64/smm_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/smm_test.c
> @@ -4,7 +4,6 @@
> *
> * Tests for SMM.
> */
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/state_test.c b/tools/testing/selftests/kvm/x86_64/state_test.c
> index 88b58aab7207..1c756db329e5 100644
> --- a/tools/testing/selftests/kvm/x86_64/state_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/state_test.c
> @@ -6,7 +6,6 @@
> *
> * Tests for vCPU state save/restore, including nested guest state.
> */
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/sync_regs_test.c b/tools/testing/selftests/kvm/x86_64/sync_regs_test.c
> index adb5593daf48..8fa3948b0170 100644
> --- a/tools/testing/selftests/kvm/x86_64/sync_regs_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/sync_regs_test.c
> @@ -8,8 +8,6 @@
> * including requesting an invalid register set, updates to/from values
> * in kvm_run.s.regs when kvm_valid_regs and kvm_dirty_regs are toggled.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/ucna_injection_test.c b/tools/testing/selftests/kvm/x86_64/ucna_injection_test.c
> index dcbb3c29fb8e..abe71946941f 100644
> --- a/tools/testing/selftests/kvm/x86_64/ucna_injection_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/ucna_injection_test.c
> @@ -17,8 +17,6 @@
> * delivered into the guest or not.
> *
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <pthread.h>
> #include <inttypes.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c b/tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c
> index f4f61a2d2464..53afbea4df88 100644
> --- a/tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c
> @@ -4,8 +4,6 @@
> *
> * Tests for exiting into userspace on registered MSRs
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <sys/ioctl.h>
>
> #include "kvm_test_harness.h"
> diff --git a/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c b/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c
> index 977948fd52e6..fa512d033205 100644
> --- a/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c
> @@ -4,9 +4,6 @@
> *
> * Copyright (C) 2018, Red Hat, Inc.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_name */
> -
> #include <stdio.h>
> #include <stdlib.h>
> #include <linux/bitmap.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
> index ea0cb3cae0f7..3b93f262b797 100644
> --- a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
> @@ -10,7 +10,6 @@
> * and check it can be retrieved with KVM_GET_MSR, also test
> * the invalid LBR formats are rejected.
> */
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <sys/ioctl.h>
>
> #include <linux/bitmap.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c b/tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c
> index affc32800158..00dd2ac07a61 100644
> --- a/tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c
> @@ -9,7 +9,6 @@
> * value instead of partially decayed timer value
> *
> */
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c b/tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c
> index 725c206ba0b9..c78e5f755116 100644
> --- a/tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c
> @@ -19,8 +19,6 @@
> * Migration is a command line option. When used on non-numa machines will
> * exit with error. Test is still usefull on non-numa for testing IPIs.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <getopt.h>
> #include <pthread.h>
> #include <inttypes.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/xapic_state_test.c b/tools/testing/selftests/kvm/x86_64/xapic_state_test.c
> index ab75b873a4ad..69849acd95b0 100644
> --- a/tools/testing/selftests/kvm/x86_64/xapic_state_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/xapic_state_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0-only
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <fcntl.h>
> #include <stdio.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/kvm/x86_64/xss_msr_test.c b/tools/testing/selftests/kvm/x86_64/xss_msr_test.c
> index 167c97abff1b..f331a4e9bae3 100644
> --- a/tools/testing/selftests/kvm/x86_64/xss_msr_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/xss_msr_test.c
> @@ -4,8 +4,6 @@
> *
> * Tests for the IA32_XSS MSR.
> */
> -
> -#define _GNU_SOURCE /* for program_invocation_short_name */
> #include <sys/ioctl.h>
>
> #include "test_util.h"
> diff --git a/tools/testing/selftests/landlock/base_test.c b/tools/testing/selftests/landlock/base_test.c
> index a6f89aaea77d..bdb3955a9452 100644
> --- a/tools/testing/selftests/landlock/base_test.c
> +++ b/tools/testing/selftests/landlock/base_test.c
> @@ -5,8 +5,6 @@
> * Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
> * Copyright © 2019-2020 ANSSI
> */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <linux/landlock.h>
> diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
> index 9a6036fbf289..acec1c82c8b4 100644
> --- a/tools/testing/selftests/landlock/fs_test.c
> +++ b/tools/testing/selftests/landlock/fs_test.c
> @@ -6,8 +6,6 @@
> * Copyright © 2020 ANSSI
> * Copyright © 2020-2022 Microsoft Corporation
> */
> -
> -#define _GNU_SOURCE
> #include <fcntl.h>
> #include <linux/landlock.h>
> #include <linux/magic.h>
> diff --git a/tools/testing/selftests/landlock/net_test.c b/tools/testing/selftests/landlock/net_test.c
> index f21cfbbc3638..eed040adcbac 100644
> --- a/tools/testing/selftests/landlock/net_test.c
> +++ b/tools/testing/selftests/landlock/net_test.c
> @@ -5,8 +5,6 @@
> * Copyright © 2022-2023 Huawei Tech. Co., Ltd.
> * Copyright © 2023 Microsoft Corporation
> */
> -
> -#define _GNU_SOURCE
> #include <arpa/inet.h>
> #include <errno.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/landlock/ptrace_test.c b/tools/testing/selftests/landlock/ptrace_test.c
> index a19db4d0b3bd..c831e6d03b02 100644
> --- a/tools/testing/selftests/landlock/ptrace_test.c
> +++ b/tools/testing/selftests/landlock/ptrace_test.c
> @@ -5,8 +5,6 @@
> * Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
> * Copyright © 2019-2020 ANSSI
> */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <linux/landlock.h>
> diff --git a/tools/testing/selftests/lsm/common.c b/tools/testing/selftests/lsm/common.c
> index 9ad258912646..1b18aac570f1 100644
> --- a/tools/testing/selftests/lsm/common.c
> +++ b/tools/testing/selftests/lsm/common.c
> @@ -4,8 +4,6 @@
> *
> * Copyright © 2023 Casey Schaufler <casey@schaufler-ca.com>
> */
> -
> -#define _GNU_SOURCE
> #include <linux/lsm.h>
> #include <fcntl.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/lsm/lsm_get_self_attr_test.c b/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
> index df215e4aa63f..7465bde3f922 100644
> --- a/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
> +++ b/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
> @@ -5,8 +5,6 @@
> *
> * Copyright © 2022 Casey Schaufler <casey@schaufler-ca.com>
> */
> -
> -#define _GNU_SOURCE
> #include <linux/lsm.h>
> #include <fcntl.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/lsm/lsm_list_modules_test.c b/tools/testing/selftests/lsm/lsm_list_modules_test.c
> index 06d24d4679a6..a6b44e25c21f 100644
> --- a/tools/testing/selftests/lsm/lsm_list_modules_test.c
> +++ b/tools/testing/selftests/lsm/lsm_list_modules_test.c
> @@ -5,8 +5,6 @@
> *
> * Copyright © 2022 Casey Schaufler <casey@schaufler-ca.com>
> */
> -
> -#define _GNU_SOURCE
> #include <linux/lsm.h>
> #include <string.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/lsm/lsm_set_self_attr_test.c b/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
> index 66dec47e3ca3..110c6a07e74c 100644
> --- a/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
> +++ b/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
> @@ -5,8 +5,6 @@
> *
> * Copyright © 2022 Casey Schaufler <casey@schaufler-ca.com>
> */
> -
> -#define _GNU_SOURCE
> #include <linux/lsm.h>
> #include <string.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/membarrier/membarrier_test_impl.h b/tools/testing/selftests/membarrier/membarrier_test_impl.h
> index af89855adb7b..a8a60b6271a5 100644
> --- a/tools/testing/selftests/membarrier/membarrier_test_impl.h
> +++ b/tools/testing/selftests/membarrier/membarrier_test_impl.h
> @@ -1,5 +1,4 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> -#define _GNU_SOURCE
> #include <linux/membarrier.h>
> #include <syscall.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c b/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
> index a9cc17facfb3..b4651e2ade00 100644
> --- a/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
> +++ b/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <linux/membarrier.h>
> #include <syscall.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/membarrier/membarrier_test_single_thread.c b/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
> index 4cdc8b1d124c..17ae5199b916 100644
> --- a/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
> +++ b/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <linux/membarrier.h>
> #include <syscall.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/memfd/common.c b/tools/testing/selftests/memfd/common.c
> index 8eb3d75f6e60..879d4f4c66fa 100644
> --- a/tools/testing/selftests/memfd/common.c
> +++ b/tools/testing/selftests/memfd/common.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #define __EXPORTED_HEADERS__
>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
> index 93798c8c5d54..15bc189bf831 100644
> --- a/tools/testing/selftests/memfd/fuse_test.c
> +++ b/tools/testing/selftests/memfd/fuse_test.c
> @@ -12,8 +12,6 @@
> * the read() syscall with our memory-mapped memfd object as receive buffer to
> * force the kernel to write into our memfd object.
> */
> -
> -#define _GNU_SOURCE
> #define __EXPORTED_HEADERS__
>
> #include <errno.h>
> diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
> index 18f585684e20..5172c27a8748 100644
> --- a/tools/testing/selftests/memfd/memfd_test.c
> +++ b/tools/testing/selftests/memfd/memfd_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #define __EXPORTED_HEADERS__
>
> #include <errno.h>
> diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
> index 363bf5f801be..6f1a36d51f19 100644
> --- a/tools/testing/selftests/mm/cow.c
> +++ b/tools/testing/selftests/mm/cow.c
> @@ -6,7 +6,6 @@
> *
> * Author(s): David Hildenbrand <david@redhat.com>
> */
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <string.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/mm/gup_longterm.c b/tools/testing/selftests/mm/gup_longterm.c
> index ad168d35b23b..3bfd5a630081 100644
> --- a/tools/testing/selftests/mm/gup_longterm.c
> +++ b/tools/testing/selftests/mm/gup_longterm.c
> @@ -6,7 +6,6 @@
> *
> * Author(s): David Hildenbrand <david@redhat.com>
> */
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <string.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/mm/hugepage-mmap.c b/tools/testing/selftests/mm/hugepage-mmap.c
> index 267eea2e0e0b..edb46888222f 100644
> --- a/tools/testing/selftests/mm/hugepage-mmap.c
> +++ b/tools/testing/selftests/mm/hugepage-mmap.c
> @@ -16,7 +16,6 @@
> * range.
> * Other architectures, such as ppc64, i386 or x86_64 are not so constrained.
> */
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <stdio.h>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/mm/hugepage-mremap.c b/tools/testing/selftests/mm/hugepage-mremap.c
> index c463d1c09c9b..8e22822bb754 100644
> --- a/tools/testing/selftests/mm/hugepage-mremap.c
> +++ b/tools/testing/selftests/mm/hugepage-mremap.c
> @@ -11,8 +11,6 @@
> * To make sure the test triggers pmd sharing and goes through the 'unshare'
> * path in the mremap code use 1GB (1024) or more.
> */
> -
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <stdio.h>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/mm/hugetlb-madvise.c b/tools/testing/selftests/mm/hugetlb-madvise.c
> index e74107185324..70c40c67bc5d 100644
> --- a/tools/testing/selftests/mm/hugetlb-madvise.c
> +++ b/tools/testing/selftests/mm/hugetlb-madvise.c
> @@ -11,8 +11,6 @@
> * filesystem. Therefore, a hugetlbfs filesystem must be mounted on some
> * directory.
> */
> -
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <stdio.h>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> index ba6cc6f9cabc..6b8b41b4f754 100644
> --- a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> +++ b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
> index 829320a519e7..d18bf400dae6 100644
> --- a/tools/testing/selftests/mm/khugepaged.c
> +++ b/tools/testing/selftests/mm/khugepaged.c
> @@ -1,4 +1,3 @@
> -#define _GNU_SOURCE
> #include <ctype.h>
> #include <errno.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c
> index d615767e396b..1deae905c42e 100644
> --- a/tools/testing/selftests/mm/ksm_functional_tests.c
> +++ b/tools/testing/selftests/mm/ksm_functional_tests.c
> @@ -6,7 +6,6 @@
> *
> * Author(s): David Hildenbrand <david@redhat.com>
> */
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <string.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/mm/madv_populate.c b/tools/testing/selftests/mm/madv_populate.c
> index 17bcb07f19f3..d19ad13ffd7e 100644
> --- a/tools/testing/selftests/mm/madv_populate.c
> +++ b/tools/testing/selftests/mm/madv_populate.c
> @@ -6,7 +6,6 @@
> *
> * Author(s): David Hildenbrand <david@redhat.com>
> */
> -#define _GNU_SOURCE
> #include <stdlib.h>
> #include <string.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/mm/map_populate.c b/tools/testing/selftests/mm/map_populate.c
> index 5c8a53869b1b..ff4d4079bd0e 100644
> --- a/tools/testing/selftests/mm/map_populate.c
> +++ b/tools/testing/selftests/mm/map_populate.c
> @@ -4,8 +4,6 @@
> *
> * MAP_POPULATE | MAP_PRIVATE should COW VMA pages.
> */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <sys/mman.h>
> diff --git a/tools/testing/selftests/mm/mdwe_test.c b/tools/testing/selftests/mm/mdwe_test.c
> index 1e01d3ddc11c..200bedcdc32e 100644
> --- a/tools/testing/selftests/mm/mdwe_test.c
> +++ b/tools/testing/selftests/mm/mdwe_test.c
> @@ -7,7 +7,6 @@
> #include <linux/mman.h>
> #include <linux/prctl.h>
>
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/auxv.h>
> diff --git a/tools/testing/selftests/mm/memfd_secret.c b/tools/testing/selftests/mm/memfd_secret.c
> index 9b298f6a04b3..750adede2816 100644
> --- a/tools/testing/selftests/mm/memfd_secret.c
> +++ b/tools/testing/selftests/mm/memfd_secret.c
> @@ -4,8 +4,6 @@
> *
> * Author: Mike Rapoport <rppt@linux.ibm.com>
> */
> -
> -#define _GNU_SOURCE
> #include <sys/uio.h>
> #include <sys/mman.h>
> #include <sys/wait.h>
> diff --git a/tools/testing/selftests/mm/mlock2-tests.c b/tools/testing/selftests/mm/mlock2-tests.c
> index 26f744188ad0..42574290d728 100644
> --- a/tools/testing/selftests/mm/mlock2-tests.c
> +++ b/tools/testing/selftests/mm/mlock2-tests.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <sys/mman.h>
> #include <stdint.h>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/mm/mrelease_test.c b/tools/testing/selftests/mm/mrelease_test.c
> index 100370a7111d..d78bf686e99f 100644
> --- a/tools/testing/selftests/mm/mrelease_test.c
> +++ b/tools/testing/selftests/mm/mrelease_test.c
> @@ -2,7 +2,6 @@
> /*
> * Copyright 2022 Google LLC
> */
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <stdbool.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/mm/mremap_dontunmap.c b/tools/testing/selftests/mm/mremap_dontunmap.c
> index 1d75084b9ca5..934fa6b441b2 100644
> --- a/tools/testing/selftests/mm/mremap_dontunmap.c
> +++ b/tools/testing/selftests/mm/mremap_dontunmap.c
> @@ -5,7 +5,6 @@
> *
> * Copyright 2020, Brian Geffon <bgeffon@google.com>
> */
> -#define _GNU_SOURCE
> #include <sys/mman.h>
> #include <linux/mman.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
> index 2f8b991f78cb..e057154630e0 100644
> --- a/tools/testing/selftests/mm/mremap_test.c
> +++ b/tools/testing/selftests/mm/mremap_test.c
> @@ -2,8 +2,6 @@
> /*
> * Copyright 2020 Google LLC
> */
> -#define _GNU_SOURCE
> -
> #include <errno.h>
> #include <stdlib.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/selftests/mm/pagemap_ioctl.c
> index d59517ed3d48..2a18b5d276f0 100644
> --- a/tools/testing/selftests/mm/pagemap_ioctl.c
> +++ b/tools/testing/selftests/mm/pagemap_ioctl.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <fcntl.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h
> index 1af3156a9db8..37d6b01ce90a 100644
> --- a/tools/testing/selftests/mm/pkey-helpers.h
> +++ b/tools/testing/selftests/mm/pkey-helpers.h
> @@ -1,7 +1,6 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> #ifndef _PKEYS_HELPER_H
> #define _PKEYS_HELPER_H
> -#define _GNU_SOURCE
> #include <string.h>
> #include <stdarg.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c
> index 48dc151f8fca..9f7de92caeda 100644
> --- a/tools/testing/selftests/mm/protection_keys.c
> +++ b/tools/testing/selftests/mm/protection_keys.c
> @@ -21,7 +21,6 @@
> * gcc -mxsave -o protection_keys -O2 -g -std=gnu99 -pthread -Wall protection_keys.c -lrt -ldl -lm
> * gcc -mxsave -m32 -o protection_keys_32 -O2 -g -std=gnu99 -pthread -Wall protection_keys.c -lrt -ldl -lm
> */
> -#define _GNU_SOURCE
> #define __SANE_USERSPACE_TYPES__
> #include <errno.h>
> #include <linux/elf.h>
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index d3c7f5fb3e7b..ae6ac950d7a1 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -3,8 +3,6 @@
> * A test of splitting PMD THPs and PTE-mapped THPs from a specified virtual
> * address range in a process via <debugfs>/split_huge_pages interface.
> */
> -
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdarg.h>
> diff --git a/tools/testing/selftests/mm/thuge-gen.c b/tools/testing/selftests/mm/thuge-gen.c
> index ea7fd8fe2876..28a5c31bd791 100644
> --- a/tools/testing/selftests/mm/thuge-gen.c
> +++ b/tools/testing/selftests/mm/thuge-gen.c
> @@ -12,8 +12,6 @@
> ipcrm -m by hand, like this
> sudo ipcs | awk '$1 == "0x00000000" {print $2}' | xargs -n1 sudo ipcrm -m
> (warning this will remove all if someone else uses them) */
> -
> -#define _GNU_SOURCE 1
> #include <sys/mman.h>
> #include <stdlib.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/mm/uffd-common.h b/tools/testing/selftests/mm/uffd-common.h
> index cc5629c3d2aa..abb44319264a 100644
> --- a/tools/testing/selftests/mm/uffd-common.h
> +++ b/tools/testing/selftests/mm/uffd-common.h
> @@ -7,7 +7,6 @@
> #ifndef __UFFD_COMMON_H__
> #define __UFFD_COMMON_H__
>
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <errno.h>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/mount_setattr/mount_setattr_test.c b/tools/testing/selftests/mount_setattr/mount_setattr_test.c
> index c6a8c732b802..d894417134b6 100644
> --- a/tools/testing/selftests/mount_setattr/mount_setattr_test.c
> +++ b/tools/testing/selftests/mount_setattr/mount_setattr_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <sched.h>
> #include <stdio.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> index bcf51d785a37..bd975670f61d 100644
> --- a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> +++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <sched.h>
> #include <stdio.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/net/af_unix/diag_uid.c b/tools/testing/selftests/net/af_unix/diag_uid.c
> index 79a3dd75590e..279d0c5f70d3 100644
> --- a/tools/testing/selftests/net/af_unix/diag_uid.c
> +++ b/tools/testing/selftests/net/af_unix/diag_uid.c
> @@ -1,7 +1,5 @@
> // SPDX-License-Identifier: GPL-2.0
> /* Copyright Amazon.com Inc. or its affiliates. */
> -
> -#define _GNU_SOURCE
> #include <sched.h>
>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/net/af_unix/scm_pidfd.c b/tools/testing/selftests/net/af_unix/scm_pidfd.c
> index 7e534594167e..2986b8cd0418 100644
> --- a/tools/testing/selftests/net/af_unix/scm_pidfd.c
> +++ b/tools/testing/selftests/net/af_unix/scm_pidfd.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0 OR MIT
> -#define _GNU_SOURCE
> #include <error.h>
> #include <limits.h>
> #include <stddef.h>
> diff --git a/tools/testing/selftests/net/af_unix/unix_connect.c b/tools/testing/selftests/net/af_unix/unix_connect.c
> index d799fd8f5c7c..34e816862cc7 100644
> --- a/tools/testing/selftests/net/af_unix/unix_connect.c
> +++ b/tools/testing/selftests/net/af_unix/unix_connect.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <sched.h>
>
> #include <stddef.h>
> diff --git a/tools/testing/selftests/net/csum.c b/tools/testing/selftests/net/csum.c
> index 90eb06fefa59..8262aa862331 100644
> --- a/tools/testing/selftests/net/csum.c
> +++ b/tools/testing/selftests/net/csum.c
> @@ -58,9 +58,6 @@
> * different seed for each run (and logs this for reproducibility). It
> * is advised to enable this for extra coverage in continuous testing.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <asm/byteorder.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/net/gro.c
> index 353e1e867fbb..f5d7032e6466 100644
> --- a/tools/testing/selftests/net/gro.c
> +++ b/tools/testing/selftests/net/gro.c
> @@ -34,9 +34,6 @@
> * flakiness is to be expected.
> *
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/ip_defrag.c b/tools/testing/selftests/net/ip_defrag.c
> index f9ed749fd8c7..80c9e567a3d8 100644
> --- a/tools/testing/selftests/net/ip_defrag.c
> +++ b/tools/testing/selftests/net/ip_defrag.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c
> index be4a30a0d02a..04aa06d26b09 100644
> --- a/tools/testing/selftests/net/ipsec.c
> +++ b/tools/testing/selftests/net/ipsec.c
> @@ -3,9 +3,6 @@
> * ipsec.c - Check xfrm on veth inside a net-ns.
> * Copyright (c) 2018 Dmitry Safonov
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <asm/types.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/net/ipv6_flowlabel.c b/tools/testing/selftests/net/ipv6_flowlabel.c
> index 708a9822259d..b7e0c3c02e20 100644
> --- a/tools/testing/selftests/net/ipv6_flowlabel.c
> +++ b/tools/testing/selftests/net/ipv6_flowlabel.c
> @@ -1,8 +1,5 @@
> // SPDX-License-Identifier: GPL-2.0
> /* Test IPV6_FLOWINFO cmsg on send and recv */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <asm/byteorder.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
> index af95b48acea9..ebd219ba386e 100644
> --- a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
> +++ b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
> @@ -1,8 +1,5 @@
> // SPDX-License-Identifier: GPL-2.0
> /* Test IPV6_FLOWINFO_MGR */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <error.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> index d2043ec3bf6d..ea93030ed3ec 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <errno.h>
> #include <limits.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/selftests/net/mptcp/mptcp_inq.c
> index 218aac467321..c5bf873d76c2 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_inq.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_inq.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <assert.h>
> #include <errno.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> index 926b0be87c99..7203ca9900e9 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <assert.h>
> #include <errno.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/net/msg_zerocopy.c b/tools/testing/selftests/net/msg_zerocopy.c
> index bdc03a2097e8..9278bf585c80 100644
> --- a/tools/testing/selftests/net/msg_zerocopy.c
> +++ b/tools/testing/selftests/net/msg_zerocopy.c
> @@ -24,9 +24,6 @@
> * the kernel queues completions on the error queue for all zerocopy
> * transfers.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <error.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/net/nettest.c b/tools/testing/selftests/net/nettest.c
> index cd8a58097448..88e1d3b2ddf1 100644
> --- a/tools/testing/selftests/net/nettest.c
> +++ b/tools/testing/selftests/net/nettest.c
> @@ -3,8 +3,6 @@
> *
> * Copyright (c) 2013-2019 David Ahern <dsahern@gmail.com>. All rights reserved.
> */
> -
> -#define _GNU_SOURCE
> #include <features.h>
> #include <sys/types.h>
> #include <sys/ioctl.h>
> diff --git a/tools/testing/selftests/net/psock_fanout.c b/tools/testing/selftests/net/psock_fanout.c
> index 1a736f700be4..5b2d34440ae9 100644
> --- a/tools/testing/selftests/net/psock_fanout.c
> +++ b/tools/testing/selftests/net/psock_fanout.c
> @@ -26,9 +26,6 @@
> * Todo:
> * - functionality: PACKET_FANOUT_FLAG_DEFRAG
> */
> -
> -#define _GNU_SOURCE /* for sched_setaffinity */
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/net/psock_snd.c b/tools/testing/selftests/net/psock_snd.c
> index edf1e6f80d41..2f29b513e18f 100644
> --- a/tools/testing/selftests/net/psock_snd.c
> +++ b/tools/testing/selftests/net/psock_snd.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/reuseport_addr_any.c b/tools/testing/selftests/net/reuseport_addr_any.c
> index b8475cb29be7..9ee6ece52865 100644
> --- a/tools/testing/selftests/net/reuseport_addr_any.c
> +++ b/tools/testing/selftests/net/reuseport_addr_any.c
> @@ -3,9 +3,6 @@
> /* Test that sockets listening on a specific address are preferred
> * over sockets listening on addr_any.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/reuseport_bpf_cpu.c b/tools/testing/selftests/net/reuseport_bpf_cpu.c
> index 2d646174729f..e93e38cfb2a8 100644
> --- a/tools/testing/selftests/net/reuseport_bpf_cpu.c
> +++ b/tools/testing/selftests/net/reuseport_bpf_cpu.c
> @@ -11,9 +11,6 @@
> * This entire process is done for several different core id permutations
> * and for each IPv4/IPv6 and TCP/UDP combination.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/reuseport_bpf_numa.c b/tools/testing/selftests/net/reuseport_bpf_numa.c
> index c9ba36aa688e..502fdb9ce770 100644
> --- a/tools/testing/selftests/net/reuseport_bpf_numa.c
> +++ b/tools/testing/selftests/net/reuseport_bpf_numa.c
> @@ -3,9 +3,6 @@
> * Test functionality of BPF filters with SO_REUSEPORT. Same test as
> * in reuseport_bpf_cpu, only as one socket per NUMA node.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/reuseport_dualstack.c b/tools/testing/selftests/net/reuseport_dualstack.c
> index fb7a59ed759e..d3c3d3f39f8f 100644
> --- a/tools/testing/selftests/net/reuseport_dualstack.c
> +++ b/tools/testing/selftests/net/reuseport_dualstack.c
> @@ -10,9 +10,6 @@
> * This test creates these mixed AF_INET/AF_INET6 sockets and asserts the
> * AF_INET preference for v4 packets.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/so_incoming_cpu.c b/tools/testing/selftests/net/so_incoming_cpu.c
> index e9fa14e10732..95bd0cdc3253 100644
> --- a/tools/testing/selftests/net/so_incoming_cpu.c
> +++ b/tools/testing/selftests/net/so_incoming_cpu.c
> @@ -1,6 +1,5 @@
> // SPDX-License-Identifier: GPL-2.0
> /* Copyright Amazon.com Inc. or its affiliates. */
> -#define _GNU_SOURCE
> #include <sched.h>
>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/net/so_netns_cookie.c b/tools/testing/selftests/net/so_netns_cookie.c
> index b39e87e967cd..18532d564f79 100644
> --- a/tools/testing/selftests/net/so_netns_cookie.c
> +++ b/tools/testing/selftests/net/so_netns_cookie.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <sched.h>
> #include <unistd.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c
> index 8457b7ccbc09..011a24af9786 100644
> --- a/tools/testing/selftests/net/so_txtime.c
> +++ b/tools/testing/selftests/net/so_txtime.c
> @@ -9,9 +9,6 @@
> * the expected stream. Sender will read transmit timestamps from the error
> * queue. The streams can differ due to out-of-order delivery and drops.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <error.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/net/tap.c b/tools/testing/selftests/net/tap.c
> index 247c3b3ac1c9..fa78b92d9740 100644
> --- a/tools/testing/selftests/net/tap.c
> +++ b/tools/testing/selftests/net/tap.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <errno.h>
> #include <fcntl.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/net/tcp_fastopen_backup_key.c b/tools/testing/selftests/net/tcp_fastopen_backup_key.c
> index c1cb0c75156a..d30f89bb944c 100644
> --- a/tools/testing/selftests/net/tcp_fastopen_backup_key.c
> +++ b/tools/testing/selftests/net/tcp_fastopen_backup_key.c
> @@ -12,7 +12,6 @@
> * there are no cases in which a cookie is not accepted by verifying
> * that TcpExtTCPFastOpenPassiveFail remains 0.
> */
> -#define _GNU_SOURCE
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/tcp_inq.c b/tools/testing/selftests/net/tcp_inq.c
> index bd6a9c7a3e8a..71ee145f151e 100644
> --- a/tools/testing/selftests/net/tcp_inq.c
> +++ b/tools/testing/selftests/net/tcp_inq.c
> @@ -5,8 +5,6 @@
> *
> * Simple example on how to use TCP_INQ and TCP_CM_INQ.
> */
> -#define _GNU_SOURCE
> -
> #include <error.h>
> #include <netinet/in.h>
> #include <netinet/tcp.h>
> diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
> index 4fcce5150850..72d5f1207ee0 100644
> --- a/tools/testing/selftests/net/tcp_mmap.c
> +++ b/tools/testing/selftests/net/tcp_mmap.c
> @@ -46,7 +46,6 @@
> * received 32768 MB (99.9939 % mmap'ed) in 7.43764 s, 36.9577 Gbit
> * cpu usage user:0.035 sys:3.467, 106.873 usec per MB, 65530 c-switches
> */
> -#define _GNU_SOURCE
> #include <pthread.h>
> #include <sys/types.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
> index f27a12d2a2c9..6dbad97d1d0a 100644
> --- a/tools/testing/selftests/net/tls.c
> +++ b/tools/testing/selftests/net/tls.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/toeplitz.c b/tools/testing/selftests/net/toeplitz.c
> index 9ba03164d73a..e2d739892ce4 100644
> --- a/tools/testing/selftests/net/toeplitz.c
> +++ b/tools/testing/selftests/net/toeplitz.c
> @@ -20,9 +20,6 @@
> * 5. Compute the cpu that RPS should select based on rx_hash and $rps_bitmap
> * 6. Compare the cpus from 4 and 5
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/tun.c b/tools/testing/selftests/net/tun.c
> index fa83918b62d1..a64dcfb242c1 100644
> --- a/tools/testing/selftests/net/tun.c
> +++ b/tools/testing/selftests/net/tun.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <errno.h>
> #include <fcntl.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/net/txring_overwrite.c b/tools/testing/selftests/net/txring_overwrite.c
> index 7d9ea039450a..96972e0110a0 100644
> --- a/tools/testing/selftests/net/txring_overwrite.c
> +++ b/tools/testing/selftests/net/txring_overwrite.c
> @@ -4,9 +4,6 @@
> * Verify that consecutive sends over packet tx_ring are mirrored
> * with their original content intact.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <assert.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
> index ec60a16c9307..33dba9e90dea 100644
> --- a/tools/testing/selftests/net/txtimestamp.c
> +++ b/tools/testing/selftests/net/txtimestamp.c
> @@ -16,9 +16,6 @@
> * This test requires a dummy TCP server.
> * A simple `nc6 [-u] -l -p $DESTPORT` will do
> */
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <asm/types.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/udpgso.c b/tools/testing/selftests/net/udpgso.c
> index 85b3baa3f7f3..9dc1026a033a 100644
> --- a/tools/testing/selftests/net/udpgso.c
> +++ b/tools/testing/selftests/net/udpgso.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <stddef.h>
> #include <arpa/inet.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c
> index 1cbadd267c96..999df1236320 100644
> --- a/tools/testing/selftests/net/udpgso_bench_rx.c
> +++ b/tools/testing/selftests/net/udpgso_bench_rx.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <error.h>
> #include <errno.h>
> diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c
> index 477392715a9a..d7632993b354 100644
> --- a/tools/testing/selftests/net/udpgso_bench_tx.c
> +++ b/tools/testing/selftests/net/udpgso_bench_tx.c
> @@ -1,7 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> -
> #include <arpa/inet.h>
> #include <errno.h>
> #include <error.h>
> diff --git a/tools/testing/selftests/perf_events/remove_on_exec.c b/tools/testing/selftests/perf_events/remove_on_exec.c
> index 5814611a1dc7..ef4d923f4759 100644
> --- a/tools/testing/selftests/perf_events/remove_on_exec.c
> +++ b/tools/testing/selftests/perf_events/remove_on_exec.c
> @@ -5,8 +5,6 @@
> * Copyright (C) 2021, Google LLC.
> */
>
> -#define _GNU_SOURCE
> -
> /* We need the latest siginfo from the kernel repo. */
> #include <sys/types.h>
> #include <asm/siginfo.h>
> diff --git a/tools/testing/selftests/perf_events/sigtrap_threads.c b/tools/testing/selftests/perf_events/sigtrap_threads.c
> index d1d8483ac628..14d1a3c8cb5c 100644
> --- a/tools/testing/selftests/perf_events/sigtrap_threads.c
> +++ b/tools/testing/selftests/perf_events/sigtrap_threads.c
> @@ -5,8 +5,6 @@
> * Copyright (C) 2021, Google LLC.
> */
>
> -#define _GNU_SOURCE
> -
> /* We need the latest siginfo from the kernel repo. */
> #include <sys/types.h>
> #include <asm/siginfo.h>
> diff --git a/tools/testing/selftests/pid_namespace/regression_enomem.c b/tools/testing/selftests/pid_namespace/regression_enomem.c
> index 7d84097ad45c..54dc8f16d92a 100644
> --- a/tools/testing/selftests/pid_namespace/regression_enomem.c
> +++ b/tools/testing/selftests/pid_namespace/regression_enomem.c
> @@ -1,4 +1,3 @@
> -#define _GNU_SOURCE
> #include <assert.h>
> #include <errno.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h
> index 88d6830ee004..e33177b1aa41 100644
> --- a/tools/testing/selftests/pidfd/pidfd.h
> +++ b/tools/testing/selftests/pidfd/pidfd.h
> @@ -3,7 +3,6 @@
> #ifndef __PIDFD_H
> #define __PIDFD_H
>
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <sched.h>
> diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
> index 01cc37bf611c..67c9dc436c71 100644
> --- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
> +++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <assert.h>
> #include <errno.h>
> #include <fcntl.h>
> diff --git a/tools/testing/selftests/pidfd/pidfd_getfd_test.c b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
> index cd51d547b751..b6a0e9b3d2f5 100644
> --- a/tools/testing/selftests/pidfd/pidfd_getfd_test.c
> +++ b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <limits.h>
> diff --git a/tools/testing/selftests/pidfd/pidfd_open_test.c b/tools/testing/selftests/pidfd/pidfd_open_test.c
> index 8a59438ccc78..781a3931fb5a 100644
> --- a/tools/testing/selftests/pidfd/pidfd_open_test.c
> +++ b/tools/testing/selftests/pidfd/pidfd_open_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <inttypes.h>
> diff --git a/tools/testing/selftests/pidfd/pidfd_poll_test.c b/tools/testing/selftests/pidfd/pidfd_poll_test.c
> index 610811275357..a40fb27a78bb 100644
> --- a/tools/testing/selftests/pidfd/pidfd_poll_test.c
> +++ b/tools/testing/selftests/pidfd/pidfd_poll_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <linux/types.h>
> #include <poll.h>
> diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testing/selftests/pidfd/pidfd_setns_test.c
> index 6e2f2cd400ca..49d7a78cc4fe 100644
> --- a/tools/testing/selftests/pidfd/pidfd_setns_test.c
> +++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <limits.h>
> diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c
> index c081ae91313a..c3d52406b8fd 100644
> --- a/tools/testing/selftests/pidfd/pidfd_test.c
> +++ b/tools/testing/selftests/pidfd/pidfd_test.c
> @@ -1,6 +1,4 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <fcntl.h>
> #include <linux/types.h>
> diff --git a/tools/testing/selftests/pidfd/pidfd_wait.c b/tools/testing/selftests/pidfd/pidfd_wait.c
> index 0dcb8365ddc3..54beba0983f1 100644
> --- a/tools/testing/selftests/pidfd/pidfd_wait.c
> +++ b/tools/testing/selftests/pidfd/pidfd_wait.c
> @@ -1,6 +1,4 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <linux/sched.h>
> #include <linux/types.h>
> diff --git a/tools/testing/selftests/ptrace/get_set_sud.c b/tools/testing/selftests/ptrace/get_set_sud.c
> index 5297b10d25c3..054a78ebe8b5 100644
> --- a/tools/testing/selftests/ptrace/get_set_sud.c
> +++ b/tools/testing/selftests/ptrace/get_set_sud.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include "../kselftest_harness.h"
> #include <stdio.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/ptrace/peeksiginfo.c b/tools/testing/selftests/ptrace/peeksiginfo.c
> index a6884f66dc01..1b7b77190f72 100644
> --- a/tools/testing/selftests/ptrace/peeksiginfo.c
> +++ b/tools/testing/selftests/ptrace/peeksiginfo.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <signal.h>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/rseq/basic_percpu_ops_test.c b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
> index 2348d2c20d0a..5961c24ee1ae 100644
> --- a/tools/testing/selftests/rseq/basic_percpu_ops_test.c
> +++ b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: LGPL-2.1
> -#define _GNU_SOURCE
> #include <assert.h>
> #include <pthread.h>
> #include <sched.h>
> diff --git a/tools/testing/selftests/rseq/basic_test.c b/tools/testing/selftests/rseq/basic_test.c
> index 295eea16466f..1fed749b4bd7 100644
> --- a/tools/testing/selftests/rseq/basic_test.c
> +++ b/tools/testing/selftests/rseq/basic_test.c
> @@ -2,8 +2,6 @@
> /*
> * Basic test coverage for critical regions and rseq_current_cpu().
> */
> -
> -#define _GNU_SOURCE
> #include <assert.h>
> #include <sched.h>
> #include <signal.h>
> diff --git a/tools/testing/selftests/rseq/param_test.c b/tools/testing/selftests/rseq/param_test.c
> index 2f37961240ca..48a55d94eb72 100644
> --- a/tools/testing/selftests/rseq/param_test.c
> +++ b/tools/testing/selftests/rseq/param_test.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: LGPL-2.1
> -#define _GNU_SOURCE
> #include <assert.h>
> #include <linux/membarrier.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c
> index 96e812bdf8a4..88602889414c 100644
> --- a/tools/testing/selftests/rseq/rseq.c
> +++ b/tools/testing/selftests/rseq/rseq.c
> @@ -14,8 +14,6 @@
> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> * Lesser General Public License for more details.
> */
> -
> -#define _GNU_SOURCE
> #include <errno.h>
> #include <sched.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> index b83099160fbc..3632a4890da9 100644
> --- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
> +++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
> @@ -2,7 +2,6 @@
> * Strictly speaking, this is not a test. But it can report during test
> * runs so relative performace can be measured.
> */
> -#define _GNU_SOURCE
> #include <assert.h>
> #include <err.h>
> #include <limits.h>
> diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
> index 783ebce8c4de..972ccc12553e 100644
> --- a/tools/testing/selftests/seccomp/seccomp_bpf.c
> +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
> @@ -4,8 +4,6 @@
> *
> * Test code for seccomp bpf.
> */
> -
> -#define _GNU_SOURCE
> #include <sys/types.h>
>
> /*
> diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c
> index 7288a05136ba..a1f156dbbd56 100644
> --- a/tools/testing/selftests/user_events/abi_test.c
> +++ b/tools/testing/selftests/user_events/abi_test.c
> @@ -4,8 +4,6 @@
> *
> * Copyright (c) 2022 Beau Belgrave <beaub@linux.microsoft.com>
> */
> -
> -#define _GNU_SOURCE
> #include <sched.h>
>
> #include <errno.h>
> diff --git a/tools/testing/selftests/x86/amx.c b/tools/testing/selftests/x86/amx.c
> index d884fd69dd51..9441635fc452 100644
> --- a/tools/testing/selftests/x86/amx.c
> +++ b/tools/testing/selftests/x86/amx.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -
> -#define _GNU_SOURCE
> #include <err.h>
> #include <errno.h>
> #include <pthread.h>
> diff --git a/tools/testing/selftests/x86/check_initial_reg_state.c b/tools/testing/selftests/x86/check_initial_reg_state.c
> index 3bc95f3ed585..0129cdae8abe 100644
> --- a/tools/testing/selftests/x86/check_initial_reg_state.c
> +++ b/tools/testing/selftests/x86/check_initial_reg_state.c
> @@ -3,9 +3,6 @@
> * check_initial_reg_state.c - check that execve sets the correct state
> * Copyright (c) 2014-2016 Andrew Lutomirski
> */
> -
> -#define _GNU_SOURCE
> -
> #include <stdio.h>
>
> unsigned long ax, bx, cx, dx, si, di, bp, sp, flags;
> diff --git a/tools/testing/selftests/x86/corrupt_xstate_header.c b/tools/testing/selftests/x86/corrupt_xstate_header.c
> index cf9ce8fbb656..d2c746149678 100644
> --- a/tools/testing/selftests/x86/corrupt_xstate_header.c
> +++ b/tools/testing/selftests/x86/corrupt_xstate_header.c
> @@ -4,9 +4,6 @@
> *
> * Based on analysis and a test case from Thomas Gleixner.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/x86/entry_from_vm86.c b/tools/testing/selftests/x86/entry_from_vm86.c
> index d1e919b0c1dc..9fa9d4a847ac 100644
> --- a/tools/testing/selftests/x86/entry_from_vm86.c
> +++ b/tools/testing/selftests/x86/entry_from_vm86.c
> @@ -5,9 +5,6 @@
> *
> * This exercises a few paths that need to special-case vm86 mode.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <assert.h>
> #include <stdlib.h>
> #include <sys/syscall.h>
> diff --git a/tools/testing/selftests/x86/fsgsbase.c b/tools/testing/selftests/x86/fsgsbase.c
> index 8c780cce941d..348134d2cefc 100644
> --- a/tools/testing/selftests/x86/fsgsbase.c
> +++ b/tools/testing/selftests/x86/fsgsbase.c
> @@ -3,8 +3,6 @@
> * fsgsbase.c, an fsgsbase test
> * Copyright (c) 2014-2016 Andy Lutomirski
> */
> -
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/x86/fsgsbase_restore.c b/tools/testing/selftests/x86/fsgsbase_restore.c
> index 6fffadc51579..88dce47ab8e6 100644
> --- a/tools/testing/selftests/x86/fsgsbase_restore.c
> +++ b/tools/testing/selftests/x86/fsgsbase_restore.c
> @@ -12,8 +12,6 @@
> *
> * This is not part of fsgsbase.c, because that test is 64-bit only.
> */
> -
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/x86/ioperm.c b/tools/testing/selftests/x86/ioperm.c
> index 57ec5e99edb9..07b7c10f8d39 100644
> --- a/tools/testing/selftests/x86/ioperm.c
> +++ b/tools/testing/selftests/x86/ioperm.c
> @@ -3,8 +3,6 @@
> * ioperm.c - Test case for ioperm(2)
> * Copyright (c) 2015 Andrew Lutomirski
> */
> -
> -#define _GNU_SOURCE
> #include <err.h>
> #include <stdio.h>
> #include <stdint.h>
> diff --git a/tools/testing/selftests/x86/iopl.c b/tools/testing/selftests/x86/iopl.c
> index 7e3e09c1abac..baa691154905 100644
> --- a/tools/testing/selftests/x86/iopl.c
> +++ b/tools/testing/selftests/x86/iopl.c
> @@ -3,8 +3,6 @@
> * iopl.c - Test case for a Linux on Xen 64-bit bug
> * Copyright (c) 2015 Andrew Lutomirski
> */
> -
> -#define _GNU_SOURCE
> #include <err.h>
> #include <stdio.h>
> #include <stdint.h>
> diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c
> index 215b8150b7cc..39edfd7f6037 100644
> --- a/tools/testing/selftests/x86/lam.c
> +++ b/tools/testing/selftests/x86/lam.c
> @@ -1,5 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
> index 3a29346e1452..3b4237a85a12 100644
> --- a/tools/testing/selftests/x86/ldt_gdt.c
> +++ b/tools/testing/selftests/x86/ldt_gdt.c
> @@ -3,8 +3,6 @@
> * ldt_gdt.c - Test cases for LDT and GDT access
> * Copyright (c) 2015 Andrew Lutomirski
> */
> -
> -#define _GNU_SOURCE
> #include <err.h>
> #include <stdio.h>
> #include <stdint.h>
> diff --git a/tools/testing/selftests/x86/mov_ss_trap.c b/tools/testing/selftests/x86/mov_ss_trap.c
> index cc3de6ff9fba..47ecc63220b7 100644
> --- a/tools/testing/selftests/x86/mov_ss_trap.c
> +++ b/tools/testing/selftests/x86/mov_ss_trap.c
> @@ -19,8 +19,6 @@
> *
> * This should mostly cover CVE-2018-1087 and CVE-2018-8897.
> */
> -#define _GNU_SOURCE
> -
> #include <stdlib.h>
> #include <sys/ptrace.h>
> #include <sys/types.h>
> diff --git a/tools/testing/selftests/x86/nx_stack.c b/tools/testing/selftests/x86/nx_stack.c
> index ea4a4e246879..97c5b34096cc 100644
> --- a/tools/testing/selftests/x86/nx_stack.c
> +++ b/tools/testing/selftests/x86/nx_stack.c
> @@ -23,8 +23,6 @@
> * Regular stack is completely overwritten before testing.
> * Test doesn't exit SIGSEGV handler after first fault at INT3.
> */
> -#undef _GNU_SOURCE
> -#define _GNU_SOURCE
> #undef NDEBUG
> #include <assert.h>
> #include <signal.h>
> diff --git a/tools/testing/selftests/x86/ptrace_syscall.c b/tools/testing/selftests/x86/ptrace_syscall.c
> index 12aaa063196e..bdc81c8bd1a7 100644
> --- a/tools/testing/selftests/x86/ptrace_syscall.c
> +++ b/tools/testing/selftests/x86/ptrace_syscall.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#define _GNU_SOURCE
> -
> #include <sys/ptrace.h>
> #include <sys/types.h>
> #include <sys/wait.h>
> diff --git a/tools/testing/selftests/x86/sigaltstack.c b/tools/testing/selftests/x86/sigaltstack.c
> index f689af75e979..7f41c3a4268b 100644
> --- a/tools/testing/selftests/x86/sigaltstack.c
> +++ b/tools/testing/selftests/x86/sigaltstack.c
> @@ -1,6 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0-only
> -
> -#define _GNU_SOURCE
> #include <signal.h>
> #include <stdio.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/x86/sigreturn.c b/tools/testing/selftests/x86/sigreturn.c
> index 5d7961a5f7f6..2054f729b2c2 100644
> --- a/tools/testing/selftests/x86/sigreturn.c
> +++ b/tools/testing/selftests/x86/sigreturn.c
> @@ -24,9 +24,6 @@
> *
> * Do not run on outdated, unpatched kernels at risk of nasty crashes.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <sys/time.h>
> #include <time.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/x86/single_step_syscall.c b/tools/testing/selftests/x86/single_step_syscall.c
> index 9a30f443e928..375f3b50a0b5 100644
> --- a/tools/testing/selftests/x86/single_step_syscall.c
> +++ b/tools/testing/selftests/x86/single_step_syscall.c
> @@ -9,9 +9,6 @@
> * immediately issues #DB from CPL 0. This requires special handling in
> * the kernel.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <sys/time.h>
> #include <time.h>
> #include <stdlib.h>
> diff --git a/tools/testing/selftests/x86/syscall_arg_fault.c b/tools/testing/selftests/x86/syscall_arg_fault.c
> index 461fa41a4d02..10eee1bcd015 100644
> --- a/tools/testing/selftests/x86/syscall_arg_fault.c
> +++ b/tools/testing/selftests/x86/syscall_arg_fault.c
> @@ -3,9 +3,6 @@
> * syscall_arg_fault.c - tests faults 32-bit fast syscall stack args
> * Copyright (c) 2015 Andrew Lutomirski
> */
> -
> -#define _GNU_SOURCE
> -
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/x86/syscall_numbering.c b/tools/testing/selftests/x86/syscall_numbering.c
> index 991591718bb0..c72fc8aaa4d3 100644
> --- a/tools/testing/selftests/x86/syscall_numbering.c
> +++ b/tools/testing/selftests/x86/syscall_numbering.c
> @@ -5,9 +5,6 @@
> *
> * Copyright (c) 2018 Andrew Lutomirski
> */
> -
> -#define _GNU_SOURCE
> -
> #include <stdlib.h>
> #include <stdio.h>
> #include <stdbool.h>
> diff --git a/tools/testing/selftests/x86/sysret_rip.c b/tools/testing/selftests/x86/sysret_rip.c
> index 84d74be1d902..24bc219358a5 100644
> --- a/tools/testing/selftests/x86/sysret_rip.c
> +++ b/tools/testing/selftests/x86/sysret_rip.c
> @@ -3,9 +3,6 @@
> * sigreturn.c - tests that x86 avoids Intel SYSRET pitfalls
> * Copyright (c) 2014-2016 Andrew Lutomirski
> */
> -
> -#define _GNU_SOURCE
> -
> #include <stdlib.h>
> #include <unistd.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/x86/sysret_ss_attrs.c b/tools/testing/selftests/x86/sysret_ss_attrs.c
> index 5f3d4fca440f..f8b9e0b2a0c5 100644
> --- a/tools/testing/selftests/x86/sysret_ss_attrs.c
> +++ b/tools/testing/selftests/x86/sysret_ss_attrs.c
> @@ -7,9 +7,6 @@
> * the hidden attributes set to an unusable state. Make sure the kernel
> * doesn't let this happen.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <stdlib.h>
> #include <unistd.h>
> #include <stdio.h>
> diff --git a/tools/testing/selftests/x86/test_FCMOV.c b/tools/testing/selftests/x86/test_FCMOV.c
> index 6b5036fbb735..0c9431ba7d31 100644
> --- a/tools/testing/selftests/x86/test_FCMOV.c
> +++ b/tools/testing/selftests/x86/test_FCMOV.c
> @@ -1,8 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#undef _GNU_SOURCE
> -#define _GNU_SOURCE 1
> -#undef __USE_GNU
> -#define __USE_GNU 1
> #include <unistd.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/x86/test_FCOMI.c b/tools/testing/selftests/x86/test_FCOMI.c
> index aec6692c6dcf..ba186665918d 100644
> --- a/tools/testing/selftests/x86/test_FCOMI.c
> +++ b/tools/testing/selftests/x86/test_FCOMI.c
> @@ -1,8 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#undef _GNU_SOURCE
> -#define _GNU_SOURCE 1
> -#undef __USE_GNU
> -#define __USE_GNU 1
> #include <unistd.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/x86/test_FISTTP.c b/tools/testing/selftests/x86/test_FISTTP.c
> index 09789c0ce3e9..95580cdaaa32 100644
> --- a/tools/testing/selftests/x86/test_FISTTP.c
> +++ b/tools/testing/selftests/x86/test_FISTTP.c
> @@ -1,8 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> -#undef _GNU_SOURCE
> -#define _GNU_SOURCE 1
> -#undef __USE_GNU
> -#define __USE_GNU 1
> #include <unistd.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/x86/test_mremap_vdso.c b/tools/testing/selftests/x86/test_mremap_vdso.c
> index f0d876d48277..a8bdba356682 100644
> --- a/tools/testing/selftests/x86/test_mremap_vdso.c
> +++ b/tools/testing/selftests/x86/test_mremap_vdso.c
> @@ -9,7 +9,6 @@
> * Can be built statically:
> * gcc -Os -Wall -static -m32 test_mremap_vdso.c
> */
> -#define _GNU_SOURCE
> #include <stdio.h>
> #include <errno.h>
> #include <unistd.h>
> diff --git a/tools/testing/selftests/x86/test_shadow_stack.c b/tools/testing/selftests/x86/test_shadow_stack.c
> index 757e6527f67e..0ceca9064cec 100644
> --- a/tools/testing/selftests/x86/test_shadow_stack.c
> +++ b/tools/testing/selftests/x86/test_shadow_stack.c
> @@ -7,9 +7,6 @@
> * special glibc shadow stack support (longjmp(), swapcontext(), etc). Just
> * stick to the basics and hope the compiler doesn't do anything strange.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <sys/syscall.h>
> #include <asm/mman.h>
> #include <sys/mman.h>
> diff --git a/tools/testing/selftests/x86/test_syscall_vdso.c b/tools/testing/selftests/x86/test_syscall_vdso.c
> index 8965c311bd65..5cd13279bba5 100644
> --- a/tools/testing/selftests/x86/test_syscall_vdso.c
> +++ b/tools/testing/selftests/x86/test_syscall_vdso.c
> @@ -8,10 +8,6 @@
> * Can be built statically:
> * gcc -Os -Wall -static -m32 test_syscall_vdso.c thunks_32.S
> */
> -#undef _GNU_SOURCE
> -#define _GNU_SOURCE 1
> -#undef __USE_GNU
> -#define __USE_GNU 1
> #include <unistd.h>
> #include <stdlib.h>
> #include <string.h>
> diff --git a/tools/testing/selftests/x86/test_vsyscall.c b/tools/testing/selftests/x86/test_vsyscall.c
> index 47cab972807c..cbf4e5012005 100644
> --- a/tools/testing/selftests/x86/test_vsyscall.c
> +++ b/tools/testing/selftests/x86/test_vsyscall.c
> @@ -1,7 +1,4 @@
> /* SPDX-License-Identifier: GPL-2.0 */
> -
> -#define _GNU_SOURCE
> -
> #include <stdio.h>
> #include <sys/time.h>
> #include <time.h>
> diff --git a/tools/testing/selftests/x86/unwind_vdso.c b/tools/testing/selftests/x86/unwind_vdso.c
> index 4c311e1af4c7..754f5d4d425a 100644
> --- a/tools/testing/selftests/x86/unwind_vdso.c
> +++ b/tools/testing/selftests/x86/unwind_vdso.c
> @@ -5,9 +5,6 @@
> *
> * This tests __kernel_vsyscall's unwind info.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <features.h>
> #include <stdio.h>
>
> diff --git a/tools/testing/selftests/x86/vdso_restorer.c b/tools/testing/selftests/x86/vdso_restorer.c
> index fe99f2434155..8193de22a390 100644
> --- a/tools/testing/selftests/x86/vdso_restorer.c
> +++ b/tools/testing/selftests/x86/vdso_restorer.c
> @@ -10,9 +10,6 @@
> * 64-bit userspace has never supported sa_restorer == NULL, so this is
> * 32-bit only.
> */
> -
> -#define _GNU_SOURCE
> -
> #include <err.h>
> #include <stdio.h>
> #include <dlfcn.h>
--
BR,
Muhammad Usama Anjum
^ permalink raw reply
* Re: [PATCH v2 2/5] selftests/sgx: Include KHDR_INCLUDES in Makefile
From: Muhammad Usama Anjum @ 2024-05-08 7:49 UTC (permalink / raw)
To: Edward Liaw, shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Catalin Marinas, Will Deacon, Nhat Pham, Johannes Weiner,
Christian Brauner, Eric Biederman, Kees Cook, OGAWA Hirofumi,
Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
Davidlohr Bueso, André Almeida, Jiri Kosina,
Benjamin Tissoires, Jason Gunthorpe, Kevin Tian, Andy Lutomirski,
Will Drewry, Marc Zyngier, Oliver Upton, James Morse,
Suzuki K Poulose, Zenghui Yu, Paolo Bonzini, Sean Christopherson,
Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen
Cc: Muhammad Usama Anjum, linux-kernel, linux-kselftest, kernel-team,
linux-sound, linux-arm-kernel, linux-mm, linux-input, iommu,
kvmarm, kvm, kvm-riscv, linux-riscv, linux-security-module,
linux-fsdevel, netdev, linux-actions, mptcp, linux-rtc, linux-sgx,
bpf, kernel test robot
In-Reply-To: <20240507214254.2787305-3-edliaw@google.com>
On 5/8/24 2:38 AM, Edward Liaw wrote:
> Add KHDR_INCLUDES to the CFLAGS to pull in the kselftest harness
> dependencies (-D_GNU_SOURCE).
>
> Also, remove redefinitions of _GNU_SOURCE in the source code.
>
> Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202404301040.3bea5782-oliver.sang@intel.com
> Signed-off-by: Edward Liaw <edliaw@google.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> tools/testing/selftests/sgx/Makefile | 2 +-
> tools/testing/selftests/sgx/sigstruct.c | 1 -
> 2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/sgx/Makefile b/tools/testing/selftests/sgx/Makefile
> index 867f88ce2570..26ea30fae23c 100644
> --- a/tools/testing/selftests/sgx/Makefile
> +++ b/tools/testing/selftests/sgx/Makefile
> @@ -12,7 +12,7 @@ OBJCOPY := $(CROSS_COMPILE)objcopy
> endif
>
> INCLUDES := -I$(top_srcdir)/tools/include
> -HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) -fPIC
> +HOST_CFLAGS := -Wall -Werror $(KHDR_INCLUDES) -g $(INCLUDES) -fPIC
> HOST_LDFLAGS := -z noexecstack -lcrypto
> ENCL_CFLAGS += -Wall -Werror -static-pie -nostdlib -ffreestanding -fPIE \
> -fno-stack-protector -mrdrnd $(INCLUDES)
> diff --git a/tools/testing/selftests/sgx/sigstruct.c b/tools/testing/selftests/sgx/sigstruct.c
> index d73b29becf5b..200034a0fee5 100644
> --- a/tools/testing/selftests/sgx/sigstruct.c
> +++ b/tools/testing/selftests/sgx/sigstruct.c
> @@ -1,7 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0
> /* Copyright(c) 2016-20 Intel Corporation. */
>
> -#define _GNU_SOURCE
> #include <assert.h>
> #include <getopt.h>
> #include <stdbool.h>
--
BR,
Muhammad Usama Anjum
^ permalink raw reply
* Re: [PATCH v2 1/5] selftests: Compile kselftest headers with -D_GNU_SOURCE
From: Muhammad Usama Anjum @ 2024-05-08 7:48 UTC (permalink / raw)
To: Edward Liaw, shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Catalin Marinas, Will Deacon, Nhat Pham, Johannes Weiner,
Christian Brauner, Eric Biederman, Kees Cook, OGAWA Hirofumi,
Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
Davidlohr Bueso, André Almeida, Jiri Kosina,
Benjamin Tissoires, Jason Gunthorpe, Kevin Tian, Andy Lutomirski,
Will Drewry, Marc Zyngier, Oliver Upton, James Morse,
Suzuki K Poulose, Zenghui Yu, Paolo Bonzini, Sean Christopherson,
Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen
Cc: Muhammad Usama Anjum, linux-kernel, linux-kselftest, kernel-team,
linux-sound, linux-arm-kernel, linux-mm, linux-input, iommu,
kvmarm, kvm, kvm-riscv, linux-riscv, linux-security-module,
linux-fsdevel, netdev, linux-actions, mptcp, linux-rtc, linux-sgx,
bpf, kernel test robot
In-Reply-To: <20240507214254.2787305-2-edliaw@google.com>
Thanks for patches
On 5/8/24 2:38 AM, Edward Liaw wrote:
> Add the -D_GNU_SOURCE flag to KHDR_INCLUDES so that it is defined in a
> central location.
>
> 809216233555 ("selftests/harness: remove use of LINE_MAX") introduced
> asprintf into kselftest_harness.h, which is a GNU extension and needs
> _GNU_SOURCE to either be defined prior to including headers or with the
> -D_GNU_SOURCE flag passed to the compiler.
>
> Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202404301040.3bea5782-oliver.sang@intel.com
> Signed-off-by: Edward Liaw <edliaw@google.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> tools/testing/selftests/Makefile | 4 ++--
> tools/testing/selftests/kselftest_harness.h | 2 +-
> tools/testing/selftests/lib.mk | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index e1504833654d..ed012a7f0786 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -161,11 +161,11 @@ ifneq ($(KBUILD_OUTPUT),)
> # $(realpath ...) resolves symlinks
> abs_objtree := $(realpath $(abs_objtree))
> BUILD := $(abs_objtree)/kselftest
> - KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
> + KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
> else
> BUILD := $(CURDIR)
> abs_srctree := $(shell cd $(top_srcdir) && pwd)
> - KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
> + KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
> DEFAULT_INSTALL_HDR_PATH := 1
> endif
>
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index d98702b6955d..b2a1b6343896 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -51,7 +51,7 @@
> #define __KSELFTEST_HARNESS_H
>
> #ifndef _GNU_SOURCE
> -#define _GNU_SOURCE
> +static_assert(0, "kselftest harness requires _GNU_SOURCE to be defined");
> #endif
> #include <asm/types.h>
> #include <ctype.h>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index da2cade3bab0..2503dc732b4d 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -45,7 +45,7 @@ selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
> top_srcdir = $(selfdir)/../../..
>
> ifeq ($(KHDR_INCLUDES),)
> -KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
> +KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
> endif
>
> # The following are built by lib.mk common compile rules.
--
BR,
Muhammad Usama Anjum
^ permalink raw reply
* Re: [PATCH v2 3/7] dt-bindings: HID: i2c-hid: elan: add 'no-reset-on-power-off' property
From: Krzysztof Kozlowski @ 2024-05-08 7:29 UTC (permalink / raw)
To: Johan Hovold, Jiri Kosina, Benjamin Tissoires, Bjorn Andersson
Cc: Dmitry Torokhov, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Konrad Dybcio, Linus Walleij, Douglas Anderson, linux-input,
devicetree, linux-arm-msm, linux-kernel
In-Reply-To: <20240507144821.12275-4-johan+linaro@kernel.org>
On 07/05/2024 16:48, Johan Hovold wrote:
> When the power supply is shared with other peripherals the reset line
> can be wired in such a way that it can remain deasserted regardless of
> whether the supply is on or not.
>
> This is important as it can be used to avoid holding the controller in
> reset for extended periods of time when it remains powered, something
> which can lead to increased power consumption. Leaving reset deasserted
> also avoids leaking current through the reset circuitry pull-up
> resistors.
>
> Add a new 'no-reset-on-power-off' devicetree property which can be used
> by the OS to determine when reset needs to be asserted on power down.
>
> Note that this property can also be used when the supply cannot be
> turned off by the OS at all.
>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply
* Re: [PATCH] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers
From: Mark Brown @ 2024-05-08 2:37 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Jeff LaBundy, Hans de Goede, Charles Wang, hadess, Richard Hughes,
linux-input, linux-kernel, neil.armstrong
In-Reply-To: <ZjqYp1oxPPWcF3jW@google.com>
[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]
On Tue, May 07, 2024 at 02:09:59PM -0700, Dmitry Torokhov wrote:
> On Tue, May 07, 2024 at 10:14:28AM -0500, Jeff LaBundy wrote:
> > For example, many devices must be placed in a bootloader mode during
> > the FW update, and may clamp or toggle an interrupt pin during this
> > mode switch. If user space initiates this sequence while the driver is
> > unaware of this process, it may attempt to read status registers from
> > an I2C address that is temporarily offline.
> And yet we have i2c-dev and hidraw that are often successfully used to
> flash the firmware, do diagnostics, etc. without encumbering the kernel.
Yeah, those seem like a reasonable enough model for safer devices - they
do the exclusion thing so you don't have a real driver running at the
same time. For things like PMICs there's some concerns of course.
The other model I've seen used BTW is to expose a MTD device, if the
device actually looks like a MTD device (perhaps even is just a flash
that's fairly directly exposed) that minimises the kernel code quite
well.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH v2 0/5] Define _GNU_SOURCE for sources using
From: Kees Cook @ 2024-05-07 23:28 UTC (permalink / raw)
To: Edward Liaw
Cc: shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
Will Deacon, Nhat Pham, Johannes Weiner, Christian Brauner,
Eric Biederman, OGAWA Hirofumi, Thomas Gleixner, Ingo Molnar,
Peter Zijlstra, Darren Hart, Davidlohr Bueso, André Almeida,
Jiri Kosina, Benjamin Tissoires, Jason Gunthorpe, Kevin Tian,
Andy Lutomirski, Will Drewry, Marc Zyngier, Oliver Upton,
James Morse, Suzuki K Poulose, Zenghui Yu, Paolo Bonzini,
Sean Christopherson, Anup Patel, Atish Patra, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Christian Borntraeger, Janosch Frank,
Claudio Imbrenda, David Hildenbrand, Mickaël Salaün,
Paul Moore, James Morris, Serge E. Hallyn, Andrew Morton,
Seth Forshee, Bongsu Jeon, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Steffen Klassert, Herbert Xu,
Andreas Färber, Manivannan Sadhasivam, Matthieu Baerts,
Mat Martineau, Geliang Tang, Willem de Bruijn, Fenghua Yu,
Reinette Chatre, Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen,
Muhammad Usama Anjum, linux-kernel, linux-kselftest, kernel-team,
linux-sound, linux-arm-kernel, linux-mm, linux-input, iommu,
kvmarm, kvm, kvm-riscv, linux-riscv, linux-security-module,
linux-fsdevel, netdev, linux-actions, mptcp, linux-rtc, linux-sgx,
bpf
In-Reply-To: <20240507214254.2787305-1-edliaw@google.com>
On Tue, May 07, 2024 at 09:38:25PM +0000, Edward Liaw wrote:
> 809216233555 ("selftests/harness: remove use of LINE_MAX") introduced
> asprintf into kselftest_harness.h, which is a GNU extension and needs
> _GNU_SOURCE to either be defined prior to including headers or with the
> -D_GNU_SOURCE flag passed to the compiler.
>
> v1: https://lore.kernel.org/linux-kselftest/20240430235057.1351993-1-edliaw@google.com/
> v2: add -D_GNU_SOURCE to KHDR_INCLUDES so that it is in a single
> location. Remove #define _GNU_SOURCE from source code to resolve
> redefinition warnings.
>
> Edward Liaw (5):
> selftests: Compile kselftest headers with -D_GNU_SOURCE
> selftests/sgx: Include KHDR_INCLUDES in Makefile
> selftests: Include KHDR_INCLUDES in Makefile
> selftests: Drop define _GNU_SOURCE
> selftests: Drop duplicate -D_GNU_SOURCE
It's a lot of churn, but I don't see a way to do it differently. :)
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply
* [PATCH AUTOSEL 6.6 16/43] Input: xpad - add support for ASUS ROG RAIKIRI
From: Sasha Levin @ 2024-05-07 23:09 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Vicki Pfau, Dmitry Torokhov, Sasha Levin, appsforartists,
maxwell.nguyen, carl.ng, swyterzone, slouken, christophe.jaillet,
linux-input
In-Reply-To: <20240507231033.393285-1-sashal@kernel.org>
From: Vicki Pfau <vi@endrift.com>
[ Upstream commit be81415a32ef6d8a8a85529fcfac03d05b3e757d ]
Add the VID/PID for ASUS ROG RAIKIRI to xpad_device and the VID to xpad_table
Signed-off-by: Vicki Pfau <vi@endrift.com>
Link: https://lore.kernel.org/r/20240404035345.159643-1-vi@endrift.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/input/joystick/xpad.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 9206253422016..cd97a7a9f812d 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -207,6 +207,7 @@ static const struct xpad_device {
{ 0x0738, 0xcb29, "Saitek Aviator Stick AV8R02", 0, XTYPE_XBOX360 },
{ 0x0738, 0xf738, "Super SFIV FightStick TE S", 0, XTYPE_XBOX360 },
{ 0x07ff, 0xffff, "Mad Catz GamePad", 0, XTYPE_XBOX360 },
+ { 0x0b05, 0x1a38, "ASUS ROG RAIKIRI", 0, XTYPE_XBOXONE },
{ 0x0c12, 0x0005, "Intec wireless", 0, XTYPE_XBOX },
{ 0x0c12, 0x8801, "Nyko Xbox Controller", 0, XTYPE_XBOX },
{ 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
@@ -482,6 +483,7 @@ static const struct usb_device_id xpad_table[] = {
{ USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */
XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */
XPAD_XBOX360_VENDOR(0x07ff), /* Mad Catz Gamepad */
+ XPAD_XBOXONE_VENDOR(0x0b05), /* ASUS controllers */
XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */
XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f Xbox 360 controllers */
XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f Xbox One controllers */
--
2.43.0
^ permalink raw reply related
* [PATCH AUTOSEL 6.8 34/52] Input: amimouse - mark driver struct with __refdata to prevent section mismatch
From: Sasha Levin @ 2024-05-07 23:07 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Uwe Kleine-König, Dmitry Torokhov, Sasha Levin, linux-input
In-Reply-To: <20240507230800.392128-1-sashal@kernel.org>
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
[ Upstream commit 0537c8eef4f699aacdeb67c6181c66cccd63c7f5 ]
As described in the added code comment, a reference to .exit.text is ok
for drivers registered via module_platform_driver_probe(). Make this
explicit to prevent the following section mismatch warning
WARNING: modpost: drivers/input/mouse/amimouse: section mismatch in reference: amimouse_driver+0x8 (section: .data) -> amimouse_remove (section: .exit.text)
that triggers on an allmodconfig W=1 build.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/2e3783106bf6bd9a7bdeb12b706378fb16316471.1711748999.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/input/mouse/amimouse.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/input/mouse/amimouse.c b/drivers/input/mouse/amimouse.c
index cda0c3ff5a288..2fbbaeb76d708 100644
--- a/drivers/input/mouse/amimouse.c
+++ b/drivers/input/mouse/amimouse.c
@@ -132,7 +132,13 @@ static void __exit amimouse_remove(struct platform_device *pdev)
input_unregister_device(dev);
}
-static struct platform_driver amimouse_driver = {
+/*
+ * amimouse_remove() lives in .exit.text. For drivers registered via
+ * module_platform_driver_probe() this is ok because they cannot get unbound at
+ * runtime. So mark the driver struct with __refdata to prevent modpost
+ * triggering a section mismatch warning.
+ */
+static struct platform_driver amimouse_driver __refdata = {
.remove_new = __exit_p(amimouse_remove),
.driver = {
.name = "amiga-mouse",
--
2.43.0
^ permalink raw reply related
* [PATCH AUTOSEL 6.8 19/52] Input: xpad - add support for ASUS ROG RAIKIRI
From: Sasha Levin @ 2024-05-07 23:06 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Vicki Pfau, Dmitry Torokhov, Sasha Levin, maxwell.nguyen, carl.ng,
appsforartists, swyterzone, luca, christophe.jaillet, linux-input
In-Reply-To: <20240507230800.392128-1-sashal@kernel.org>
From: Vicki Pfau <vi@endrift.com>
[ Upstream commit be81415a32ef6d8a8a85529fcfac03d05b3e757d ]
Add the VID/PID for ASUS ROG RAIKIRI to xpad_device and the VID to xpad_table
Signed-off-by: Vicki Pfau <vi@endrift.com>
Link: https://lore.kernel.org/r/20240404035345.159643-1-vi@endrift.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/input/joystick/xpad.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 1fad51b51b0e1..c2de2f063cb8d 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -207,6 +207,7 @@ static const struct xpad_device {
{ 0x0738, 0xcb29, "Saitek Aviator Stick AV8R02", 0, XTYPE_XBOX360 },
{ 0x0738, 0xf738, "Super SFIV FightStick TE S", 0, XTYPE_XBOX360 },
{ 0x07ff, 0xffff, "Mad Catz GamePad", 0, XTYPE_XBOX360 },
+ { 0x0b05, 0x1a38, "ASUS ROG RAIKIRI", 0, XTYPE_XBOXONE },
{ 0x0c12, 0x0005, "Intec wireless", 0, XTYPE_XBOX },
{ 0x0c12, 0x8801, "Nyko Xbox Controller", 0, XTYPE_XBOX },
{ 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
@@ -482,6 +483,7 @@ static const struct usb_device_id xpad_table[] = {
{ USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */
XPAD_XBOXONE_VENDOR(0x0738), /* Mad Catz FightStick TE 2 */
XPAD_XBOX360_VENDOR(0x07ff), /* Mad Catz Gamepad */
+ XPAD_XBOXONE_VENDOR(0x0b05), /* ASUS controllers */
XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */
XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f Xbox 360 controllers */
XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f Xbox One controllers */
--
2.43.0
^ permalink raw reply related
* [PATCH AUTOSEL 6.6 05/19] HID: mcp-2221: cancel delayed_work only when CONFIG_IIO is enabled
From: Sasha Levin @ 2024-05-07 22:58 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Abdelrahman Morsy, Jiri Kosina, Sasha Levin, gupt21, jikos,
bentiss, linux-i2c, linux-input
In-Reply-To: <20240507225910.390914-1-sashal@kernel.org>
From: Abdelrahman Morsy <abdelrahmanhesham94@gmail.com>
[ Upstream commit 3cba9cfcc1520a2307a29f6fab887bcfc121c417 ]
If the device is unplugged and CONFIG_IIO is not supported, this will
result in a warning message at kernel/workqueue.
Only cancel delayed work in mcp2221_remove(), when CONFIG_IIO is enabled.
Signed-off-by: Abdelrahman Morsy <abdelrahmanhesham94@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-mcp2221.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index aef0785c91cc2..c5bfca8ac5e6e 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -922,9 +922,11 @@ static void mcp2221_hid_unregister(void *ptr)
/* This is needed to be sure hid_hw_stop() isn't called twice by the subsystem */
static void mcp2221_remove(struct hid_device *hdev)
{
+#if IS_REACHABLE(CONFIG_IIO)
struct mcp2221 *mcp = hid_get_drvdata(hdev);
cancel_delayed_work_sync(&mcp->init_work);
+#endif
}
#if IS_REACHABLE(CONFIG_IIO)
--
2.43.0
^ permalink raw reply related
* [PATCH AUTOSEL 6.8 07/23] HID: mcp-2221: cancel delayed_work only when CONFIG_IIO is enabled
From: Sasha Levin @ 2024-05-07 22:56 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Abdelrahman Morsy, Jiri Kosina, Sasha Levin, gupt21, jikos,
bentiss, linux-i2c, linux-input
In-Reply-To: <20240507225725.390306-1-sashal@kernel.org>
From: Abdelrahman Morsy <abdelrahmanhesham94@gmail.com>
[ Upstream commit 3cba9cfcc1520a2307a29f6fab887bcfc121c417 ]
If the device is unplugged and CONFIG_IIO is not supported, this will
result in a warning message at kernel/workqueue.
Only cancel delayed work in mcp2221_remove(), when CONFIG_IIO is enabled.
Signed-off-by: Abdelrahman Morsy <abdelrahmanhesham94@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-mcp2221.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index f9cceaeffd081..da5ea5a23b087 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -944,9 +944,11 @@ static void mcp2221_hid_unregister(void *ptr)
/* This is needed to be sure hid_hw_stop() isn't called twice by the subsystem */
static void mcp2221_remove(struct hid_device *hdev)
{
+#if IS_REACHABLE(CONFIG_IIO)
struct mcp2221 *mcp = hid_get_drvdata(hdev);
cancel_delayed_work_sync(&mcp->init_work);
+#endif
}
#if IS_REACHABLE(CONFIG_IIO)
--
2.43.0
^ permalink raw reply related
* [PATCH AUTOSEL 6.8 01/23] HID: nintendo: Fix N64 controller being identified as mouse
From: Sasha Levin @ 2024-05-07 22:56 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Nuno Pereira, Jiri Kosina, Sasha Levin, djogorchock, jikos,
bentiss, linux-input
From: Nuno Pereira <nf.pereira@outlook.pt>
[ Upstream commit 8db8c77059e75a0f418b10ede39dd82a9eb031fa ]
This patch is regarding the recent addition of support for the NSO
controllers to hid-nintendo. All controllers are working correctly with the
exception of the N64 controller, which is being identified as a mouse by
udev. This results in the joystick controlling the mouse cursor and the
controller not being detected by games.
The reason for this is because the N64's C buttons have been attributed to
BTN_FORWARD, BTN_BACK, BTN_LEFT, BTN_RIGHT, which are buttons typically
attributed to mice.
This patch changes those buttons to controller buttons, making the
controller be correctly identified as such.
Signed-off-by: Nuno Pereira <nf.pereira@outlook.pt>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-nintendo.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index ccc4032fb2b03..4b2c81b49b80e 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -481,10 +481,10 @@ static const struct joycon_ctlr_button_mapping n64con_button_mappings[] = {
{ BTN_TR, JC_BTN_R, },
{ BTN_TR2, JC_BTN_LSTICK, }, /* ZR */
{ BTN_START, JC_BTN_PLUS, },
- { BTN_FORWARD, JC_BTN_Y, }, /* C UP */
- { BTN_BACK, JC_BTN_ZR, }, /* C DOWN */
- { BTN_LEFT, JC_BTN_X, }, /* C LEFT */
- { BTN_RIGHT, JC_BTN_MINUS, }, /* C RIGHT */
+ { BTN_SELECT, JC_BTN_Y, }, /* C UP */
+ { BTN_X, JC_BTN_ZR, }, /* C DOWN */
+ { BTN_Y, JC_BTN_X, }, /* C LEFT */
+ { BTN_C, JC_BTN_MINUS, }, /* C RIGHT */
{ BTN_MODE, JC_BTN_HOME, },
{ BTN_Z, JC_BTN_CAP, },
{ /* sentinel */ },
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v2 3/5] selftests: Include KHDR_INCLUDES in Makefile
From: Jarkko Sakkinen @ 2024-05-07 22:36 UTC (permalink / raw)
To: Edward Liaw, shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Catalin Marinas, Will Deacon, Nhat Pham, Johannes Weiner,
Christian Brauner, Eric Biederman, Kees Cook, OGAWA Hirofumi,
Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
Davidlohr Bueso, André Almeida, Jiri Kosina,
Benjamin Tissoires, Jason Gunthorpe, Kevin Tian, Andy Lutomirski,
Will Drewry, Marc Zyngier, Oliver Upton, James Morse,
Suzuki K Poulose, Zenghui Yu, Paolo Bonzini, Sean Christopherson,
Anup Patel, Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Dave Hansen, Muhammad Usama Anjum
Cc: linux-kernel, linux-kselftest, kernel-team, linux-sound,
linux-arm-kernel, linux-mm, linux-input, iommu, kvmarm, kvm,
kvm-riscv, linux-riscv, linux-security-module, linux-fsdevel,
netdev, linux-actions, mptcp, linux-rtc, linux-sgx, bpf
In-Reply-To: <20240507214254.2787305-4-edliaw@google.com>
On Wed May 8, 2024 at 12:38 AM EEST, Edward Liaw wrote:
> Add KHDR_INCLUDES to CFLAGS to pull in the kselftest harness
> dependencies (-D_GNU_SOURCE).
>
> Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
> Signed-off-by: Edward Liaw <edliaw@google.com>
Oops, this is not for this patch but for SGX. Pressed D by mistake
in aerch, so for SGX one:
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
^ permalink raw reply
* [PATCH v2 5/5] selftests: Drop duplicate -D_GNU_SOURCE
From: Edward Liaw @ 2024-05-07 21:38 UTC (permalink / raw)
To: shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
Will Deacon, Nhat Pham, Johannes Weiner, Christian Brauner,
Eric Biederman, Kees Cook, OGAWA Hirofumi, Thomas Gleixner,
Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
André Almeida, Jiri Kosina, Benjamin Tissoires,
Jason Gunthorpe, Kevin Tian, Andy Lutomirski, Will Drewry,
Marc Zyngier, Oliver Upton, James Morse, Suzuki K Poulose,
Zenghui Yu, Paolo Bonzini, Sean Christopherson, Anup Patel,
Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen,
Muhammad Usama Anjum, Edward Liaw
Cc: linux-kernel, linux-kselftest, kernel-team, linux-sound,
linux-arm-kernel, linux-mm, linux-input, iommu, kvmarm, kvm,
kvm-riscv, linux-riscv, linux-security-module, linux-fsdevel,
netdev, linux-actions, mptcp, linux-rtc, linux-sgx, bpf
In-Reply-To: <20240507214254.2787305-1-edliaw@google.com>
-D_GNU_SOURCE can be de-duplicated here, as it is added by
KHDR_INCLUDES.
Signed-off-by: Edward Liaw <edliaw@google.com>
---
tools/testing/selftests/futex/functional/Makefile | 2 +-
tools/testing/selftests/iommu/Makefile | 2 --
tools/testing/selftests/net/tcp_ao/Makefile | 2 +-
tools/testing/selftests/resctrl/Makefile | 2 +-
4 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index a392d0917b4e..f79f9bac7918 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
-CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) $(KHDR_INCLUDES)
+CFLAGS := $(CFLAGS) -g -O2 -Wall -pthread $(INCLUDES) $(KHDR_INCLUDES)
LDLIBS := -lpthread -lrt
LOCAL_HDRS := \
diff --git a/tools/testing/selftests/iommu/Makefile b/tools/testing/selftests/iommu/Makefile
index 32c5fdfd0eef..fd6477911f24 100644
--- a/tools/testing/selftests/iommu/Makefile
+++ b/tools/testing/selftests/iommu/Makefile
@@ -2,8 +2,6 @@
CFLAGS += -Wall -O2 -Wno-unused-function
CFLAGS += $(KHDR_INCLUDES)
-CFLAGS += -D_GNU_SOURCE
-
TEST_GEN_PROGS :=
TEST_GEN_PROGS += iommufd
TEST_GEN_PROGS += iommufd_fail_nth
diff --git a/tools/testing/selftests/net/tcp_ao/Makefile b/tools/testing/selftests/net/tcp_ao/Makefile
index 522d991e310e..c608b1ec02e6 100644
--- a/tools/testing/selftests/net/tcp_ao/Makefile
+++ b/tools/testing/selftests/net/tcp_ao/Makefile
@@ -26,7 +26,7 @@ LIB := $(LIBDIR)/libaotst.a
LDLIBS += $(LIB) -pthread
LIBDEPS := lib/aolib.h Makefile
-CFLAGS := -Wall -O2 -g -D_GNU_SOURCE -fno-strict-aliasing
+CFLAGS := -Wall -O2 -g -fno-strict-aliasing
CFLAGS += $(KHDR_INCLUDES)
CFLAGS += -iquote ./lib/ -I ../../../../include/
diff --git a/tools/testing/selftests/resctrl/Makefile b/tools/testing/selftests/resctrl/Makefile
index 2deac2031de9..5073dbc96125 100644
--- a/tools/testing/selftests/resctrl/Makefile
+++ b/tools/testing/selftests/resctrl/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
-CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE
+CFLAGS = -g -Wall -O2 -D_FORTIFY_SOURCE=2
CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := resctrl_tests
--
2.45.0.rc1.225.g2a3ae87e7f-goog
^ permalink raw reply related
* [PATCH v2 4/5] selftests: Drop define _GNU_SOURCE
From: Edward Liaw @ 2024-05-07 21:38 UTC (permalink / raw)
To: shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
Will Deacon, Nhat Pham, Johannes Weiner, Christian Brauner,
Eric Biederman, Kees Cook, OGAWA Hirofumi, Thomas Gleixner,
Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
André Almeida, Jiri Kosina, Benjamin Tissoires,
Jason Gunthorpe, Kevin Tian, Andy Lutomirski, Will Drewry,
Marc Zyngier, Oliver Upton, James Morse, Suzuki K Poulose,
Zenghui Yu, Paolo Bonzini, Sean Christopherson, Anup Patel,
Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen,
Muhammad Usama Anjum, Edward Liaw
Cc: linux-kernel, linux-kselftest, kernel-team, linux-sound,
linux-arm-kernel, linux-mm, linux-input, iommu, kvmarm, kvm,
kvm-riscv, linux-riscv, linux-security-module, linux-fsdevel,
netdev, linux-actions, mptcp, linux-rtc, linux-sgx, bpf
In-Reply-To: <20240507214254.2787305-1-edliaw@google.com>
_GNU_SOURCE is provided by KHDR_INCLUDES, so it should be dropped to
prevent _GNU_SOURCE redefined warnings.
Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Signed-off-by: Edward Liaw <edliaw@google.com>
---
tools/testing/selftests/cachestat/test_cachestat.c | 2 --
tools/testing/selftests/capabilities/test_execve.c | 2 --
tools/testing/selftests/clone3/clone3.c | 2 --
.../testing/selftests/clone3/clone3_cap_checkpoint_restore.c | 2 --
tools/testing/selftests/clone3/clone3_clear_sighand.c | 2 --
tools/testing/selftests/clone3/clone3_selftests.h | 1 -
tools/testing/selftests/clone3/clone3_set_tid.c | 2 --
tools/testing/selftests/core/close_range_test.c | 2 --
tools/testing/selftests/drivers/dma-buf/udmabuf.c | 1 -
tools/testing/selftests/fchmodat2/fchmodat2_test.c | 2 --
tools/testing/selftests/filesystems/binderfs/binderfs_test.c | 2 --
tools/testing/selftests/filesystems/devpts_pts.c | 1 -
tools/testing/selftests/filesystems/dnotify_test.c | 1 -
tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c | 2 --
tools/testing/selftests/filesystems/eventfd/eventfd_test.c | 2 --
tools/testing/selftests/filesystems/fat/rename_exchange.c | 2 --
tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 --
.../testing/selftests/filesystems/statmount/statmount_test.c | 3 ---
tools/testing/selftests/futex/functional/futex_requeue_pi.c | 3 ---
tools/testing/selftests/ipc/msgque.c | 1 -
tools/testing/selftests/kcmp/kcmp_test.c | 2 --
tools/testing/selftests/kvm/aarch64/arch_timer.c | 2 --
tools/testing/selftests/kvm/aarch64/page_fault_test.c | 1 -
tools/testing/selftests/kvm/aarch64/psci_test.c | 3 ---
tools/testing/selftests/kvm/aarch64/vgic_init.c | 1 -
tools/testing/selftests/kvm/arch_timer.c | 3 ---
tools/testing/selftests/kvm/demand_paging_test.c | 3 ---
tools/testing/selftests/kvm/dirty_log_test.c | 3 ---
tools/testing/selftests/kvm/guest_memfd_test.c | 2 --
tools/testing/selftests/kvm/hardware_disable_test.c | 3 ---
tools/testing/selftests/kvm/include/userfaultfd_util.h | 3 ---
tools/testing/selftests/kvm/kvm_binary_stats_test.c | 2 --
tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 2 --
tools/testing/selftests/kvm/kvm_page_table_test.c | 3 ---
tools/testing/selftests/kvm/lib/assert.c | 3 ---
tools/testing/selftests/kvm/lib/kvm_util.c | 2 --
tools/testing/selftests/kvm/lib/memstress.c | 2 --
tools/testing/selftests/kvm/lib/test_util.c | 2 --
tools/testing/selftests/kvm/lib/userfaultfd_util.c | 3 ---
tools/testing/selftests/kvm/lib/x86_64/sev.c | 1 -
tools/testing/selftests/kvm/max_guest_memory_test.c | 2 --
.../testing/selftests/kvm/memslot_modification_stress_test.c | 3 ---
tools/testing/selftests/kvm/riscv/arch_timer.c | 3 ---
tools/testing/selftests/kvm/rseq_test.c | 1 -
tools/testing/selftests/kvm/s390x/cmma_test.c | 2 --
tools/testing/selftests/kvm/s390x/sync_regs_test.c | 2 --
tools/testing/selftests/kvm/set_memory_region_test.c | 1 -
tools/testing/selftests/kvm/steal_time.c | 1 -
tools/testing/selftests/kvm/x86_64/amx_test.c | 2 --
.../selftests/kvm/x86_64/exit_on_emulation_failure_test.c | 3 ---
tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c | 2 --
tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 2 --
tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c | 1 -
tools/testing/selftests/kvm/x86_64/hyperv_ipi.c | 2 --
tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c | 1 -
tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c | 2 --
tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c | 2 --
tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 3 ---
tools/testing/selftests/kvm/x86_64/platform_info_test.c | 2 --
tools/testing/selftests/kvm/x86_64/pmu_counters_test.c | 2 --
tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c | 3 ---
.../selftests/kvm/x86_64/private_mem_conversions_test.c | 1 -
tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c | 1 -
tools/testing/selftests/kvm/x86_64/set_sregs_test.c | 1 -
.../selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c | 3 ---
tools/testing/selftests/kvm/x86_64/smm_test.c | 1 -
tools/testing/selftests/kvm/x86_64/state_test.c | 1 -
tools/testing/selftests/kvm/x86_64/sync_regs_test.c | 2 --
tools/testing/selftests/kvm/x86_64/ucna_injection_test.c | 2 --
tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c | 2 --
tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c | 3 ---
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c | 1 -
.../testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c | 1 -
tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c | 2 --
tools/testing/selftests/kvm/x86_64/xapic_state_test.c | 1 -
tools/testing/selftests/kvm/x86_64/xss_msr_test.c | 2 --
tools/testing/selftests/landlock/base_test.c | 2 --
tools/testing/selftests/landlock/fs_test.c | 2 --
tools/testing/selftests/landlock/net_test.c | 2 --
tools/testing/selftests/landlock/ptrace_test.c | 2 --
tools/testing/selftests/lsm/common.c | 2 --
tools/testing/selftests/lsm/lsm_get_self_attr_test.c | 2 --
tools/testing/selftests/lsm/lsm_list_modules_test.c | 2 --
tools/testing/selftests/lsm/lsm_set_self_attr_test.c | 2 --
tools/testing/selftests/membarrier/membarrier_test_impl.h | 1 -
.../selftests/membarrier/membarrier_test_multi_thread.c | 1 -
.../selftests/membarrier/membarrier_test_single_thread.c | 1 -
tools/testing/selftests/memfd/common.c | 1 -
tools/testing/selftests/memfd/fuse_test.c | 2 --
tools/testing/selftests/memfd/memfd_test.c | 1 -
tools/testing/selftests/mm/cow.c | 1 -
tools/testing/selftests/mm/gup_longterm.c | 1 -
tools/testing/selftests/mm/hugepage-mmap.c | 1 -
tools/testing/selftests/mm/hugepage-mremap.c | 2 --
tools/testing/selftests/mm/hugetlb-madvise.c | 2 --
tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 2 --
tools/testing/selftests/mm/khugepaged.c | 1 -
tools/testing/selftests/mm/ksm_functional_tests.c | 1 -
tools/testing/selftests/mm/madv_populate.c | 1 -
tools/testing/selftests/mm/map_populate.c | 2 --
tools/testing/selftests/mm/mdwe_test.c | 1 -
tools/testing/selftests/mm/memfd_secret.c | 2 --
tools/testing/selftests/mm/mlock2-tests.c | 1 -
tools/testing/selftests/mm/mrelease_test.c | 1 -
tools/testing/selftests/mm/mremap_dontunmap.c | 1 -
tools/testing/selftests/mm/mremap_test.c | 2 --
tools/testing/selftests/mm/pagemap_ioctl.c | 1 -
tools/testing/selftests/mm/pkey-helpers.h | 1 -
tools/testing/selftests/mm/protection_keys.c | 1 -
tools/testing/selftests/mm/split_huge_page_test.c | 2 --
tools/testing/selftests/mm/thuge-gen.c | 2 --
tools/testing/selftests/mm/uffd-common.h | 1 -
tools/testing/selftests/mount_setattr/mount_setattr_test.c | 1 -
.../move_mount_set_group/move_mount_set_group_test.c | 1 -
tools/testing/selftests/net/af_unix/diag_uid.c | 2 --
tools/testing/selftests/net/af_unix/scm_pidfd.c | 1 -
tools/testing/selftests/net/af_unix/unix_connect.c | 2 --
tools/testing/selftests/net/csum.c | 3 ---
tools/testing/selftests/net/gro.c | 3 ---
tools/testing/selftests/net/ip_defrag.c | 3 ---
tools/testing/selftests/net/ipsec.c | 3 ---
tools/testing/selftests/net/ipv6_flowlabel.c | 3 ---
tools/testing/selftests/net/ipv6_flowlabel_mgr.c | 3 ---
tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 ---
tools/testing/selftests/net/mptcp/mptcp_inq.c | 3 ---
tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 3 ---
tools/testing/selftests/net/msg_zerocopy.c | 3 ---
tools/testing/selftests/net/nettest.c | 2 --
tools/testing/selftests/net/psock_fanout.c | 3 ---
tools/testing/selftests/net/psock_snd.c | 3 ---
tools/testing/selftests/net/reuseport_addr_any.c | 3 ---
tools/testing/selftests/net/reuseport_bpf_cpu.c | 3 ---
tools/testing/selftests/net/reuseport_bpf_numa.c | 3 ---
tools/testing/selftests/net/reuseport_dualstack.c | 3 ---
tools/testing/selftests/net/so_incoming_cpu.c | 1 -
tools/testing/selftests/net/so_netns_cookie.c | 1 -
tools/testing/selftests/net/so_txtime.c | 3 ---
tools/testing/selftests/net/tap.c | 3 ---
tools/testing/selftests/net/tcp_fastopen_backup_key.c | 1 -
tools/testing/selftests/net/tcp_inq.c | 2 --
tools/testing/selftests/net/tcp_mmap.c | 1 -
tools/testing/selftests/net/tls.c | 3 ---
tools/testing/selftests/net/toeplitz.c | 3 ---
tools/testing/selftests/net/tun.c | 3 ---
tools/testing/selftests/net/txring_overwrite.c | 3 ---
tools/testing/selftests/net/txtimestamp.c | 3 ---
tools/testing/selftests/net/udpgso.c | 3 ---
tools/testing/selftests/net/udpgso_bench_rx.c | 3 ---
tools/testing/selftests/net/udpgso_bench_tx.c | 3 ---
tools/testing/selftests/perf_events/remove_on_exec.c | 2 --
tools/testing/selftests/perf_events/sigtrap_threads.c | 2 --
tools/testing/selftests/pid_namespace/regression_enomem.c | 1 -
tools/testing/selftests/pidfd/pidfd.h | 1 -
tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_getfd_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_open_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_poll_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_setns_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_wait.c | 2 --
tools/testing/selftests/ptrace/get_set_sud.c | 1 -
tools/testing/selftests/ptrace/peeksiginfo.c | 1 -
tools/testing/selftests/rseq/basic_percpu_ops_test.c | 1 -
tools/testing/selftests/rseq/basic_test.c | 2 --
tools/testing/selftests/rseq/param_test.c | 1 -
tools/testing/selftests/rseq/rseq.c | 2 --
tools/testing/selftests/seccomp/seccomp_benchmark.c | 1 -
tools/testing/selftests/seccomp/seccomp_bpf.c | 2 --
tools/testing/selftests/user_events/abi_test.c | 2 --
tools/testing/selftests/x86/amx.c | 2 --
tools/testing/selftests/x86/check_initial_reg_state.c | 3 ---
| 3 ---
tools/testing/selftests/x86/entry_from_vm86.c | 3 ---
tools/testing/selftests/x86/fsgsbase.c | 2 --
tools/testing/selftests/x86/fsgsbase_restore.c | 2 --
tools/testing/selftests/x86/ioperm.c | 2 --
tools/testing/selftests/x86/iopl.c | 2 --
tools/testing/selftests/x86/lam.c | 1 -
tools/testing/selftests/x86/ldt_gdt.c | 2 --
tools/testing/selftests/x86/mov_ss_trap.c | 2 --
tools/testing/selftests/x86/nx_stack.c | 2 --
tools/testing/selftests/x86/ptrace_syscall.c | 2 --
tools/testing/selftests/x86/sigaltstack.c | 2 --
tools/testing/selftests/x86/sigreturn.c | 3 ---
tools/testing/selftests/x86/single_step_syscall.c | 3 ---
tools/testing/selftests/x86/syscall_arg_fault.c | 3 ---
tools/testing/selftests/x86/syscall_numbering.c | 3 ---
tools/testing/selftests/x86/sysret_rip.c | 3 ---
tools/testing/selftests/x86/sysret_ss_attrs.c | 3 ---
tools/testing/selftests/x86/test_FCMOV.c | 4 ----
tools/testing/selftests/x86/test_FCOMI.c | 4 ----
tools/testing/selftests/x86/test_FISTTP.c | 4 ----
tools/testing/selftests/x86/test_mremap_vdso.c | 1 -
tools/testing/selftests/x86/test_shadow_stack.c | 3 ---
tools/testing/selftests/x86/test_syscall_vdso.c | 4 ----
tools/testing/selftests/x86/test_vsyscall.c | 3 ---
tools/testing/selftests/x86/unwind_vdso.c | 3 ---
tools/testing/selftests/x86/vdso_restorer.c | 3 ---
198 files changed, 405 deletions(-)
diff --git a/tools/testing/selftests/cachestat/test_cachestat.c b/tools/testing/selftests/cachestat/test_cachestat.c
index b171fd53b004..c1a6ce7b0912 100644
--- a/tools/testing/selftests/cachestat/test_cachestat.c
+++ b/tools/testing/selftests/cachestat/test_cachestat.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
#include <stdio.h>
#include <stdbool.h>
#include <linux/kernel.h>
diff --git a/tools/testing/selftests/capabilities/test_execve.c b/tools/testing/selftests/capabilities/test_execve.c
index 7cde07a5df78..e3954b88c3ee 100644
--- a/tools/testing/selftests/capabilities/test_execve.c
+++ b/tools/testing/selftests/capabilities/test_execve.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
#include <cap-ng.h>
#include <linux/capability.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
index 3c9bf0cd82a8..3c5e45dae617 100644
--- a/tools/testing/selftests/clone3/clone3.c
+++ b/tools/testing/selftests/clone3/clone3.c
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/* Based on Christian Brauner's clone3() example */
-
-#define _GNU_SOURCE
#include <errno.h>
#include <inttypes.h>
#include <linux/types.h>
diff --git a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
index 31b56d625655..bb99ea20f7d5 100644
--- a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
+++ b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
@@ -7,8 +7,6 @@
*/
/* capabilities related code based on selftests/bpf/test_verifier.c */
-
-#define _GNU_SOURCE
#include <errno.h>
#include <linux/types.h>
#include <linux/sched.h>
diff --git a/tools/testing/selftests/clone3/clone3_clear_sighand.c b/tools/testing/selftests/clone3/clone3_clear_sighand.c
index 54a8b2445be9..50336d56db6b 100644
--- a/tools/testing/selftests/clone3/clone3_clear_sighand.c
+++ b/tools/testing/selftests/clone3/clone3_clear_sighand.c
@@ -1,6 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
diff --git a/tools/testing/selftests/clone3/clone3_selftests.h b/tools/testing/selftests/clone3/clone3_selftests.h
index 3d2663fe50ba..172e19d5515f 100644
--- a/tools/testing/selftests/clone3/clone3_selftests.h
+++ b/tools/testing/selftests/clone3/clone3_selftests.h
@@ -3,7 +3,6 @@
#ifndef _CLONE3_SELFTESTS_H
#define _CLONE3_SELFTESTS_H
-#define _GNU_SOURCE
#include <sched.h>
#include <linux/sched.h>
#include <linux/types.h>
diff --git a/tools/testing/selftests/clone3/clone3_set_tid.c b/tools/testing/selftests/clone3/clone3_set_tid.c
index ed785afb6077..8b5ed4484ee6 100644
--- a/tools/testing/selftests/clone3/clone3_set_tid.c
+++ b/tools/testing/selftests/clone3/clone3_set_tid.c
@@ -5,8 +5,6 @@
* These tests are assuming to be running in the host's
* PID namespace.
*/
-
-#define _GNU_SOURCE
#include <errno.h>
#include <linux/types.h>
#include <linux/sched.h>
diff --git a/tools/testing/selftests/core/close_range_test.c b/tools/testing/selftests/core/close_range_test.c
index c59e4adb905d..1c2902bcc913 100644
--- a/tools/testing/selftests/core/close_range_test.c
+++ b/tools/testing/selftests/core/close_range_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <linux/kernel.h>
diff --git a/tools/testing/selftests/drivers/dma-buf/udmabuf.c b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
index c812080e304e..7c8dbab8ac44 100644
--- a/tools/testing/selftests/drivers/dma-buf/udmabuf.c
+++ b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#define __EXPORTED_HEADERS__
#include <stdio.h>
diff --git a/tools/testing/selftests/fchmodat2/fchmodat2_test.c b/tools/testing/selftests/fchmodat2/fchmodat2_test.c
index e0319417124d..6b411859c2cd 100644
--- a/tools/testing/selftests/fchmodat2/fchmodat2_test.c
+++ b/tools/testing/selftests/fchmodat2/fchmodat2_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-or-later
-
-#define _GNU_SOURCE
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
index 5f362c0fd890..fca693db1b09 100644
--- a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
+++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/filesystems/devpts_pts.c b/tools/testing/selftests/filesystems/devpts_pts.c
index b1fc9b916ace..73766447eeb0 100644
--- a/tools/testing/selftests/filesystems/devpts_pts.c
+++ b/tools/testing/selftests/filesystems/devpts_pts.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
diff --git a/tools/testing/selftests/filesystems/dnotify_test.c b/tools/testing/selftests/filesystems/dnotify_test.c
index c0a9b2d3302d..05367a70b963 100644
--- a/tools/testing/selftests/filesystems/dnotify_test.c
+++ b/tools/testing/selftests/filesystems/dnotify_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE /* needed to get the defines */
#include <fcntl.h> /* in glibc 2.2 this has the needed
values defined */
#include <signal.h>
diff --git a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
index 65ede506305c..9bc2ddad7e92 100644
--- a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
+++ b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <asm/unistd.h>
#include <linux/time_types.h>
#include <poll.h>
diff --git a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
index f142a137526c..17935f42fbc9 100644
--- a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
+++ b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <asm/unistd.h>
diff --git a/tools/testing/selftests/filesystems/fat/rename_exchange.c b/tools/testing/selftests/filesystems/fat/rename_exchange.c
index e488ad354fce..56cf3ad8640d 100644
--- a/tools/testing/selftests/filesystems/fat/rename_exchange.c
+++ b/tools/testing/selftests/filesystems/fat/rename_exchange.c
@@ -6,8 +6,6 @@
* Copyright 2022 Red Hat Inc.
* Author: Javier Martinez Canillas <javierm@redhat.com>
*/
-
-#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
index 759f86e7d263..b58a80bde95a 100644
--- a/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
+++ b/tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
#include <inttypes.h>
#include <unistd.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test.c b/tools/testing/selftests/filesystems/statmount/statmount_test.c
index 3eafd7da58e2..d1cefd1b7d16 100644
--- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
+++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-or-later
-
-#define _GNU_SOURCE
-
#include <assert.h>
#include <stdint.h>
#include <sched.h>
diff --git a/tools/testing/selftests/futex/functional/futex_requeue_pi.c b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
index 7f3ca5c78df1..8e41f9fe784c 100644
--- a/tools/testing/selftests/futex/functional/futex_requeue_pi.c
+++ b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
@@ -16,9 +16,6 @@
* 2009-Nov-6: futex test adaptation by Darren Hart <dvhart@linux.intel.com>
*
*****************************************************************************/
-
-#define _GNU_SOURCE
-
#include <errno.h>
#include <limits.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c
index 656c43c24044..291c81d59a9d 100644
--- a/tools/testing/selftests/ipc/msgque.c
+++ b/tools/testing/selftests/ipc/msgque.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/tools/testing/selftests/kcmp/kcmp_test.c b/tools/testing/selftests/kcmp/kcmp_test.c
index 25110c7c0b3e..885c9e943cee 100644
--- a/tools/testing/selftests/kcmp/kcmp_test.c
+++ b/tools/testing/selftests/kcmp/kcmp_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
diff --git a/tools/testing/selftests/kvm/aarch64/arch_timer.c b/tools/testing/selftests/kvm/aarch64/arch_timer.c
index 4eaba83cdcf3..5369959e9fc2 100644
--- a/tools/testing/selftests/kvm/aarch64/arch_timer.c
+++ b/tools/testing/selftests/kvm/aarch64/arch_timer.c
@@ -5,8 +5,6 @@
*
* Copyright (c) 2021, Google LLC.
*/
-#define _GNU_SOURCE
-
#include "arch_timer.h"
#include "delay.h"
#include "gic.h"
diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftests/kvm/aarch64/page_fault_test.c
index 5972905275cf..79e99f47a9fe 100644
--- a/tools/testing/selftests/kvm/aarch64/page_fault_test.c
+++ b/tools/testing/selftests/kvm/aarch64/page_fault_test.c
@@ -7,7 +7,6 @@
* hugetlbfs with a hole). It checks that the expected handling method is
* called (e.g., uffd faults with the right address and write/read flag).
*/
-#define _GNU_SOURCE
#include <linux/bitmap.h>
#include <fcntl.h>
#include <test_util.h>
diff --git a/tools/testing/selftests/kvm/aarch64/psci_test.c b/tools/testing/selftests/kvm/aarch64/psci_test.c
index 9b004905d1d3..1c8c6f0c1ca3 100644
--- a/tools/testing/selftests/kvm/aarch64/psci_test.c
+++ b/tools/testing/selftests/kvm/aarch64/psci_test.c
@@ -10,9 +10,6 @@
* - A test for KVM's handling of PSCI SYSTEM_SUSPEND and the associated
* KVM_SYSTEM_EVENT_SUSPEND UAPI.
*/
-
-#define _GNU_SOURCE
-
#include <linux/psci.h>
#include "kvm_util.h"
diff --git a/tools/testing/selftests/kvm/aarch64/vgic_init.c b/tools/testing/selftests/kvm/aarch64/vgic_init.c
index ca917c71ff60..b3b5fb0ff0a9 100644
--- a/tools/testing/selftests/kvm/aarch64/vgic_init.c
+++ b/tools/testing/selftests/kvm/aarch64/vgic_init.c
@@ -4,7 +4,6 @@
*
* Copyright (C) 2020, Red Hat, Inc.
*/
-#define _GNU_SOURCE
#include <linux/kernel.h>
#include <sys/syscall.h>
#include <asm/kvm.h>
diff --git a/tools/testing/selftests/kvm/arch_timer.c b/tools/testing/selftests/kvm/arch_timer.c
index ae1f1a6d8312..fcebd8d81ce4 100644
--- a/tools/testing/selftests/kvm/arch_timer.c
+++ b/tools/testing/selftests/kvm/arch_timer.c
@@ -19,9 +19,6 @@
*
* Copyright (c) 2021, Google LLC.
*/
-
-#define _GNU_SOURCE
-
#include <stdlib.h>
#include <pthread.h>
#include <linux/sizes.h>
diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
index bf3609f71854..0c4d3b6afbf8 100644
--- a/tools/testing/selftests/kvm/demand_paging_test.c
+++ b/tools/testing/selftests/kvm/demand_paging_test.c
@@ -6,9 +6,6 @@
* Copyright (C) 2018, Red Hat, Inc.
* Copyright (C) 2019, Google, Inc.
*/
-
-#define _GNU_SOURCE /* for pipe2 */
-
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c
index eaad5b20854c..bf1ebc29f22a 100644
--- a/tools/testing/selftests/kvm/dirty_log_test.c
+++ b/tools/testing/selftests/kvm/dirty_log_test.c
@@ -4,9 +4,6 @@
*
* Copyright (C) 2018, Red Hat, Inc.
*/
-
-#define _GNU_SOURCE /* for program_invocation_name */
-
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
index 92eae206baa6..309fe84b84ad 100644
--- a/tools/testing/selftests/kvm/guest_memfd_test.c
+++ b/tools/testing/selftests/kvm/guest_memfd_test.c
@@ -4,8 +4,6 @@
*
* Author: Chao Peng <chao.p.peng@linux.intel.com>
*/
-
-#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/kvm/hardware_disable_test.c b/tools/testing/selftests/kvm/hardware_disable_test.c
index decc521fc760..bce73bcb973c 100644
--- a/tools/testing/selftests/kvm/hardware_disable_test.c
+++ b/tools/testing/selftests/kvm/hardware_disable_test.c
@@ -4,9 +4,6 @@
* kvm_arch_hardware_disable is called and it attempts to unregister the user
* return notifiers.
*/
-
-#define _GNU_SOURCE
-
#include <fcntl.h>
#include <pthread.h>
#include <semaphore.h>
diff --git a/tools/testing/selftests/kvm/include/userfaultfd_util.h b/tools/testing/selftests/kvm/include/userfaultfd_util.h
index 877449c34592..a9d97c213584 100644
--- a/tools/testing/selftests/kvm/include/userfaultfd_util.h
+++ b/tools/testing/selftests/kvm/include/userfaultfd_util.h
@@ -5,9 +5,6 @@
* Copyright (C) 2018, Red Hat, Inc.
* Copyright (C) 2019-2022 Google LLC
*/
-
-#define _GNU_SOURCE /* for pipe2 */
-
#include <inttypes.h>
#include <time.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
index 698c1cfa3111..f02355c3c4c2 100644
--- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c
+++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c
@@ -6,8 +6,6 @@
*
* Test the fd-based interface for KVM statistics.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
index b9e23265e4b3..c78f34699f73 100644
--- a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
+++ b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
@@ -6,8 +6,6 @@
*
* Test for KVM_CAP_MAX_VCPUS and KVM_CAP_MAX_VCPU_ID.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
index e0ba97ac1c56..7759c685086b 100644
--- a/tools/testing/selftests/kvm/kvm_page_table_test.c
+++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
@@ -8,9 +8,6 @@
* page size have been pre-allocated on your system, if you are planning to
* use hugepages to back the guest memory for testing.
*/
-
-#define _GNU_SOURCE /* for program_invocation_name */
-
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
diff --git a/tools/testing/selftests/kvm/lib/assert.c b/tools/testing/selftests/kvm/lib/assert.c
index 2bd25b191d15..b49690658c60 100644
--- a/tools/testing/selftests/kvm/lib/assert.c
+++ b/tools/testing/selftests/kvm/lib/assert.c
@@ -4,9 +4,6 @@
*
* Copyright (C) 2018, Google LLC.
*/
-
-#define _GNU_SOURCE /* for getline(3) and strchrnul(3)*/
-
#include "test_util.h"
#include <execinfo.h>
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index b2262b5fad9e..1eaf001d0ad4 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -4,8 +4,6 @@
*
* Copyright (C) 2018, Google LLC.
*/
-
-#define _GNU_SOURCE /* for program_invocation_name */
#include "test_util.h"
#include "kvm_util.h"
#include "processor.h"
diff --git a/tools/testing/selftests/kvm/lib/memstress.c b/tools/testing/selftests/kvm/lib/memstress.c
index cf2c73971308..555e3932e529 100644
--- a/tools/testing/selftests/kvm/lib/memstress.c
+++ b/tools/testing/selftests/kvm/lib/memstress.c
@@ -2,8 +2,6 @@
/*
* Copyright (C) 2020, Google LLC.
*/
-#define _GNU_SOURCE
-
#include <inttypes.h>
#include <linux/bitmap.h>
diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c
index 5a8f8becb129..8ed0b74ae837 100644
--- a/tools/testing/selftests/kvm/lib/test_util.c
+++ b/tools/testing/selftests/kvm/lib/test_util.c
@@ -4,8 +4,6 @@
*
* Copyright (C) 2020, Google LLC.
*/
-
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
diff --git a/tools/testing/selftests/kvm/lib/userfaultfd_util.c b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
index f4eef6eb2dc2..bd07568a5240 100644
--- a/tools/testing/selftests/kvm/lib/userfaultfd_util.c
+++ b/tools/testing/selftests/kvm/lib/userfaultfd_util.c
@@ -6,9 +6,6 @@
* Copyright (C) 2018, Red Hat, Inc.
* Copyright (C) 2019-2022 Google LLC
*/
-
-#define _GNU_SOURCE /* for pipe2 */
-
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/lib/x86_64/sev.c b/tools/testing/selftests/kvm/lib/x86_64/sev.c
index e248d3364b9c..e83809febae1 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/sev.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/sev.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <stdint.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/kvm/max_guest_memory_test.c b/tools/testing/selftests/kvm/max_guest_memory_test.c
index 1a6da7389bf1..0b9678858b6d 100644
--- a/tools/testing/selftests/kvm/max_guest_memory_test.c
+++ b/tools/testing/selftests/kvm/max_guest_memory_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c
index 156361966612..05fcf902e067 100644
--- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c
+++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c
@@ -6,9 +6,6 @@
* Copyright (C) 2018, Red Hat, Inc.
* Copyright (C) 2020, Google, Inc.
*/
-
-#define _GNU_SOURCE /* for program_invocation_name */
-
#include <stdio.h>
#include <stdlib.h>
#include <sys/syscall.h>
diff --git a/tools/testing/selftests/kvm/riscv/arch_timer.c b/tools/testing/selftests/kvm/riscv/arch_timer.c
index 0f9cabd99fd4..4b5004ef9c6b 100644
--- a/tools/testing/selftests/kvm/riscv/arch_timer.c
+++ b/tools/testing/selftests/kvm/riscv/arch_timer.c
@@ -7,9 +7,6 @@
*
* Copyright (c) 2024, Intel Corporation.
*/
-
-#define _GNU_SOURCE
-
#include "arch_timer.h"
#include "kvm_util.h"
#include "processor.h"
diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
index 28f97fb52044..b3536400f9ac 100644
--- a/tools/testing/selftests/kvm/rseq_test.c
+++ b/tools/testing/selftests/kvm/rseq_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/kvm/s390x/cmma_test.c b/tools/testing/selftests/kvm/s390x/cmma_test.c
index 626a2b8a2037..84ba79c42ab1 100644
--- a/tools/testing/selftests/kvm/s390x/cmma_test.c
+++ b/tools/testing/selftests/kvm/s390x/cmma_test.c
@@ -7,8 +7,6 @@
* Authors:
* Nico Boehr <nrb@linux.ibm.com>
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/s390x/sync_regs_test.c b/tools/testing/selftests/kvm/s390x/sync_regs_test.c
index 43fb25ddc3ec..53def355ccba 100644
--- a/tools/testing/selftests/kvm/s390x/sync_regs_test.c
+++ b/tools/testing/selftests/kvm/s390x/sync_regs_test.c
@@ -10,8 +10,6 @@
*
* Test expected behavior of the KVM_CAP_SYNC_REGS functionality.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c
index bd57d991e27d..214ff84f6fdb 100644
--- a/tools/testing/selftests/kvm/set_memory_region_test.c
+++ b/tools/testing/selftests/kvm/set_memory_region_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <pthread.h>
#include <sched.h>
diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
index bae0c5026f82..e9231387c589 100644
--- a/tools/testing/selftests/kvm/steal_time.c
+++ b/tools/testing/selftests/kvm/steal_time.c
@@ -4,7 +4,6 @@
*
* Copyright (C) 2020, Red Hat, Inc.
*/
-#define _GNU_SOURCE
#include <stdio.h>
#include <time.h>
#include <sched.h>
diff --git a/tools/testing/selftests/kvm/x86_64/amx_test.c b/tools/testing/selftests/kvm/x86_64/amx_test.c
index eae521f050e0..8e5713e36d4b 100644
--- a/tools/testing/selftests/kvm/x86_64/amx_test.c
+++ b/tools/testing/selftests/kvm/x86_64/amx_test.c
@@ -6,8 +6,6 @@
*
* Tests for amx #NM exception and save/restore.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/exit_on_emulation_failure_test.c b/tools/testing/selftests/kvm/x86_64/exit_on_emulation_failure_test.c
index 6c2e5e0ceb1f..9c21b6bccc38 100644
--- a/tools/testing/selftests/kvm/x86_64/exit_on_emulation_failure_test.c
+++ b/tools/testing/selftests/kvm/x86_64/exit_on_emulation_failure_test.c
@@ -4,9 +4,6 @@
*
* Test for KVM_CAP_EXIT_ON_EMULATION_FAILURE.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
-
#include "flds_emulation.h"
#include "test_util.h"
diff --git a/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c b/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c
index df351ae17029..10b1b0ba374e 100644
--- a/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c
+++ b/tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c
@@ -2,8 +2,6 @@
/*
* Copyright (C) 2023, Google LLC.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <sys/ioctl.h>
#include "test_util.h"
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
index 5c27efbf405e..4f5881d4ef66 100644
--- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
+++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c
@@ -7,8 +7,6 @@
* This work is licensed under the terms of the GNU GPL, version 2.
*
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c b/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
index 4c7257ecd2a6..4f3f3a9b038b 100644
--- a/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
+++ b/tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c
@@ -4,7 +4,6 @@
*
* Tests for Enlightened VMCS, including nested guest state.
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c b/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
index f1617762c22f..8206f5ef42dd 100644
--- a/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
+++ b/tools/testing/selftests/kvm/x86_64/hyperv_ipi.c
@@ -5,8 +5,6 @@
* Copyright (C) 2022, Red Hat, Inc.
*
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <pthread.h>
#include <inttypes.h>
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
index c9b18707edc0..b987a3d79715 100644
--- a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
+++ b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
@@ -4,7 +4,6 @@
*
* Tests for Hyper-V extensions to SVM.
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c b/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
index 05b56095cf76..077cd0ec3040 100644
--- a/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
+++ b/tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c
@@ -5,8 +5,6 @@
* Copyright (C) 2022, Red Hat, Inc.
*
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <asm/barrier.h>
#include <pthread.h>
#include <inttypes.h>
diff --git a/tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c b/tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c
index 3670331adf21..3eb0313ffa39 100644
--- a/tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c
+++ b/tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
-#define _GNU_SOURCE /* for program_invocation_short_name */
-
#include "test_util.h"
#include "kvm_util.h"
#include "processor.h"
diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
index 17bbb96fc4df..e7efb2b35f8b 100644
--- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
+++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
@@ -5,9 +5,6 @@
*
* Copyright (C) 2022, Google LLC.
*/
-
-#define _GNU_SOURCE
-
#include <fcntl.h>
#include <stdint.h>
#include <time.h>
diff --git a/tools/testing/selftests/kvm/x86_64/platform_info_test.c b/tools/testing/selftests/kvm/x86_64/platform_info_test.c
index 87011965dc41..2165b1ad8b38 100644
--- a/tools/testing/selftests/kvm/x86_64/platform_info_test.c
+++ b/tools/testing/selftests/kvm/x86_64/platform_info_test.c
@@ -9,8 +9,6 @@
* Verifies expected behavior of controlling guest access to
* MSR_PLATFORM_INFO.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c
index 26c85815f7e9..77f14138594e 100644
--- a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c
+++ b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c
@@ -2,8 +2,6 @@
/*
* Copyright (C) 2023, Tencent, Inc.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <x86intrin.h>
#include "pmu.h"
diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
index 3c85d1ae9893..5ce53b8c46e0 100644
--- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
+++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
@@ -9,9 +9,6 @@
* Verifies the expected behavior of allow lists and deny lists for
* virtual PMU events.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
-
#include "kvm_util.h"
#include "pmu.h"
#include "processor.h"
diff --git a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
index e0f642d2a3c4..82a8d88b5338 100644
--- a/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
+++ b/tools/testing/selftests/kvm/x86_64/private_mem_conversions_test.c
@@ -2,7 +2,6 @@
/*
* Copyright (C) 2022, Google LLC.
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <limits.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c b/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
index 366cf18600bc..d691d86e5bc3 100644
--- a/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
+++ b/tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
@@ -4,7 +4,6 @@
*
* Copyright (C) 2020, Red Hat, Inc.
*/
-#define _GNU_SOURCE /* for program_invocation_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/set_sregs_test.c b/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
index 3610981d9162..c021c0795a96 100644
--- a/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
+++ b/tools/testing/selftests/kvm/x86_64/set_sregs_test.c
@@ -10,7 +10,6 @@
* That bug allowed a user-mode program that called the KVM_SET_SREGS
* ioctl to put a VCPU's local APIC into an invalid state.
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c b/tools/testing/selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c
index 416207c38a17..362be40fc00d 100644
--- a/tools/testing/selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c
+++ b/tools/testing/selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c
@@ -5,9 +5,6 @@
* Test that KVM emulates instructions in response to EPT violations when
* allow_smaller_maxphyaddr is enabled and guest.MAXPHYADDR < host.MAXPHYADDR.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
-
#include "flds_emulation.h"
#include "test_util.h"
diff --git a/tools/testing/selftests/kvm/x86_64/smm_test.c b/tools/testing/selftests/kvm/x86_64/smm_test.c
index e18b86666e1f..55c88d664a94 100644
--- a/tools/testing/selftests/kvm/x86_64/smm_test.c
+++ b/tools/testing/selftests/kvm/x86_64/smm_test.c
@@ -4,7 +4,6 @@
*
* Tests for SMM.
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/state_test.c b/tools/testing/selftests/kvm/x86_64/state_test.c
index 88b58aab7207..1c756db329e5 100644
--- a/tools/testing/selftests/kvm/x86_64/state_test.c
+++ b/tools/testing/selftests/kvm/x86_64/state_test.c
@@ -6,7 +6,6 @@
*
* Tests for vCPU state save/restore, including nested guest state.
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/sync_regs_test.c b/tools/testing/selftests/kvm/x86_64/sync_regs_test.c
index adb5593daf48..8fa3948b0170 100644
--- a/tools/testing/selftests/kvm/x86_64/sync_regs_test.c
+++ b/tools/testing/selftests/kvm/x86_64/sync_regs_test.c
@@ -8,8 +8,6 @@
* including requesting an invalid register set, updates to/from values
* in kvm_run.s.regs when kvm_valid_regs and kvm_dirty_regs are toggled.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/ucna_injection_test.c b/tools/testing/selftests/kvm/x86_64/ucna_injection_test.c
index dcbb3c29fb8e..abe71946941f 100644
--- a/tools/testing/selftests/kvm/x86_64/ucna_injection_test.c
+++ b/tools/testing/selftests/kvm/x86_64/ucna_injection_test.c
@@ -17,8 +17,6 @@
* delivered into the guest or not.
*
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <pthread.h>
#include <inttypes.h>
#include <string.h>
diff --git a/tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c b/tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c
index f4f61a2d2464..53afbea4df88 100644
--- a/tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c
+++ b/tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c
@@ -4,8 +4,6 @@
*
* Tests for exiting into userspace on registered MSRs
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <sys/ioctl.h>
#include "kvm_test_harness.h"
diff --git a/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c b/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c
index 977948fd52e6..fa512d033205 100644
--- a/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c
+++ b/tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c
@@ -4,9 +4,6 @@
*
* Copyright (C) 2018, Red Hat, Inc.
*/
-
-#define _GNU_SOURCE /* for program_invocation_name */
-
#include <stdio.h>
#include <stdlib.h>
#include <linux/bitmap.h>
diff --git a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
index ea0cb3cae0f7..3b93f262b797 100644
--- a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
+++ b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c
@@ -10,7 +10,6 @@
* and check it can be retrieved with KVM_GET_MSR, also test
* the invalid LBR formats are rejected.
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <sys/ioctl.h>
#include <linux/bitmap.h>
diff --git a/tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c b/tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c
index affc32800158..00dd2ac07a61 100644
--- a/tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c
+++ b/tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c
@@ -9,7 +9,6 @@
* value instead of partially decayed timer value
*
*/
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c b/tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c
index 725c206ba0b9..c78e5f755116 100644
--- a/tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c
+++ b/tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c
@@ -19,8 +19,6 @@
* Migration is a command line option. When used on non-numa machines will
* exit with error. Test is still usefull on non-numa for testing IPIs.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <getopt.h>
#include <pthread.h>
#include <inttypes.h>
diff --git a/tools/testing/selftests/kvm/x86_64/xapic_state_test.c b/tools/testing/selftests/kvm/x86_64/xapic_state_test.c
index ab75b873a4ad..69849acd95b0 100644
--- a/tools/testing/selftests/kvm/x86_64/xapic_state_test.c
+++ b/tools/testing/selftests/kvm/x86_64/xapic_state_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/kvm/x86_64/xss_msr_test.c b/tools/testing/selftests/kvm/x86_64/xss_msr_test.c
index 167c97abff1b..f331a4e9bae3 100644
--- a/tools/testing/selftests/kvm/x86_64/xss_msr_test.c
+++ b/tools/testing/selftests/kvm/x86_64/xss_msr_test.c
@@ -4,8 +4,6 @@
*
* Tests for the IA32_XSS MSR.
*/
-
-#define _GNU_SOURCE /* for program_invocation_short_name */
#include <sys/ioctl.h>
#include "test_util.h"
diff --git a/tools/testing/selftests/landlock/base_test.c b/tools/testing/selftests/landlock/base_test.c
index a6f89aaea77d..bdb3955a9452 100644
--- a/tools/testing/selftests/landlock/base_test.c
+++ b/tools/testing/selftests/landlock/base_test.c
@@ -5,8 +5,6 @@
* Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
* Copyright © 2019-2020 ANSSI
*/
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <linux/landlock.h>
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index 9a6036fbf289..acec1c82c8b4 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -6,8 +6,6 @@
* Copyright © 2020 ANSSI
* Copyright © 2020-2022 Microsoft Corporation
*/
-
-#define _GNU_SOURCE
#include <fcntl.h>
#include <linux/landlock.h>
#include <linux/magic.h>
diff --git a/tools/testing/selftests/landlock/net_test.c b/tools/testing/selftests/landlock/net_test.c
index f21cfbbc3638..eed040adcbac 100644
--- a/tools/testing/selftests/landlock/net_test.c
+++ b/tools/testing/selftests/landlock/net_test.c
@@ -5,8 +5,6 @@
* Copyright © 2022-2023 Huawei Tech. Co., Ltd.
* Copyright © 2023 Microsoft Corporation
*/
-
-#define _GNU_SOURCE
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/landlock/ptrace_test.c b/tools/testing/selftests/landlock/ptrace_test.c
index a19db4d0b3bd..c831e6d03b02 100644
--- a/tools/testing/selftests/landlock/ptrace_test.c
+++ b/tools/testing/selftests/landlock/ptrace_test.c
@@ -5,8 +5,6 @@
* Copyright © 2017-2020 Mickaël Salaün <mic@digikod.net>
* Copyright © 2019-2020 ANSSI
*/
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <linux/landlock.h>
diff --git a/tools/testing/selftests/lsm/common.c b/tools/testing/selftests/lsm/common.c
index 9ad258912646..1b18aac570f1 100644
--- a/tools/testing/selftests/lsm/common.c
+++ b/tools/testing/selftests/lsm/common.c
@@ -4,8 +4,6 @@
*
* Copyright © 2023 Casey Schaufler <casey@schaufler-ca.com>
*/
-
-#define _GNU_SOURCE
#include <linux/lsm.h>
#include <fcntl.h>
#include <string.h>
diff --git a/tools/testing/selftests/lsm/lsm_get_self_attr_test.c b/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
index df215e4aa63f..7465bde3f922 100644
--- a/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
+++ b/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
@@ -5,8 +5,6 @@
*
* Copyright © 2022 Casey Schaufler <casey@schaufler-ca.com>
*/
-
-#define _GNU_SOURCE
#include <linux/lsm.h>
#include <fcntl.h>
#include <string.h>
diff --git a/tools/testing/selftests/lsm/lsm_list_modules_test.c b/tools/testing/selftests/lsm/lsm_list_modules_test.c
index 06d24d4679a6..a6b44e25c21f 100644
--- a/tools/testing/selftests/lsm/lsm_list_modules_test.c
+++ b/tools/testing/selftests/lsm/lsm_list_modules_test.c
@@ -5,8 +5,6 @@
*
* Copyright © 2022 Casey Schaufler <casey@schaufler-ca.com>
*/
-
-#define _GNU_SOURCE
#include <linux/lsm.h>
#include <string.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/lsm/lsm_set_self_attr_test.c b/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
index 66dec47e3ca3..110c6a07e74c 100644
--- a/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
+++ b/tools/testing/selftests/lsm/lsm_set_self_attr_test.c
@@ -5,8 +5,6 @@
*
* Copyright © 2022 Casey Schaufler <casey@schaufler-ca.com>
*/
-
-#define _GNU_SOURCE
#include <linux/lsm.h>
#include <string.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/membarrier/membarrier_test_impl.h b/tools/testing/selftests/membarrier/membarrier_test_impl.h
index af89855adb7b..a8a60b6271a5 100644
--- a/tools/testing/selftests/membarrier/membarrier_test_impl.h
+++ b/tools/testing/selftests/membarrier/membarrier_test_impl.h
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
-#define _GNU_SOURCE
#include <linux/membarrier.h>
#include <syscall.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c b/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
index a9cc17facfb3..b4651e2ade00 100644
--- a/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
+++ b/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <linux/membarrier.h>
#include <syscall.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/membarrier/membarrier_test_single_thread.c b/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
index 4cdc8b1d124c..17ae5199b916 100644
--- a/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
+++ b/tools/testing/selftests/membarrier/membarrier_test_single_thread.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <linux/membarrier.h>
#include <syscall.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/memfd/common.c b/tools/testing/selftests/memfd/common.c
index 8eb3d75f6e60..879d4f4c66fa 100644
--- a/tools/testing/selftests/memfd/common.c
+++ b/tools/testing/selftests/memfd/common.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#define __EXPORTED_HEADERS__
#include <stdio.h>
diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
index 93798c8c5d54..15bc189bf831 100644
--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -12,8 +12,6 @@
* the read() syscall with our memory-mapped memfd object as receive buffer to
* force the kernel to write into our memfd object.
*/
-
-#define _GNU_SOURCE
#define __EXPORTED_HEADERS__
#include <errno.h>
diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index 18f585684e20..5172c27a8748 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#define __EXPORTED_HEADERS__
#include <errno.h>
diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
index 363bf5f801be..6f1a36d51f19 100644
--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -6,7 +6,6 @@
*
* Author(s): David Hildenbrand <david@redhat.com>
*/
-#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/mm/gup_longterm.c b/tools/testing/selftests/mm/gup_longterm.c
index ad168d35b23b..3bfd5a630081 100644
--- a/tools/testing/selftests/mm/gup_longterm.c
+++ b/tools/testing/selftests/mm/gup_longterm.c
@@ -6,7 +6,6 @@
*
* Author(s): David Hildenbrand <david@redhat.com>
*/
-#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/mm/hugepage-mmap.c b/tools/testing/selftests/mm/hugepage-mmap.c
index 267eea2e0e0b..edb46888222f 100644
--- a/tools/testing/selftests/mm/hugepage-mmap.c
+++ b/tools/testing/selftests/mm/hugepage-mmap.c
@@ -16,7 +16,6 @@
* range.
* Other architectures, such as ppc64, i386 or x86_64 are not so constrained.
*/
-#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/mm/hugepage-mremap.c b/tools/testing/selftests/mm/hugepage-mremap.c
index c463d1c09c9b..8e22822bb754 100644
--- a/tools/testing/selftests/mm/hugepage-mremap.c
+++ b/tools/testing/selftests/mm/hugepage-mremap.c
@@ -11,8 +11,6 @@
* To make sure the test triggers pmd sharing and goes through the 'unshare'
* path in the mremap code use 1GB (1024) or more.
*/
-
-#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/mm/hugetlb-madvise.c b/tools/testing/selftests/mm/hugetlb-madvise.c
index e74107185324..70c40c67bc5d 100644
--- a/tools/testing/selftests/mm/hugetlb-madvise.c
+++ b/tools/testing/selftests/mm/hugetlb-madvise.c
@@ -11,8 +11,6 @@
* filesystem. Therefore, a hugetlbfs filesystem must be mounted on some
* directory.
*/
-
-#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
index ba6cc6f9cabc..6b8b41b4f754 100644
--- a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
+++ b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
index 829320a519e7..d18bf400dae6 100644
--- a/tools/testing/selftests/mm/khugepaged.c
+++ b/tools/testing/selftests/mm/khugepaged.c
@@ -1,4 +1,3 @@
-#define _GNU_SOURCE
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c
index d615767e396b..1deae905c42e 100644
--- a/tools/testing/selftests/mm/ksm_functional_tests.c
+++ b/tools/testing/selftests/mm/ksm_functional_tests.c
@@ -6,7 +6,6 @@
*
* Author(s): David Hildenbrand <david@redhat.com>
*/
-#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/mm/madv_populate.c b/tools/testing/selftests/mm/madv_populate.c
index 17bcb07f19f3..d19ad13ffd7e 100644
--- a/tools/testing/selftests/mm/madv_populate.c
+++ b/tools/testing/selftests/mm/madv_populate.c
@@ -6,7 +6,6 @@
*
* Author(s): David Hildenbrand <david@redhat.com>
*/
-#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/mm/map_populate.c b/tools/testing/selftests/mm/map_populate.c
index 5c8a53869b1b..ff4d4079bd0e 100644
--- a/tools/testing/selftests/mm/map_populate.c
+++ b/tools/testing/selftests/mm/map_populate.c
@@ -4,8 +4,6 @@
*
* MAP_POPULATE | MAP_PRIVATE should COW VMA pages.
*/
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
diff --git a/tools/testing/selftests/mm/mdwe_test.c b/tools/testing/selftests/mm/mdwe_test.c
index 1e01d3ddc11c..200bedcdc32e 100644
--- a/tools/testing/selftests/mm/mdwe_test.c
+++ b/tools/testing/selftests/mm/mdwe_test.c
@@ -7,7 +7,6 @@
#include <linux/mman.h>
#include <linux/prctl.h>
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sys/auxv.h>
diff --git a/tools/testing/selftests/mm/memfd_secret.c b/tools/testing/selftests/mm/memfd_secret.c
index 9b298f6a04b3..750adede2816 100644
--- a/tools/testing/selftests/mm/memfd_secret.c
+++ b/tools/testing/selftests/mm/memfd_secret.c
@@ -4,8 +4,6 @@
*
* Author: Mike Rapoport <rppt@linux.ibm.com>
*/
-
-#define _GNU_SOURCE
#include <sys/uio.h>
#include <sys/mman.h>
#include <sys/wait.h>
diff --git a/tools/testing/selftests/mm/mlock2-tests.c b/tools/testing/selftests/mm/mlock2-tests.c
index 26f744188ad0..42574290d728 100644
--- a/tools/testing/selftests/mm/mlock2-tests.c
+++ b/tools/testing/selftests/mm/mlock2-tests.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <sys/mman.h>
#include <stdint.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/mm/mrelease_test.c b/tools/testing/selftests/mm/mrelease_test.c
index 100370a7111d..d78bf686e99f 100644
--- a/tools/testing/selftests/mm/mrelease_test.c
+++ b/tools/testing/selftests/mm/mrelease_test.c
@@ -2,7 +2,6 @@
/*
* Copyright 2022 Google LLC
*/
-#define _GNU_SOURCE
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/mm/mremap_dontunmap.c b/tools/testing/selftests/mm/mremap_dontunmap.c
index 1d75084b9ca5..934fa6b441b2 100644
--- a/tools/testing/selftests/mm/mremap_dontunmap.c
+++ b/tools/testing/selftests/mm/mremap_dontunmap.c
@@ -5,7 +5,6 @@
*
* Copyright 2020, Brian Geffon <bgeffon@google.com>
*/
-#define _GNU_SOURCE
#include <sys/mman.h>
#include <linux/mman.h>
#include <errno.h>
diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
index 2f8b991f78cb..e057154630e0 100644
--- a/tools/testing/selftests/mm/mremap_test.c
+++ b/tools/testing/selftests/mm/mremap_test.c
@@ -2,8 +2,6 @@
/*
* Copyright 2020 Google LLC
*/
-#define _GNU_SOURCE
-
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/mm/pagemap_ioctl.c b/tools/testing/selftests/mm/pagemap_ioctl.c
index d59517ed3d48..2a18b5d276f0 100644
--- a/tools/testing/selftests/mm/pagemap_ioctl.c
+++ b/tools/testing/selftests/mm/pagemap_ioctl.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h
index 1af3156a9db8..37d6b01ce90a 100644
--- a/tools/testing/selftests/mm/pkey-helpers.h
+++ b/tools/testing/selftests/mm/pkey-helpers.h
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _PKEYS_HELPER_H
#define _PKEYS_HELPER_H
-#define _GNU_SOURCE
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c
index 48dc151f8fca..9f7de92caeda 100644
--- a/tools/testing/selftests/mm/protection_keys.c
+++ b/tools/testing/selftests/mm/protection_keys.c
@@ -21,7 +21,6 @@
* gcc -mxsave -o protection_keys -O2 -g -std=gnu99 -pthread -Wall protection_keys.c -lrt -ldl -lm
* gcc -mxsave -m32 -o protection_keys_32 -O2 -g -std=gnu99 -pthread -Wall protection_keys.c -lrt -ldl -lm
*/
-#define _GNU_SOURCE
#define __SANE_USERSPACE_TYPES__
#include <errno.h>
#include <linux/elf.h>
diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index d3c7f5fb3e7b..ae6ac950d7a1 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -3,8 +3,6 @@
* A test of splitting PMD THPs and PTE-mapped THPs from a specified virtual
* address range in a process via <debugfs>/split_huge_pages interface.
*/
-
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
diff --git a/tools/testing/selftests/mm/thuge-gen.c b/tools/testing/selftests/mm/thuge-gen.c
index ea7fd8fe2876..28a5c31bd791 100644
--- a/tools/testing/selftests/mm/thuge-gen.c
+++ b/tools/testing/selftests/mm/thuge-gen.c
@@ -12,8 +12,6 @@
ipcrm -m by hand, like this
sudo ipcs | awk '$1 == "0x00000000" {print $2}' | xargs -n1 sudo ipcrm -m
(warning this will remove all if someone else uses them) */
-
-#define _GNU_SOURCE 1
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/mm/uffd-common.h b/tools/testing/selftests/mm/uffd-common.h
index cc5629c3d2aa..abb44319264a 100644
--- a/tools/testing/selftests/mm/uffd-common.h
+++ b/tools/testing/selftests/mm/uffd-common.h
@@ -7,7 +7,6 @@
#ifndef __UFFD_COMMON_H__
#define __UFFD_COMMON_H__
-#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/mount_setattr/mount_setattr_test.c b/tools/testing/selftests/mount_setattr/mount_setattr_test.c
index c6a8c732b802..d894417134b6 100644
--- a/tools/testing/selftests/mount_setattr/mount_setattr_test.c
+++ b/tools/testing/selftests/mount_setattr/mount_setattr_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <errno.h>
diff --git a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
index bcf51d785a37..bd975670f61d 100644
--- a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
+++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <errno.h>
diff --git a/tools/testing/selftests/net/af_unix/diag_uid.c b/tools/testing/selftests/net/af_unix/diag_uid.c
index 79a3dd75590e..279d0c5f70d3 100644
--- a/tools/testing/selftests/net/af_unix/diag_uid.c
+++ b/tools/testing/selftests/net/af_unix/diag_uid.c
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright Amazon.com Inc. or its affiliates. */
-
-#define _GNU_SOURCE
#include <sched.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/net/af_unix/scm_pidfd.c b/tools/testing/selftests/net/af_unix/scm_pidfd.c
index 7e534594167e..2986b8cd0418 100644
--- a/tools/testing/selftests/net/af_unix/scm_pidfd.c
+++ b/tools/testing/selftests/net/af_unix/scm_pidfd.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0 OR MIT
-#define _GNU_SOURCE
#include <error.h>
#include <limits.h>
#include <stddef.h>
diff --git a/tools/testing/selftests/net/af_unix/unix_connect.c b/tools/testing/selftests/net/af_unix/unix_connect.c
index d799fd8f5c7c..34e816862cc7 100644
--- a/tools/testing/selftests/net/af_unix/unix_connect.c
+++ b/tools/testing/selftests/net/af_unix/unix_connect.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <sched.h>
#include <stddef.h>
diff --git a/tools/testing/selftests/net/csum.c b/tools/testing/selftests/net/csum.c
index 90eb06fefa59..8262aa862331 100644
--- a/tools/testing/selftests/net/csum.c
+++ b/tools/testing/selftests/net/csum.c
@@ -58,9 +58,6 @@
* different seed for each run (and logs this for reproducibility). It
* is advised to enable this for extra coverage in continuous testing.
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <asm/byteorder.h>
#include <errno.h>
diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/net/gro.c
index 353e1e867fbb..f5d7032e6466 100644
--- a/tools/testing/selftests/net/gro.c
+++ b/tools/testing/selftests/net/gro.c
@@ -34,9 +34,6 @@
* flakiness is to be expected.
*
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/ip_defrag.c b/tools/testing/selftests/net/ip_defrag.c
index f9ed749fd8c7..80c9e567a3d8 100644
--- a/tools/testing/selftests/net/ip_defrag.c
+++ b/tools/testing/selftests/net/ip_defrag.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/ipsec.c b/tools/testing/selftests/net/ipsec.c
index be4a30a0d02a..04aa06d26b09 100644
--- a/tools/testing/selftests/net/ipsec.c
+++ b/tools/testing/selftests/net/ipsec.c
@@ -3,9 +3,6 @@
* ipsec.c - Check xfrm on veth inside a net-ns.
* Copyright (c) 2018 Dmitry Safonov
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <asm/types.h>
#include <errno.h>
diff --git a/tools/testing/selftests/net/ipv6_flowlabel.c b/tools/testing/selftests/net/ipv6_flowlabel.c
index 708a9822259d..b7e0c3c02e20 100644
--- a/tools/testing/selftests/net/ipv6_flowlabel.c
+++ b/tools/testing/selftests/net/ipv6_flowlabel.c
@@ -1,8 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Test IPV6_FLOWINFO cmsg on send and recv */
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <asm/byteorder.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
index af95b48acea9..ebd219ba386e 100644
--- a/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
+++ b/tools/testing/selftests/net/ipv6_flowlabel_mgr.c
@@ -1,8 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Test IPV6_FLOWINFO_MGR */
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <error.h>
#include <errno.h>
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index d2043ec3bf6d..ea93030ed3ec 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/net/mptcp/mptcp_inq.c b/tools/testing/selftests/net/mptcp/mptcp_inq.c
index 218aac467321..c5bf873d76c2 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_inq.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_inq.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index 926b0be87c99..7203ca9900e9 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/net/msg_zerocopy.c b/tools/testing/selftests/net/msg_zerocopy.c
index bdc03a2097e8..9278bf585c80 100644
--- a/tools/testing/selftests/net/msg_zerocopy.c
+++ b/tools/testing/selftests/net/msg_zerocopy.c
@@ -24,9 +24,6 @@
* the kernel queues completions on the error queue for all zerocopy
* transfers.
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <error.h>
#include <errno.h>
diff --git a/tools/testing/selftests/net/nettest.c b/tools/testing/selftests/net/nettest.c
index cd8a58097448..88e1d3b2ddf1 100644
--- a/tools/testing/selftests/net/nettest.c
+++ b/tools/testing/selftests/net/nettest.c
@@ -3,8 +3,6 @@
*
* Copyright (c) 2013-2019 David Ahern <dsahern@gmail.com>. All rights reserved.
*/
-
-#define _GNU_SOURCE
#include <features.h>
#include <sys/types.h>
#include <sys/ioctl.h>
diff --git a/tools/testing/selftests/net/psock_fanout.c b/tools/testing/selftests/net/psock_fanout.c
index 1a736f700be4..5b2d34440ae9 100644
--- a/tools/testing/selftests/net/psock_fanout.c
+++ b/tools/testing/selftests/net/psock_fanout.c
@@ -26,9 +26,6 @@
* Todo:
* - functionality: PACKET_FANOUT_FLAG_DEFRAG
*/
-
-#define _GNU_SOURCE /* for sched_setaffinity */
-
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/net/psock_snd.c b/tools/testing/selftests/net/psock_snd.c
index edf1e6f80d41..2f29b513e18f 100644
--- a/tools/testing/selftests/net/psock_snd.c
+++ b/tools/testing/selftests/net/psock_snd.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/reuseport_addr_any.c b/tools/testing/selftests/net/reuseport_addr_any.c
index b8475cb29be7..9ee6ece52865 100644
--- a/tools/testing/selftests/net/reuseport_addr_any.c
+++ b/tools/testing/selftests/net/reuseport_addr_any.c
@@ -3,9 +3,6 @@
/* Test that sockets listening on a specific address are preferred
* over sockets listening on addr_any.
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/reuseport_bpf_cpu.c b/tools/testing/selftests/net/reuseport_bpf_cpu.c
index 2d646174729f..e93e38cfb2a8 100644
--- a/tools/testing/selftests/net/reuseport_bpf_cpu.c
+++ b/tools/testing/selftests/net/reuseport_bpf_cpu.c
@@ -11,9 +11,6 @@
* This entire process is done for several different core id permutations
* and for each IPv4/IPv6 and TCP/UDP combination.
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/reuseport_bpf_numa.c b/tools/testing/selftests/net/reuseport_bpf_numa.c
index c9ba36aa688e..502fdb9ce770 100644
--- a/tools/testing/selftests/net/reuseport_bpf_numa.c
+++ b/tools/testing/selftests/net/reuseport_bpf_numa.c
@@ -3,9 +3,6 @@
* Test functionality of BPF filters with SO_REUSEPORT. Same test as
* in reuseport_bpf_cpu, only as one socket per NUMA node.
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/reuseport_dualstack.c b/tools/testing/selftests/net/reuseport_dualstack.c
index fb7a59ed759e..d3c3d3f39f8f 100644
--- a/tools/testing/selftests/net/reuseport_dualstack.c
+++ b/tools/testing/selftests/net/reuseport_dualstack.c
@@ -10,9 +10,6 @@
* This test creates these mixed AF_INET/AF_INET6 sockets and asserts the
* AF_INET preference for v4 packets.
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/so_incoming_cpu.c b/tools/testing/selftests/net/so_incoming_cpu.c
index e9fa14e10732..95bd0cdc3253 100644
--- a/tools/testing/selftests/net/so_incoming_cpu.c
+++ b/tools/testing/selftests/net/so_incoming_cpu.c
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright Amazon.com Inc. or its affiliates. */
-#define _GNU_SOURCE
#include <sched.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/net/so_netns_cookie.c b/tools/testing/selftests/net/so_netns_cookie.c
index b39e87e967cd..18532d564f79 100644
--- a/tools/testing/selftests/net/so_netns_cookie.c
+++ b/tools/testing/selftests/net/so_netns_cookie.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <sched.h>
#include <unistd.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/net/so_txtime.c b/tools/testing/selftests/net/so_txtime.c
index 8457b7ccbc09..011a24af9786 100644
--- a/tools/testing/selftests/net/so_txtime.c
+++ b/tools/testing/selftests/net/so_txtime.c
@@ -9,9 +9,6 @@
* the expected stream. Sender will read transmit timestamps from the error
* queue. The streams can differ due to out-of-order delivery and drops.
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <error.h>
#include <errno.h>
diff --git a/tools/testing/selftests/net/tap.c b/tools/testing/selftests/net/tap.c
index 247c3b3ac1c9..fa78b92d9740 100644
--- a/tools/testing/selftests/net/tap.c
+++ b/tools/testing/selftests/net/tap.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/net/tcp_fastopen_backup_key.c b/tools/testing/selftests/net/tcp_fastopen_backup_key.c
index c1cb0c75156a..d30f89bb944c 100644
--- a/tools/testing/selftests/net/tcp_fastopen_backup_key.c
+++ b/tools/testing/selftests/net/tcp_fastopen_backup_key.c
@@ -12,7 +12,6 @@
* there are no cases in which a cookie is not accepted by verifying
* that TcpExtTCPFastOpenPassiveFail remains 0.
*/
-#define _GNU_SOURCE
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/tcp_inq.c b/tools/testing/selftests/net/tcp_inq.c
index bd6a9c7a3e8a..71ee145f151e 100644
--- a/tools/testing/selftests/net/tcp_inq.c
+++ b/tools/testing/selftests/net/tcp_inq.c
@@ -5,8 +5,6 @@
*
* Simple example on how to use TCP_INQ and TCP_CM_INQ.
*/
-#define _GNU_SOURCE
-
#include <error.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
index 4fcce5150850..72d5f1207ee0 100644
--- a/tools/testing/selftests/net/tcp_mmap.c
+++ b/tools/testing/selftests/net/tcp_mmap.c
@@ -46,7 +46,6 @@
* received 32768 MB (99.9939 % mmap'ed) in 7.43764 s, 36.9577 Gbit
* cpu usage user:0.035 sys:3.467, 106.873 usec per MB, 65530 c-switches
*/
-#define _GNU_SOURCE
#include <pthread.h>
#include <sys/types.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index f27a12d2a2c9..6dbad97d1d0a 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/toeplitz.c b/tools/testing/selftests/net/toeplitz.c
index 9ba03164d73a..e2d739892ce4 100644
--- a/tools/testing/selftests/net/toeplitz.c
+++ b/tools/testing/selftests/net/toeplitz.c
@@ -20,9 +20,6 @@
* 5. Compute the cpu that RPS should select based on rx_hash and $rps_bitmap
* 6. Compare the cpus from 4 and 5
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/tun.c b/tools/testing/selftests/net/tun.c
index fa83918b62d1..a64dcfb242c1 100644
--- a/tools/testing/selftests/net/tun.c
+++ b/tools/testing/selftests/net/tun.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/net/txring_overwrite.c b/tools/testing/selftests/net/txring_overwrite.c
index 7d9ea039450a..96972e0110a0 100644
--- a/tools/testing/selftests/net/txring_overwrite.c
+++ b/tools/testing/selftests/net/txring_overwrite.c
@@ -4,9 +4,6 @@
* Verify that consecutive sends over packet tx_ring are mirrored
* with their original content intact.
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <assert.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c
index ec60a16c9307..33dba9e90dea 100644
--- a/tools/testing/selftests/net/txtimestamp.c
+++ b/tools/testing/selftests/net/txtimestamp.c
@@ -16,9 +16,6 @@
* This test requires a dummy TCP server.
* A simple `nc6 [-u] -l -p $DESTPORT` will do
*/
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <asm/types.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/udpgso.c b/tools/testing/selftests/net/udpgso.c
index 85b3baa3f7f3..9dc1026a033a 100644
--- a/tools/testing/selftests/net/udpgso.c
+++ b/tools/testing/selftests/net/udpgso.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <stddef.h>
#include <arpa/inet.h>
#include <error.h>
diff --git a/tools/testing/selftests/net/udpgso_bench_rx.c b/tools/testing/selftests/net/udpgso_bench_rx.c
index 1cbadd267c96..999df1236320 100644
--- a/tools/testing/selftests/net/udpgso_bench_rx.c
+++ b/tools/testing/selftests/net/udpgso_bench_rx.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <error.h>
#include <errno.h>
diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c
index 477392715a9a..d7632993b354 100644
--- a/tools/testing/selftests/net/udpgso_bench_tx.c
+++ b/tools/testing/selftests/net/udpgso_bench_tx.c
@@ -1,7 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
-
#include <arpa/inet.h>
#include <errno.h>
#include <error.h>
diff --git a/tools/testing/selftests/perf_events/remove_on_exec.c b/tools/testing/selftests/perf_events/remove_on_exec.c
index 5814611a1dc7..ef4d923f4759 100644
--- a/tools/testing/selftests/perf_events/remove_on_exec.c
+++ b/tools/testing/selftests/perf_events/remove_on_exec.c
@@ -5,8 +5,6 @@
* Copyright (C) 2021, Google LLC.
*/
-#define _GNU_SOURCE
-
/* We need the latest siginfo from the kernel repo. */
#include <sys/types.h>
#include <asm/siginfo.h>
diff --git a/tools/testing/selftests/perf_events/sigtrap_threads.c b/tools/testing/selftests/perf_events/sigtrap_threads.c
index d1d8483ac628..14d1a3c8cb5c 100644
--- a/tools/testing/selftests/perf_events/sigtrap_threads.c
+++ b/tools/testing/selftests/perf_events/sigtrap_threads.c
@@ -5,8 +5,6 @@
* Copyright (C) 2021, Google LLC.
*/
-#define _GNU_SOURCE
-
/* We need the latest siginfo from the kernel repo. */
#include <sys/types.h>
#include <asm/siginfo.h>
diff --git a/tools/testing/selftests/pid_namespace/regression_enomem.c b/tools/testing/selftests/pid_namespace/regression_enomem.c
index 7d84097ad45c..54dc8f16d92a 100644
--- a/tools/testing/selftests/pid_namespace/regression_enomem.c
+++ b/tools/testing/selftests/pid_namespace/regression_enomem.c
@@ -1,4 +1,3 @@
-#define _GNU_SOURCE
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/pidfd/pidfd.h b/tools/testing/selftests/pidfd/pidfd.h
index 88d6830ee004..e33177b1aa41 100644
--- a/tools/testing/selftests/pidfd/pidfd.h
+++ b/tools/testing/selftests/pidfd/pidfd.h
@@ -3,7 +3,6 @@
#ifndef __PIDFD_H
#define __PIDFD_H
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
diff --git a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
index 01cc37bf611c..67c9dc436c71 100644
--- a/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_fdinfo_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/tools/testing/selftests/pidfd/pidfd_getfd_test.c b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
index cd51d547b751..b6a0e9b3d2f5 100644
--- a/tools/testing/selftests/pidfd/pidfd_getfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
diff --git a/tools/testing/selftests/pidfd/pidfd_open_test.c b/tools/testing/selftests/pidfd/pidfd_open_test.c
index 8a59438ccc78..781a3931fb5a 100644
--- a/tools/testing/selftests/pidfd/pidfd_open_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_open_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
diff --git a/tools/testing/selftests/pidfd/pidfd_poll_test.c b/tools/testing/selftests/pidfd/pidfd_poll_test.c
index 610811275357..a40fb27a78bb 100644
--- a/tools/testing/selftests/pidfd/pidfd_poll_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_poll_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <errno.h>
#include <linux/types.h>
#include <poll.h>
diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testing/selftests/pidfd/pidfd_setns_test.c
index 6e2f2cd400ca..49d7a78cc4fe 100644
--- a/tools/testing/selftests/pidfd/pidfd_setns_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c
index c081ae91313a..c3d52406b8fd 100644
--- a/tools/testing/selftests/pidfd/pidfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_test.c
@@ -1,6 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <linux/types.h>
diff --git a/tools/testing/selftests/pidfd/pidfd_wait.c b/tools/testing/selftests/pidfd/pidfd_wait.c
index 0dcb8365ddc3..54beba0983f1 100644
--- a/tools/testing/selftests/pidfd/pidfd_wait.c
+++ b/tools/testing/selftests/pidfd/pidfd_wait.c
@@ -1,6 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
#include <errno.h>
#include <linux/sched.h>
#include <linux/types.h>
diff --git a/tools/testing/selftests/ptrace/get_set_sud.c b/tools/testing/selftests/ptrace/get_set_sud.c
index 5297b10d25c3..054a78ebe8b5 100644
--- a/tools/testing/selftests/ptrace/get_set_sud.c
+++ b/tools/testing/selftests/ptrace/get_set_sud.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include "../kselftest_harness.h"
#include <stdio.h>
#include <string.h>
diff --git a/tools/testing/selftests/ptrace/peeksiginfo.c b/tools/testing/selftests/ptrace/peeksiginfo.c
index a6884f66dc01..1b7b77190f72 100644
--- a/tools/testing/selftests/ptrace/peeksiginfo.c
+++ b/tools/testing/selftests/ptrace/peeksiginfo.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/rseq/basic_percpu_ops_test.c b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
index 2348d2c20d0a..5961c24ee1ae 100644
--- a/tools/testing/selftests/rseq/basic_percpu_ops_test.c
+++ b/tools/testing/selftests/rseq/basic_percpu_ops_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: LGPL-2.1
-#define _GNU_SOURCE
#include <assert.h>
#include <pthread.h>
#include <sched.h>
diff --git a/tools/testing/selftests/rseq/basic_test.c b/tools/testing/selftests/rseq/basic_test.c
index 295eea16466f..1fed749b4bd7 100644
--- a/tools/testing/selftests/rseq/basic_test.c
+++ b/tools/testing/selftests/rseq/basic_test.c
@@ -2,8 +2,6 @@
/*
* Basic test coverage for critical regions and rseq_current_cpu().
*/
-
-#define _GNU_SOURCE
#include <assert.h>
#include <sched.h>
#include <signal.h>
diff --git a/tools/testing/selftests/rseq/param_test.c b/tools/testing/selftests/rseq/param_test.c
index 2f37961240ca..48a55d94eb72 100644
--- a/tools/testing/selftests/rseq/param_test.c
+++ b/tools/testing/selftests/rseq/param_test.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: LGPL-2.1
-#define _GNU_SOURCE
#include <assert.h>
#include <linux/membarrier.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c
index 96e812bdf8a4..88602889414c 100644
--- a/tools/testing/selftests/rseq/rseq.c
+++ b/tools/testing/selftests/rseq/rseq.c
@@ -14,8 +14,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
-
-#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c
index b83099160fbc..3632a4890da9 100644
--- a/tools/testing/selftests/seccomp/seccomp_benchmark.c
+++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c
@@ -2,7 +2,6 @@
* Strictly speaking, this is not a test. But it can report during test
* runs so relative performace can be measured.
*/
-#define _GNU_SOURCE
#include <assert.h>
#include <err.h>
#include <limits.h>
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index 783ebce8c4de..972ccc12553e 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -4,8 +4,6 @@
*
* Test code for seccomp bpf.
*/
-
-#define _GNU_SOURCE
#include <sys/types.h>
/*
diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c
index 7288a05136ba..a1f156dbbd56 100644
--- a/tools/testing/selftests/user_events/abi_test.c
+++ b/tools/testing/selftests/user_events/abi_test.c
@@ -4,8 +4,6 @@
*
* Copyright (c) 2022 Beau Belgrave <beaub@linux.microsoft.com>
*/
-
-#define _GNU_SOURCE
#include <sched.h>
#include <errno.h>
diff --git a/tools/testing/selftests/x86/amx.c b/tools/testing/selftests/x86/amx.c
index d884fd69dd51..9441635fc452 100644
--- a/tools/testing/selftests/x86/amx.c
+++ b/tools/testing/selftests/x86/amx.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-
-#define _GNU_SOURCE
#include <err.h>
#include <errno.h>
#include <pthread.h>
diff --git a/tools/testing/selftests/x86/check_initial_reg_state.c b/tools/testing/selftests/x86/check_initial_reg_state.c
index 3bc95f3ed585..0129cdae8abe 100644
--- a/tools/testing/selftests/x86/check_initial_reg_state.c
+++ b/tools/testing/selftests/x86/check_initial_reg_state.c
@@ -3,9 +3,6 @@
* check_initial_reg_state.c - check that execve sets the correct state
* Copyright (c) 2014-2016 Andrew Lutomirski
*/
-
-#define _GNU_SOURCE
-
#include <stdio.h>
unsigned long ax, bx, cx, dx, si, di, bp, sp, flags;
--git a/tools/testing/selftests/x86/corrupt_xstate_header.c b/tools/testing/selftests/x86/corrupt_xstate_header.c
index cf9ce8fbb656..d2c746149678 100644
--- a/tools/testing/selftests/x86/corrupt_xstate_header.c
+++ b/tools/testing/selftests/x86/corrupt_xstate_header.c
@@ -4,9 +4,6 @@
*
* Based on analysis and a test case from Thomas Gleixner.
*/
-
-#define _GNU_SOURCE
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/tools/testing/selftests/x86/entry_from_vm86.c b/tools/testing/selftests/x86/entry_from_vm86.c
index d1e919b0c1dc..9fa9d4a847ac 100644
--- a/tools/testing/selftests/x86/entry_from_vm86.c
+++ b/tools/testing/selftests/x86/entry_from_vm86.c
@@ -5,9 +5,6 @@
*
* This exercises a few paths that need to special-case vm86 mode.
*/
-
-#define _GNU_SOURCE
-
#include <assert.h>
#include <stdlib.h>
#include <sys/syscall.h>
diff --git a/tools/testing/selftests/x86/fsgsbase.c b/tools/testing/selftests/x86/fsgsbase.c
index 8c780cce941d..348134d2cefc 100644
--- a/tools/testing/selftests/x86/fsgsbase.c
+++ b/tools/testing/selftests/x86/fsgsbase.c
@@ -3,8 +3,6 @@
* fsgsbase.c, an fsgsbase test
* Copyright (c) 2014-2016 Andy Lutomirski
*/
-
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/x86/fsgsbase_restore.c b/tools/testing/selftests/x86/fsgsbase_restore.c
index 6fffadc51579..88dce47ab8e6 100644
--- a/tools/testing/selftests/x86/fsgsbase_restore.c
+++ b/tools/testing/selftests/x86/fsgsbase_restore.c
@@ -12,8 +12,6 @@
*
* This is not part of fsgsbase.c, because that test is 64-bit only.
*/
-
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/x86/ioperm.c b/tools/testing/selftests/x86/ioperm.c
index 57ec5e99edb9..07b7c10f8d39 100644
--- a/tools/testing/selftests/x86/ioperm.c
+++ b/tools/testing/selftests/x86/ioperm.c
@@ -3,8 +3,6 @@
* ioperm.c - Test case for ioperm(2)
* Copyright (c) 2015 Andrew Lutomirski
*/
-
-#define _GNU_SOURCE
#include <err.h>
#include <stdio.h>
#include <stdint.h>
diff --git a/tools/testing/selftests/x86/iopl.c b/tools/testing/selftests/x86/iopl.c
index 7e3e09c1abac..baa691154905 100644
--- a/tools/testing/selftests/x86/iopl.c
+++ b/tools/testing/selftests/x86/iopl.c
@@ -3,8 +3,6 @@
* iopl.c - Test case for a Linux on Xen 64-bit bug
* Copyright (c) 2015 Andrew Lutomirski
*/
-
-#define _GNU_SOURCE
#include <err.h>
#include <stdio.h>
#include <stdint.h>
diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c
index 215b8150b7cc..39edfd7f6037 100644
--- a/tools/testing/selftests/x86/lam.c
+++ b/tools/testing/selftests/x86/lam.c
@@ -1,5 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
index 3a29346e1452..3b4237a85a12 100644
--- a/tools/testing/selftests/x86/ldt_gdt.c
+++ b/tools/testing/selftests/x86/ldt_gdt.c
@@ -3,8 +3,6 @@
* ldt_gdt.c - Test cases for LDT and GDT access
* Copyright (c) 2015 Andrew Lutomirski
*/
-
-#define _GNU_SOURCE
#include <err.h>
#include <stdio.h>
#include <stdint.h>
diff --git a/tools/testing/selftests/x86/mov_ss_trap.c b/tools/testing/selftests/x86/mov_ss_trap.c
index cc3de6ff9fba..47ecc63220b7 100644
--- a/tools/testing/selftests/x86/mov_ss_trap.c
+++ b/tools/testing/selftests/x86/mov_ss_trap.c
@@ -19,8 +19,6 @@
*
* This should mostly cover CVE-2018-1087 and CVE-2018-8897.
*/
-#define _GNU_SOURCE
-
#include <stdlib.h>
#include <sys/ptrace.h>
#include <sys/types.h>
diff --git a/tools/testing/selftests/x86/nx_stack.c b/tools/testing/selftests/x86/nx_stack.c
index ea4a4e246879..97c5b34096cc 100644
--- a/tools/testing/selftests/x86/nx_stack.c
+++ b/tools/testing/selftests/x86/nx_stack.c
@@ -23,8 +23,6 @@
* Regular stack is completely overwritten before testing.
* Test doesn't exit SIGSEGV handler after first fault at INT3.
*/
-#undef _GNU_SOURCE
-#define _GNU_SOURCE
#undef NDEBUG
#include <assert.h>
#include <signal.h>
diff --git a/tools/testing/selftests/x86/ptrace_syscall.c b/tools/testing/selftests/x86/ptrace_syscall.c
index 12aaa063196e..bdc81c8bd1a7 100644
--- a/tools/testing/selftests/x86/ptrace_syscall.c
+++ b/tools/testing/selftests/x86/ptrace_syscall.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#define _GNU_SOURCE
-
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/tools/testing/selftests/x86/sigaltstack.c b/tools/testing/selftests/x86/sigaltstack.c
index f689af75e979..7f41c3a4268b 100644
--- a/tools/testing/selftests/x86/sigaltstack.c
+++ b/tools/testing/selftests/x86/sigaltstack.c
@@ -1,6 +1,4 @@
// SPDX-License-Identifier: GPL-2.0-only
-
-#define _GNU_SOURCE
#include <signal.h>
#include <stdio.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/x86/sigreturn.c b/tools/testing/selftests/x86/sigreturn.c
index 5d7961a5f7f6..2054f729b2c2 100644
--- a/tools/testing/selftests/x86/sigreturn.c
+++ b/tools/testing/selftests/x86/sigreturn.c
@@ -24,9 +24,6 @@
*
* Do not run on outdated, unpatched kernels at risk of nasty crashes.
*/
-
-#define _GNU_SOURCE
-
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/x86/single_step_syscall.c b/tools/testing/selftests/x86/single_step_syscall.c
index 9a30f443e928..375f3b50a0b5 100644
--- a/tools/testing/selftests/x86/single_step_syscall.c
+++ b/tools/testing/selftests/x86/single_step_syscall.c
@@ -9,9 +9,6 @@
* immediately issues #DB from CPL 0. This requires special handling in
* the kernel.
*/
-
-#define _GNU_SOURCE
-
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
diff --git a/tools/testing/selftests/x86/syscall_arg_fault.c b/tools/testing/selftests/x86/syscall_arg_fault.c
index 461fa41a4d02..10eee1bcd015 100644
--- a/tools/testing/selftests/x86/syscall_arg_fault.c
+++ b/tools/testing/selftests/x86/syscall_arg_fault.c
@@ -3,9 +3,6 @@
* syscall_arg_fault.c - tests faults 32-bit fast syscall stack args
* Copyright (c) 2015 Andrew Lutomirski
*/
-
-#define _GNU_SOURCE
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/tools/testing/selftests/x86/syscall_numbering.c b/tools/testing/selftests/x86/syscall_numbering.c
index 991591718bb0..c72fc8aaa4d3 100644
--- a/tools/testing/selftests/x86/syscall_numbering.c
+++ b/tools/testing/selftests/x86/syscall_numbering.c
@@ -5,9 +5,6 @@
*
* Copyright (c) 2018 Andrew Lutomirski
*/
-
-#define _GNU_SOURCE
-
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/x86/sysret_rip.c b/tools/testing/selftests/x86/sysret_rip.c
index 84d74be1d902..24bc219358a5 100644
--- a/tools/testing/selftests/x86/sysret_rip.c
+++ b/tools/testing/selftests/x86/sysret_rip.c
@@ -3,9 +3,6 @@
* sigreturn.c - tests that x86 avoids Intel SYSRET pitfalls
* Copyright (c) 2014-2016 Andrew Lutomirski
*/
-
-#define _GNU_SOURCE
-
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/x86/sysret_ss_attrs.c b/tools/testing/selftests/x86/sysret_ss_attrs.c
index 5f3d4fca440f..f8b9e0b2a0c5 100644
--- a/tools/testing/selftests/x86/sysret_ss_attrs.c
+++ b/tools/testing/selftests/x86/sysret_ss_attrs.c
@@ -7,9 +7,6 @@
* the hidden attributes set to an unusable state. Make sure the kernel
* doesn't let this happen.
*/
-
-#define _GNU_SOURCE
-
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/x86/test_FCMOV.c b/tools/testing/selftests/x86/test_FCMOV.c
index 6b5036fbb735..0c9431ba7d31 100644
--- a/tools/testing/selftests/x86/test_FCMOV.c
+++ b/tools/testing/selftests/x86/test_FCMOV.c
@@ -1,8 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#undef _GNU_SOURCE
-#define _GNU_SOURCE 1
-#undef __USE_GNU
-#define __USE_GNU 1
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tools/testing/selftests/x86/test_FCOMI.c b/tools/testing/selftests/x86/test_FCOMI.c
index aec6692c6dcf..ba186665918d 100644
--- a/tools/testing/selftests/x86/test_FCOMI.c
+++ b/tools/testing/selftests/x86/test_FCOMI.c
@@ -1,8 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#undef _GNU_SOURCE
-#define _GNU_SOURCE 1
-#undef __USE_GNU
-#define __USE_GNU 1
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tools/testing/selftests/x86/test_FISTTP.c b/tools/testing/selftests/x86/test_FISTTP.c
index 09789c0ce3e9..95580cdaaa32 100644
--- a/tools/testing/selftests/x86/test_FISTTP.c
+++ b/tools/testing/selftests/x86/test_FISTTP.c
@@ -1,8 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
-#undef _GNU_SOURCE
-#define _GNU_SOURCE 1
-#undef __USE_GNU
-#define __USE_GNU 1
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tools/testing/selftests/x86/test_mremap_vdso.c b/tools/testing/selftests/x86/test_mremap_vdso.c
index f0d876d48277..a8bdba356682 100644
--- a/tools/testing/selftests/x86/test_mremap_vdso.c
+++ b/tools/testing/selftests/x86/test_mremap_vdso.c
@@ -9,7 +9,6 @@
* Can be built statically:
* gcc -Os -Wall -static -m32 test_mremap_vdso.c
*/
-#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
diff --git a/tools/testing/selftests/x86/test_shadow_stack.c b/tools/testing/selftests/x86/test_shadow_stack.c
index 757e6527f67e..0ceca9064cec 100644
--- a/tools/testing/selftests/x86/test_shadow_stack.c
+++ b/tools/testing/selftests/x86/test_shadow_stack.c
@@ -7,9 +7,6 @@
* special glibc shadow stack support (longjmp(), swapcontext(), etc). Just
* stick to the basics and hope the compiler doesn't do anything strange.
*/
-
-#define _GNU_SOURCE
-
#include <sys/syscall.h>
#include <asm/mman.h>
#include <sys/mman.h>
diff --git a/tools/testing/selftests/x86/test_syscall_vdso.c b/tools/testing/selftests/x86/test_syscall_vdso.c
index 8965c311bd65..5cd13279bba5 100644
--- a/tools/testing/selftests/x86/test_syscall_vdso.c
+++ b/tools/testing/selftests/x86/test_syscall_vdso.c
@@ -8,10 +8,6 @@
* Can be built statically:
* gcc -Os -Wall -static -m32 test_syscall_vdso.c thunks_32.S
*/
-#undef _GNU_SOURCE
-#define _GNU_SOURCE 1
-#undef __USE_GNU
-#define __USE_GNU 1
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
diff --git a/tools/testing/selftests/x86/test_vsyscall.c b/tools/testing/selftests/x86/test_vsyscall.c
index 47cab972807c..cbf4e5012005 100644
--- a/tools/testing/selftests/x86/test_vsyscall.c
+++ b/tools/testing/selftests/x86/test_vsyscall.c
@@ -1,7 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
-
-#define _GNU_SOURCE
-
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
diff --git a/tools/testing/selftests/x86/unwind_vdso.c b/tools/testing/selftests/x86/unwind_vdso.c
index 4c311e1af4c7..754f5d4d425a 100644
--- a/tools/testing/selftests/x86/unwind_vdso.c
+++ b/tools/testing/selftests/x86/unwind_vdso.c
@@ -5,9 +5,6 @@
*
* This tests __kernel_vsyscall's unwind info.
*/
-
-#define _GNU_SOURCE
-
#include <features.h>
#include <stdio.h>
diff --git a/tools/testing/selftests/x86/vdso_restorer.c b/tools/testing/selftests/x86/vdso_restorer.c
index fe99f2434155..8193de22a390 100644
--- a/tools/testing/selftests/x86/vdso_restorer.c
+++ b/tools/testing/selftests/x86/vdso_restorer.c
@@ -10,9 +10,6 @@
* 64-bit userspace has never supported sa_restorer == NULL, so this is
* 32-bit only.
*/
-
-#define _GNU_SOURCE
-
#include <err.h>
#include <stdio.h>
#include <dlfcn.h>
--
2.45.0.rc1.225.g2a3ae87e7f-goog
^ permalink raw reply related
* [PATCH v2 3/5] selftests: Include KHDR_INCLUDES in Makefile
From: Edward Liaw @ 2024-05-07 21:38 UTC (permalink / raw)
To: shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
Will Deacon, Nhat Pham, Johannes Weiner, Christian Brauner,
Eric Biederman, Kees Cook, OGAWA Hirofumi, Thomas Gleixner,
Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
André Almeida, Jiri Kosina, Benjamin Tissoires,
Jason Gunthorpe, Kevin Tian, Andy Lutomirski, Will Drewry,
Marc Zyngier, Oliver Upton, James Morse, Suzuki K Poulose,
Zenghui Yu, Paolo Bonzini, Sean Christopherson, Anup Patel,
Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen,
Muhammad Usama Anjum, Edward Liaw
Cc: linux-kernel, linux-kselftest, kernel-team, linux-sound,
linux-arm-kernel, linux-mm, linux-input, iommu, kvmarm, kvm,
kvm-riscv, linux-riscv, linux-security-module, linux-fsdevel,
netdev, linux-actions, mptcp, linux-rtc, linux-sgx, bpf
In-Reply-To: <20240507214254.2787305-1-edliaw@google.com>
Add KHDR_INCLUDES to CFLAGS to pull in the kselftest harness
dependencies (-D_GNU_SOURCE).
Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Signed-off-by: Edward Liaw <edliaw@google.com>
---
tools/testing/selftests/alsa/Makefile | 2 +-
tools/testing/selftests/arm64/signal/Makefile | 2 +-
tools/testing/selftests/exec/Makefile | 2 +-
tools/testing/selftests/filesystems/overlayfs/Makefile | 2 +-
tools/testing/selftests/hid/Makefile | 2 +-
tools/testing/selftests/nci/Makefile | 2 +-
tools/testing/selftests/prctl/Makefile | 2 ++
tools/testing/selftests/proc/Makefile | 2 +-
tools/testing/selftests/riscv/mm/Makefile | 2 +-
tools/testing/selftests/rtc/Makefile | 2 +-
tools/testing/selftests/tmpfs/Makefile | 2 +-
11 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/tools/testing/selftests/alsa/Makefile b/tools/testing/selftests/alsa/Makefile
index 5af9ba8a4645..9a0ef194522c 100644
--- a/tools/testing/selftests/alsa/Makefile
+++ b/tools/testing/selftests/alsa/Makefile
@@ -6,7 +6,7 @@ LDLIBS += $(shell pkg-config --libs alsa)
ifeq ($(LDLIBS),)
LDLIBS += -lasound
endif
-CFLAGS += -L$(OUTPUT) -Wl,-rpath=./
+CFLAGS += $(KHDR_INCLUDES) -L$(OUTPUT) -Wl,-rpath=./
LDLIBS+=-lpthread
diff --git a/tools/testing/selftests/arm64/signal/Makefile b/tools/testing/selftests/arm64/signal/Makefile
index 8f5febaf1a9a..ae682ade615d 100644
--- a/tools/testing/selftests/arm64/signal/Makefile
+++ b/tools/testing/selftests/arm64/signal/Makefile
@@ -2,7 +2,7 @@
# Copyright (C) 2019 ARM Limited
# Additional include paths needed by kselftest.h and local headers
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
+CFLAGS += $(KHDR_INCLUDES) -std=gnu99 -I.
SRCS := $(filter-out testcases/testcases.c,$(wildcard testcases/*.c))
PROGS := $(patsubst %.c,%,$(SRCS))
diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index fb4472ddffd8..15e78ec7c55e 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
CFLAGS = -Wall
CFLAGS += -Wno-nonnull
-CFLAGS += -D_GNU_SOURCE
+CFLAGS += $(KHDR_INCLUDES)
TEST_PROGS := binfmt_script.py
TEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 load_address_16777216 non-regular
diff --git a/tools/testing/selftests/filesystems/overlayfs/Makefile b/tools/testing/selftests/filesystems/overlayfs/Makefile
index 56b2b48a765b..6c29c963c7a8 100644
--- a/tools/testing/selftests/filesystems/overlayfs/Makefile
+++ b/tools/testing/selftests/filesystems/overlayfs/Makefile
@@ -2,6 +2,6 @@
TEST_GEN_PROGS := dev_in_maps
-CFLAGS := -Wall -Werror
+CFLAGS := -Wall -Werror $(KHDR_INCLUDES)
include ../../lib.mk
diff --git a/tools/testing/selftests/hid/Makefile b/tools/testing/selftests/hid/Makefile
index 2b5ea18bde38..0661b34488ef 100644
--- a/tools/testing/selftests/hid/Makefile
+++ b/tools/testing/selftests/hid/Makefile
@@ -21,7 +21,7 @@ CXX ?= $(CROSS_COMPILE)g++
HOSTPKG_CONFIG := pkg-config
-CFLAGS += -g -O0 -rdynamic -Wall -Werror -I$(OUTPUT)
+CFLAGS += -g -O0 -rdynamic -Wall -Werror $(KHDR_INCLUDES) -I$(OUTPUT)
CFLAGS += -I$(OUTPUT)/tools/include
LDLIBS += -lelf -lz -lrt -lpthread
diff --git a/tools/testing/selftests/nci/Makefile b/tools/testing/selftests/nci/Makefile
index 47669a1d6a59..bbc5b8ec3b17 100644
--- a/tools/testing/selftests/nci/Makefile
+++ b/tools/testing/selftests/nci/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-CFLAGS += -Wl,-no-as-needed -Wall
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
LDFLAGS += -lpthread
TEST_GEN_PROGS := nci_dev
diff --git a/tools/testing/selftests/prctl/Makefile b/tools/testing/selftests/prctl/Makefile
index 01dc90fbb509..1a0aefec9d6f 100644
--- a/tools/testing/selftests/prctl/Makefile
+++ b/tools/testing/selftests/prctl/Makefile
@@ -6,6 +6,8 @@ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
ifeq ($(ARCH),x86)
TEST_PROGS := disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test \
disable-tsc-test set-anon-vma-name-test set-process-name
+
+CFLAGS += $(KHDR_INCLUDES)
all: $(TEST_PROGS)
include ../lib.mk
diff --git a/tools/testing/selftests/proc/Makefile b/tools/testing/selftests/proc/Makefile
index cd95369254c0..9596014c10a0 100644
--- a/tools/testing/selftests/proc/Makefile
+++ b/tools/testing/selftests/proc/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
CFLAGS += -Wall -O2 -Wno-unused-function
-CFLAGS += -D_GNU_SOURCE
+CFLAGS += $(KHDR_INCLUDES)
LDFLAGS += -pthread
TEST_GEN_PROGS :=
diff --git a/tools/testing/selftests/riscv/mm/Makefile b/tools/testing/selftests/riscv/mm/Makefile
index c333263f2b27..715a21241113 100644
--- a/tools/testing/selftests/riscv/mm/Makefile
+++ b/tools/testing/selftests/riscv/mm/Makefile
@@ -3,7 +3,7 @@
# Originally tools/testing/arm64/abi/Makefile
# Additional include paths needed by kselftest.h and local headers
-CFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
+CFLAGS += $(KHDR_INCLUDES) -std=gnu99 -I.
TEST_GEN_FILES := mmap_default mmap_bottomup
diff --git a/tools/testing/selftests/rtc/Makefile b/tools/testing/selftests/rtc/Makefile
index 55198ecc04db..654f9d58da3c 100644
--- a/tools/testing/selftests/rtc/Makefile
+++ b/tools/testing/selftests/rtc/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-CFLAGS += -O3 -Wl,-no-as-needed -Wall
+CFLAGS += -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
LDLIBS += -lrt -lpthread -lm
TEST_GEN_PROGS = rtctest
diff --git a/tools/testing/selftests/tmpfs/Makefile b/tools/testing/selftests/tmpfs/Makefile
index aa11ccc92e5b..bcdc1bb6d2e6 100644
--- a/tools/testing/selftests/tmpfs/Makefile
+++ b/tools/testing/selftests/tmpfs/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
CFLAGS += -Wall -O2
-CFLAGS += -D_GNU_SOURCE
+CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS :=
TEST_GEN_PROGS += bug-link-o-tmpfile
--
2.45.0.rc1.225.g2a3ae87e7f-goog
^ permalink raw reply related
* [PATCH v2 2/5] selftests/sgx: Include KHDR_INCLUDES in Makefile
From: Edward Liaw @ 2024-05-07 21:38 UTC (permalink / raw)
To: shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
Will Deacon, Nhat Pham, Johannes Weiner, Christian Brauner,
Eric Biederman, Kees Cook, OGAWA Hirofumi, Thomas Gleixner,
Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
André Almeida, Jiri Kosina, Benjamin Tissoires,
Jason Gunthorpe, Kevin Tian, Andy Lutomirski, Will Drewry,
Marc Zyngier, Oliver Upton, James Morse, Suzuki K Poulose,
Zenghui Yu, Paolo Bonzini, Sean Christopherson, Anup Patel,
Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen,
Muhammad Usama Anjum, Edward Liaw
Cc: linux-kernel, linux-kselftest, kernel-team, linux-sound,
linux-arm-kernel, linux-mm, linux-input, iommu, kvmarm, kvm,
kvm-riscv, linux-riscv, linux-security-module, linux-fsdevel,
netdev, linux-actions, mptcp, linux-rtc, linux-sgx, bpf,
kernel test robot
In-Reply-To: <20240507214254.2787305-1-edliaw@google.com>
Add KHDR_INCLUDES to the CFLAGS to pull in the kselftest harness
dependencies (-D_GNU_SOURCE).
Also, remove redefinitions of _GNU_SOURCE in the source code.
Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202404301040.3bea5782-oliver.sang@intel.com
Signed-off-by: Edward Liaw <edliaw@google.com>
---
tools/testing/selftests/sgx/Makefile | 2 +-
tools/testing/selftests/sgx/sigstruct.c | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/testing/selftests/sgx/Makefile b/tools/testing/selftests/sgx/Makefile
index 867f88ce2570..26ea30fae23c 100644
--- a/tools/testing/selftests/sgx/Makefile
+++ b/tools/testing/selftests/sgx/Makefile
@@ -12,7 +12,7 @@ OBJCOPY := $(CROSS_COMPILE)objcopy
endif
INCLUDES := -I$(top_srcdir)/tools/include
-HOST_CFLAGS := -Wall -Werror -g $(INCLUDES) -fPIC
+HOST_CFLAGS := -Wall -Werror $(KHDR_INCLUDES) -g $(INCLUDES) -fPIC
HOST_LDFLAGS := -z noexecstack -lcrypto
ENCL_CFLAGS += -Wall -Werror -static-pie -nostdlib -ffreestanding -fPIE \
-fno-stack-protector -mrdrnd $(INCLUDES)
diff --git a/tools/testing/selftests/sgx/sigstruct.c b/tools/testing/selftests/sgx/sigstruct.c
index d73b29becf5b..200034a0fee5 100644
--- a/tools/testing/selftests/sgx/sigstruct.c
+++ b/tools/testing/selftests/sgx/sigstruct.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 2016-20 Intel Corporation. */
-#define _GNU_SOURCE
#include <assert.h>
#include <getopt.h>
#include <stdbool.h>
--
2.45.0.rc1.225.g2a3ae87e7f-goog
^ permalink raw reply related
* [PATCH v2 1/5] selftests: Compile kselftest headers with -D_GNU_SOURCE
From: Edward Liaw @ 2024-05-07 21:38 UTC (permalink / raw)
To: shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
Will Deacon, Nhat Pham, Johannes Weiner, Christian Brauner,
Eric Biederman, Kees Cook, OGAWA Hirofumi, Thomas Gleixner,
Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
André Almeida, Jiri Kosina, Benjamin Tissoires,
Jason Gunthorpe, Kevin Tian, Andy Lutomirski, Will Drewry,
Marc Zyngier, Oliver Upton, James Morse, Suzuki K Poulose,
Zenghui Yu, Paolo Bonzini, Sean Christopherson, Anup Patel,
Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen,
Muhammad Usama Anjum, Edward Liaw
Cc: linux-kernel, linux-kselftest, kernel-team, linux-sound,
linux-arm-kernel, linux-mm, linux-input, iommu, kvmarm, kvm,
kvm-riscv, linux-riscv, linux-security-module, linux-fsdevel,
netdev, linux-actions, mptcp, linux-rtc, linux-sgx, bpf,
kernel test robot
In-Reply-To: <20240507214254.2787305-1-edliaw@google.com>
Add the -D_GNU_SOURCE flag to KHDR_INCLUDES so that it is defined in a
central location.
809216233555 ("selftests/harness: remove use of LINE_MAX") introduced
asprintf into kselftest_harness.h, which is a GNU extension and needs
_GNU_SOURCE to either be defined prior to including headers or with the
-D_GNU_SOURCE flag passed to the compiler.
Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202404301040.3bea5782-oliver.sang@intel.com
Signed-off-by: Edward Liaw <edliaw@google.com>
---
tools/testing/selftests/Makefile | 4 ++--
tools/testing/selftests/kselftest_harness.h | 2 +-
tools/testing/selftests/lib.mk | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index e1504833654d..ed012a7f0786 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -161,11 +161,11 @@ ifneq ($(KBUILD_OUTPUT),)
# $(realpath ...) resolves symlinks
abs_objtree := $(realpath $(abs_objtree))
BUILD := $(abs_objtree)/kselftest
- KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
+ KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
else
BUILD := $(CURDIR)
abs_srctree := $(shell cd $(top_srcdir) && pwd)
- KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
+ KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
DEFAULT_INSTALL_HDR_PATH := 1
endif
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index d98702b6955d..b2a1b6343896 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -51,7 +51,7 @@
#define __KSELFTEST_HARNESS_H
#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
+static_assert(0, "kselftest harness requires _GNU_SOURCE to be defined");
#endif
#include <asm/types.h>
#include <ctype.h>
diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index da2cade3bab0..2503dc732b4d 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -45,7 +45,7 @@ selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
top_srcdir = $(selfdir)/../../..
ifeq ($(KHDR_INCLUDES),)
-KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
+KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
endif
# The following are built by lib.mk common compile rules.
--
2.45.0.rc1.225.g2a3ae87e7f-goog
^ permalink raw reply related
* [PATCH v2 0/5] Define _GNU_SOURCE for sources using
From: Edward Liaw @ 2024-05-07 21:38 UTC (permalink / raw)
To: shuah, Mark Brown, Jaroslav Kysela, Takashi Iwai, Catalin Marinas,
Will Deacon, Nhat Pham, Johannes Weiner, Christian Brauner,
Eric Biederman, Kees Cook, OGAWA Hirofumi, Thomas Gleixner,
Ingo Molnar, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
André Almeida, Jiri Kosina, Benjamin Tissoires,
Jason Gunthorpe, Kevin Tian, Andy Lutomirski, Will Drewry,
Marc Zyngier, Oliver Upton, James Morse, Suzuki K Poulose,
Zenghui Yu, Paolo Bonzini, Sean Christopherson, Anup Patel,
Atish Patra, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
David Hildenbrand, Mickaël Salaün, Paul Moore,
James Morris, Serge E. Hallyn, Andrew Morton, Seth Forshee,
Bongsu Jeon, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steffen Klassert, Herbert Xu, Andreas Färber,
Manivannan Sadhasivam, Matthieu Baerts, Mat Martineau,
Geliang Tang, Willem de Bruijn, Fenghua Yu, Reinette Chatre,
Mathieu Desnoyers, Paul E. McKenney, Boqun Feng,
Alexandre Belloni, Jarkko Sakkinen, Dave Hansen,
Muhammad Usama Anjum, Edward Liaw
Cc: linux-kernel, linux-kselftest, kernel-team, linux-sound,
linux-arm-kernel, linux-mm, linux-input, iommu, kvmarm, kvm,
kvm-riscv, linux-riscv, linux-security-module, linux-fsdevel,
netdev, linux-actions, mptcp, linux-rtc, linux-sgx, bpf
809216233555 ("selftests/harness: remove use of LINE_MAX") introduced
asprintf into kselftest_harness.h, which is a GNU extension and needs
_GNU_SOURCE to either be defined prior to including headers or with the
-D_GNU_SOURCE flag passed to the compiler.
v1: https://lore.kernel.org/linux-kselftest/20240430235057.1351993-1-edliaw@google.com/
v2: add -D_GNU_SOURCE to KHDR_INCLUDES so that it is in a single
location. Remove #define _GNU_SOURCE from source code to resolve
redefinition warnings.
Edward Liaw (5):
selftests: Compile kselftest headers with -D_GNU_SOURCE
selftests/sgx: Include KHDR_INCLUDES in Makefile
selftests: Include KHDR_INCLUDES in Makefile
selftests: Drop define _GNU_SOURCE
selftests: Drop duplicate -D_GNU_SOURCE
tools/testing/selftests/Makefile | 4 ++--
tools/testing/selftests/alsa/Makefile | 2 +-
tools/testing/selftests/arm64/signal/Makefile | 2 +-
tools/testing/selftests/cachestat/test_cachestat.c | 2 --
tools/testing/selftests/capabilities/test_execve.c | 2 --
tools/testing/selftests/clone3/clone3.c | 2 --
.../testing/selftests/clone3/clone3_cap_checkpoint_restore.c | 2 --
tools/testing/selftests/clone3/clone3_clear_sighand.c | 2 --
tools/testing/selftests/clone3/clone3_selftests.h | 1 -
tools/testing/selftests/clone3/clone3_set_tid.c | 2 --
tools/testing/selftests/core/close_range_test.c | 2 --
tools/testing/selftests/drivers/dma-buf/udmabuf.c | 1 -
tools/testing/selftests/exec/Makefile | 2 +-
tools/testing/selftests/fchmodat2/fchmodat2_test.c | 2 --
tools/testing/selftests/filesystems/binderfs/binderfs_test.c | 2 --
tools/testing/selftests/filesystems/devpts_pts.c | 1 -
tools/testing/selftests/filesystems/dnotify_test.c | 1 -
tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c | 2 --
tools/testing/selftests/filesystems/eventfd/eventfd_test.c | 2 --
tools/testing/selftests/filesystems/fat/rename_exchange.c | 2 --
tools/testing/selftests/filesystems/overlayfs/Makefile | 2 +-
tools/testing/selftests/filesystems/overlayfs/dev_in_maps.c | 2 --
.../testing/selftests/filesystems/statmount/statmount_test.c | 3 ---
tools/testing/selftests/futex/functional/Makefile | 2 +-
tools/testing/selftests/futex/functional/futex_requeue_pi.c | 3 ---
tools/testing/selftests/hid/Makefile | 2 +-
tools/testing/selftests/iommu/Makefile | 2 --
tools/testing/selftests/ipc/msgque.c | 1 -
tools/testing/selftests/kcmp/kcmp_test.c | 2 --
tools/testing/selftests/kselftest_harness.h | 2 +-
tools/testing/selftests/kvm/aarch64/arch_timer.c | 2 --
tools/testing/selftests/kvm/aarch64/page_fault_test.c | 1 -
tools/testing/selftests/kvm/aarch64/psci_test.c | 3 ---
tools/testing/selftests/kvm/aarch64/vgic_init.c | 1 -
tools/testing/selftests/kvm/arch_timer.c | 3 ---
tools/testing/selftests/kvm/demand_paging_test.c | 3 ---
tools/testing/selftests/kvm/dirty_log_test.c | 3 ---
tools/testing/selftests/kvm/guest_memfd_test.c | 2 --
tools/testing/selftests/kvm/hardware_disable_test.c | 3 ---
tools/testing/selftests/kvm/include/userfaultfd_util.h | 3 ---
tools/testing/selftests/kvm/kvm_binary_stats_test.c | 2 --
tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 2 --
tools/testing/selftests/kvm/kvm_page_table_test.c | 3 ---
tools/testing/selftests/kvm/lib/assert.c | 3 ---
tools/testing/selftests/kvm/lib/kvm_util.c | 2 --
tools/testing/selftests/kvm/lib/memstress.c | 2 --
tools/testing/selftests/kvm/lib/test_util.c | 2 --
tools/testing/selftests/kvm/lib/userfaultfd_util.c | 3 ---
tools/testing/selftests/kvm/lib/x86_64/sev.c | 1 -
tools/testing/selftests/kvm/max_guest_memory_test.c | 2 --
.../testing/selftests/kvm/memslot_modification_stress_test.c | 3 ---
tools/testing/selftests/kvm/riscv/arch_timer.c | 3 ---
tools/testing/selftests/kvm/rseq_test.c | 1 -
tools/testing/selftests/kvm/s390x/cmma_test.c | 2 --
tools/testing/selftests/kvm/s390x/sync_regs_test.c | 2 --
tools/testing/selftests/kvm/set_memory_region_test.c | 1 -
tools/testing/selftests/kvm/steal_time.c | 1 -
tools/testing/selftests/kvm/x86_64/amx_test.c | 2 --
.../selftests/kvm/x86_64/exit_on_emulation_failure_test.c | 3 ---
tools/testing/selftests/kvm/x86_64/hwcr_msr_test.c | 2 --
tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 2 --
tools/testing/selftests/kvm/x86_64/hyperv_evmcs.c | 1 -
tools/testing/selftests/kvm/x86_64/hyperv_ipi.c | 2 --
tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c | 1 -
tools/testing/selftests/kvm/x86_64/hyperv_tlb_flush.c | 2 --
tools/testing/selftests/kvm/x86_64/nested_exceptions_test.c | 2 --
tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 3 ---
tools/testing/selftests/kvm/x86_64/platform_info_test.c | 2 --
tools/testing/selftests/kvm/x86_64/pmu_counters_test.c | 2 --
tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c | 3 ---
.../selftests/kvm/x86_64/private_mem_conversions_test.c | 1 -
tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c | 1 -
tools/testing/selftests/kvm/x86_64/set_sregs_test.c | 1 -
.../selftests/kvm/x86_64/smaller_maxphyaddr_emulation_test.c | 3 ---
tools/testing/selftests/kvm/x86_64/smm_test.c | 1 -
tools/testing/selftests/kvm/x86_64/state_test.c | 1 -
tools/testing/selftests/kvm/x86_64/sync_regs_test.c | 2 --
tools/testing/selftests/kvm/x86_64/ucna_injection_test.c | 2 --
tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c | 2 --
tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c | 3 ---
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c | 1 -
.../testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c | 1 -
tools/testing/selftests/kvm/x86_64/xapic_ipi_test.c | 2 --
tools/testing/selftests/kvm/x86_64/xapic_state_test.c | 1 -
tools/testing/selftests/kvm/x86_64/xss_msr_test.c | 2 --
tools/testing/selftests/landlock/base_test.c | 2 --
tools/testing/selftests/landlock/fs_test.c | 2 --
tools/testing/selftests/landlock/net_test.c | 2 --
tools/testing/selftests/landlock/ptrace_test.c | 2 --
tools/testing/selftests/lib.mk | 2 +-
tools/testing/selftests/lsm/common.c | 2 --
tools/testing/selftests/lsm/lsm_get_self_attr_test.c | 2 --
tools/testing/selftests/lsm/lsm_list_modules_test.c | 2 --
tools/testing/selftests/lsm/lsm_set_self_attr_test.c | 2 --
tools/testing/selftests/membarrier/membarrier_test_impl.h | 1 -
.../selftests/membarrier/membarrier_test_multi_thread.c | 1 -
.../selftests/membarrier/membarrier_test_single_thread.c | 1 -
tools/testing/selftests/memfd/common.c | 1 -
tools/testing/selftests/memfd/fuse_test.c | 2 --
tools/testing/selftests/memfd/memfd_test.c | 1 -
tools/testing/selftests/mm/cow.c | 1 -
tools/testing/selftests/mm/gup_longterm.c | 1 -
tools/testing/selftests/mm/hugepage-mmap.c | 1 -
tools/testing/selftests/mm/hugepage-mremap.c | 2 --
tools/testing/selftests/mm/hugetlb-madvise.c | 2 --
tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 2 --
tools/testing/selftests/mm/khugepaged.c | 1 -
tools/testing/selftests/mm/ksm_functional_tests.c | 1 -
tools/testing/selftests/mm/madv_populate.c | 1 -
tools/testing/selftests/mm/map_populate.c | 2 --
tools/testing/selftests/mm/mdwe_test.c | 1 -
tools/testing/selftests/mm/memfd_secret.c | 2 --
tools/testing/selftests/mm/mlock2-tests.c | 1 -
tools/testing/selftests/mm/mrelease_test.c | 1 -
tools/testing/selftests/mm/mremap_dontunmap.c | 1 -
tools/testing/selftests/mm/mremap_test.c | 2 --
tools/testing/selftests/mm/pagemap_ioctl.c | 1 -
tools/testing/selftests/mm/pkey-helpers.h | 1 -
tools/testing/selftests/mm/protection_keys.c | 1 -
tools/testing/selftests/mm/split_huge_page_test.c | 2 --
tools/testing/selftests/mm/thuge-gen.c | 2 --
tools/testing/selftests/mm/uffd-common.h | 1 -
tools/testing/selftests/mount_setattr/mount_setattr_test.c | 1 -
.../move_mount_set_group/move_mount_set_group_test.c | 1 -
tools/testing/selftests/nci/Makefile | 2 +-
tools/testing/selftests/net/af_unix/diag_uid.c | 2 --
tools/testing/selftests/net/af_unix/scm_pidfd.c | 1 -
tools/testing/selftests/net/af_unix/unix_connect.c | 2 --
tools/testing/selftests/net/csum.c | 3 ---
tools/testing/selftests/net/gro.c | 3 ---
tools/testing/selftests/net/ip_defrag.c | 3 ---
tools/testing/selftests/net/ipsec.c | 3 ---
tools/testing/selftests/net/ipv6_flowlabel.c | 3 ---
tools/testing/selftests/net/ipv6_flowlabel_mgr.c | 3 ---
tools/testing/selftests/net/mptcp/mptcp_connect.c | 3 ---
tools/testing/selftests/net/mptcp/mptcp_inq.c | 3 ---
tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 3 ---
tools/testing/selftests/net/msg_zerocopy.c | 3 ---
tools/testing/selftests/net/nettest.c | 2 --
tools/testing/selftests/net/psock_fanout.c | 3 ---
tools/testing/selftests/net/psock_snd.c | 3 ---
tools/testing/selftests/net/reuseport_addr_any.c | 3 ---
tools/testing/selftests/net/reuseport_bpf_cpu.c | 3 ---
tools/testing/selftests/net/reuseport_bpf_numa.c | 3 ---
tools/testing/selftests/net/reuseport_dualstack.c | 3 ---
tools/testing/selftests/net/so_incoming_cpu.c | 1 -
tools/testing/selftests/net/so_netns_cookie.c | 1 -
tools/testing/selftests/net/so_txtime.c | 3 ---
tools/testing/selftests/net/tap.c | 3 ---
tools/testing/selftests/net/tcp_ao/Makefile | 2 +-
tools/testing/selftests/net/tcp_fastopen_backup_key.c | 1 -
tools/testing/selftests/net/tcp_inq.c | 2 --
tools/testing/selftests/net/tcp_mmap.c | 1 -
tools/testing/selftests/net/tls.c | 3 ---
tools/testing/selftests/net/toeplitz.c | 3 ---
tools/testing/selftests/net/tun.c | 3 ---
tools/testing/selftests/net/txring_overwrite.c | 3 ---
tools/testing/selftests/net/txtimestamp.c | 3 ---
tools/testing/selftests/net/udpgso.c | 3 ---
tools/testing/selftests/net/udpgso_bench_rx.c | 3 ---
tools/testing/selftests/net/udpgso_bench_tx.c | 3 ---
tools/testing/selftests/perf_events/remove_on_exec.c | 2 --
tools/testing/selftests/perf_events/sigtrap_threads.c | 2 --
tools/testing/selftests/pid_namespace/regression_enomem.c | 1 -
tools/testing/selftests/pidfd/pidfd.h | 1 -
tools/testing/selftests/pidfd/pidfd_fdinfo_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_getfd_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_open_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_poll_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_setns_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_test.c | 2 --
tools/testing/selftests/pidfd/pidfd_wait.c | 2 --
tools/testing/selftests/prctl/Makefile | 2 ++
tools/testing/selftests/proc/Makefile | 2 +-
tools/testing/selftests/ptrace/get_set_sud.c | 1 -
tools/testing/selftests/ptrace/peeksiginfo.c | 1 -
tools/testing/selftests/resctrl/Makefile | 2 +-
tools/testing/selftests/riscv/mm/Makefile | 2 +-
tools/testing/selftests/rseq/basic_percpu_ops_test.c | 1 -
tools/testing/selftests/rseq/basic_test.c | 2 --
tools/testing/selftests/rseq/param_test.c | 1 -
tools/testing/selftests/rseq/rseq.c | 2 --
tools/testing/selftests/rtc/Makefile | 2 +-
tools/testing/selftests/seccomp/seccomp_benchmark.c | 1 -
tools/testing/selftests/seccomp/seccomp_bpf.c | 2 --
tools/testing/selftests/sgx/Makefile | 2 +-
tools/testing/selftests/sgx/sigstruct.c | 1 -
tools/testing/selftests/tmpfs/Makefile | 2 +-
tools/testing/selftests/user_events/abi_test.c | 2 --
tools/testing/selftests/x86/amx.c | 2 --
tools/testing/selftests/x86/check_initial_reg_state.c | 3 ---
tools/testing/selftests/x86/corrupt_xstate_header.c | 3 ---
tools/testing/selftests/x86/entry_from_vm86.c | 3 ---
tools/testing/selftests/x86/fsgsbase.c | 2 --
tools/testing/selftests/x86/fsgsbase_restore.c | 2 --
tools/testing/selftests/x86/ioperm.c | 2 --
tools/testing/selftests/x86/iopl.c | 2 --
tools/testing/selftests/x86/lam.c | 1 -
tools/testing/selftests/x86/ldt_gdt.c | 2 --
tools/testing/selftests/x86/mov_ss_trap.c | 2 --
tools/testing/selftests/x86/nx_stack.c | 2 --
tools/testing/selftests/x86/ptrace_syscall.c | 2 --
tools/testing/selftests/x86/sigaltstack.c | 2 --
tools/testing/selftests/x86/sigreturn.c | 3 ---
tools/testing/selftests/x86/single_step_syscall.c | 3 ---
tools/testing/selftests/x86/syscall_arg_fault.c | 3 ---
tools/testing/selftests/x86/syscall_numbering.c | 3 ---
tools/testing/selftests/x86/sysret_rip.c | 3 ---
tools/testing/selftests/x86/sysret_ss_attrs.c | 3 ---
tools/testing/selftests/x86/test_FCMOV.c | 4 ----
tools/testing/selftests/x86/test_FCOMI.c | 4 ----
tools/testing/selftests/x86/test_FISTTP.c | 4 ----
tools/testing/selftests/x86/test_mremap_vdso.c | 1 -
tools/testing/selftests/x86/test_shadow_stack.c | 3 ---
tools/testing/selftests/x86/test_syscall_vdso.c | 4 ----
tools/testing/selftests/x86/test_vsyscall.c | 3 ---
tools/testing/selftests/x86/unwind_vdso.c | 3 ---
tools/testing/selftests/x86/vdso_restorer.c | 3 ---
218 files changed, 20 insertions(+), 426 deletions(-)
--
2.45.0.rc1.225.g2a3ae87e7f-goog
^ permalink raw reply
* Re: [PATCH v2 7/7] Input: mpr121: Use devm_regulator_get_enable_read_voltage()
From: Dmitry Torokhov @ 2024-05-07 21:15 UTC (permalink / raw)
To: David Lechner
Cc: Liam Girdwood, Mark Brown, Jean Delvare, Guenter Roeck,
Jonathan Cameron, Jonathan Corbet, Support Opensource,
Cosmin Tanislav, Lars-Peter Clausen, Michael Hennerich,
Antoniu Miclaus, Greg Kroah-Hartman, linux-doc, linux-kernel,
linux-hwmon, linux-iio, linux-staging, linux-input,
Jonathan Cameron
In-Reply-To: <20240429-regulator-get-enable-get-votlage-v2-7-b1f11ab766c1@baylibre.com>
On Mon, Apr 29, 2024 at 06:40:15PM -0500, David Lechner wrote:
> We can reduce boilerplate code by using
> devm_regulator_get_enable_read_voltage().
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Mark, maybe you will pick up this one as well?
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers
From: Dmitry Torokhov @ 2024-05-07 21:09 UTC (permalink / raw)
To: Jeff LaBundy
Cc: Mark Brown, Hans de Goede, Charles Wang, hadess, Richard Hughes,
linux-input, linux-kernel, neil.armstrong
In-Reply-To: <ZjpFVGw6PgjRcZY3@nixie71>
On Tue, May 07, 2024 at 10:14:28AM -0500, Jeff LaBundy wrote:
> Hi all,
>
> On Tue, May 07, 2024 at 11:36:41PM +0900, Mark Brown wrote:
> > On Mon, May 06, 2024 at 07:13:38PM -0700, Dmitry Torokhov wrote:
> > > On Mon, May 06, 2024 at 02:03:13PM +0200, Hans de Goede wrote:
> >
> > > > If raw register access is seen as a good solution, then I think this
> > > > should use regmap + some generic helpers (to be written) to export
> > > > regmap r/w access to userspace.
> >
> > > I think the less code we have in kernel the better, especially if in
> > > cases where firmware flashing is not essential for device to work (i.e.
> > > it the controller has a flash memory). That said IIRC Mark felt very
> > > strongly about allowing regmap writes from userspace... but maybe he
> > > softened the stance or we could have this functionality opt-in?
> >
> > I think unmediated raw register access is a terrible idea, you can't
> > safely write a driver if userspace can just go in and randomly write to
> > registers with no coordination with the running driver and for some
> > devices the kernel needs to ensure that any writes don't damage or
> > destabalise the system. If a driver provides an interface that looks
> > like raw register accesses that's of course fine (I mean, a lot of
> > firmware formats basically boil down to register write sequences which
> > is clearly fine) but it should be the driver doing that and it should be
> > looking at what's going on and ensure that it's joined up with the needs
> > of the rest of the system.
>
> I happen to agree here; especially in the case of writing new FW to a
> flash; this is a very hardware-centric and device-specific function,
> which by definition belongs in a kernel driver.
>
> For example, many devices must be placed in a bootloader mode during
> the FW update, and may clamp or toggle an interrupt pin during this
> mode switch. If user space initiates this sequence while the driver is
> unaware of this process, it may attempt to read status registers from
> an I2C address that is temporarily offline.
And yet we have i2c-dev and hidraw that are often successfully used to
flash the firmware, do diagnostics, etc. without encumbering the kernel.
They are more likely to work on ACPI systems because such systems have
separation between power management and function pieces (whereas on
non-ACPI systems power management is crammed into the same driver and it
is not possible to properly power up device without wiring up the rest
of it). This is something that I feel we will have to fix in the long
term.
>
> A much more common design pattern is for the driver to expose one W/O
> sysfs attribute for accepting the FW file name, and one R/O attribute
> for displaying the current FW version in flash. A small script runs at
> start-up to check the version against what is stored on "disk", and if
> what is stored in flash is deemed out of date, the script writes to the
> W/O attribute. This is the extent of user space's involvement.
This however means that code that is not used 99.9999 percent of the
time has to stay in the kernel, occupying precious memory. I agree
that if firmware update is very involved and needs precise control of
interrupts coming from the device and has certain timing restriction,
then in-kernel implementation is preferable, but in many instance
userspace updaters work just fine.
Thanks.
--
Dmitry
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox