All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: maz@kernel.org, oupton@kernel.org, kvmarm@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, joey.gouly@arm.com,
	seiden@linux.ibm.com, suzuki.poulose@arm.com,
	yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org,
	kernel-team@android.com, qperret@google.com
Subject: Re: [PATCH v4 09/17] KVM: arm64: Add selftests for the pKVM heap allocator
Date: Mon, 24 Aug 2026 17:23:30 +0100	[thread overview]
Message-ID: <aoxwAukYucNw1T2p@google.com> (raw)
In-Reply-To: <CA+EHjTy7SUFsE3N5ERV_FQw-3GyEo17mqe2=RbV1wz8bVT+JXw@mail.gmail.com>

[...]

> > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > index 346365e76ef2..d99c9b1b0c82 100644
> > --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> > @@ -633,6 +633,28 @@ static void handle___pkvm_finalize_teardown_vm(struct kvm_cpu_context *host_ctxt
> >         cpu_reg(host_ctxt, 1) = __pkvm_finalize_teardown_vm(handle);
> >  }
> >
> > +#ifdef CONFIG_NVHE_EL2_DEBUG
> > +static void handle___pkvm_hyp_alloc_selftest(struct kvm_cpu_context *host_ctxt)
> > +{
> > +       struct pkvm_hyp_req req = { .type = PKVM_HYP_NO_REQ };
> > +       int ret;
> > +
> > +       ret = hyp_allocator_selftest();
> > +       if (ret == -ENOMEM) {
> > +               req.type = PKVM_HYP_REQ_HYP_ALLOC_SELFTEST;
> > +               req.mem.nr_pages = hyp_alloc_selftest_topup_needed();
> > +       }
> > +
> > +       cpu_reg(host_ctxt, 1) = ret;
> > +       pkvm_hyp_req_to_smccc(host_ctxt, &req);
> > +}
> > +#else
> > +static void handle___pkvm_hyp_alloc_selftest(struct kvm_cpu_context *host_ctxt)
> > +{
> > +       cpu_reg(host_ctxt, 1) = -EPERM;
> > +}
> > +#endif
> 
> My tag stands, but thought about this while going through Sashiko's reviews.
> 
> The other arm writes x2 through pkvm_hyp_req_to_smccc(), this one does
> not, and -EPERM is an error so pkvm_call_hyp_req() goes and decodes
> x2. Nothing initialises it on a call with no arguments.
> 
> It is inert because pkvm_selftests() sits behind the same #ifdef, but
> the handler is registered either way and nothing states the rule.
> errno_to_smccc(-EPERM, host_ctxt) here would write the zero, and it
> may be worth saying on pkvm_call_hyp_req() that any handler reached
> through it has to set x2.
> 
> Cheers,
> /fuad

Clearly not something that would happen but I can put the #ifdef inside
handle___pkvm_hyp_alloc_selftest() so it looks cleaner:

  static void handle___pkvm_hyp_alloc_selftest(struct kvm_cpu_context *host_ctxt)
  {
          struct pkvm_hyp_req req = { .type = PKVM_HYP_NO_REQ };
          int ret = -EPERM;

  #ifdef CONFIG_NVHE_EL2_DEBUG
          ret = hyp_allocator_selftest();
          if (ret == -ENOMEM) {
                  req.type = PKVM_HYP_REQ_HYP_ALLOC_SELFTEST;
                  req.mem.nr_pages = hyp_alloc_selftest_topup_needed();
          }
  #endif
          cpu_reg(host_ctxt, 1) = ret;
          pkvm_hyp_req_to_smccc(host_ctxt, &req);
  }

Regarding pkvm_call_hyp_req(), how about a proper kerneldoc?

 /**
  * pkvm_call_hyp_req() - Issue an HVC that can return hypervisor requests
  * @f: Hypervisor function symbol to call.
  * @...: Arguments to pass to the hypercall.
  *
  * Re-issue an HVC and process any pending hypervisor request until completion
  * or error.
  *
  * Only use this helper for HVCs whose hypervisor handlers format their return
  * registers with pkvm_hyp_req_to_smccc().
  *
  * Return: Result of the hypercall or a negative error if the hyp request
  * handling failed.
  */

-- 
Vincent


  reply	other threads:[~2026-08-24 16:23 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 14:35 [PATCH v4 00/17] KVM: arm64: Introduce pKVM hypervisor heap allocator Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 01/17] KVM: arm64: Add pkvm_private_va_range_pa Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 02/17] KVM: arm64: Add pkvm_remove_mappings Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 03/17] KVM: arm64: Add pkvm_map_private_va_range Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 04/17] KVM: arm64: Add a heap allocator for the pKVM hyp Vincent Donnefort
2026-08-18 14:22   ` Fuad Tabba
2026-08-24 15:19     ` Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 05/17] KVM: arm64: Allow kvm_hyp_memcache usage outside of stage-2 Vincent Donnefort
2026-07-31 14:51   ` sashiko-bot
2026-07-31 14:35 ` [PATCH v4 06/17] KVM: arm64: Add pkvm_hyp_req infrastructure Vincent Donnefort
2026-07-31 14:45   ` sashiko-bot
2026-08-18 15:33     ` Fuad Tabba
2026-08-25  7:41   ` Aneesh Kumar K.V
2026-08-25  8:10     ` Vincent Donnefort
2026-08-25  8:51       ` Fuad Tabba
2026-08-25 13:28       ` Aneesh Kumar K.V
2026-07-31 14:35 ` [PATCH v4 07/17] KVM: arm64: Add PKVM_HYP_REQ_HYP_ALLOC request Vincent Donnefort
2026-07-31 14:52   ` sashiko-bot
2026-08-18 15:11     ` Fuad Tabba
2026-08-18 15:12   ` Fuad Tabba
2026-07-31 14:35 ` [PATCH v4 08/17] KVM: arm64: Add reclaim interface for the pKVM heap alloc Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 09/17] KVM: arm64: Add selftests for the pKVM heap allocator Vincent Donnefort
2026-07-31 15:03   ` sashiko-bot
2026-08-18 15:43   ` Fuad Tabba
2026-08-24 16:23     ` Vincent Donnefort [this message]
2026-08-24 18:15       ` Fuad Tabba
2026-07-31 14:35 ` [PATCH v4 10/17] KVM: arm64: Add a shrinker for pKVM Vincent Donnefort
2026-08-18 15:28   ` Fuad Tabba
2026-08-24 16:38     ` Vincent Donnefort
2026-08-24 18:10       ` Fuad Tabba
2026-08-25  7:22         ` Vincent Donnefort
2026-08-25  7:40           ` Fuad Tabba
2026-08-25  8:20             ` Vincent Donnefort
2026-08-25  8:38               ` Fuad Tabba
2026-07-31 14:35 ` [PATCH v4 11/17] KVM: arm64: Filter out non-kernel addresses in kern_hyp_va Vincent Donnefort
2026-08-18 14:45   ` Fuad Tabba
2026-08-25  9:34     ` Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 12/17] KVM: arm64: Move hyp_vm refcount into the structure Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 13/17] KVM: arm64: Alloc pkvm_hyp_vm using pKVM heap allocator Vincent Donnefort
2026-07-31 15:06   ` sashiko-bot
2026-08-17 13:38   ` Fuad Tabba
2026-07-31 14:35 ` [PATCH v4 14/17] KVM: arm64: Alloc pkvm_hyp_vcpu " Vincent Donnefort
2026-07-31 15:04   ` sashiko-bot
2026-08-17 13:39   ` Fuad Tabba
2026-07-31 14:35 ` [PATCH v4 15/17] KVM: arm64: Reject hyp trace descriptors with fewer CPUs than hyp_nr_cpus Vincent Donnefort
2026-07-31 14:35 ` [PATCH v4 16/17] KVM: arm64: Reject hyp trace descriptors with fewer than 3 pages Vincent Donnefort
2026-08-17 14:00   ` Fuad Tabba
2026-07-31 14:35 ` [PATCH v4 17/17] KVM: arm64: Alloc simple_buffer_page using pKVM hyp allocator Vincent Donnefort
2026-08-17 14:16   ` Fuad Tabba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aoxwAukYucNw1T2p@google.com \
    --to=vdonnefort@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=fuad.tabba@linux.dev \
    --cc=joey.gouly@arm.com \
    --cc=kernel-team@android.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=qperret@google.com \
    --cc=seiden@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.