qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/6] QEMU bug fixes for 20240320
@ 2024-03-20 10:32 Paolo Bonzini
  2024-03-20 10:32 ` [PULL 1/6] target/i386: fix direction of "32-bit MMU" test Paolo Bonzini
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Paolo Bonzini @ 2024-03-20 10:32 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit ba49d760eb04630e7b15f423ebecf6c871b8f77b:

  Merge tag 'pull-maintainer-final-130324-1' of https://gitlab.com/stsquad/qemu into staging (2024-03-13 15:12:14 +0000)

are available in the Git repository at:

  https://gitlab.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 05007258f02da253af370387b69fe98e9f37b320:

  meson: remove dead dictionary access (2024-03-20 11:30:49 +0100)

----------------------------------------------------------------
* fix use-after-free issue
* fix i386 TLB issue
* fix crash with wrong -M confidential-guest-support argument
* fix NULL pointer dereference in x86 MCE injection

----------------------------------------------------------------
Paolo Bonzini (5):
      target/i386: fix direction of "32-bit MMU" test
      vl: convert qemu_machine_creation_done() to Error **
      vl: do not assert if sev-guest is used together with TCG
      tests/plugins: fix use-after-free bug
      meson: remove dead dictionary access

Tao Su (1):
      target/i386: Revert monitor_puts() in do_inject_x86_mce()

 meson.build              |  2 +-
 target/i386/cpu.h        |  2 +-
 contrib/plugins/howvec.c |  2 +-
 system/vl.c              | 19 +++++++++++--------
 target/i386/cpu.c        |  2 +-
 target/i386/helper.c     |  2 +-
 6 files changed, 16 insertions(+), 13 deletions(-)
-- 
2.44.0



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

* [PULL 1/6] target/i386: fix direction of "32-bit MMU" test
  2024-03-20 10:32 [PULL 0/6] QEMU bug fixes for 20240320 Paolo Bonzini
@ 2024-03-20 10:32 ` Paolo Bonzini
  2024-03-20 10:32 ` [PULL 2/6] vl: convert qemu_machine_creation_done() to Error ** Paolo Bonzini
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2024-03-20 10:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland, qemu-stable

The low bit of MMU indices for x86 TCG indicates whether the processor is
in 32-bit mode and therefore linear addresses have to be masked to 32 bits.
However, the index was computed incorrectly, leading to possible conflicts
in the TLB for any address above 4G.

Analyzed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Fixes: b1661801c18 ("target/i386: Fix physical address truncation", 2024-02-28)
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2206
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/cpu.h | 2 +-
 target/i386/cpu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 952174bb6f5..6b057380791 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -2334,7 +2334,7 @@ static inline bool is_mmu_index_32(int mmu_index)
 
 static inline int cpu_mmu_index_kernel(CPUX86State *env)
 {
-    int mmu_index_32 = (env->hflags & HF_LMA_MASK) ? 1 : 0;
+    int mmu_index_32 = (env->hflags & HF_LMA_MASK) ? 0 : 1;
     int mmu_index_base =
         !(env->hflags & HF_SMAP_MASK) ? MMU_KNOSMAP64_IDX :
         ((env->hflags & HF_CPL_MASK) < 3 && (env->eflags & AC_MASK)) ? MMU_KNOSMAP64_IDX : MMU_KSMAP64_IDX;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 9a210d8d929..33760a2ee16 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -7735,7 +7735,7 @@ static bool x86_cpu_has_work(CPUState *cs)
 static int x86_cpu_mmu_index(CPUState *cs, bool ifetch)
 {
     CPUX86State *env = cpu_env(cs);
-    int mmu_index_32 = (env->hflags & HF_CS64_MASK) ? 1 : 0;
+    int mmu_index_32 = (env->hflags & HF_CS64_MASK) ? 0 : 1;
     int mmu_index_base =
         (env->hflags & HF_CPL_MASK) == 3 ? MMU_USER64_IDX :
         !(env->hflags & HF_SMAP_MASK) ? MMU_KNOSMAP64_IDX :
-- 
2.44.0



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

* [PULL 2/6] vl: convert qemu_machine_creation_done() to Error **
  2024-03-20 10:32 [PULL 0/6] QEMU bug fixes for 20240320 Paolo Bonzini
  2024-03-20 10:32 ` [PULL 1/6] target/i386: fix direction of "32-bit MMU" test Paolo Bonzini
@ 2024-03-20 10:32 ` Paolo Bonzini
  2024-03-20 10:32 ` [PULL 3/6] vl: do not assert if sev-guest is used together with TCG Paolo Bonzini
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2024-03-20 10:32 UTC (permalink / raw)
  To: qemu-devel

Allow using Error ** to pass an error string up to qmp_x_exit_preconfig()
and possibly main().

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 system/vl.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/system/vl.c b/system/vl.c
index 70f4cece7f9..0c970cf0203 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2653,7 +2653,7 @@ static void qemu_create_cli_devices(void)
     rom_reset_order_override();
 }
 
-static void qemu_machine_creation_done(void)
+static bool qemu_machine_creation_done(Error **errp)
 {
     MachineState *machine = MACHINE(qdev_get_machine());
 
@@ -2684,7 +2684,8 @@ static void qemu_machine_creation_done(void)
     }
 
     if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
-        exit(1);
+        error_setg(errp, "could not start gdbserver");
+        return false;
     }
     if (!vga_interface_created && !default_vga &&
         vga_interface_type != VGA_NONE) {
@@ -2692,6 +2693,7 @@ static void qemu_machine_creation_done(void)
                     "type does not use that option; "
                     "No VGA device has been created");
     }
+    return true;
 }
 
 void qmp_x_exit_preconfig(Error **errp)
@@ -2703,7 +2705,9 @@ void qmp_x_exit_preconfig(Error **errp)
 
     qemu_init_board();
     qemu_create_cli_devices();
-    qemu_machine_creation_done();
+    if (!qemu_machine_creation_done(errp)) {
+        return;
+    }
 
     if (loadvm) {
         RunState state = autostart ? RUN_STATE_RUNNING : runstate_get();
-- 
2.44.0



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

* [PULL 3/6] vl: do not assert if sev-guest is used together with TCG
  2024-03-20 10:32 [PULL 0/6] QEMU bug fixes for 20240320 Paolo Bonzini
  2024-03-20 10:32 ` [PULL 1/6] target/i386: fix direction of "32-bit MMU" test Paolo Bonzini
  2024-03-20 10:32 ` [PULL 2/6] vl: convert qemu_machine_creation_done() to Error ** Paolo Bonzini
@ 2024-03-20 10:32 ` Paolo Bonzini
  2024-03-20 10:32 ` [PULL 4/6] target/i386: Revert monitor_puts() in do_inject_x86_mce() Paolo Bonzini
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2024-03-20 10:32 UTC (permalink / raw)
  To: qemu-devel

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 system/vl.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/system/vl.c b/system/vl.c
index 0c970cf0203..c6442229824 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2676,11 +2676,10 @@ static bool qemu_machine_creation_done(Error **errp)
 
     qdev_machine_creation_done();
 
-    if (machine->cgs) {
-        /*
-         * Verify that Confidential Guest Support has actually been initialized
-         */
-        assert(machine->cgs->ready);
+    if (machine->cgs && !machine->cgs->ready) {
+        error_setg(errp, "accelerator does not support confidential guest %s",
+                   object_get_typename(OBJECT(machine->cgs)));
+        exit(1);
     }
 
     if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
-- 
2.44.0



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

* [PULL 4/6] target/i386: Revert monitor_puts() in do_inject_x86_mce()
  2024-03-20 10:32 [PULL 0/6] QEMU bug fixes for 20240320 Paolo Bonzini
                   ` (2 preceding siblings ...)
  2024-03-20 10:32 ` [PULL 3/6] vl: do not assert if sev-guest is used together with TCG Paolo Bonzini
@ 2024-03-20 10:32 ` Paolo Bonzini
  2024-03-20 10:32 ` [PULL 5/6] tests/plugins: fix use-after-free bug Paolo Bonzini
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2024-03-20 10:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Tao Su, Xiaoyao Li, Markus Armbruster

From: Tao Su <tao1.su@linux.intel.com>

monitor_puts() doesn't check the monitor pointer, but do_inject_x86_mce()
may have a parameter with NULL monitor pointer. Revert monitor_puts() in
do_inject_x86_mce() to fix, then the fact that we send the same message to
monitor and log is again more obvious.

Fixes: bf0c50d4aa85 (monitor: expose monitor_puts to rest of code)
Reviwed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Tao Su <tao1.su@linux.intel.com>
Message-ID: <20240320083640.523287-1-tao1.su@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/i386/helper.c b/target/i386/helper.c
index 2070dd0dda1..23ccb23a5b4 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -430,7 +430,7 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data)
         if (need_reset) {
             emit_guest_memory_failure(MEMORY_FAILURE_ACTION_RESET, ar,
                                       recursive);
-            monitor_puts(params->mon, msg);
+            monitor_printf(params->mon, "%s", msg);
             qemu_log_mask(CPU_LOG_RESET, "%s\n", msg);
             qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
             return;
-- 
2.44.0



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

* [PULL 5/6] tests/plugins: fix use-after-free bug
  2024-03-20 10:32 [PULL 0/6] QEMU bug fixes for 20240320 Paolo Bonzini
                   ` (3 preceding siblings ...)
  2024-03-20 10:32 ` [PULL 4/6] target/i386: Revert monitor_puts() in do_inject_x86_mce() Paolo Bonzini
@ 2024-03-20 10:32 ` Paolo Bonzini
  2024-03-20 10:32 ` [PULL 6/6] meson: remove dead dictionary access Paolo Bonzini
  2024-03-20 16:58 ` [PULL 0/6] QEMU bug fixes for 20240320 Peter Maydell
  6 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2024-03-20 10:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alex Bennée, Philippe Mathieu-Daudé

rec->count.score is inside rec, which is freed before rec->count.score is.
Reorder the instructions

Reported by Coverity as CID 1539967.

Cc: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 contrib/plugins/howvec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/plugins/howvec.c b/contrib/plugins/howvec.c
index 2d10c87e0fb..94bbc53820a 100644
--- a/contrib/plugins/howvec.c
+++ b/contrib/plugins/howvec.c
@@ -167,9 +167,9 @@ static gint cmp_exec_count(gconstpointer a, gconstpointer b)
 static void free_record(gpointer data)
 {
     InsnExecCount *rec = (InsnExecCount *) data;
+    qemu_plugin_scoreboard_free(rec->count.score);
     g_free(rec->insn);
     g_free(rec);
-    qemu_plugin_scoreboard_free(rec->count.score);
 }
 
 static void plugin_exit(qemu_plugin_id_t id, void *p)
-- 
2.44.0



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

* [PULL 6/6] meson: remove dead dictionary access
  2024-03-20 10:32 [PULL 0/6] QEMU bug fixes for 20240320 Paolo Bonzini
                   ` (4 preceding siblings ...)
  2024-03-20 10:32 ` [PULL 5/6] tests/plugins: fix use-after-free bug Paolo Bonzini
@ 2024-03-20 10:32 ` Paolo Bonzini
  2024-03-20 16:58 ` [PULL 0/6] QEMU bug fixes for 20240320 Peter Maydell
  6 siblings, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2024-03-20 10:32 UTC (permalink / raw)
  To: qemu-devel

The "link_depends" key has not been used since commit c46f76d1586
("meson: specify fuzz linker script as a project arg", 2020-09-08),
and even before that it was only used for fork-fuzzing which we
removed in commit d2e6f9272d3 ("fuzz: remove fork-fuzzing scaffolding",
2023-02-16).

So, remove it for a very small simplification of meson.build.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index b375248a761..c9c3217ba4b 100644
--- a/meson.build
+++ b/meson.build
@@ -3951,7 +3951,7 @@ foreach target : target_dirs
                c_args: c_args,
                dependencies: arch_deps + deps + exe['dependencies'],
                objects: lib.extract_all_objects(recursive: true),
-               link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
+               link_depends: [block_syms, qemu_syms],
                link_args: link_args,
                win_subsystem: exe['win_subsystem'])
 
-- 
2.44.0



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

* Re: [PULL 0/6] QEMU bug fixes for 20240320
  2024-03-20 10:32 [PULL 0/6] QEMU bug fixes for 20240320 Paolo Bonzini
                   ` (5 preceding siblings ...)
  2024-03-20 10:32 ` [PULL 6/6] meson: remove dead dictionary access Paolo Bonzini
@ 2024-03-20 16:58 ` Peter Maydell
  6 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2024-03-20 16:58 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

On Wed, 20 Mar 2024 at 10:32, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> The following changes since commit ba49d760eb04630e7b15f423ebecf6c871b8f77b:
>
>   Merge tag 'pull-maintainer-final-130324-1' of https://gitlab.com/stsquad/qemu into staging (2024-03-13 15:12:14 +0000)
>
> are available in the Git repository at:
>
>   https://gitlab.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 05007258f02da253af370387b69fe98e9f37b320:
>
>   meson: remove dead dictionary access (2024-03-20 11:30:49 +0100)
>
> ----------------------------------------------------------------
> * fix use-after-free issue
> * fix i386 TLB issue
> * fix crash with wrong -M confidential-guest-support argument
> * fix NULL pointer dereference in x86 MCE injection
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/9.0
for any user-visible changes.

-- PMM


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

end of thread, other threads:[~2024-03-20 16:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-20 10:32 [PULL 0/6] QEMU bug fixes for 20240320 Paolo Bonzini
2024-03-20 10:32 ` [PULL 1/6] target/i386: fix direction of "32-bit MMU" test Paolo Bonzini
2024-03-20 10:32 ` [PULL 2/6] vl: convert qemu_machine_creation_done() to Error ** Paolo Bonzini
2024-03-20 10:32 ` [PULL 3/6] vl: do not assert if sev-guest is used together with TCG Paolo Bonzini
2024-03-20 10:32 ` [PULL 4/6] target/i386: Revert monitor_puts() in do_inject_x86_mce() Paolo Bonzini
2024-03-20 10:32 ` [PULL 5/6] tests/plugins: fix use-after-free bug Paolo Bonzini
2024-03-20 10:32 ` [PULL 6/6] meson: remove dead dictionary access Paolo Bonzini
2024-03-20 16:58 ` [PULL 0/6] QEMU bug fixes for 20240320 Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).