On Tue, May 20, 2025 at 01:30:04PM +0200, Magnus Kulke wrote:
> Implement initial interrupt handling logic in the MSHV backend. This
> includes management of MSI and un/registering of irqfd mechanisms.
>
> Signed-off-by: Magnus Kulke <[email protected]>
> ---
[...]
> +int mshv_request_interrupt(int vm_fd, uint32_t interrupt_type, uint32_t
> vector,
> + uint32_t vp_index, bool logical_dest_mode,
> + bool level_triggered)
> +{
> + int ret;
> +
> + if (vector == 0) {
> + /* TODO: why do we receive this? */
You must have seen this in real life, right? We need to convince
ourselves why this is okay.
Thanks,
Wei.
> + return 0;
> + }
> +
> + union hv_interrupt_control control = {
> + .interrupt_type = interrupt_type,
> + .level_triggered = level_triggered,
> + .logical_dest_mode = logical_dest_mode,
> + .rsvd = 0,
> + };
> +
> + struct hv_input_assert_virtual_interrupt arg = {0};
> + arg.control = control;
> + arg.dest_addr = (uint64_t)vp_index;
> + arg.vector = vector;
> +
> + struct mshv_root_hvcall args = {0};
> + args.code = HVCALL_ASSERT_VIRTUAL_INTERRUPT;
> + args.in_sz = sizeof(arg);
> + args.in_ptr = (uint64_t)&arg;
> +
> + ret = mshv_hvcall(vm_fd, &args);
> + if (ret < 0) {
> + error_report("Failed to request interrupt");
> + return -errno;
> + }
> + return 0;
> +}
> +