Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
accel: Rename HVF 'struct hvf_vcpu_state' -> AccelCPUState
We want all accelerators to share the same opaque pointer in
CPUState.

Rename the 'hvf_vcpu_state' structure as 'AccelCPUState'.

Use the generic 'accel' field of CPUState instead of 'hvf'.

Replace g_malloc0() by g_new0() for readability.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20230624174121.11508-17-philmd@linaro.org>
  • Loading branch information
philmd committed Jun 28, 2023
1 parent a715924 commit 3b295bc
Show file tree
Hide file tree
Showing 12 changed files with 298 additions and 301 deletions.
19 changes: 10 additions & 9 deletions accel/hvf/hvf-accel-ops.c
Expand Up @@ -372,19 +372,19 @@ type_init(hvf_type_init);

static void hvf_vcpu_destroy(CPUState *cpu)
{
hv_return_t ret = hv_vcpu_destroy(cpu->hvf->fd);
hv_return_t ret = hv_vcpu_destroy(cpu->accel->fd);
assert_hvf_ok(ret);

hvf_arch_vcpu_destroy(cpu);
g_free(cpu->hvf);
cpu->hvf = NULL;
g_free(cpu->accel);
cpu->accel = NULL;
}

static int hvf_init_vcpu(CPUState *cpu)
{
int r;

cpu->hvf = g_malloc0(sizeof(*cpu->hvf));
cpu->accel = g_new0(AccelCPUState, 1);

/* init cpu signals */
struct sigaction sigact;
Expand All @@ -393,18 +393,19 @@ static int hvf_init_vcpu(CPUState *cpu)
sigact.sa_handler = dummy_signal;
sigaction(SIG_IPI, &sigact, NULL);

pthread_sigmask(SIG_BLOCK, NULL, &cpu->hvf->unblock_ipi_mask);
sigdelset(&cpu->hvf->unblock_ipi_mask, SIG_IPI);
pthread_sigmask(SIG_BLOCK, NULL, &cpu->accel->unblock_ipi_mask);
sigdelset(&cpu->accel->unblock_ipi_mask, SIG_IPI);

#ifdef __aarch64__
r = hv_vcpu_create(&cpu->hvf->fd, (hv_vcpu_exit_t **)&cpu->hvf->exit, NULL);
r = hv_vcpu_create(&cpu->accel->fd,
(hv_vcpu_exit_t **)&cpu->accel->exit, NULL);
#else
r = hv_vcpu_create((hv_vcpuid_t *)&cpu->hvf->fd, HV_VCPU_DEFAULT);
r = hv_vcpu_create((hv_vcpuid_t *)&cpu->accel->fd, HV_VCPU_DEFAULT);
#endif
cpu->vcpu_dirty = 1;
assert_hvf_ok(r);

cpu->hvf->guest_debug_enabled = false;
cpu->accel->guest_debug_enabled = false;

return hvf_arch_init_vcpu(cpu);
}
Expand Down
4 changes: 0 additions & 4 deletions include/hw/core/cpu.h
Expand Up @@ -241,8 +241,6 @@ typedef struct SavedIOTLB {
struct KVMState;
struct kvm_run;

struct hvf_vcpu_state;

/* work queue */

/* The union type allows passing of 64 bit target pointers on 32 bit
Expand Down Expand Up @@ -443,8 +441,6 @@ struct CPUState {
/* Used for user-only emulation of prctl(PR_SET_UNALIGN). */
bool prctl_unalign_sigbus;

struct hvf_vcpu_state *hvf;

/* track IOMMUs whose translations we've cached in the TCG TLB */
GArray *iommu_notifiers;
};
Expand Down
2 changes: 1 addition & 1 deletion include/sysemu/hvf_int.h
Expand Up @@ -49,7 +49,7 @@ struct HVFState {
};
extern HVFState *hvf_state;

struct hvf_vcpu_state {
struct AccelCPUState {
uint64_t fd;
void *exit;
bool vtimer_masked;
Expand Down

0 comments on commit 3b295bc

Please sign in to comment.