All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26
@ 2014-09-26 14:37 Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 01/11] pit: fix pit interrupt can't inject into vm after migration Paolo Bonzini
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:37 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit cc35a44cf7b522b1fd0b786562b7de4b881c41b0:

  Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging (2014-09-15 19:44:34 +0100)

are available in the git repository at:

  git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 541be9274e8ef227fb1b50ce124fd2cc2dce81a5:

  kvm/valgrind: don't mark memory as initialized (2014-09-26 13:35:08 +0200)

----------------------------------------------------------------
Usual mix of patches, the most important being Alex and Marcelo's
kvmclock fix.  This was reverted last minute for 2.1, but it is now back
with the problematic case fixed.

Note: I will soon switch to a subkey for signing purposes.  To verify
future signed pull requests from me, please update my key with
"gpg --recv-keys 9B4D86F2".  You should see 3 new subkeys---the
one for signing will be a 2048-bit RSA key, 4E6B09D7.

----------------------------------------------------------------
Alexander Graf (1):
      kvmclock: Ensure time in migration never goes backward

ChenLiang (1):
      pit: fix pit interrupt can't inject into vm after migration

Christian Borntraeger (1):
      kvm/valgrind: don't mark memory as initialized

Marcelo Tosatti (2):
      Introduce cpu_clean_all_dirty
      kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation

Paolo Bonzini (3):
      serial: reset state at startup
      serial: check if backed by a physical serial port at realize time
      po: fix conflict with %.mo rule in rules.mak

Pavel Dovgalyuk (2):
      target-i386: update fp status fix
      kvmvapic: fix migration when VM paused and when not running Windows

Philipp Hahn (1):
      hw/dma/i8257: Silence phony error message

 configure                |  3 +--
 cpus.c                   |  9 ++++++++
 hw/char/serial.c         |  6 ++++--
 hw/dma/i8257.c           |  4 ++--
 hw/i386/kvm/clock.c      | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/kvm/i8254.c      |  3 +--
 hw/i386/kvmvapic.c       | 11 ++++++++--
 include/sysemu/cpus.h    |  1 +
 include/sysemu/kvm.h     |  8 ++++++++
 kvm-all.c                | 12 +++++------
 po/Makefile              |  6 +++---
 target-i386/cpu.c        |  2 +-
 target-i386/cpu.h        |  2 ++
 target-i386/fpu_helper.c | 21 +++++++++++--------
 target-i386/gdbstub.c    |  2 +-
 target-i386/machine.c    |  2 +-
 trace-events             |  3 +++
 17 files changed, 117 insertions(+), 31 deletions(-)
-- 
2.1.0

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

* [Qemu-devel] [PULL 01/11] pit: fix pit interrupt can't inject into vm after migration
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 02/11] Introduce cpu_clean_all_dirty Paolo Bonzini
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: ChenLiang, Gonglei

From: ChenLiang <chenliang88@huawei.com>

kvm_pit is running in kmod. kvm_pit is going to inject
interrupt to vm before cpu_synchronize_all_post_init at
dest side. vcpu will lose the pit interrupt, but
ack_irq(in kmod) has been 0. ack_irq become 1 after
vcpu responds pit interrupt. pit interruptcan inject
to vm when ack_irq is 1.

By the way, kvm_pit_vm_state_change has save and load
state of pit, so pre_save and post_load is unnecessary.

Signed-off-by: ChenLiang <chenliang88@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/kvm/i8254.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
index 59373aa..472af81 100644
--- a/hw/i386/kvm/i8254.c
+++ b/hw/i386/kvm/i8254.c
@@ -239,6 +239,7 @@ static void kvm_pit_vm_state_change(void *opaque, int running,
 
     if (running) {
         kvm_pit_update_clock_offset(s);
+        kvm_pit_put(PIT_COMMON(s));
         s->vm_stopped = false;
     } else {
         kvm_pit_update_clock_offset(s);
@@ -314,8 +315,6 @@ static void kvm_pit_class_init(ObjectClass *klass, void *data)
     dc->realize = kvm_pit_realizefn;
     k->set_channel_gate = kvm_pit_set_gate;
     k->get_channel_info = kvm_pit_get_channel_info;
-    k->pre_save = kvm_pit_get;
-    k->post_load = kvm_pit_put;
     dc->reset = kvm_pit_reset;
     dc->props = kvm_pit_properties;
 }
-- 
2.1.0

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

* [Qemu-devel] [PULL 02/11] Introduce cpu_clean_all_dirty
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 01/11] pit: fix pit interrupt can't inject into vm after migration Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 03/11] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation Paolo Bonzini
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcelo Tosatti, qemu-stable

From: Marcelo Tosatti <mtosatti@redhat.com>

Introduce cpu_clean_all_dirty, to force subsequent cpu_synchronize_all_states
to read in-kernel register state.

Cc: qemu-stable@nongnu.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 cpus.c                | 9 +++++++++
 include/sysemu/cpus.h | 1 +
 include/sysemu/kvm.h  | 8 ++++++++
 kvm-all.c             | 5 +++++
 4 files changed, 23 insertions(+)

diff --git a/cpus.c b/cpus.c
index 2a0e133..0c33458 100644
--- a/cpus.c
+++ b/cpus.c
@@ -593,6 +593,15 @@ void cpu_synchronize_all_post_init(void)
     }
 }
 
+void cpu_clean_all_dirty(void)
+{
+    CPUState *cpu;
+
+    CPU_FOREACH(cpu) {
+        cpu_clean_state(cpu);
+    }
+}
+
 static int do_vm_stop(RunState state)
 {
     int ret = 0;
diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h
index 4f79081..3f162a9 100644
--- a/include/sysemu/cpus.h
+++ b/include/sysemu/cpus.h
@@ -10,6 +10,7 @@ void cpu_stop_current(void);
 void cpu_synchronize_all_states(void);
 void cpu_synchronize_all_post_reset(void);
 void cpu_synchronize_all_post_init(void);
+void cpu_clean_all_dirty(void);
 
 void qtest_clock_warp(int64_t dest);
 
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index d2000af..77ee240 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -350,6 +350,7 @@ int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
 void kvm_cpu_synchronize_state(CPUState *cpu);
 void kvm_cpu_synchronize_post_reset(CPUState *cpu);
 void kvm_cpu_synchronize_post_init(CPUState *cpu);
+void kvm_cpu_clean_state(CPUState *cpu);
 
 /* generic hooks - to be moved/refactored once there are more users */
 
@@ -374,6 +375,13 @@ static inline void cpu_synchronize_post_init(CPUState *cpu)
     }
 }
 
+static inline void cpu_clean_state(CPUState *cpu)
+{
+    if (kvm_enabled()) {
+        kvm_cpu_clean_state(cpu);
+    }
+}
+
 int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg);
 int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg);
 void kvm_irqchip_release_virq(KVMState *s, int virq);
diff --git a/kvm-all.c b/kvm-all.c
index 8b9e66d..6c6586f 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1708,6 +1708,11 @@ void kvm_cpu_synchronize_post_init(CPUState *cpu)
     run_on_cpu(cpu, do_kvm_cpu_synchronize_post_init, cpu);
 }
 
+void kvm_cpu_clean_state(CPUState *cpu)
+{
+    cpu->kvm_vcpu_dirty = false;
+}
+
 int kvm_cpu_exec(CPUState *cpu)
 {
     struct kvm_run *run = cpu->kvm_run;
-- 
2.1.0

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

* [Qemu-devel] [PULL 03/11] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 01/11] pit: fix pit interrupt can't inject into vm after migration Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 02/11] Introduce cpu_clean_all_dirty Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 04/11] kvmclock: Ensure time in migration never goes backward Paolo Bonzini
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marcelo Tosatti, qemu-stable

From: Marcelo Tosatti <mtosatti@redhat.com>

Ensure proper env->tsc value for kvmclock_current_nsec calculation.

Reported-by: Marcin Gibuła <m.gibula@beyond.pl>
Analyzed-by: Marcin Gibuła <m.gibula@beyond.pl>
Cc: qemu-stable@nongnu.org
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/kvm/clock.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index 07b9c0e..9d65766 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -16,6 +16,7 @@
 #include "qemu-common.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
+#include "sysemu/cpus.h"
 #include "hw/sysbus.h"
 #include "hw/kvm/clock.h"
 
@@ -75,6 +76,9 @@ static void kvmclock_vm_state_change(void *opaque, int running,
         if (s->clock_valid) {
             return;
         }
+
+        cpu_synchronize_all_states();
+        cpu_clean_all_dirty();
         ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data);
         if (ret < 0) {
             fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret));
-- 
2.1.0

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

* [Qemu-devel] [PULL 04/11] kvmclock: Ensure time in migration never goes backward
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (2 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 03/11] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 05/11] hw/dma/i8257: Silence phony error message Paolo Bonzini
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alexander Graf, qemu-stable

From: Alexander Graf <agraf@suse.de>

When we migrate we ask the kernel about its current belief on what the guest
time would be. However, I've seen cases where the kvmclock guest structure
indicates a time more recent than the kvm returned time.

To make sure we never go backwards, calculate what the guest would have seen as time at the point of migration and use that value instead of the kernel returned one when it's more recent.
This bases the view of the kvmclock after migration on the
same foundation in host as well as guest.

Signed-off-by: Alexander Graf <agraf@suse.de>
Cc: qemu-stable@nongnu.org
Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/kvm/clock.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index 9d65766..1ac60d6 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -14,6 +14,7 @@
  */
 
 #include "qemu-common.h"
+#include "qemu/host-utils.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "sysemu/cpus.h"
@@ -35,6 +36,48 @@ typedef struct KVMClockState {
     bool clock_valid;
 } KVMClockState;
 
+struct pvclock_vcpu_time_info {
+    uint32_t   version;
+    uint32_t   pad0;
+    uint64_t   tsc_timestamp;
+    uint64_t   system_time;
+    uint32_t   tsc_to_system_mul;
+    int8_t     tsc_shift;
+    uint8_t    flags;
+    uint8_t    pad[2];
+} __attribute__((__packed__)); /* 32 bytes */
+
+static uint64_t kvmclock_current_nsec(KVMClockState *s)
+{
+    CPUState *cpu = first_cpu;
+    CPUX86State *env = cpu->env_ptr;
+    hwaddr kvmclock_struct_pa = env->system_time_msr & ~1ULL;
+    uint64_t migration_tsc = env->tsc;
+    struct pvclock_vcpu_time_info time;
+    uint64_t delta;
+    uint64_t nsec_lo;
+    uint64_t nsec_hi;
+    uint64_t nsec;
+
+    if (!(env->system_time_msr & 1ULL)) {
+        /* KVM clock not active */
+        return 0;
+    }
+
+    cpu_physical_memory_read(kvmclock_struct_pa, &time, sizeof(time));
+
+    assert(time.tsc_timestamp <= migration_tsc);
+    delta = migration_tsc - time.tsc_timestamp;
+    if (time.tsc_shift < 0) {
+        delta >>= -time.tsc_shift;
+    } else {
+        delta <<= time.tsc_shift;
+    }
+
+    mulu64(&nsec_lo, &nsec_hi, delta, time.tsc_to_system_mul);
+    nsec = (nsec_lo >> 32) | (nsec_hi << 32);
+    return nsec + time.system_time;
+}
 
 static void kvmclock_vm_state_change(void *opaque, int running,
                                      RunState state)
@@ -46,9 +89,15 @@ static void kvmclock_vm_state_change(void *opaque, int running,
 
     if (running) {
         struct kvm_clock_data data;
+        uint64_t time_at_migration = kvmclock_current_nsec(s);
 
         s->clock_valid = false;
 
+        /* We can't rely on the migrated clock value, just discard it */
+        if (time_at_migration) {
+            s->clock = time_at_migration;
+        }
+
         data.clock = s->clock;
         data.flags = 0;
         ret = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data);
-- 
2.1.0

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

* [Qemu-devel] [PULL 05/11] hw/dma/i8257: Silence phony error message
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (3 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 04/11] kvmclock: Ensure time in migration never goes backward Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 06/11] target-i386: update fp status fix Paolo Bonzini
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philipp Hahn

From: Philipp Hahn <hahn@univention.de>

Convert into trace event. Otherwise the message
	dma: unregistered DMA channel used nchan=0 dma_pos=0 dma_len=1
gets printed every time and fills up the log-file with 50 MiB / minute.

Signed-off-by: Philipp Hahn <hahn@univention.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/dma/i8257.c | 4 ++--
 trace-events   | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index dd370ed..a414029 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -24,6 +24,7 @@
 #include "hw/hw.h"
 #include "hw/isa/isa.h"
 #include "qemu/main-loop.h"
+#include "trace.h"
 
 /* #define DEBUG_DMA */
 
@@ -473,8 +474,7 @@ static void dma_reset(void *opaque)
 
 static int dma_phony_handler (void *opaque, int nchan, int dma_pos, int dma_len)
 {
-    dolog ("unregistered DMA channel used nchan=%d dma_pos=%d dma_len=%d\n",
-           nchan, dma_pos, dma_len);
+    trace_i8257_unregistered_dma(nchan, dma_pos, dma_len);
     return dma_pos;
 }
 
diff --git a/trace-events b/trace-events
index fb58963..b680a6b 100644
--- a/trace-events
+++ b/trace-events
@@ -1318,3 +1318,6 @@ mhp_pc_dimm_assigned_address(uint64_t addr) "0x%"PRIx64
 # target-s390x/kvm.c
 kvm_enable_cmma(int rc) "CMMA: enabling with result code %d"
 kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
+
+# hw/dma/i8257.c
+i8257_unregistered_dma(int nchan, int dma_pos, int dma_len) "unregistered DMA channel used nchan=%d dma_pos=%d dma_len=%d"
-- 
2.1.0

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

* [Qemu-devel] [PULL 06/11] target-i386: update fp status fix
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (4 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 05/11] hw/dma/i8257: Silence phony error message Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 07/11] serial: reset state at startup Paolo Bonzini
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Pavel Dovgalyuk

From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>

This patch introduces cpu_set_fpuc() function, which changes fpuc field
of the CPU state and calls update_fp_status() function.
These calls update status of softfloat library and prevent bugs caused
by non-coherent rounding settings of the FPU and softfloat.

v2 changes:
 * Added missed calls and intoduced setter function (as suggested by TeLeMan)

Reviewed-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
---
 target-i386/cpu.c        |  2 +-
 target-i386/cpu.h        |  2 ++
 target-i386/fpu_helper.c | 21 +++++++++++++--------
 target-i386/gdbstub.c    |  2 +-
 target-i386/machine.c    |  2 +-
 5 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 90d0a05..25e74b0 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2580,7 +2580,7 @@ static void x86_cpu_reset(CPUState *s)
     for (i = 0; i < 8; i++) {
         env->fptags[i] = 1;
     }
-    env->fpuc = 0x37f;
+    cpu_set_fpuc(env, 0x37f);
 
     env->mxcsr = 0x1f80;
     env->xstate_bv = XSTATE_FP | XSTATE_SSE;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 71b505f..2968749 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -1251,6 +1251,7 @@ void QEMU_NORETURN raise_interrupt(CPUX86State *nenv, int intno, int is_int,
 /* cc_helper.c */
 extern const uint8_t parity_table[256];
 uint32_t cpu_cc_compute_all(CPUX86State *env1, int op);
+void update_fp_status(CPUX86State *env);
 
 static inline uint32_t cpu_compute_eflags(CPUX86State *env)
 {
@@ -1286,6 +1287,7 @@ static inline void cpu_load_efer(CPUX86State *env, uint64_t val)
 
 /* fpu_helper.c */
 void cpu_set_mxcsr(CPUX86State *env, uint32_t val);
+void cpu_set_fpuc(CPUX86State *env, uint16_t val);
 
 /* svm_helper.c */
 void cpu_svm_check_intercept_param(CPUX86State *env1, uint32_t type,
diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c
index 1b2900d..1d4eee3 100644
--- a/target-i386/fpu_helper.c
+++ b/target-i386/fpu_helper.c
@@ -537,7 +537,7 @@ uint32_t helper_fnstcw(CPUX86State *env)
     return env->fpuc;
 }
 
-static void update_fp_status(CPUX86State *env)
+void update_fp_status(CPUX86State *env)
 {
     int rnd_type;
 
@@ -575,8 +575,7 @@ static void update_fp_status(CPUX86State *env)
 
 void helper_fldcw(CPUX86State *env, uint32_t val)
 {
-    env->fpuc = val;
-    update_fp_status(env);
+    cpu_set_fpuc(env, val);
 }
 
 void helper_fclex(CPUX86State *env)
@@ -595,7 +594,7 @@ void helper_fninit(CPUX86State *env)
 {
     env->fpus = 0;
     env->fpstt = 0;
-    env->fpuc = 0x37f;
+    cpu_set_fpuc(env, 0x37f);
     env->fptags[0] = 1;
     env->fptags[1] = 1;
     env->fptags[2] = 1;
@@ -1013,11 +1012,11 @@ void helper_fldenv(CPUX86State *env, target_ulong ptr, int data32)
     int i, fpus, fptag;
 
     if (data32) {
-        env->fpuc = cpu_lduw_data(env, ptr);
+        cpu_set_fpuc(env, cpu_lduw_data(env, ptr));
         fpus = cpu_lduw_data(env, ptr + 4);
         fptag = cpu_lduw_data(env, ptr + 8);
     } else {
-        env->fpuc = cpu_lduw_data(env, ptr);
+        cpu_set_fpuc(env, cpu_lduw_data(env, ptr));
         fpus = cpu_lduw_data(env, ptr + 2);
         fptag = cpu_lduw_data(env, ptr + 4);
     }
@@ -1046,7 +1045,7 @@ void helper_fsave(CPUX86State *env, target_ulong ptr, int data32)
     /* fninit */
     env->fpus = 0;
     env->fpstt = 0;
-    env->fpuc = 0x37f;
+    cpu_set_fpuc(env, 0x37f);
     env->fptags[0] = 1;
     env->fptags[1] = 1;
     env->fptags[2] = 1;
@@ -1157,7 +1156,7 @@ void helper_fxrstor(CPUX86State *env, target_ulong ptr, int data64)
         raise_exception(env, EXCP0D_GPF);
     }
 
-    env->fpuc = cpu_lduw_data(env, ptr);
+    cpu_set_fpuc(env, cpu_lduw_data(env, ptr));
     fpus = cpu_lduw_data(env, ptr + 2);
     fptag = cpu_lduw_data(env, ptr + 4);
     env->fpstt = (fpus >> 11) & 7;
@@ -1257,6 +1256,12 @@ void cpu_set_mxcsr(CPUX86State *env, uint32_t mxcsr)
     set_flush_to_zero((mxcsr & SSE_FZ) ? 1 : 0, &env->fp_status);
 }
 
+void cpu_set_fpuc(CPUX86State *env, uint16_t val)
+{
+    env->fpuc = val;
+    update_fp_status(env);
+}
+
 void helper_ldmxcsr(CPUX86State *env, uint32_t val)
 {
     cpu_set_mxcsr(env, val);
diff --git a/target-i386/gdbstub.c b/target-i386/gdbstub.c
index 19fe9ad..ff99cfb 100644
--- a/target-i386/gdbstub.c
+++ b/target-i386/gdbstub.c
@@ -203,7 +203,7 @@ int x86_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
             return x86_cpu_gdb_load_seg(cpu, R_GS, mem_buf);
 
         case IDX_FP_REGS + 8:
-            env->fpuc = ldl_p(mem_buf);
+            cpu_set_fpuc(env, ldl_p(mem_buf));
             return 4;
         case IDX_FP_REGS + 9:
             tmp = ldl_p(mem_buf);
diff --git a/target-i386/machine.c b/target-i386/machine.c
index fb89065..0dd49f0 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -315,13 +315,13 @@ static int cpu_post_load(void *opaque, int version_id)
     env->hflags &= ~HF_CPL_MASK;
     env->hflags |= (env->segs[R_SS].flags >> DESC_DPL_SHIFT) & HF_CPL_MASK;
 
-    /* XXX: restore FPU round state */
     env->fpstt = (env->fpus_vmstate >> 11) & 7;
     env->fpus = env->fpus_vmstate & ~0x3800;
     env->fptag_vmstate ^= 0xff;
     for(i = 0; i < 8; i++) {
         env->fptags[i] = (env->fptag_vmstate >> i) & 1;
     }
+    update_fp_status(env);
 
     cpu_breakpoint_remove_all(cs, BP_CPU);
     cpu_watchpoint_remove_all(cs, BP_CPU);
-- 
2.1.0

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

* [Qemu-devel] [PULL 07/11] serial: reset state at startup
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (5 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 06/11] target-i386: update fp status fix Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 08/11] serial: check if backed by a physical serial port at realize time Paolo Bonzini
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel

When a serial port is started, its initial state is all zero.  Make
it consistent with reset state instead.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/char/serial.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index a668249..847dacc 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -833,6 +833,7 @@ void serial_realize_core(SerialState *s, Error **errp)
                           serial_event, s);
     fifo8_create(&s->recv_fifo, UART_FIFO_LENGTH);
     fifo8_create(&s->xmit_fifo, UART_FIFO_LENGTH);
+    serial_reset(s);
 }
 
 void serial_exit_core(SerialState *s)
-- 
2.1.0

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

* [Qemu-devel] [PULL 08/11] serial: check if backed by a physical serial port at realize time
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (6 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 07/11] serial: reset state at startup Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 09/11] kvmvapic: fix migration when VM paused and when not running Windows Paolo Bonzini
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel

Right now, s->poll_msl may linger at "0" value for an arbitrarily long
time, until serial_update_msl is called for the first time.  This is
unnecessary, and will lead to the s->poll_msl field being unnecessarily
migrated.

We can call serial_update_msl immediately at realize time (via
serial_reset) and be done with it.  The memory-mapped UART was already
doing that, but not the ISA and PCI variants.

Regarding the delta bits, be consistent with what serial_reset does when
the serial port is not backed by a physical serial port, and always clear
them at reset time.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/char/serial.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 847dacc..ebcacdc 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -815,6 +815,9 @@ static void serial_reset(void *opaque)
     s->thr_ipending = 0;
     s->last_break_enable = 0;
     qemu_irq_lower(s->irq);
+
+    serial_update_msl(s);
+    s->msr &= ~UART_MSR_ANY_DELTA;
 }
 
 void serial_realize_core(SerialState *s, Error **errp)
@@ -945,7 +948,5 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
     memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], s,
                           "serial", 8 << it_shift);
     memory_region_add_subregion(address_space, base, &s->io);
-
-    serial_update_msl(s);
     return s;
 }
-- 
2.1.0

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

* [Qemu-devel] [PULL 09/11] kvmvapic: fix migration when VM paused and when not running Windows
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (7 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 08/11] serial: check if backed by a physical serial port at realize time Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 10/11] po: fix conflict with %.mo rule in rules.mak Paolo Bonzini
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Pavel Dovgalyuk

From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>

This patch fixes migration by extending do_vapic_enable function. This function
called vapic_enable which read cpu number from the guest memory. When cpu
number could not be read, vapic was not enabled while loading the VM state.
This patch adds required code for cpu_number=0 to do_vapic_enable function,
because it is called only when cpu_number=0.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/kvmvapic.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index 2cca7a4..2dc362b 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -732,7 +732,11 @@ static void do_vapic_enable(void *data)
     VAPICROMState *s = data;
     X86CPU *cpu = X86_CPU(first_cpu);
 
-    vapic_enable(s, cpu);
+    static const uint8_t enabled = 1;
+    cpu_physical_memory_write(s->vapic_paddr + offsetof(VAPICState, enabled),
+                              &enabled, sizeof(enabled));
+    apic_enable_vapic(cpu->apic_state, s->vapic_paddr);
+    s->state = VAPIC_ACTIVE;
 }
 
 static void kvmvapic_vm_state_change(void *opaque, int running,
@@ -777,7 +781,10 @@ static int vapic_post_load(void *opaque, int version_id)
         }
     }
 
-    s->vmsentry = qemu_add_vm_change_state_handler(kvmvapic_vm_state_change, s);
+    if (!s->vmsentry) {
+        s->vmsentry =
+            qemu_add_vm_change_state_handler(kvmvapic_vm_state_change, s);
+    }
     return 0;
 }
 
-- 
2.1.0

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

* [Qemu-devel] [PULL 10/11] po: fix conflict with %.mo rule in rules.mak
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (8 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 09/11] kvmvapic: fix migration when VM paused and when not running Windows Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 14:38 ` [Qemu-devel] [PULL 11/11] kvm/valgrind: don't mark memory as initialized Paolo Bonzini
  2014-09-26 17:16 ` [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Peter Maydell
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel

po/Makefile includes rules.mak to use the nice quiet-command macro.
However, this also brings in a %.mo rule that breaks "make build".
Put our own rule before the include, so that it has precedence.

Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 po/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/po/Makefile b/po/Makefile
index 1ab241a..b271f79 100644
--- a/po/Makefile
+++ b/po/Makefile
@@ -9,6 +9,9 @@ all:
 
 .PHONY:	all build clean install update
 
+%.mo: %.po
+	$(call quiet-command, msgfmt -o $@ $<, "  GEN   $@")
+
 -include ../config-host.mak
 include $(SRC_PATH)/rules.mak
 
@@ -38,9 +41,6 @@ install: $(OBJS)
 	    $(INSTALL) -m644 $$obj $(DESTDIR)$(prefix)/share/locale/$$base/LC_MESSAGES/qemu.mo; \
 	done
 
-%.mo: %.po
-	$(call quiet-command, msgfmt -o $@ $<, "  GEN   $@")
-
 $(PO_PATH)/messages.po: $(SRC_PATH)/ui/gtk.c
 	$(call quiet-command, ( cd $(SRC_PATH) && \
           xgettext -o - --from-code=UTF-8 --foreign-user \
-- 
2.1.0

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

* [Qemu-devel] [PULL 11/11] kvm/valgrind: don't mark memory as initialized
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (9 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 10/11] po: fix conflict with %.mo rule in rules.mak Paolo Bonzini
@ 2014-09-26 14:38 ` Paolo Bonzini
  2014-09-26 17:16 ` [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Peter Maydell
  11 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2014-09-26 14:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Christian Borntraeger

From: Christian Borntraeger <borntraeger@de.ibm.com>

since commit 7dda5dc82a77 ("migration: initialize RAM to zero") the
guest memory is defined zero. No need to call valgrind on guest memory.
This reverts commit 62fe83318d2f ("qemu: Use valgrind annotations to
mark kvm guest memory as defined") thus speeding up kvm start if
<includedir>/valgrind/valgrind.h is available.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 3 +--
 kvm-all.c | 7 -------
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/configure b/configure
index 1a9daa5..f9c0926 100755
--- a/configure
+++ b/configure
@@ -3961,12 +3961,11 @@ else
 fi
 
 ########################################
-# check if we have valgrind/valgrind.h and valgrind/memcheck.h
+# check if we have valgrind/valgrind.h
 
 valgrind_h=no
 cat > $TMPC << EOF
 #include <valgrind/valgrind.h>
-#include <valgrind/memcheck.h>
 int main(void) {
   return 0;
 }
diff --git a/kvm-all.c b/kvm-all.c
index 6c6586f..4afcd05 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -44,10 +44,6 @@
 #include <sys/eventfd.h>
 #endif
 
-#ifdef CONFIG_VALGRIND_H
-#include <valgrind/memcheck.h>
-#endif
-
 /* KVM uses PAGE_SIZE in its definition of COALESCED_MMIO_MAX */
 #define PAGE_SIZE TARGET_PAGE_SIZE
 
@@ -1959,9 +1955,6 @@ int kvm_has_intx_set_mask(void)
 
 void kvm_setup_guest_memory(void *start, size_t size)
 {
-#ifdef CONFIG_VALGRIND_H
-    VALGRIND_MAKE_MEM_DEFINED(start, size);
-#endif
     if (!kvm_has_sync_mmu()) {
         int ret = qemu_madvise(start, size, QEMU_MADV_DONTFORK);
 
-- 
2.1.0

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

* Re: [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26
  2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
                   ` (10 preceding siblings ...)
  2014-09-26 14:38 ` [Qemu-devel] [PULL 11/11] kvm/valgrind: don't mark memory as initialized Paolo Bonzini
@ 2014-09-26 17:16 ` Peter Maydell
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2014-09-26 17:16 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On 26 September 2014 15:37, Paolo Bonzini <pbonzini@redhat.com> wrote:
> The following changes since commit cc35a44cf7b522b1fd0b786562b7de4b881c41b0:
>
>   Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging (2014-09-15 19:44:34 +0100)
>
> are available in the git repository at:
>
>   git://github.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 541be9274e8ef227fb1b50ce124fd2cc2dce81a5:
>
>   kvm/valgrind: don't mark memory as initialized (2014-09-26 13:35:08 +0200)
>
> ----------------------------------------------------------------
> Usual mix of patches, the most important being Alex and Marcelo's
> kvmclock fix.  This was reverted last minute for 2.1, but it is now back
> with the problematic case fixed.
>
> Note: I will soon switch to a subkey for signing purposes.  To verify
> future signed pull requests from me, please update my key with
> "gpg --recv-keys 9B4D86F2".  You should see 3 new subkeys---the
> one for signing will be a 2048-bit RSA key, 4E6B09D7.
>
> ----------------------------------------------------------------

Applied, thanks (and gpg keyring updated).

-- PMM

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

end of thread, other threads:[~2014-09-26 17:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-26 14:37 [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 01/11] pit: fix pit interrupt can't inject into vm after migration Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 02/11] Introduce cpu_clean_all_dirty Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 03/11] kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 04/11] kvmclock: Ensure time in migration never goes backward Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 05/11] hw/dma/i8257: Silence phony error message Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 06/11] target-i386: update fp status fix Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 07/11] serial: reset state at startup Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 08/11] serial: check if backed by a physical serial port at realize time Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 09/11] kvmvapic: fix migration when VM paused and when not running Windows Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 10/11] po: fix conflict with %.mo rule in rules.mak Paolo Bonzini
2014-09-26 14:38 ` [Qemu-devel] [PULL 11/11] kvm/valgrind: don't mark memory as initialized Paolo Bonzini
2014-09-26 17:16 ` [Qemu-devel] [PULL 00/11] KVM (and more) patches for 2014-09-26 Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.