public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] KVM: Fix ELF segment with RWX permissions warnings
@ 2023-03-13 17:15 Martin Doucha
  2023-03-13 22:12 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Doucha @ 2023-03-13 17:15 UTC (permalink / raw)
  To: ltp

Linker complains that some ASM bootstrap segments have both write
and execute permissions. Rename .data.gdt32 section because the ASM
compiler seems to make it writable regardless of section flags.
Also define new ELF segment for writable data sections.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/kernel/kvm/Makefile           | 2 +-
 testcases/kernel/kvm/bootstrap_x86.S    | 2 +-
 testcases/kernel/kvm/bootstrap_x86_64.S | 2 +-
 testcases/kernel/kvm/linker/x86.lds     | 5 +++--
 testcases/kernel/kvm/linker/x86_64.lds  | 5 +++--
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
index 6986844be..e12cb4e98 100644
--- a/testcases/kernel/kvm/Makefile
+++ b/testcases/kernel/kvm/Makefile
@@ -9,7 +9,7 @@ ASFLAGS =
 CPPFLAGS += -I$(abs_srcdir)/include
 GUEST_CPPFLAGS = $(CPPFLAGS) -DCOMPILE_PAYLOAD
 GUEST_CFLAGS = -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx -mno-sse
-GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none -fno-stack-protector
+GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none -fno-stack-protector -z noexecstack
 GUEST_LDLIBS =
 KVM_LD ?= $(LD)
 
diff --git a/testcases/kernel/kvm/bootstrap_x86.S b/testcases/kernel/kvm/bootstrap_x86.S
index 5ec4c0b7e..1aaf0a4d1 100644
--- a/testcases/kernel/kvm/bootstrap_x86.S
+++ b/testcases/kernel/kvm/bootstrap_x86.S
@@ -31,7 +31,7 @@ protected_mode_entry:
 	mov %eax, %es
 	jmp init_memlayout
 
-.section .data.gdt32, "a", @progbits
+.section .init.gdt32, "a", @progbits
 
 .macro gdt32_entry type:req l=0 d=0 dpl=0 limit=0xfffff g=1 p=1
 	.4byte \limit & 0xffff
diff --git a/testcases/kernel/kvm/bootstrap_x86_64.S b/testcases/kernel/kvm/bootstrap_x86_64.S
index 9ddbd17ed..0cffd5a12 100644
--- a/testcases/kernel/kvm/bootstrap_x86_64.S
+++ b/testcases/kernel/kvm/bootstrap_x86_64.S
@@ -32,7 +32,7 @@ protected_mode_entry:
 	mov %eax, %es
 	jmp init_memlayout
 
-.section .data.gdt32, "a", @progbits
+.section .init.gdt32, "a", @progbits
 
 .macro gdt32_entry type:req l=0 d=0 dpl=0 limit=0xfffff g=1 p=1
 	.4byte \limit & 0xffff
diff --git a/testcases/kernel/kvm/linker/x86.lds b/testcases/kernel/kvm/linker/x86.lds
index 95edb0be0..6e69c4d0f 100644
--- a/testcases/kernel/kvm/linker/x86.lds
+++ b/testcases/kernel/kvm/linker/x86.lds
@@ -4,6 +4,7 @@ PHDRS
 {
 	headers PT_PHDR PHDRS ;
 	text PT_LOAD FILEHDR PHDRS ;
+	data PT_LOAD ;
 	bss PT_LOAD ;
 }
 
@@ -18,7 +19,7 @@ SECTIONS
 	.init.boot :
 	{
 		*(.init.protected_mode)
-		*(.data.gdt32)
+		*(.init.gdt32)
 		*(.init.memlayout)
 	} :text
 
@@ -40,7 +41,7 @@ SECTIONS
 	{
 		*(.data.strings)
 		*(.data)
-	}
+	} :data
 
 	.preinit_array :
 	{
diff --git a/testcases/kernel/kvm/linker/x86_64.lds b/testcases/kernel/kvm/linker/x86_64.lds
index ac372f863..9e62aa5ad 100644
--- a/testcases/kernel/kvm/linker/x86_64.lds
+++ b/testcases/kernel/kvm/linker/x86_64.lds
@@ -4,6 +4,7 @@ PHDRS
 {
 	headers PT_PHDR PHDRS ;
 	text PT_LOAD FILEHDR PHDRS ;
+	data PT_LOAD ;
 	bss PT_LOAD ;
 }
 
@@ -18,7 +19,7 @@ SECTIONS
 	.init.boot :
 	{
 		*(.init.protected_mode)
-		*(.data.gdt32)
+		*(.init.gdt32)
 		*(.init.memlayout)
 	} :text
 
@@ -40,7 +41,7 @@ SECTIONS
 	{
 		*(.data.strings)
 		*(.data)
-	}
+	} :data
 
 	.preinit_array :
 	{
-- 
2.39.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH] KVM: Fix ELF segment with RWX permissions warnings
  2023-03-13 17:15 [LTP] [PATCH] KVM: Fix ELF segment with RWX permissions warnings Martin Doucha
@ 2023-03-13 22:12 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2023-03-13 22:12 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi Martin,

thank you, merged!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-13 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-13 17:15 [LTP] [PATCH] KVM: Fix ELF segment with RWX permissions warnings Martin Doucha
2023-03-13 22:12 ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox