[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 16/19] accel/kvm: Move the 'kvm_run' field to AccelvCPUState
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 16/19] accel/kvm: Move the 'kvm_run' field to AccelvCPUState |
Date: |
Wed, 3 Mar 2021 19:22:16 +0100 |
Patch created mechanically using:
$ sed -i 's/->kvm_run/->accel_vcpu->kvm_run/' $(git grep -l kvm_run)
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
include/hw/core/cpu.h | 1 -
include/sysemu/kvm_int.h | 1 +
accel/kvm/kvm-all.c | 16 ++++++++--------
hw/s390x/pv.c | 3 ++-
target/i386/kvm/kvm.c | 2 +-
target/s390x/kvm.c | 19 ++++++++++---------
6 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 4f280509f9b..3268f1393f1 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -415,7 +415,6 @@ struct CPUState {
/* Accelerator-specific fields. */
struct AccelvCPUState *accel_vcpu;
- struct kvm_run *kvm_run;
int hvf_fd;
/* shared by kvm, hax and hvf */
bool vcpu_dirty;
diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h
index dc45b3c3afa..b83264847aa 100644
--- a/include/sysemu/kvm_int.h
+++ b/include/sysemu/kvm_int.h
@@ -19,6 +19,7 @@ struct AccelvCPUState {
*/
int kvm_fd;
struct KVMState *kvm_state;
+ struct kvm_run *kvm_run;
};
typedef struct KVMSlot
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 737db3d3e0e..69df35497d2 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -380,7 +380,7 @@ static int do_kvm_destroy_vcpu(CPUState *cpu)
goto err;
}
- ret = munmap(cpu->kvm_run, mmap_size);
+ ret = munmap(cpu->accel_vcpu->kvm_run, mmap_size);
if (ret < 0) {
goto err;
}
@@ -448,9 +448,9 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp)
goto err;
}
- cpu->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
- cpu->accel_vcpu->kvm_fd, 0);
- if (cpu->kvm_run == MAP_FAILED) {
+ cpu->accel_vcpu->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, cpu->accel_vcpu->kvm_fd, 0);
+ if (cpu->accel_vcpu->kvm_run == MAP_FAILED) {
ret = -errno;
error_setg_errno(errp, ret,
"kvm_init_vcpu: mmap'ing vcpu state failed (%lu)",
@@ -460,7 +460,7 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp)
if (s->coalesced_mmio && !s->coalesced_mmio_ring) {
s->coalesced_mmio_ring =
- (void *)cpu->kvm_run + s->coalesced_mmio * PAGE_SIZE;
+ (void *)cpu->accel_vcpu->kvm_run + s->coalesced_mmio * PAGE_SIZE;
}
ret = kvm_arch_init_vcpu(cpu);
@@ -2382,7 +2382,7 @@ static __thread bool have_sigbus_pending;
static void kvm_cpu_kick(CPUState *cpu)
{
- qatomic_set(&cpu->kvm_run->immediate_exit, 1);
+ qatomic_set(&cpu->accel_vcpu->kvm_run->immediate_exit, 1);
}
static void kvm_cpu_kick_self(void)
@@ -2403,7 +2403,7 @@ static void kvm_eat_signals(CPUState *cpu)
int r;
if (kvm_immediate_exit) {
- qatomic_set(&cpu->kvm_run->immediate_exit, 0);
+ qatomic_set(&cpu->accel_vcpu->kvm_run->immediate_exit, 0);
/* Write kvm_run->immediate_exit before the cpu->exit_request
* write in kvm_cpu_exec.
*/
@@ -2431,7 +2431,7 @@ static void kvm_eat_signals(CPUState *cpu)
int kvm_cpu_exec(CPUState *cpu)
{
- struct kvm_run *run = cpu->kvm_run;
+ struct kvm_run *run = cpu->accel_vcpu->kvm_run;
int ret, run_ret;
DPRINTF("kvm_cpu_exec()\n");
diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c
index 93eccfc05d5..061c92fc4e3 100644
--- a/hw/s390x/pv.c
+++ b/hw/s390x/pv.c
@@ -17,6 +17,7 @@
#include "qapi/error.h"
#include "qemu/error-report.h"
#include "sysemu/kvm.h"
+#include "sysemu/kvm_int.h"
#include "qom/object_interfaces.h"
#include "exec/confidential-guest-support.h"
#include "hw/s390x/ipl.h"
@@ -108,7 +109,7 @@ void s390_pv_unshare(void)
void s390_pv_inject_reset_error(CPUState *cs)
{
- int r1 = (cs->kvm_run->s390_sieic.ipa & 0x00f0) >> 4;
+ int r1 = (cs->accel_vcpu->kvm_run->s390_sieic.ipa & 0x00f0) >> 4;
CPUS390XState *env = &S390_CPU(cs)->env;
/* Report that we are unable to enter protected mode */
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index b2facf4f7c1..c0ccaf6b06a 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -4329,7 +4329,7 @@ static int kvm_handle_halt(X86CPU *cpu)
static int kvm_handle_tpr_access(X86CPU *cpu)
{
CPUState *cs = CPU(cpu);
- struct kvm_run *run = cs->kvm_run;
+ struct kvm_run *run = cs->accel_vcpu->kvm_run;
apic_handle_tpr_access_report(cpu->apic_state, run->tpr_access.rip,
run->tpr_access.is_write ? TPR_ACCESS_WRITE
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index cf6790b2678..7968b10fa52 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -460,14 +460,15 @@ void kvm_s390_reset_vcpu_normal(S390CPU *cpu)
static int can_sync_regs(CPUState *cs, int regs)
{
- return cap_sync_regs && (cs->kvm_run->kvm_valid_regs & regs) == regs;
+ return cap_sync_regs
+ && (cs->accel_vcpu->kvm_run->kvm_valid_regs & regs) == regs;
}
int kvm_arch_put_registers(CPUState *cs, int level)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
- struct kvm_run *run = cs->kvm_run;
+ struct kvm_run *run = cs->accel_vcpu->kvm_run;
struct kvm_sregs sregs;
struct kvm_regs regs;
struct kvm_fpu fpu = {};
@@ -624,7 +625,7 @@ int kvm_arch_get_registers(CPUState *cs)
{
S390CPU *cpu = S390_CPU(cs);
CPUS390XState *env = &cpu->env;
- struct kvm_run *run = cs->kvm_run;
+ struct kvm_run *run = cs->accel_vcpu->kvm_run;
struct kvm_sregs sregs;
struct kvm_regs regs;
struct kvm_fpu fpu;
@@ -1621,8 +1622,8 @@ void kvm_s390_set_diag318(CPUState *cs, uint64_t
diag318_info)
/* Feat bit is set only if KVM supports sync for diag318 */
if (s390_has_feat(S390_FEAT_DIAG_318)) {
env->diag318_info = diag318_info;
- cs->kvm_run->s.regs.diag318 = diag318_info;
- cs->kvm_run->kvm_dirty_regs |= KVM_SYNC_DIAG318;
+ cs->accel_vcpu->kvm_run->s.regs.diag318 = diag318_info;
+ cs->accel_vcpu->kvm_run->kvm_dirty_regs |= KVM_SYNC_DIAG318;
}
}
@@ -1783,7 +1784,7 @@ static int handle_oper_loop(S390CPU *cpu, struct kvm_run
*run)
static int handle_intercept(S390CPU *cpu)
{
CPUState *cs = CPU(cpu);
- struct kvm_run *run = cs->kvm_run;
+ struct kvm_run *run = cs->accel_vcpu->kvm_run;
int icpt_code = run->s390_sieic.icptcode;
int r = 0;
@@ -1844,7 +1845,7 @@ static int handle_intercept(S390CPU *cpu)
static int handle_tsch(S390CPU *cpu)
{
CPUState *cs = CPU(cpu);
- struct kvm_run *run = cs->kvm_run;
+ struct kvm_run *run = cs->accel_vcpu->kvm_run;
int ret;
ret = ioinst_handle_tsch(cpu, cpu->env.regs[1], run->s390_tsch.ipb,
@@ -1934,7 +1935,7 @@ static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr,
uint8_t ar)
static int handle_stsi(S390CPU *cpu)
{
CPUState *cs = CPU(cpu);
- struct kvm_run *run = cs->kvm_run;
+ struct kvm_run *run = cs->accel_vcpu->kvm_run;
switch (run->s390_stsi.fc) {
case 3:
@@ -1952,7 +1953,7 @@ static int handle_stsi(S390CPU *cpu)
static int kvm_arch_handle_debug_exit(S390CPU *cpu)
{
CPUState *cs = CPU(cpu);
- struct kvm_run *run = cs->kvm_run;
+ struct kvm_run *run = cs->accel_vcpu->kvm_run;
int ret = 0;
struct kvm_debug_exit_arch *arch_info = &run->debug.arch;
--
2.26.2
- [RFC PATCH 06/19] accel/whpx: Add typedef for 'struct whpx_vcpu', (continued)
- [RFC PATCH 06/19] accel/whpx: Add typedef for 'struct whpx_vcpu', Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 07/19] accel/whpx: Rename struct whpx_vcpu -> AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 08/19] accel/whpx: Use 'accel_vcpu' generic pointer, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 09/19] accel/hax: Add typedef for 'struct hax_vcpu_state', Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 10/19] accel/hax: Use 'accel_vcpu' generic pointer, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 11/19] accel/kvm: Introduce kvm_vcpu_state() helper, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 12/19] accel/kvm: Use kvm_vcpu_state() when possible, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 13/19] accel/kvm: Declare and allocate AccelvCPUState struct, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 14/19] accel/kvm: Move the 'kvm_fd' field to AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 15/19] accel/kvm: Move the 'kvm_state' field to AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 16/19] accel/kvm: Move the 'kvm_run' field to AccelvCPUState,
Philippe Mathieu-Daudé <=
- [RFC PATCH 17/19] accel/hvf: Reduce deref by declaring 'hv_vcpuid_t hvf_fd' on stack, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 18/19] accel/hvf: Declare and allocate AccelvCPUState struct, Philippe Mathieu-Daudé, 2021/03/03
- [RFC PATCH 19/19] accel/hvf: Move the 'hvf_fd' field to AccelvCPUState, Philippe Mathieu-Daudé, 2021/03/03
- Re: [RFC PATCH 00/19] accel: Introduce AccelvCPUState opaque structure, Paolo Bonzini, 2021/03/04