* [PATCH qom-cpu-next 3/6] cpu: Move exit_request field to CPUState
[not found] <1359722312-2391-1-git-send-email-afaerber@suse.de>
@ 2013-02-01 12:38 ` Andreas Färber
2013-02-14 17:49 ` [Qemu-devel] [PATCH qom-cpu-next 0/6] QOM CPUState, part 8: CPU_COMMON continued Andreas Färber
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Färber @ 2013-02-01 12:38 UTC (permalink / raw)
To: qemu-devel
Cc: Andreas Färber, David Gibson, Alexander Graf, Gleb Natapov,
Marcelo Tosatti, open list:sPAPR, open list:Overall
Since it was located before breakpoints field, it needs to be reset.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
cpu-exec.c | 8 ++++----
exec.c | 4 +++-
hw/spapr_hcall.c | 5 +++--
include/exec/cpu-defs.h | 2 --
include/qom/cpu.h | 2 ++
kvm-all.c | 6 +++---
qom/cpu.c | 1 +
target-i386/kvm.c | 4 ++--
8 Dateien geändert, 18 Zeilen hinzugefügt(+), 14 Zeilen entfernt(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 19ebb4a..32f3559 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -198,7 +198,7 @@ int cpu_exec(CPUArchState *env)
cpu_single_env = env;
if (unlikely(exit_request)) {
- env->exit_request = 1;
+ cpu->exit_request = 1;
}
#if defined(TARGET_I386)
@@ -539,8 +539,8 @@ int cpu_exec(CPUArchState *env)
next_tb = 0;
}
}
- if (unlikely(env->exit_request)) {
- env->exit_request = 0;
+ if (unlikely(cpu->exit_request)) {
+ cpu->exit_request = 0;
env->exception_index = EXCP_INTERRUPT;
cpu_loop_exit(env);
}
@@ -593,7 +593,7 @@ int cpu_exec(CPUArchState *env)
starting execution if there is a pending interrupt. */
env->current_tb = tb;
barrier();
- if (likely(!env->exit_request)) {
+ if (likely(!cpu->exit_request)) {
tc_ptr = tb->tc_ptr;
/* execute the generated code */
next_tb = tcg_qemu_tb_exec(env, tc_ptr);
diff --git a/exec.c b/exec.c
index b85508b..dbb893a 100644
--- a/exec.c
+++ b/exec.c
@@ -492,7 +492,9 @@ void cpu_reset_interrupt(CPUArchState *env, int mask)
void cpu_exit(CPUArchState *env)
{
- env->exit_request = 1;
+ CPUState *cpu = ENV_GET_CPU(env);
+
+ cpu->exit_request = 1;
cpu_unlink_tb(env);
}
diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c
index 2889742..af1db6e 100644
--- a/hw/spapr_hcall.c
+++ b/hw/spapr_hcall.c
@@ -513,13 +513,14 @@ static target_ulong h_cede(PowerPCCPU *cpu, sPAPREnvironment *spapr,
target_ulong opcode, target_ulong *args)
{
CPUPPCState *env = &cpu->env;
+ CPUState *cs = CPU(cpu);
env->msr |= (1ULL << MSR_EE);
hreg_compute_hflags(env);
- if (!cpu_has_work(CPU(cpu))) {
+ if (!cpu_has_work(cs)) {
env->halted = 1;
env->exception_index = EXCP_HLT;
- env->exit_request = 1;
+ cs->exit_request = 1;
}
return H_SUCCESS;
}
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index ba814ff..ca39f05 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -26,7 +26,6 @@
#include "config.h"
#include <setjmp.h>
#include <inttypes.h>
-#include <signal.h>
#include "qemu/osdep.h"
#include "qemu/queue.h"
#include "exec/hwaddr.h"
@@ -160,7 +159,6 @@ typedef struct CPUWatchpoint {
memory was accessed */ \
uint32_t halted; /* Nonzero if the CPU is in suspend state */ \
uint32_t interrupt_request; \
- volatile sig_atomic_t exit_request; \
CPU_COMMON_TLB \
struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \
/* buffer for temporaries in the code generator */ \
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index c465d88..42f3f34 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -20,6 +20,7 @@
#ifndef QEMU_CPU_H
#define QEMU_CPU_H
+#include <signal.h>
#include "hw/qdev-core.h"
#include "qemu/thread.h"
@@ -96,6 +97,7 @@ struct CPUState {
bool created;
bool stop;
bool stopped;
+ volatile sig_atomic_t exit_request;
int kvm_fd;
bool kvm_vcpu_dirty;
diff --git a/kvm-all.c b/kvm-all.c
index 04ec2d5..4decfdc 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1537,7 +1537,7 @@ int kvm_cpu_exec(CPUArchState *env)
DPRINTF("kvm_cpu_exec()\n");
if (kvm_arch_process_async_events(cpu)) {
- env->exit_request = 0;
+ cpu->exit_request = 0;
return EXCP_HLT;
}
@@ -1548,7 +1548,7 @@ int kvm_cpu_exec(CPUArchState *env)
}
kvm_arch_pre_run(cpu, run);
- if (env->exit_request) {
+ if (cpu->exit_request) {
DPRINTF("interrupt exit requested\n");
/*
* KVM requires us to reenter the kernel after IO exits to complete
@@ -1622,7 +1622,7 @@ int kvm_cpu_exec(CPUArchState *env)
vm_stop(RUN_STATE_INTERNAL_ERROR);
}
- env->exit_request = 0;
+ cpu->exit_request = 0;
return ret;
}
diff --git a/qom/cpu.c b/qom/cpu.c
index 870e9ba..7d8c675 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -32,6 +32,7 @@ void cpu_reset(CPUState *cpu)
static void cpu_common_reset(CPUState *cpu)
{
+ cpu->exit_request = 0;
}
ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 9ebf181..0cf413d 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -1777,7 +1777,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run)
* or pending TPR access reports. */
if (env->interrupt_request &
(CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR)) {
- env->exit_request = 1;
+ cpu->exit_request = 1;
}
/* Try to inject an interrupt if the guest can accept it */
@@ -1847,7 +1847,7 @@ int kvm_arch_process_async_events(CPUState *cs)
if (env->exception_injected == EXCP08_DBLE) {
/* this means triple fault */
qemu_system_reset_request();
- env->exit_request = 1;
+ cs->exit_request = 1;
return 0;
}
env->exception_injected = EXCP12_MCHK;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Qemu-devel] [PATCH qom-cpu-next 0/6] QOM CPUState, part 8: CPU_COMMON continued
[not found] <1359722312-2391-1-git-send-email-afaerber@suse.de>
2013-02-01 12:38 ` [PATCH qom-cpu-next 3/6] cpu: Move exit_request field to CPUState Andreas Färber
@ 2013-02-14 17:49 ` Andreas Färber
2013-02-15 17:17 ` Andreas Färber
1 sibling, 1 reply; 3+ messages in thread
From: Andreas Färber @ 2013-02-14 17:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, kvm@vger.kernel.org list, Alexander Graf
Am 01.02.2013 13:38, schrieb Andreas Färber:
> Hello,
>
> This series moves more fields from CPU_COMMON / CPU*State to CPUState,
> allowing access from target-independent code.
>
> The final patch in this series will help solve some issues (in particular
> avoid a dependency on CPU_COMMON TLB refactoring for now) but opens a can
> of worms: Since it is initialized in derived instance_init functions,
> functions cannot randomly be changed to operate on CPUState and be called
> from CPUState's instance_init or they will crash due to NULL env_ptr.
The "questionable" patch in this series has been acked by rth, so if
nobody objects, I'll queue it on qom-cpu-next tonight, to base further
work on. I'm not aware of any conflicting maintainer's queue so far.
Andreas
>
> For those of you that may have been following the CPU refactorings closely,
> I have now split off part of former qom-cpu-8 branch into qom-cpu-9.
> This series thereby applies directly to qom-cpu-next,
> whereas qom-cpu-9 depends on the pending s390x pull, my m68k cleanups and
> may be changed for VMState changes cooking elsewhere to keep i386 v5 compat.
>
> Available for testing at:
> git://github.com/afaerber/qemu-cpu.git qom-cpu-8.v1
> https://github.com/afaerber/qemu-cpu/commits/qom-cpu-8.v1
>
> Regards,
> Andreas
>
> Changes from previews:
> * Drop #ifdefs for user-only CPUState fields.
> * Defer interrupt-related changes to part 9.
>
> Andreas Färber (6):
> cpu: Move host_tid field to CPUState
> cpu: Move running field to CPUState
> cpu: Move exit_request field to CPUState
> cpu: Move current_tb field to CPUState
> cputlb: Pass CPUState to cpu_unlink_tb()
> cpu: Add CPUArchState pointer to CPUState
>
> cpu-exec.c | 21 ++++++++++++---------
> cputlb.c | 6 ++++--
> dump.c | 8 ++++++--
> exec.c | 6 ++++--
> gdbstub.c | 14 +++++++++-----
> hw/apic_common.c | 2 +-
> hw/apic_internal.h | 2 +-
> hw/kvmvapic.c | 13 ++++++++-----
> hw/spapr_hcall.c | 5 +++--
> include/exec/cpu-defs.h | 5 -----
> include/exec/exec-all.h | 4 +++-
> include/exec/gdbstub.h | 5 ++---
> include/qom/cpu.h | 11 +++++++++++
> kvm-all.c | 6 +++---
> linux-user/main.c | 37 ++++++++++++++++++++++---------------
> linux-user/syscall.c | 4 +++-
> qom/cpu.c | 2 ++
> target-alpha/cpu.c | 2 ++
> target-arm/cpu.c | 2 ++
> target-cris/cpu.c | 2 ++
> target-i386/cpu.c | 1 +
> target-i386/kvm.c | 4 ++--
> target-lm32/cpu.c | 2 ++
> target-m68k/cpu.c | 2 ++
> target-microblaze/cpu.c | 2 ++
> target-mips/cpu.c | 2 ++
> target-openrisc/cpu.c | 2 ++
> target-ppc/translate_init.c | 2 ++
> target-s390x/cpu.c | 2 ++
> target-sh4/cpu.c | 2 ++
> target-sparc/cpu.c | 2 ++
> target-unicore32/cpu.c | 2 ++
> target-xtensa/cpu.c | 2 ++
> translate-all.c | 36 +++++++++++++++++++++++-------------
> translate-all.h | 2 +-
> 35 Dateien geändert, 149 Zeilen hinzugefügt(+), 73 Zeilen entfernt(-)
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 3+ messages in thread