[PATCH v2 08/18] KVM: arm64: Handle PKVM_HYP_REQ_HYP_ALLOC request
Fuad Tabba
fuad.tabba at linux.dev
Tue Jul 14 23:28:20 PDT 2026
On Mon, 6 Jul 2026 at 18:54, Vincent Donnefort <vdonnefort at google.com> wrote:
>
> Introduce a new pkvm_hyp_request type asking the host to top up the pKVM
> heap allocator.
>
> Signed-off-by: Vincent Donnefort <vdonnefort at google.com>
>
> diff --git a/arch/arm64/include/asm/kvm_pkvm.h b/arch/arm64/include/asm/kvm_pkvm.h
> index 0be1469e7874..99daa985856f 100644
> --- a/arch/arm64/include/asm/kvm_pkvm.h
> +++ b/arch/arm64/include/asm/kvm_pkvm.h
> @@ -205,6 +205,7 @@ struct pkvm_mapping {
>
> enum pkvm_hyp_req_type {
> PKVM_HYP_NO_REQ = 0,
> + PKVM_HYP_REQ_HYP_ALLOC,
Now that the enum has a request type the tracepoint can actually fire
for, would you be able to print it symbolically:
TRACE_DEFINE_ENUM(PKVM_HYP_REQ_HYP_ALLOC) plus __print_symbolic() in
kvm_handle_pkvm_hyp_req's TP_printk, so traces read HYP_ALLOC rather
than a raw number. I'm referring to trace_pkvm.h from the previous
patch.
Cheers,
/fuad
> __PKVM_HYP_REQ_TYPE_MAX,
> };
>
> @@ -226,9 +227,13 @@ struct pkvm_hyp_req {
>
> static inline size_t pkvm_hyp_req_arg_size(u8 type)
> {
> + struct pkvm_hyp_req *req;
> +
> switch (type) {
> case PKVM_HYP_NO_REQ:
> return 0;
> + case PKVM_HYP_REQ_HYP_ALLOC:
> + return sizeof(req->mem);
> default:
> WARN_ON(1);
> }
> diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c
> index 5ba8b81b8c6c..adc418076cb0 100644
> --- a/arch/arm64/kvm/pkvm.c
> +++ b/arch/arm64/kvm/pkvm.c
> @@ -626,6 +626,9 @@ static int pkvm_handle_hyp_req(struct pkvm_hyp_req *req)
> int ret = -EINVAL;
>
> switch (req->type) {
> + case PKVM_HYP_REQ_HYP_ALLOC:
> + ret = pkvm_hyp_topup(PKVM_TOPUP_HYP_ALLOC, req->mem.nr_pages);
> + break;
> }
>
> trace_kvm_handle_pkvm_hyp_req(req, ret);
> --
> 2.55.0.rc2.803.g1fd1e6609c-goog
>
More information about the linux-arm-kernel
mailing list