From f2932ce4ea9b69b92f1e711224d90f98c114668e Mon Sep 17 00:00:00 2001 From: MSVSphere Packaging Team Date: Tue, 23 Jan 2024 16:11:22 +0300 Subject: [PATCH] import SLOF-20210217-1.module+el8.9.0+20735+c763a519.1 --- ...erial-Do-not-close-stdout-on-quiesce.patch | 90 +++++++++++++++++++ ...ke-read-and-write-methods-report-fai.patch | 61 +++++++++++++ SPECS/SLOF.spec | 12 ++- 3 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 SOURCES/slof-virtio-serial-Do-not-close-stdout-on-quiesce.patch create mode 100644 SOURCES/slof-virtio-serial-Make-read-and-write-methods-report-fai.patch diff --git a/SOURCES/slof-virtio-serial-Do-not-close-stdout-on-quiesce.patch b/SOURCES/slof-virtio-serial-Do-not-close-stdout-on-quiesce.patch new file mode 100644 index 0000000..6119f6d --- /dev/null +++ b/SOURCES/slof-virtio-serial-Do-not-close-stdout-on-quiesce.patch @@ -0,0 +1,90 @@ +From 75b3aadd67cd00f89304c7ce153da984635ddd4b Mon Sep 17 00:00:00 2001 +From: Thomas Huth +Date: Fri, 10 Nov 2023 12:24:20 +0100 +Subject: [PATCH 2/2] virtio-serial: Do not close stdout on quiesce +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Thomas Huth +RH-MergeRequest: 2: Fix SLOF regression that prevents VM startup with virtio-serial consoles +RH-Jira: RHEL-15999 +RH-Acked-by: Laurent Vivier +RH-Acked-by: Cédric Le Goater +RH-Commit: [2/2] c31c71be9476f21a07ee386a0d62b62e2d37d373 + +Commit 76fee95 ("slof: Only close stdout for virtio-serial devices") +says that commit cf28264 ("virtio-serial: Rework shutdown sequence") +fixed a hang. The problem was believed to be that it was necessary to +close stdout to shutdown the underlying virtio device. + +Commit cf28264 ("virtio-serial: Rework shutdown sequence") closed stdout +on quiesce. This meant when prom_init() called write on stdout after +quiesce, there is a use after free so this is unreliable, and can also +hang (especially after reboots). + +Quiescing is intended to put hardware into a safe state for the client +to take over. It is incorrect for SLOF to close ihandles that the client +could still be using, even after a quiesce. + +Rather than closing the stdout device, all that needs to happen is to +ensure virtio-serial-shutdown gets called. On quiesce, close the virtio +device, but leave the stdout device itself open. + +Commit 8174acd ("virtio-serial: Close device completely") handles reads +and writes as no-ops if the underlying virtio device is closed so there +is no problem with the client calling "write" on stdout after this, but +no output will be displayed. + +Fixes: cf28264 ("virtio-serial: Rework shutdown sequence") +Debugged-by: Kautuk Consul +Co-developed-by: Kautuk Consul +Signed-off-by: Kautuk Consul +Signed-off-by: Jordan Niethe +Reviewed-by: Thomas Huth +Signed-off-by: Alexey Kardashevskiy +(cherry picked from commit dd4d4ea0add97df078d571b48192adaf7c4b0d87) +JIRA: https://issues.redhat.com/browse/RHEL-15999 +Signed-off-by: Thomas Huth +--- + board-qemu/slof/virtio-serial.fs | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/board-qemu/slof/virtio-serial.fs b/board-qemu/slof/virtio-serial.fs +index 41e2e04..de42cc7 100644 +--- a/board-qemu/slof/virtio-serial.fs ++++ b/board-qemu/slof/virtio-serial.fs +@@ -33,16 +33,14 @@ virtio-setup-vd VALUE virtiodev + : virtio-serial-term-key? virtiodev virtio-serial-haschar ; + : virtio-serial-term-key BEGIN virtio-serial-term-key? UNTIL virtiodev virtio-serial-getchar ; + +-: virtio-serial-close-stdout s" stdout" get-chosen IF decode-int nip nip close-dev THEN ; +- + \ Basic device initialization - which has only to be done once + : init ( -- ) + virtiodev virtio-serial-init drop + TRUE to initialized? +- \ Linux closes stdin at some point in prom_init(). This internally triggers a +- \ quiesce in SLOF. We must ensure stdout gets closed as well otherwise the +- \ device cannot be reset properly and the boot will hang. +- ['] virtio-serial-close-stdout add-quiesce-xt ++ \ virtiodev must be shutdown at quiesce so the device is reset properly. ++ \ The read and write methods can be called after quiesce so must handle ++ \ virtiodev being closed. ++ ['] shutdown add-quiesce-xt + ; + + 0 VALUE open-count +@@ -62,8 +60,8 @@ virtiodev virtio-serial-init drop + open-count 0> IF + open-count 1 - dup to open-count + 0= IF shutdown THEN ++ close + THEN +- close + ; + + : write ( addr len -- actual ) +-- +2.39.3 + diff --git a/SOURCES/slof-virtio-serial-Make-read-and-write-methods-report-fai.patch b/SOURCES/slof-virtio-serial-Make-read-and-write-methods-report-fai.patch new file mode 100644 index 0000000..a00f30e --- /dev/null +++ b/SOURCES/slof-virtio-serial-Make-read-and-write-methods-report-fai.patch @@ -0,0 +1,61 @@ +From b9cd05513cc18363f46ad14a09c26b1dbc5c5c3f Mon Sep 17 00:00:00 2001 +From: Thomas Huth +Date: Fri, 10 Nov 2023 12:23:47 +0100 +Subject: [PATCH 1/2] virtio-serial: Make read and write methods report failure +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Thomas Huth +RH-MergeRequest: 2: Fix SLOF regression that prevents VM startup with virtio-serial consoles +RH-Jira: RHEL-15999 +RH-Acked-by: Laurent Vivier +RH-Acked-by: Cédric Le Goater +RH-Commit: [1/2] dbe438e180d62b9550abdc60e6166f88115fe642 + +The read and write methods return successfully even if the virtio device +is closed (virtiodev is 0) and it is not able to send or receive any +characters. + +Make the read and write methods return 0 to indicate they did not +succeed in this case. + +This also fixes an invalid stack access in the read method. + +Fixes: 8174acd ("virtio-serial: Close device completely") +Signed-off-by: Kautuk Consul +Signed-off-by: Jordan Niethe +Reviewed-by: Thomas Huth +Signed-off-by: Alexey Kardashevskiy +(cherry picked from commit 63b66a5147069bda815989732442cb07790609db) +JIRA: https://issues.redhat.com/browse/RHEL-15999 +Signed-off-by: Thomas Huth +--- + board-qemu/slof/virtio-serial.fs | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/board-qemu/slof/virtio-serial.fs b/board-qemu/slof/virtio-serial.fs +index 82868e2..41e2e04 100644 +--- a/board-qemu/slof/virtio-serial.fs ++++ b/board-qemu/slof/virtio-serial.fs +@@ -67,7 +67,7 @@ virtiodev virtio-serial-init drop + ; + + : write ( addr len -- actual ) +- virtiodev 0= IF nip EXIT THEN ++ virtiodev 0= IF 2drop 0 EXIT THEN + tuck + 0 ?DO + dup c@ virtiodev SWAP virtio-serial-putchar +@@ -78,7 +78,7 @@ virtiodev virtio-serial-init drop + + : read ( addr len -- actual ) + 0= IF drop 0 EXIT THEN +- virtiodev 0= IF nip EXIT THEN ++ virtiodev 0= IF drop 0 EXIT THEN + virtiodev virtio-serial-haschar 0= IF 0 swap c! -2 EXIT THEN + virtiodev virtio-serial-getchar swap c! 1 + ; +-- +2.39.3 + diff --git a/SPECS/SLOF.spec b/SPECS/SLOF.spec index c3a3c19..13765a1 100644 --- a/SPECS/SLOF.spec +++ b/SPECS/SLOF.spec @@ -4,7 +4,7 @@ Name: SLOF Version: %{GITDATE} -Release: 1%{?dist} +Release: 1%{?dist}.1 Summary: Slimline Open Firmware Group: Applications/Emulators License: BSD @@ -12,6 +12,10 @@ URL: http://www.openfirmware.info/SLOF Source0: https://github.com/aik/SLOF/archive/qemu-slof-20210217.tar.gz +# For RHEL-15999 - SLOF regression prevents VM startup [rhel-8.9.0.z] +Patch1: slof-virtio-serial-Make-read-and-write-methods-report-fai.patch +# For RHEL-15999 - SLOF regression prevents VM startup [rhel-8.9.0.z] +Patch2: slof-virtio-serial-Do-not-close-stdout-on-quiesce.patch BuildArch: noarch ExclusiveArch: %{power64} @@ -56,6 +60,12 @@ install -c -m 0644 boot_rom.bin $RPM_BUILD_ROOT%{_datadir}/qemu-kvm/slof.bin %{_datadir}/qemu-kvm/slof.bin %changelog +* Wed Nov 22 2023 Miroslav Rezanina - 20210217-1.el8_9.1 +- slof-virtio-serial-Make-read-and-write-methods-report-fai.patch [RHEL-15999] +- slof-virtio-serial-Do-not-close-stdout-on-quiesce.patch [RHEL-15999] +- Resolves: RHEL-15999 + (SLOF regression prevents VM startup [rhel-8.9.0.z]) + * Thu Sep 2 2021 Danilo C. L. de Paula - 20210217-1.el8 - Resolves: bz#2000225 (Rebase virt:rhel module:stream based on AV-8.6)