On Tue, Sep 16, 2025 at 06:48:45PM +0200, Magnus Kulke wrote:
> There are hvcalls that are invoked during MMIO exits, the payload is of
> dynamic size. To avoid heap allocations we can use preallocated pages as
> in/out buffer for those calls. A page is reserved per vCPU and used for
> set/get register hv calls.
>
> Signed-off-by: Magnus Kulke <[email protected]>
> ---
> accel/mshv/mshv-all.c | 2 +-
> include/system/mshv.h | 7 +++++++
> target/i386/mshv/mshv-cpu.c | 39 +++++++++++++++++++++++++------------
> 3 files changed, 35 insertions(+), 13 deletions(-)
>
> diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c
> index 2f7b325985..35a10f7a78 100644
> --- a/accel/mshv/mshv-all.c
> +++ b/accel/mshv/mshv-all.c
> @@ -398,8 +398,8 @@ static int mshv_init_vcpu(CPUState *cpu)
> uint8_t vp_index = cpu->cpu_index;
> int ret;
>
> - mshv_arch_init_vcpu(cpu);
> cpu->accel = g_new0(AccelCPUState, 1);
> + mshv_arch_init_vcpu(cpu);
This change can either be dropped, or squashed into the
earlier patch in this series that introduced this method.
>
> ret = mshv_create_vcpu(vm_fd, vp_index, &cpu->accel->cpufd);
> if (ret < 0) {
> diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c
> index 6b7e795a36..52afc6b303 100644
> --- a/target/i386/mshv/mshv-cpu.c
> +++ b/target/i386/mshv/mshv-cpu.c
> @@ -33,6 +33,11 @@
>
> #include <sys/ioctl.h>
>
> +#define MAX_SIZE(a, b) ((a) > (b) ? (a) : (b))
Isn't this the same as the existing 'MAX(a, b)' macro in osdep.h ?
> +#define MAX_REGISTER_COUNT (MAX_SIZE(ARRAY_SIZE(STANDARD_REGISTER_NAMES), \
> + MAX_SIZE(ARRAY_SIZE(SPECIAL_REGISTER_NAMES), \
> + ARRAY_SIZE(FPU_REGISTER_NAMES))))
> +
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|