Skip to contentSkip to conversation

drm/i915/gvt: Add __nonstring annotations for unterminated strings

PATCH In review Kees Cook 6 participants 10 messages Mar 10, 2025 – Apr 1, 2025

Subsystems (3)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 drm/i915/gvt: Add __nonstring annotations for unterminated strings

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

---
 drivers/gpu/drm/i915/gvt/opregion.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/opregion.c +2 -2
index 509f9ccae3a9..f701638d3145 100644
@@ -43,7 +43,7 @@
 #define DEVICE_TYPE_EFP4   0x10
 
 struct opregion_header {
-	u8 signature[16];
+	u8 signature[16] __nonstring;
 	u32 size;
 	u32 opregion_ver;
 	u8 bios_ver[32];
@@ -222,7 +222,7 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
 	u8 *buf;
 	struct opregion_header *header;
 	struct vbt v;
-	const char opregion_signature[16] = OPREGION_SIGNATURE;
+	const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
 
 	gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
 	vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
Signature · 1 line
2.34.1
#1 lore raw

✓ i915.CI.BAT: success for drm/i915/gvt: Add __nonstring annotations for unterminated strings

== Series Details ==

== Series Details ==

Series: drm/i915/gvt: Add __nonstring annotations for unterminated strings
URL : https://patchwork.freedesktop.org/series/146111/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_16259 -> Patchwork_146111v1
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146111v1/index.html

Participating hosts (44 -> 43)
------------------------------

Missing (1): fi-snb-2520m

Known issues
------------

Here are the changes found in Patchwork_146111v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@dmabuf@all-tests@dma_fence_chain:
- fi-bsw-nick: [PASS][1] -> [INCOMPLETE][2] ([i915#12904]) +1 other test incomplete
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16259/fi-bsw-nick/igt@dmabuf@all-tests@dma_fence_chain.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146111v1/fi-bsw-nick/igt@dmabuf@all-tests@dma_fence_chain.html

* igt@fbdev@info:
- fi-kbl-8809g: NOTRUN -> [SKIP][3] ([i915#1849])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146111v1/fi-kbl-8809g/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-kbl-8809g: NOTRUN -> [SKIP][4] ([i915#2190])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146111v1/fi-kbl-8809g/igt@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- fi-kbl-8809g: NOTRUN -> [SKIP][5] ([i915#4613]) +3 other tests skip
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146111v1/fi-kbl-8809g/igt@[email protected]

* igt@kms_dsc@dsc-basic:
- fi-kbl-8809g: NOTRUN -> [SKIP][6] +34 other tests skip
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146111v1/fi-kbl-8809g/igt@[email protected]

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
- bat-dg2-11: [PASS][7] -> [SKIP][8] ([i915#9197]) +3 other tests skip
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_16259/bat-dg2-11/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146111v1/bat-dg2-11/igt@[email protected]

[i915#12904]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12904
[i915#1849]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/1849
[i915#2190]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/2190
[i915#4613]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4613
[i915#9197]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9197

Build changes
-------------

* Linux: CI_DRM_16259 -> Patchwork_146111v1

CI-20190529: 20190529
CI_DRM_16259: fd356d116b876e8778d2a52820c832f95dcdd3d5 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_8269: 8269
Patchwork_146111v1: fd356d116b876e8778d2a52820c832f95dcdd3d5 @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_146111v1/index.html

#2 lore raw
In reply to Kees Cook
Quoted 48 lines · Kees Cook

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

---
 drivers/gpu/drm/i915/gvt/opregion.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/opregion.c +2 -2
index 509f9ccae3a9..f701638d3145 100644
@@ -43,7 +43,7 @@
 #define DEVICE_TYPE_EFP4   0x10
 
 struct opregion_header {
-	u8 signature[16];
+	u8 signature[16] __nonstring;
 	u32 size;
 	u32 opregion_ver;
 	u8 bios_ver[32];
@@ -222,7 +222,7 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
 	u8 *buf;
 	struct opregion_header *header;
 	struct vbt v;
-	const char opregion_signature[16] = OPREGION_SIGNATURE;
+	const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
 
 	gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
 	vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
Signature · 1 line
2.34.1

Hello together,

it doesnt resolve the build issue with gcc15 gcc (GCC) 15.0.1 20250228

CC [M] drivers/gpu/drm/i915/gvt/scheduler.o
/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c: In function ‘intel_vgpu_init_opregion’:
/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c:35:28: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
35 | #define OPREGION_SIGNATURE "IntelGraphicsMem"

      |                            ^~~~~~~~~~~~~~~~~~

/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c:225:57: note: in expansion of macro ‘OPREGION_SIGNATURE’
225 | const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
| ^~~~~~~~~~~~~~~~~~
CC [M] drivers/gpu/drm/i915/gvt/trace_points.o
cc1: all warnings being treated as errors
make[7]: *** [/home/damian/kernel/linux/scripts/Makefile.build:207: drivers/gpu/drm/i915/gvt/opregion.o] Error 1 make[7]: *** Waiting for unfinished jobs....
CC [M] drivers/gpu/drm/i915/gvt/vgpu.o
make[6]: *** [/home/damian/kernel/linux/scripts/Makefile.build:465: drivers/gpu/drm/i915] Error 2 make[5]: *** [/home/damian/kernel/linux/s

Signature · 2 lines
VG
Damian Tometzki
maintainer
#3 lore raw
Quoted 31 lines · Damian Tometzki
Quoted 30 lines · Kees Cook

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

---
 drivers/gpu/drm/i915/gvt/opregion.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/opregion.c +0 -0
index 509f9ccae3a9..f701638d3145 100644
@@ -43,7 +43,7 @@
 #define DEVICE_TYPE_EFP4   0x10
 
Quoted 3 lines

drivers/gpu/drm/i915/gvt/opregion.c line 46

Quoted 3 lines
drivers/gpu/drm/i915/gvt/opregion.c +1 -1
 struct opregion_header {
-	u8 signature[16];
+	u8 signature[16] __nonstring;

Why would this annotation be needed? It's not treated as a string anywhere, and it's u8 not char.

Quoted 24 lines
Quoted 15 lines
drivers/gpu/drm/i915/gvt/opregion.c +1 -1
 	u32 size;
 	u32 opregion_ver;
 	u8 bios_ver[32];
@@ -222,7 +222,7 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
 	u8 *buf;
 	struct opregion_header *header;
 	struct vbt v;
-	const char opregion_signature[16] = OPREGION_SIGNATURE;
+	const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
 
 	gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
 	vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
Signature · 1 line
2.34.1

Hello together,

it doesnt resolve the build issue with gcc15 gcc (GCC) 15.0.1 20250228

CC [M] drivers/gpu/drm/i915/gvt/scheduler.o
/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c: In function ‘intel_vgpu_init_opregion’:
/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c:35:28: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
35 | #define OPREGION_SIGNATURE "IntelGraphicsMem"

      |                            ^~~~~~~~~~~~~~~~~~
Quoted 10 lines

/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c:225:57: note: in expansion of macro ‘OPREGION_SIGNATURE’
225 | const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
| ^~~~~~~~~~~~~~~~~~
CC [M] drivers/gpu/drm/i915/gvt/trace_points.o
cc1: all warnings being treated as errors
make[7]: *** [/home/damian/kernel/linux/scripts/Makefile.build:207: drivers/gpu/drm/i915/gvt/opregion.o] Error 1 make[7]: *** Waiting for unfinished jobs....
CC [M] drivers/gpu/drm/i915/gvt/vgpu.o
make[6]: *** [/home/damian/kernel/linux/scripts/Makefile.build:465: drivers/gpu/drm/i915] Error 2 make[5]: *** [/home/damian/kernel/linux/s

What about this?

IMO it's anyway good practice to use sizeof(dest) rather than sizeof(src) for memcpy.

drivers/gpu/drm/i915/gvt/opregion.c +4 -3
index 509f9ccae3a9..dbad4d853d3a 100644
@@ -222,7 +222,6 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
 	u8 *buf;
 	struct opregion_header *header;
 	struct vbt v;
-	const char opregion_signature[16] = OPREGION_SIGNATURE;
 
 	gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
 	vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
@@ -236,8 +235,10 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
 	/* emulated opregion with VBT mailbox only */
 	buf = (u8 *)vgpu_opregion(vgpu)->va;
 	header = (struct opregion_header *)buf;
-	memcpy(header->signature, opregion_signature,
-	       sizeof(opregion_signature));
+
+	static_assert(sizeof(header->signature) == sizeof(OPREGION_SIGNATURE) - 1);
+	memcpy(header->signature, OPREGION_SIGNATURE, sizeof(header->signature));
+
 	header->size = 0x8;
 	header->opregion_ver = 0x02000000;
 	header->mboxes = MBOX_VBT;
Signature · 1 line
Jani Nikula, Intel
#4 lore raw
Quoted 110 lines · Jani Nikula
Quoted 31 lines · Damian Tometzki
Quoted 30 lines · Kees Cook

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

---
 drivers/gpu/drm/i915/gvt/opregion.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/opregion.c +0 -0
index 509f9ccae3a9..f701638d3145 100644
@@ -43,7 +43,7 @@
 #define DEVICE_TYPE_EFP4   0x10
 
Quoted 3 lines

drivers/gpu/drm/i915/gvt/opregion.c line 46

Quoted 3 lines
drivers/gpu/drm/i915/gvt/opregion.c +1 -1
 struct opregion_header {
-    u8 signature[16];
+    u8 signature[16] __nonstring;

Why would this annotation be needed? It's not treated as a string anywhere, and it's u8 not char.

Quoted 24 lines
Quoted 13 lines
drivers/gpu/drm/i915/gvt/opregion.c +1 -2
     u32 size;
     u32 opregion_ver;
     u8 bios_ver[32];
@@ -222,7 +222,7 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
     u8 *buf;
     struct opregion_header *header;
     struct vbt v;
-    const char opregion_signature[16] = OPREGION_SIGNATURE;
+    const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
 
     gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
     vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
--
Quoted 2 lines

2.34.1

Hello together,

it doesnt resolve the build issue with gcc15 gcc (GCC) 15.0.1 20250228

CC [M] drivers/gpu/drm/i915/gvt/scheduler.o
/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c: In function ‘intel_vgpu_init_opregion’:
/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c:35:28: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
35 | #define OPREGION_SIGNATURE "IntelGraphicsMem"

      |                            ^~~~~~~~~~~~~~~~~~
Quoted 10 lines

/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c:225:57: note: in expansion of macro ‘OPREGION_SIGNATURE’
225 | const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
| ^~~~~~~~~~~~~~~~~~
CC [M] drivers/gpu/drm/i915/gvt/trace_points.o
cc1: all warnings being treated as errors
make[7]: *** [/home/damian/kernel/linux/scripts/Makefile.build:207: drivers/gpu/drm/i915/gvt/opregion.o] Error 1 make[7]: *** Waiting for unfinished jobs....
CC [M] drivers/gpu/drm/i915/gvt/vgpu.o
make[6]: *** [/home/damian/kernel/linux/scripts/Makefile.build:465: drivers/gpu/drm/i915] Error 2 make[5]: *** [/home/damian/kernel/linux/s

What about this?

IMO it's anyway good practice to use sizeof(dest) rather than sizeof(src) for memcpy.

drivers/gpu/drm/i915/gvt/opregion.c +4 -4
index 509f9ccae3a9..dbad4d853d3a 100644
@@ -222,7 +222,6 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
        u8 *buf;
        struct opregion_header *header;
        struct vbt v;
-       const char opregion_signature[16] = OPREGION_SIGNATURE;
 
        gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
        vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
@@ -236,8 +235,10 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
        /* emulated opregion with VBT mailbox only */
        buf = (u8 *)vgpu_opregion(vgpu)->va;
        header = (struct opregion_header *)buf;
-       memcpy(header->signature, opregion_signature,
-              sizeof(opregion_signature));
+
+       static_assert(sizeof(header->signature) == sizeof(OPREGION_SIGNATURE) - 1);
+       memcpy(header->signature, OPREGION_SIGNATURE, sizeof(header->signature));
+
        header->size = 0x8;
        header->opregion_ver = 0x02000000;
        header->mboxes = MBOX_VBT;
 
 
 
--
Quoted 1 line

Jani Nikula, Intel

This patch does solve the build issue with gcc-15 on Fedora-42 (gcc-15.0.1-0.9.fc42.x86_64).
https://copr.fedorainfracloud.org/coprs/kwizart/kernel-longterm-6.12/build/8812754/

Thanks.

#5 lore raw
Quoted 111 lines · Nicolas Chauvet
Quoted 109 lines · Jani Nikula
Quoted 31 lines · Damian Tometzki
Quoted 30 lines · Kees Cook

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

---
 drivers/gpu/drm/i915/gvt/opregion.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/opregion.c +0 -0
index 509f9ccae3a9..f701638d3145 100644
@@ -43,7 +43,7 @@
 #define DEVICE_TYPE_EFP4   0x10
 
Quoted 3 lines

drivers/gpu/drm/i915/gvt/opregion.c line 46

Quoted 3 lines
drivers/gpu/drm/i915/gvt/opregion.c +1 -1
 struct opregion_header {
-    u8 signature[16];
+    u8 signature[16] __nonstring;

Why would this annotation be needed? It's not treated as a string anywhere, and it's u8 not char.

Quoted 24 lines
Quoted 13 lines
drivers/gpu/drm/i915/gvt/opregion.c +1 -2
     u32 size;
     u32 opregion_ver;
     u8 bios_ver[32];
@@ -222,7 +222,7 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
     u8 *buf;
     struct opregion_header *header;
     struct vbt v;
-    const char opregion_signature[16] = OPREGION_SIGNATURE;
+    const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
 
     gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
     vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
--
Quoted 2 lines

2.34.1

Hello together,

it doesnt resolve the build issue with gcc15 gcc (GCC) 15.0.1 20250228

CC [M] drivers/gpu/drm/i915/gvt/scheduler.o
/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c: In function ‘intel_vgpu_init_opregion’:
/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c:35:28: error: initializer-string for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
35 | #define OPREGION_SIGNATURE "IntelGraphicsMem"

      |                            ^~~~~~~~~~~~~~~~~~
Quoted 10 lines

/home/damian/kernel/linux/drivers/gpu/drm/i915/gvt/opregion.c:225:57: note: in expansion of macro ‘OPREGION_SIGNATURE’
225 | const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
| ^~~~~~~~~~~~~~~~~~
CC [M] drivers/gpu/drm/i915/gvt/trace_points.o
cc1: all warnings being treated as errors
make[7]: *** [/home/damian/kernel/linux/scripts/Makefile.build:207: drivers/gpu/drm/i915/gvt/opregion.o] Error 1 make[7]: *** Waiting for unfinished jobs....
CC [M] drivers/gpu/drm/i915/gvt/vgpu.o
make[6]: *** [/home/damian/kernel/linux/scripts/Makefile.build:465: drivers/gpu/drm/i915] Error 2 make[5]: *** [/home/damian/kernel/linux/s

What about this?

IMO it's anyway good practice to use sizeof(dest) rather than sizeof(src) for memcpy.

drivers/gpu/drm/i915/gvt/opregion.c +4 -3
index 509f9ccae3a9..dbad4d853d3a 100644
@@ -222,7 +222,6 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
        u8 *buf;
        struct opregion_header *header;
        struct vbt v;
-       const char opregion_signature[16] = OPREGION_SIGNATURE;
 
        gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
        vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
@@ -236,8 +235,10 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
        /* emulated opregion with VBT mailbox only */
        buf = (u8 *)vgpu_opregion(vgpu)->va;
        header = (struct opregion_header *)buf;
-       memcpy(header->signature, opregion_signature,
-              sizeof(opregion_signature));
+
+       static_assert(sizeof(header->signature) == sizeof(OPREGION_SIGNATURE) - 1);
+       memcpy(header->signature, OPREGION_SIGNATURE, sizeof(header->signature));
+
        header->size = 0x8;
        header->opregion_ver = 0x02000000;
        header->mboxes = MBOX_VBT;
Quoted 6 lines
Quoted 2 lines

--
Jani Nikula, Intel

This patch does solve the build issue with gcc-15 on Fedora-42 (gcc-15.0.1-0.9.fc42.x86_64).
https://copr.fedorainfracloud.org/coprs/kwizart/kernel-longterm-6.12/build/8812754/

testet-by Damian Tometzki
Thanks
Damian

Quoted 2 lines

Thanks.

Signature · 2 lines
VG
Damian Tometzki
author
#6 lore raw
In reply to Damian Tometzki
Quoted 44 lines · Damian Tometzki
Quoted 43 lines · Kees Cook

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

---
 drivers/gpu/drm/i915/gvt/opregion.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gvt/opregion.c +2 -2
index 509f9ccae3a9..f701638d3145 100644
@@ -43,7 +43,7 @@
 #define DEVICE_TYPE_EFP4   0x10
 
 struct opregion_header {
-	u8 signature[16];
+	u8 signature[16] __nonstring;
 	u32 size;
 	u32 opregion_ver;
 	u8 bios_ver[32];
@@ -222,7 +222,7 @@ int intel_vgpu_init_opregion(struct intel_vgpu *vgpu)
 	u8 *buf;
 	struct opregion_header *header;
 	struct vbt v;
-	const char opregion_signature[16] = OPREGION_SIGNATURE;
+	const char opregion_signature[16] __nonstring = OPREGION_SIGNATURE;
 
Quoted 8 lines
Quoted 5 lines
drivers/gpu/drm/i915/gvt/opregion.c +0 -0
 	gvt_dbg_core("init vgpu%d opregion\n", vgpu->id);
 	vgpu_opregion(vgpu)->va = (void *)__get_free_pages(GFP_KERNEL |
Signature · 1 line
2.34.1

Hello together,

it doesnt resolve the build issue with gcc15 gcc (GCC) 15.0.1 20250228

This was a recent enhancement to GCC, and that 20250228 build does not include it. (GCC 15 is not actually released yet...)

Signature · 1 line
Kees Cook
Tested-by on v1 1/1
#7 lore raw
In reply to Kees Cook
Quoted 9 lines · Kees Cook

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

To provide another small data point:

A "Compile-Tested-by", to be precise: after a handful similar patches reached mainline recently this is the only one I still need to compile the pretty broad Fedora rawhide config on rawhide using the GCC 15 pre-release it currently includes. The latter or the final will hopefully soon also reach Fedora 42 beta as well and bring the "[1]" mentioned in the patch description above to F42 -- which will be released in a few weeks, so I guess it would be nice to have this patch mainlined rather sooner that later to avoid more people running into this.

HTH, ciao, Thorsten

maintainer
#8 lore raw
Quoted 15 lines · Thorsten Leemhuis
Quoted 9 lines · Kees Cook

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

To provide another small data point:

Quoted 8 lines

A "Compile-Tested-by", to be precise: after a handful similar patches reached mainline recently this is the only one I still need to compile the pretty broad Fedora rawhide config on rawhide using the GCC 15 pre-release it currently includes. The latter or the final will hopefully soon also reach Fedora 42 beta as well and bring the "[1]" mentioned in the patch description above to F42 -- which will be released in a few weeks, so I guess it would be nice to have this patch mainlined rather sooner that later to avoid more people running into this.

Thanks for testing, though I've merged [1] instead.

BR,
Jani.

[1] https://lore.kernel.org/r/[email protected]

Signature · 1 line
Jani Nikula, Intel
#9 lore raw
Quoted 25 lines · Jani Nikula
Quoted 15 lines · Thorsten Leemhuis
Quoted 9 lines · Kees Cook

When a character array without a terminating NUL character has a static initializer, GCC 15's -Wunterminated-string-initialization will only warn if the array lacks the "nonstring" attribute[1]. Mark the arrays with __nonstring to and correctly identify the char array as "not a C string" and thereby eliminate the warning.

To provide another small data point:

Quoted 8 lines

A "Compile-Tested-by", to be precise: after a handful similar patches reached mainline recently this is the only one I still need to compile the pretty broad Fedora rawhide config on rawhide using the GCC 15 pre-release it currently includes. The latter or the final will hopefully soon also reach Fedora 42 beta as well and bring the "[1]" mentioned in the patch description above to F42 -- which will be released in a few weeks, so I guess it would be nice to have this patch mainlined rather sooner that later to avoid more people running into this.

Quoted 3 lines

Thanks for testing, though I've merged [1] instead.

[1] https://lore.kernel.org/r/[email protected]

Yeah, sorry, I only spotted that one two hours ago and started a test compile a while ago, but seems I'm too late here. Whatever, happens. :-D

Many thx for taking care of that! Ciao, Thorsten