qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL v2 00/21] i386, qgraph patches for 2020-02-15
@ 2021-02-16 18:26 Paolo Bonzini
  2021-02-16 18:26 ` [PULL 20/21] event_notifier: Set ->initialized earlier in event_notifier_init() Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-02-16 18:26 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit 8ba4bca570ace1e60614a0808631a517cf5df67a:

  Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2021-02-15 17:13:57 +0000)

are available in the Git repository at:

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

for you to fetch changes up to 366a85e4bb748794b1ae0ca0ccc2d95f316679a0:

  replay: fix icount request when replaying clock access (2021-02-16 17:15:39 +0100)

----------------------------------------------------------------
* HVF fixes
* Extra qos-test debugging output (Christian)
* SEV secret address autodetection (James)
* SEV-ES support (Thomas)
* Relocatable paths bugfix (Stefan)
* RR fix (Pavel)
* EventNotifier fix (Greg)

----------------------------------------------------------------
Alexander Graf (2):
      hvf: x86: Remove unused definitions
      hvf: Fetch cr4 before evaluating CPUID(1)

Christian Schoenebeck (5):
      libqos/qgraph: add qos_node_create_driver_named()
      libqos/qgraph_internal: add qos_printf() and qos_printf_literal()
      tests/qtest/qos-test: dump qos graph if verbose
      tests/qtest/qos-test: dump environment variables if verbose
      tests/qtest/qos-test: dump QEMU command if verbose

Greg Kurz (1):
      event_notifier: Set ->initialized earlier in event_notifier_init()

Hill Ma (1):
      hvf: Guard xgetbv call

James Bottomley (2):
      pc: add parser for OVMF reset block
      sev: update sev-inject-launch-secret to make gpa optional

Paolo Bonzini (1):
      sev/i386: Allow AP booting under SEV-ES

Pavel Dovgalyuk (1):
      replay: fix icount request when replaying clock access

Stefan Weil (1):
      util/cutils: Skip "." when looking for next directory component

Tom Lendacky (5):
      sev/i386: Add initial support for SEV-ES
      sev/i386: Require in-kernel irqchip support for SEV-ES guests
      sev/i386: Don't allow a system reset under an SEV-ES guest
      kvm/i386: Use a per-VM check for SMM capability
      sev/i386: Enable an SEV-ES guest based on SEV policy

Vladislav Yaroshchuk (2):
      target/i386/hvf: add vmware-cpuid-freq cpu feature
      target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT

 accel/kvm/kvm-all.c                  |   6 +-
 hw/i386/pc_sysfw.c                   | 130 ++++++++++++++++++++++++-
 include/hw/i386/pc.h                 |   4 +
 include/sysemu/cpus.h                |   2 +
 include/sysemu/hw_accel.h            |   5 +
 include/sysemu/kvm.h                 |  10 ++
 include/sysemu/replay.h              |  14 +--
 include/sysemu/sev.h                 |   5 +
 qapi/misc-target.json                |   2 +-
 replay/replay-internal.c             |  29 +++++-
 replay/replay-time.c                 |   4 +-
 replay/replay.c                      |  23 +----
 softmmu/cpus.c                       |   5 +
 softmmu/runstate.c                   |   3 +
 stubs/replay-tools.c                 |   2 +-
 target/arm/kvm.c                     |   5 +
 target/i386/cpu.c                    |   1 +
 target/i386/cpu.h                    |   1 +
 target/i386/hvf/hvf-i386.h           |  16 ----
 target/i386/hvf/hvf.c                | 100 +++++++++++++++++++-
 target/i386/hvf/x86_cpuid.c          |  34 ++++---
 target/i386/hvf/x86_emu.c            |   5 +
 target/i386/kvm/kvm.c                |  10 +-
 target/i386/monitor.c                |  23 ++++-
 target/i386/sev-stub.c               |  15 +++
 target/i386/sev.c                    | 178 ++++++++++++++++++++++++++++++++++-
 target/i386/sev_i386.h               |   2 +-
 target/mips/kvm.c                    |   5 +
 target/ppc/kvm.c                     |   5 +
 target/s390x/kvm.c                   |   5 +
 tests/qtest/libqos/qgraph.c          |  99 ++++++++++++++++++-
 tests/qtest/libqos/qgraph.h          |  36 +++++++
 tests/qtest/libqos/qgraph_internal.h |  12 +++
 tests/qtest/qos-test.c               |  15 ++-
 util/cutils.c                        |   3 +-
 util/event_notifier-posix.c          |   2 +-
 36 files changed, 735 insertions(+), 81 deletions(-)
-- 
2.29.2



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

* [PULL 20/21] event_notifier: Set ->initialized earlier in event_notifier_init()
  2021-02-16 18:26 [PULL v2 00/21] i386, qgraph patches for 2020-02-15 Paolo Bonzini
@ 2021-02-16 18:26 ` Paolo Bonzini
  2021-02-16 18:26 ` [PULL 21/21] replay: fix icount request when replaying clock access Paolo Bonzini
  2021-02-17 14:44 ` [PULL v2 00/21] i386, qgraph patches for 2020-02-15 Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-02-16 18:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, mlevitsk

From: Greg Kurz <groug@kaod.org>

Otherwise the call to event_notifier_set() is a nop, which causes
the SLOF firmware on POWER to hang when booting from a virtio-scsi
device:

virtio_scsi_dataplane_start()
 virtio_scsi_vring_init()
  virtio_bus_set_host_notifier() <- assign == true
   event_notifier_init() <- active == 1
    event_notifier_set() <- fails right away if !e->initialized

Fixes: e34e47eb28c0 ("event_notifier: handle initialization failure better")
Cc: mlevitsk@redhat.com
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20210216120247.1293569-1-groug@kaod.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 util/event_notifier-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c
index 5b2110e861..8307013c5d 100644
--- a/util/event_notifier-posix.c
+++ b/util/event_notifier-posix.c
@@ -66,10 +66,10 @@ int event_notifier_init(EventNotifier *e, int active)
         e->rfd = fds[0];
         e->wfd = fds[1];
     }
+    e->initialized = true;
     if (active) {
         event_notifier_set(e);
     }
-    e->initialized = true;
     return 0;
 
 fail:
-- 
2.29.2




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

* [PULL 21/21] replay: fix icount request when replaying clock access
  2021-02-16 18:26 [PULL v2 00/21] i386, qgraph patches for 2020-02-15 Paolo Bonzini
  2021-02-16 18:26 ` [PULL 20/21] event_notifier: Set ->initialized earlier in event_notifier_init() Paolo Bonzini
@ 2021-02-16 18:26 ` Paolo Bonzini
  2021-02-17 14:44 ` [PULL v2 00/21] i386, qgraph patches for 2020-02-15 Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-02-16 18:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Pavel Dovgalyuk

From: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>

Record/replay provides REPLAY_CLOCK_LOCKED macro to access
the clock when vm_clock_seqlock is locked. This macro is
needed because replay internals operate icount. In locked case
replay use icount_get_raw_locked for icount request, which prevents
excess locking which leads to deadlock. But previously only
record code used *_locked function and replay did not.
Therefore sometimes clock access lead to deadlocks.
This patch fixes clock access for replay too and uses *_locked
icount access function.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
Message-Id: <161347990483.1313189.8371838968343494161.stgit@pasha-ThinkPad-X280>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/sysemu/replay.h  | 14 ++++++++------
 replay/replay-internal.c | 29 +++++++++++++++++++++++++----
 replay/replay-time.c     |  4 ++--
 replay/replay.c          | 23 +----------------------
 stubs/replay-tools.c     |  2 +-
 5 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h
index 56c0c17c30..0f3b0f7eac 100644
--- a/include/sysemu/replay.h
+++ b/include/sysemu/replay.h
@@ -128,18 +128,20 @@ bool replay_has_interrupt(void);
 int64_t replay_save_clock(ReplayClockKind kind, int64_t clock,
                           int64_t raw_icount);
 /*! Read the specified clock from the log or return cached data */
-int64_t replay_read_clock(ReplayClockKind kind);
+int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount);
 /*! Saves or reads the clock depending on the current replay mode. */
 #define REPLAY_CLOCK(clock, value)                                      \
-    (replay_mode == REPLAY_MODE_PLAY ? replay_read_clock((clock))       \
+    (replay_mode == REPLAY_MODE_PLAY                                    \
+        ? replay_read_clock((clock), icount_get_raw())                  \
         : replay_mode == REPLAY_MODE_RECORD                             \
-            ? replay_save_clock((clock), (value), icount_get_raw()) \
-        : (value))
+            ? replay_save_clock((clock), (value), icount_get_raw())     \
+            : (value))
 #define REPLAY_CLOCK_LOCKED(clock, value)                               \
-    (replay_mode == REPLAY_MODE_PLAY ? replay_read_clock((clock))       \
+    (replay_mode == REPLAY_MODE_PLAY                                    \
+        ? replay_read_clock((clock), icount_get_raw_locked())           \
         : replay_mode == REPLAY_MODE_RECORD                             \
             ? replay_save_clock((clock), (value), icount_get_raw_locked()) \
-        : (value))
+            : (value))
 
 /* Processing data from random generators */
 
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index 2e8a3e947a..77d0c82327 100644
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -247,10 +247,31 @@ void replay_advance_current_icount(uint64_t current_icount)
     /* Time can only go forward */
     assert(diff >= 0);
 
-    if (diff > 0) {
-        replay_put_event(EVENT_INSTRUCTION);
-        replay_put_dword(diff);
-        replay_state.current_icount += diff;
+    if (replay_mode == REPLAY_MODE_RECORD) {
+        if (diff > 0) {
+            replay_put_event(EVENT_INSTRUCTION);
+            replay_put_dword(diff);
+            replay_state.current_icount += diff;
+        }
+    } else if (replay_mode == REPLAY_MODE_PLAY) {
+        if (diff > 0) {
+            replay_state.instruction_count -= diff;
+            replay_state.current_icount += diff;
+            if (replay_state.instruction_count == 0) {
+                assert(replay_state.data_kind == EVENT_INSTRUCTION);
+                replay_finish_event();
+                /* Wake up iothread. This is required because
+                    timers will not expire until clock counters
+                    will be read from the log. */
+                qemu_notify_event();
+            }
+        }
+        /* Execution reached the break step */
+        if (replay_break_icount == replay_state.current_icount) {
+            /* Cannot make callback directly from the vCPU thread */
+            timer_mod_ns(replay_break_timer,
+                qemu_clock_get_ns(QEMU_CLOCK_REALTIME));
+        }
     }
 }
 
diff --git a/replay/replay-time.c b/replay/replay-time.c
index 43357c9f24..00ebcb7a49 100644
--- a/replay/replay-time.c
+++ b/replay/replay-time.c
@@ -46,12 +46,12 @@ void replay_read_next_clock(ReplayClockKind kind)
 }
 
 /*! Reads next clock event from the input. */
-int64_t replay_read_clock(ReplayClockKind kind)
+int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount)
 {
     int64_t ret;
     g_assert(replay_file && replay_mutex_locked());
 
-    replay_account_executed_instructions();
+    replay_advance_current_icount(raw_icount);
 
     if (replay_next_event_is(EVENT_CLOCK + kind)) {
         replay_read_next_clock(kind);
diff --git a/replay/replay.c b/replay/replay.c
index d4c228ab28..c806fec69a 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -94,28 +94,7 @@ void replay_account_executed_instructions(void)
     if (replay_mode == REPLAY_MODE_PLAY) {
         g_assert(replay_mutex_locked());
         if (replay_state.instruction_count > 0) {
-            int count = (int)(replay_get_current_icount()
-                              - replay_state.current_icount);
-
-            /* Time can only go forward */
-            assert(count >= 0);
-
-            replay_state.instruction_count -= count;
-            replay_state.current_icount += count;
-            if (replay_state.instruction_count == 0) {
-                assert(replay_state.data_kind == EVENT_INSTRUCTION);
-                replay_finish_event();
-                /* Wake up iothread. This is required because
-                   timers will not expire until clock counters
-                   will be read from the log. */
-                qemu_notify_event();
-            }
-            /* Execution reached the break step */
-            if (replay_break_icount == replay_state.current_icount) {
-                /* Cannot make callback directly from the vCPU thread */
-                timer_mod_ns(replay_break_timer,
-                    qemu_clock_get_ns(QEMU_CLOCK_REALTIME));
-            }
+            replay_advance_current_icount(replay_get_current_icount());
         }
     }
 }
diff --git a/stubs/replay-tools.c b/stubs/replay-tools.c
index c06b360e22..43296b3d4e 100644
--- a/stubs/replay-tools.c
+++ b/stubs/replay-tools.c
@@ -13,7 +13,7 @@ int64_t replay_save_clock(unsigned int kind, int64_t clock, int64_t raw_icount)
     return 0;
 }
 
-int64_t replay_read_clock(unsigned int kind)
+int64_t replay_read_clock(unsigned int kind, int64_t raw_icount)
 {
     abort();
     return 0;
-- 
2.29.2



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

* Re: [PULL v2 00/21] i386, qgraph patches for 2020-02-15
  2021-02-16 18:26 [PULL v2 00/21] i386, qgraph patches for 2020-02-15 Paolo Bonzini
  2021-02-16 18:26 ` [PULL 20/21] event_notifier: Set ->initialized earlier in event_notifier_init() Paolo Bonzini
  2021-02-16 18:26 ` [PULL 21/21] replay: fix icount request when replaying clock access Paolo Bonzini
@ 2021-02-17 14:44 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2021-02-17 14:44 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On Tue, 16 Feb 2021 at 18:29, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> The following changes since commit 8ba4bca570ace1e60614a0808631a517cf5df67a:
>
>   Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2021-02-15 17:13:57 +0000)
>
> are available in the Git repository at:
>
>   https://gitlab.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 366a85e4bb748794b1ae0ca0ccc2d95f316679a0:
>
>   replay: fix icount request when replaying clock access (2021-02-16 17:15:39 +0100)
>
> ----------------------------------------------------------------
> * HVF fixes
> * Extra qos-test debugging output (Christian)
> * SEV secret address autodetection (James)
> * SEV-ES support (Thomas)
> * Relocatable paths bugfix (Stefan)
> * RR fix (Pavel)
> * EventNotifier fix (Greg)


Applied, thanks.

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

-- PMM


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

end of thread, other threads:[~2021-02-17 14:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-16 18:26 [PULL v2 00/21] i386, qgraph patches for 2020-02-15 Paolo Bonzini
2021-02-16 18:26 ` [PULL 20/21] event_notifier: Set ->initialized earlier in event_notifier_init() Paolo Bonzini
2021-02-16 18:26 ` [PULL 21/21] replay: fix icount request when replaying clock access Paolo Bonzini
2021-02-17 14:44 ` [PULL v2 00/21] i386, qgraph patches for 2020-02-15 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).