[PATCH v1 2/3] KVM: arm64: Add guest_hvc hyp event

Fuad Tabba fuad.tabba at linux.dev
Fri Oct 9 05:06:05 PDT 2026


Hi Vincent,

On Fri, 09 Oct 2026 09:45:28 +0100, Vincent Donnefort
<vdonnefort at google.com> wrote:

> Add a guest_hvc hypervisor trace event to log protected VM HVC call IDs,
> return values, and whether the call was handled by the hypervisor.

nit: only the first return value is logged.

[...]
> diff --git a/arch/arm64/include/asm/kvm_hypevents.h b/arch/arm64/include/asm/kvm_hypevents.h

[...]
> +HYP_EVENT(guest_hvc,
> +        HE_PROTO(u32 id, u64 val, u8 handled),
> +        HE_STRUCT(
> +                he_field(u8, handled)
> +                he_field(u32, id)
> +                he_field(u64, val)
> +        ),

remote_event_format_show() doesn't align the field offsets, so the
format file puts id at 3 and val at 7 instead of 4 and 8. hyp_enter's
vcpu is already off the same way, so should this be a separate fix in
trace_remote.c, with ALIGN(offset, field->align)?

[...]
> diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c

[...]
> @@ -1183,5 +1185,8 @@ bool kvm_handle_pvm_hvc64(struct kvm_vcpu *vcpu, u64 *exit_code)
>
>          if (handled)
>                  smccc_set_retval(vcpu, val[0], val[1], val[2], val[3]);
> +
> +        trace_guest_hvc(fn, val[0], handled);
> +
>          return handled;

When handled is false, val[0] is the SMCCC_RET_INVALID_PARAMETER
initialiser, which the guest never gets. For example, a MEM_SHARE
forwarded to the host logs "id=0xc6000003 val=0xfffffffffffffffd
handled=0". Could this log 0 in that case?

Cheers,
/fuad



More information about the linux-arm-kernel mailing list