From 26c10b56eeacc17a7e11b1930012582577b30b23 Mon Sep 17 00:00:00 2001 From: Miroslav Rezanina Date: Wed, 12 Jul 2023 15:31:57 +0200 Subject: [PATCH] Add fixes necessary for ELN build to pass Fixing 2 issues with ELEN buildroot: - xkeyboard-config removed legacy 'ar' map - clang + binutils 2.4 are failing to build s390-ccw Signed-off-by: Miroslav Rezanina --- ...e-ara-X11-keyboard-map-instead-of-ar.patch | 33 +++ ...-Makefile-Use-z-noexecstack-to-silen.patch | 40 ++++ ...-s390-ccw-Fix-indentation-in-start.S.patch | 211 ++++++++++++++++++ ...-Provide-space-for-initial-stack-fra.patch | 52 +++++ ...-Don-t-use-__bss_start-with-the-larl.patch | 68 ++++++ qemu.spec | 7 + 6 files changed, 411 insertions(+) create mode 100644 1001-keymaps-use-ara-X11-keyboard-map-instead-of-ar.patch create mode 100644 1002-pc-bios-s390-ccw-Makefile-Use-z-noexecstack-to-silen.patch create mode 100644 1003-pc-bios-s390-ccw-Fix-indentation-in-start.S.patch create mode 100644 1004-pc-bios-s390-ccw-Provide-space-for-initial-stack-fra.patch create mode 100644 1005-pc-bios-s390-ccw-Don-t-use-__bss_start-with-the-larl.patch diff --git a/1001-keymaps-use-ara-X11-keyboard-map-instead-of-ar.patch b/1001-keymaps-use-ara-X11-keyboard-map-instead-of-ar.patch new file mode 100644 index 0000000..232474c --- /dev/null +++ b/1001-keymaps-use-ara-X11-keyboard-map-instead-of-ar.patch @@ -0,0 +1,33 @@ +From 46ae4ae0cec2af37130f235ffea9d615f3990364 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= +Date: Fri, 23 Jun 2023 12:05:20 +0200 +Subject: [PATCH] keymaps: use 'ara' X11 keyboard map instead of 'ar' +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The keyboard mapping name 'ar' was a legacy name only available from +xkeyboard-config via a (15 year old) backcompat mapping. This mapping +was finally removed in the latest upstream release 2.39: + + https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/commit/470ad2cd8fea84d7210377161d86b31999bb5ea6 + +Signed-off-by: Daniel P. Berrangé +--- + pc-bios/keymaps/meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pc-bios/keymaps/meson.build b/pc-bios/keymaps/meson.build +index 158a3b410..1cbcdebef 100644 +--- a/pc-bios/keymaps/meson.build ++++ b/pc-bios/keymaps/meson.build +@@ -1,5 +1,5 @@ + keymaps = { +- 'ar': '-l ar', ++ 'ar': '-l ara', + 'bepo': '-l fr -v dvorak', + 'cz': '-l cz', + 'da': '-l dk', +-- +2.40.1 + diff --git a/1002-pc-bios-s390-ccw-Makefile-Use-z-noexecstack-to-silen.patch b/1002-pc-bios-s390-ccw-Makefile-Use-z-noexecstack-to-silen.patch new file mode 100644 index 0000000..434942c --- /dev/null +++ b/1002-pc-bios-s390-ccw-Makefile-Use-z-noexecstack-to-silen.patch @@ -0,0 +1,40 @@ +From d8048e4eb5efcc52c4c77c3443a1cabbf12d087c Mon Sep 17 00:00:00 2001 +From: Thomas Huth +Date: Thu, 22 Jun 2023 15:08:22 +0200 +Subject: [PATCH 1/4] pc-bios/s390-ccw/Makefile: Use -z noexecstack to silence + linker warning + +Recent versions of ld complain when linking the s390-ccw bios: + + /usr/bin/ld: warning: start.o: missing .note.GNU-stack section implies + executable stack + /usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in + a future version of the linker + +We can silence the warning by telling the linker to mark the stack +as not executable. + +Message-Id: <20230622130822.396793-1-thuth@redhat.com> +Acked-by: Christian Borntraeger +Signed-off-by: Thomas Huth +(cherry picked from commit 442ef32ee5b6059a8f247fb2def9d449578d0a89) +--- + pc-bios/s390-ccw/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile +index 10e8f5cb63..2a590af4a9 100644 +--- a/pc-bios/s390-ccw/Makefile ++++ b/pc-bios/s390-ccw/Makefile +@@ -53,7 +53,7 @@ config-cc.mak: Makefile + $(call cc-option,-march=z900,-march=z10)) 3> config-cc.mak + -include config-cc.mak + +-LDFLAGS += -Wl,-pie -nostdlib ++LDFLAGS += -Wl,-pie -nostdlib -z noexecstack + + build-all: s390-ccw.img s390-netboot.img + +-- +2.39.3 + diff --git a/1003-pc-bios-s390-ccw-Fix-indentation-in-start.S.patch b/1003-pc-bios-s390-ccw-Fix-indentation-in-start.S.patch new file mode 100644 index 0000000..25e037e --- /dev/null +++ b/1003-pc-bios-s390-ccw-Fix-indentation-in-start.S.patch @@ -0,0 +1,211 @@ +From ef50e8f94f0467d7f55745be9f58c7cd369e57c6 Mon Sep 17 00:00:00 2001 +From: Thomas Huth +Date: Tue, 27 Jun 2023 09:47:00 +0200 +Subject: [PATCH 2/4] pc-bios/s390-ccw: Fix indentation in start.S +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +start.S is currently indented with a mixture of spaces and tabs, which +is quite ugly. QEMU coding style says indentation should be 4 spaces, +and this is also what we are using in the assembler files in the +tests/tcg/s390x/ folder already, so let's adjust start.S accordingly. + +Reviewed-by: Cédric Le Goater +Message-Id: <20230627074703.99608-2-thuth@redhat.com> +Reviewed-by: Claudio Imbrenda +Reviewed-by: Eric Farman +Reviewed-by: Philippe Mathieu-Daudé +Signed-off-by: Thomas Huth +(cherry picked from commit f52420fa4fd9f519dc42c20d2616aba4149adc25) +--- + pc-bios/s390-ccw/start.S | 136 +++++++++++++++++++-------------------- + 1 file changed, 68 insertions(+), 68 deletions(-) + +diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S +index 6072906df4..d29de09cc6 100644 +--- a/pc-bios/s390-ccw/start.S ++++ b/pc-bios/s390-ccw/start.S +@@ -10,37 +10,37 @@ + * directory. + */ + +- .globl _start ++ .globl _start + _start: + +- larl %r15, stack + 0x8000 /* Set up stack */ ++ larl %r15,stack + 0x8000 /* Set up stack */ + +- /* clear bss */ +- larl %r2, __bss_start +- larl %r3, _end +- slgr %r3, %r2 /* get sizeof bss */ +- ltgr %r3,%r3 /* bss empty? */ +- jz done +- aghi %r3,-1 +- srlg %r4,%r3,8 /* how many 256 byte chunks? */ +- ltgr %r4,%r4 +- lgr %r1,%r2 +- jz remainder ++ /* clear bss */ ++ larl %r2,__bss_start ++ larl %r3,_end ++ slgr %r3,%r2 /* get sizeof bss */ ++ ltgr %r3,%r3 /* bss empty? */ ++ jz done ++ aghi %r3,-1 ++ srlg %r4,%r3,8 /* how many 256 byte chunks? */ ++ ltgr %r4,%r4 ++ lgr %r1,%r2 ++ jz remainder + loop: +- xc 0(256,%r1),0(%r1) +- la %r1,256(%r1) +- brctg %r4,loop ++ xc 0(256,%r1),0(%r1) ++ la %r1,256(%r1) ++ brctg %r4,loop + remainder: +- larl %r2,memsetxc +- ex %r3,0(%r2) ++ larl %r2,memsetxc ++ ex %r3,0(%r2) + done: +- /* set up a pgm exception disabled wait psw */ +- larl %r2, disabled_wait_psw +- mvc 0x01d0(16), 0(%r2) +- j main /* And call C */ ++ /* set up a pgm exception disabled wait psw */ ++ larl %r2,disabled_wait_psw ++ mvc 0x01d0(16),0(%r2) ++ j main /* And call C */ + + memsetxc: +- xc 0(1,%r1),0(%r1) ++ xc 0(1,%r1),0(%r1) + + + /* +@@ -48,11 +48,11 @@ memsetxc: + * + * stops the current guest cpu. + */ +- .globl disabled_wait ++ .globl disabled_wait + disabled_wait: +- larl %r1,disabled_wait_psw +- lpswe 0(%r1) +-1: j 1b ++ larl %r1,disabled_wait_psw ++ lpswe 0(%r1) ++1: j 1b + + + /* +@@ -60,61 +60,61 @@ disabled_wait: + * + * eats one sclp interrupt + */ +- .globl consume_sclp_int ++ .globl consume_sclp_int + consume_sclp_int: +- /* enable service interrupts in cr0 */ +- stctg %c0,%c0,0(%r15) +- oi 6(%r15),0x2 +- lctlg %c0,%c0,0(%r15) +- /* prepare external call handler */ +- larl %r1, external_new_code +- stg %r1, 0x1b8 +- larl %r1, external_new_mask +- mvc 0x1b0(8),0(%r1) +- /* load enabled wait PSW */ +- larl %r1, enabled_wait_psw +- lpswe 0(%r1) ++ /* enable service interrupts in cr0 */ ++ stctg %c0,%c0,0(%r15) ++ oi 6(%r15),0x2 ++ lctlg %c0,%c0,0(%r15) ++ /* prepare external call handler */ ++ larl %r1,external_new_code ++ stg %r1,0x1b8 ++ larl %r1,external_new_mask ++ mvc 0x1b0(8),0(%r1) ++ /* load enabled wait PSW */ ++ larl %r1,enabled_wait_psw ++ lpswe 0(%r1) + + /* + * void consume_io_int(void) + * + * eats one I/O interrupt + */ +- .globl consume_io_int ++ .globl consume_io_int + consume_io_int: +- /* enable I/O interrupts in cr6 */ +- stctg %c6,%c6,0(%r15) +- oi 4(%r15), 0xff +- lctlg %c6,%c6,0(%r15) +- /* prepare i/o call handler */ +- larl %r1, io_new_code +- stg %r1, 0x1f8 +- larl %r1, io_new_mask +- mvc 0x1f0(8),0(%r1) +- /* load enabled wait PSW */ +- larl %r1, enabled_wait_psw +- lpswe 0(%r1) ++ /* enable I/O interrupts in cr6 */ ++ stctg %c6,%c6,0(%r15) ++ oi 4(%r15), 0xff ++ lctlg %c6,%c6,0(%r15) ++ /* prepare i/o call handler */ ++ larl %r1,io_new_code ++ stg %r1,0x1f8 ++ larl %r1,io_new_mask ++ mvc 0x1f0(8),0(%r1) ++ /* load enabled wait PSW */ ++ larl %r1,enabled_wait_psw ++ lpswe 0(%r1) + + external_new_code: +- /* disable service interrupts in cr0 */ +- stctg %c0,%c0,0(%r15) +- ni 6(%r15),0xfd +- lctlg %c0,%c0,0(%r15) +- br %r14 ++ /* disable service interrupts in cr0 */ ++ stctg %c0,%c0,0(%r15) ++ ni 6(%r15),0xfd ++ lctlg %c0,%c0,0(%r15) ++ br %r14 + + io_new_code: +- /* disable I/O interrupts in cr6 */ +- stctg %c6,%c6,0(%r15) +- ni 4(%r15), 0x00 +- lctlg %c6,%c6,0(%r15) +- br %r14 ++ /* disable I/O interrupts in cr6 */ ++ stctg %c6,%c6,0(%r15) ++ ni 4(%r15),0x00 ++ lctlg %c6,%c6,0(%r15) ++ br %r14 + +- .align 8 ++ .align 8 + disabled_wait_psw: +- .quad 0x0002000180000000,0x0000000000000000 ++ .quad 0x0002000180000000,0x0000000000000000 + enabled_wait_psw: +- .quad 0x0302000180000000,0x0000000000000000 ++ .quad 0x0302000180000000,0x0000000000000000 + external_new_mask: +- .quad 0x0000000180000000 ++ .quad 0x0000000180000000 + io_new_mask: +- .quad 0x0000000180000000 ++ .quad 0x0000000180000000 +-- +2.39.3 + diff --git a/1004-pc-bios-s390-ccw-Provide-space-for-initial-stack-fra.patch b/1004-pc-bios-s390-ccw-Provide-space-for-initial-stack-fra.patch new file mode 100644 index 0000000..896dc6e --- /dev/null +++ b/1004-pc-bios-s390-ccw-Provide-space-for-initial-stack-fra.patch @@ -0,0 +1,52 @@ +From 5db331dc14cea38ceb96f7cd55365f7c7d326c29 Mon Sep 17 00:00:00 2001 +From: Thomas Huth +Date: Tue, 27 Jun 2023 09:47:01 +0200 +Subject: [PATCH 3/4] pc-bios/s390-ccw: Provide space for initial stack frame + in start.S +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Providing the space of a stack frame is the duty of the caller, +so we should reserve 160 bytes before jumping into the main function. +Otherwise the main() function might write past the stack array. + +While we're at it, add a proper STACK_SIZE macro for the stack size +instead of using magic numbers (this is also required for the following +patch). + +Reviewed-by: Christian Borntraeger +Reviewed-by: Cédric Le Goater +Message-Id: <20230627074703.99608-3-thuth@redhat.com> +Reviewed-by: Eric Farman +Reviewed-by: Claudio Imbrenda +Reviewed-by: Marc Hartmayer +Reviewed-by: Philippe Mathieu-Daudé +Signed-off-by: Thomas Huth +(cherry picked from commit 74fe98ee7fb3344dbd085d1fa32c0dc2fc2c831f) +--- + pc-bios/s390-ccw/start.S | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S +index d29de09cc6..abd6fe6639 100644 +--- a/pc-bios/s390-ccw/start.S ++++ b/pc-bios/s390-ccw/start.S +@@ -10,10 +10,13 @@ + * directory. + */ + ++#define STACK_SIZE 0x8000 ++#define STACK_FRAME_SIZE 160 ++ + .globl _start + _start: + +- larl %r15,stack + 0x8000 /* Set up stack */ ++ larl %r15,stack + STACK_SIZE - STACK_FRAME_SIZE /* Set up stack */ + + /* clear bss */ + larl %r2,__bss_start +-- +2.39.3 + diff --git a/1005-pc-bios-s390-ccw-Don-t-use-__bss_start-with-the-larl.patch b/1005-pc-bios-s390-ccw-Don-t-use-__bss_start-with-the-larl.patch new file mode 100644 index 0000000..ae3bac6 --- /dev/null +++ b/1005-pc-bios-s390-ccw-Don-t-use-__bss_start-with-the-larl.patch @@ -0,0 +1,68 @@ +From ee8a96338078126e17d6aa8569b4638fdfa9423b Mon Sep 17 00:00:00 2001 +From: Thomas Huth +Date: Tue, 27 Jun 2023 09:47:03 +0200 +Subject: [PATCH 4/4] pc-bios/s390-ccw: Don't use __bss_start with the "larl" + instruction + +start.S currently cannot be compiled with Clang 16 and binutils 2.40: + + ld: start.o(.text+0x8): misaligned symbol `__bss_start' (0xc1e5) for + relocation R_390_PC32DBL + +According to the built-in linker script of ld, the symbol __bss_start +can actually point *before* the .bss section and does not need to have +any alignment, so in certain situations (like when using the internal +assembler of Clang), the __bss_start symbol can indeed be unaligned +and thus it is not suitable for being used with the "larl" instruction +that needs an address that is at least aligned to halfwords. +The problem went unnoticed so far since binutils <= 2.39 did not +check the alignment, but starting with binutils 2.40, such unaligned +addresses are now refused. + +Fix it by loading the address indirectly instead. + +Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2216662 +Reported-by: Miroslav Rezanina +Suggested-by: Andreas Krebbel +Message-Id: <20230629104821.194859-8-thuth@redhat.com> +Reviewed-by: Claudio Imbrenda +Signed-off-by: Thomas Huth +(cherry picked from commit 7cd50cbe4ca3e2860b31b06ec92c17c54bd82d48) +--- + pc-bios/s390-ccw/start.S | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S +index abd6fe6639..22c1c296df 100644 +--- a/pc-bios/s390-ccw/start.S ++++ b/pc-bios/s390-ccw/start.S +@@ -19,7 +19,8 @@ _start: + larl %r15,stack + STACK_SIZE - STACK_FRAME_SIZE /* Set up stack */ + + /* clear bss */ +- larl %r2,__bss_start ++ larl %r2,bss_start_literal /* __bss_start might be unaligned ... */ ++ lg %r2,0(%r2) /* ... so load it indirectly */ + larl %r3,_end + slgr %r3,%r2 /* get sizeof bss */ + ltgr %r3,%r3 /* bss empty? */ +@@ -45,7 +46,6 @@ done: + memsetxc: + xc 0(1,%r1),0(%r1) + +- + /* + * void disabled_wait(void) + * +@@ -113,6 +113,8 @@ io_new_code: + br %r14 + + .align 8 ++bss_start_literal: ++ .quad __bss_start + disabled_wait_psw: + .quad 0x0002000180000000,0x0000000000000000 + enabled_wait_psw: +-- +2.39.3 + diff --git a/qemu.spec b/qemu.spec index ad8ea7e..8bc652f 100644 --- a/qemu.spec +++ b/qemu.spec @@ -373,6 +373,13 @@ Patch109: kvm-kvm-reuse-per-vcpu-stats-fd-to-avoid-vcpu-interrupti.patch # For bz#2128929 - [rhel9.2] hotplug/hotunplug mlx vdpa device to the occupied addr port, then qemu core dump occurs after shutdown guest Patch110: kvm-vhost-vdpa-do-not-cleanup-the-vdpa-vhost-net-structu.patch +# ELN specific changes +Patch1001: 1001-keymaps-use-ara-X11-keyboard-map-instead-of-ar.patch +Patch1002: 1002-pc-bios-s390-ccw-Makefile-Use-z-noexecstack-to-silen.patch +Patch1003: 1003-pc-bios-s390-ccw-Fix-indentation-in-start.S.patch +Patch1004: 1004-pc-bios-s390-ccw-Provide-space-for-initial-stack-fra.patch +Patch1005: 1005-pc-bios-s390-ccw-Don-t-use-__bss_start-with-the-larl.patch + %if %{have_clang} BuildRequires: clang %if %{have_safe_stack}