Skip to content

Commit

Permalink
cpu: call plugin init hook asynchronously
Browse files Browse the repository at this point in the history
This ensures we run during a cpu_exec, which allows to call start/end
exclusive from this init hook (needed for new scoreboard API introduced
later).

async work is run before any tb is translated/executed, so we can
guarantee plugin init will be called before any other hook.

The previous change made sure that any idle/resume cb call will not be
done before initializing plugin for a given vcpu.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Message-Id: <20240213094009.150349-5-pierrick.bouvier@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240227144335.1196131-20-alex.bennee@linaro.org>
  • Loading branch information
pbo-linaro authored and stsquad committed Feb 28, 2024
1 parent f2e8d2d commit 81cf548
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hw/core/cpu-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ static void cpu_common_parse_features(const char *typename, char *features,
}
}

static void qemu_plugin_vcpu_init__async(CPUState *cpu, run_on_cpu_data unused)
{
qemu_plugin_vcpu_init_hook(cpu);
}

static void cpu_common_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cpu = CPU(dev);
Expand All @@ -217,9 +222,9 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
cpu_resume(cpu);
}

/* Plugin initialization must wait until the cpu is fully realized. */
/* Plugin initialization must wait until the cpu start executing code */
if (tcg_enabled()) {
qemu_plugin_vcpu_init_hook(cpu);
async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL);
}

/* NOTE: latest generic point where the cpu is fully realized */
Expand Down

0 comments on commit 81cf548

Please sign in to comment.