[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 13/35] hvf: access cpu->interrupt_request with atomi
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH 13/35] hvf: access cpu->interrupt_request with atomics |
Date: |
Mon, 17 Sep 2018 12:30:41 -0400 |
I am not familiar with hvf, so I opted for the safe
(and slow) route of performing probably many unnecessary
atomic_reads.
Cc: Richard Henderson <address@hidden>
Cc: Eduardo Habkost <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
---
target/i386/hvf/hvf.c | 7 ++++---
target/i386/hvf/x86hvf.c | 22 +++++++++++-----------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index df69e6d0a7..9c49d3c318 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -251,7 +251,7 @@ void update_apic_tpr(CPUState *cpu)
static void hvf_handle_interrupt(CPUState * cpu, int mask)
{
- cpu->interrupt_request |= mask;
+ atomic_or(&cpu->interrupt_request, mask);
if (!qemu_cpu_is_self(cpu)) {
qemu_cpu_kick(cpu);
}
@@ -713,10 +713,11 @@ int hvf_vcpu_exec(CPUState *cpu)
ret = 0;
switch (exit_reason) {
case EXIT_REASON_HLT: {
+ int interrupt_request = atomic_read(&cpu->interrupt_request);
macvm_set_rip(cpu, rip + ins_len);
- if (!((cpu->interrupt_request & CPU_INTERRUPT_HARD) &&
+ if (!((interrupt_request & CPU_INTERRUPT_HARD) &&
(EFLAGS(env) & IF_MASK))
- && !(cpu->interrupt_request & CPU_INTERRUPT_NMI) &&
+ && !(interrupt_request & CPU_INTERRUPT_NMI) &&
!(idtvec_info & VMCS_IDT_VEC_VALID)) {
cpu->halted = 1;
ret = EXCP_HLT;
diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index 3ac796b885..878714b99c 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -400,7 +400,7 @@ bool hvf_inject_interrupts(CPUState *cpu_state)
};
}
- if (cpu_state->interrupt_request & CPU_INTERRUPT_NMI) {
+ if (atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_NMI) {
if (!(env->hflags2 & HF2_NMI_MASK) && !(info & VMCS_INTR_VALID)) {
cpu_reset_interrupt(cpu_state, CPU_INTERRUPT_NMI);
info = VMCS_INTR_VALID | VMCS_INTR_T_NMI | NMI_VEC;
@@ -411,7 +411,7 @@ bool hvf_inject_interrupts(CPUState *cpu_state)
}
if (!(env->hflags & HF_INHIBIT_IRQ_MASK) &&
- (cpu_state->interrupt_request & CPU_INTERRUPT_HARD) &&
+ (atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_HARD) &&
(EFLAGS(env) & IF_MASK) && !(info & VMCS_INTR_VALID)) {
int line = cpu_get_pic_interrupt(&x86cpu->env);
cpu_reset_interrupt(cpu_state, CPU_INTERRUPT_HARD);
@@ -420,11 +420,11 @@ bool hvf_inject_interrupts(CPUState *cpu_state)
VMCS_INTR_VALID | VMCS_INTR_T_HWINTR);
}
}
- if (cpu_state->interrupt_request & CPU_INTERRUPT_HARD) {
+ if (atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_HARD) {
vmx_set_int_window_exiting(cpu_state);
}
- return (cpu_state->interrupt_request
- & (CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR));
+ return atomic_read(&cpu_state->interrupt_request)
+ & (CPU_INTERRUPT_INIT | CPU_INTERRUPT_TPR);
}
int hvf_process_events(CPUState *cpu_state)
@@ -434,25 +434,25 @@ int hvf_process_events(CPUState *cpu_state)
EFLAGS(env) = rreg(cpu_state->hvf_fd, HV_X86_RFLAGS);
- if (cpu_state->interrupt_request & CPU_INTERRUPT_INIT) {
+ if (atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_INIT) {
hvf_cpu_synchronize_state(cpu_state);
do_cpu_init(cpu);
}
- if (cpu_state->interrupt_request & CPU_INTERRUPT_POLL) {
+ if (atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_POLL) {
cpu_reset_interrupt(cpu_state, CPU_INTERRUPT_POLL);
apic_poll_irq(cpu->apic_state);
}
- if (((cpu_state->interrupt_request & CPU_INTERRUPT_HARD) &&
+ if (((atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_HARD) &&
(EFLAGS(env) & IF_MASK)) ||
- (cpu_state->interrupt_request & CPU_INTERRUPT_NMI)) {
+ (atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_NMI)) {
cpu_state->halted = 0;
}
- if (cpu_state->interrupt_request & CPU_INTERRUPT_SIPI) {
+ if (atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_SIPI) {
hvf_cpu_synchronize_state(cpu_state);
do_cpu_sipi(cpu);
}
- if (cpu_state->interrupt_request & CPU_INTERRUPT_TPR) {
+ if (atomic_read(&cpu_state->interrupt_request) & CPU_INTERRUPT_TPR) {
cpu_reset_interrupt(cpu_state, CPU_INTERRUPT_TPR);
hvf_cpu_synchronize_state(cpu_state);
apic_handle_tpr_access_report(cpu->apic_state, env->eip,
--
2.17.1
- Re: [Qemu-devel] [PATCH 01/35] tcg: access cpu->icount_decr.u16.high with atomics, (continued)
- [Qemu-devel] [PATCH 34/35] exec: push BQL down to cpu->do_interrupt, Emilio G. Cota, 2018/09/17
- [Qemu-devel] [PATCH 16/35] target/m68k: access cpu->interrupt_request with atomics, Emilio G. Cota, 2018/09/17
- [Qemu-devel] [PATCH 20/35] target/nios2: access cpu->interrupt_request with atomics, Emilio G. Cota, 2018/09/17
- [Qemu-devel] [PATCH 13/35] hvf: access cpu->interrupt_request with atomics,
Emilio G. Cota <=
- [Qemu-devel] [PATCH 25/35] target/sparc: access cpu->interrupt_request with atomics, Emilio G. Cota, 2018/09/17
- [Qemu-devel] [PATCH 15/35] target/lm32: access cpu->interrupt_request with atomics, Emilio G. Cota, 2018/09/17
- [Qemu-devel] [PATCH 17/35] target/microblaze: access cpu->interrupt_request with atomics, Emilio G. Cota, 2018/09/17
- [Qemu-devel] [PATCH 28/35] exec: access cpu->interrupt_request with atomics, Emilio G. Cota, 2018/09/17