All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jia He" <justin.he@arm.com>
Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
	"Oliver Upton" <oupton@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v2 2/2] KVM: selftests: arm64: Test KVM_PRE_FAULT_MEMORY before first KVM_RUN
Date: Fri, 04 Dec 2026 09:25:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-249501@kernel.org> (raw)
In-Reply-To: <20261204090914.459990-3-justin.he@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: selftests: test_pre_first_run_el1() uses guest page size
  for pre-fault
--

commit efb55a38dc35f83285043845cf36eea7648a5fbe
Author: Jia He <justin.he@arm.com>

KVM: selftests: arm64: Test KVM_PRE_FAULT_MEMORY before first KVM_RUN

This commit extends nv_pre_fault_memory_test to exercise
KVM_PRE_FAULT_MEMORY before the first KVM_RUN and across vCPU thread
handoffs, both with and without EL2 enabled.

> diff --git a/tools/testing/selftests/kvm/arm64/nv_pre_fault_memory_test.c b/tools/testing/selftests/kvm/arm64/nv_pre_fault_memory_test.c
> index 09c1db3038566..57e3aaeea8947 100644
> --- a/tools/testing/selftests/kvm/arm64/nv_pre_fault_memory_test.c
> +++ b/tools/testing/selftests/kvm/arm64/nv_pre_fault_memory_test.c

[ ... ]

> +static void test_pre_first_run_el1(void)
> +{
> +	int feature = KVM_ARM_VCPU_SVE;
> +	struct kvm_vcpu *vcpu;
> +	struct kvm_vm *vm;
> +	int ret;
> +
> +	pr_info("Testing pre-fault, then immediate_exit on the first KVM_RUN\n");
> +	vm = setup_test_vm(false, false, guest_el1_touch_and_done, &vcpu);
> +	pre_fault(vcpu, TEST_MEM_GPA, vm->page_size);
> +
> +	vcpu->run->immediate_exit = 1;
> +	ret = __vcpu_run(vcpu);
> +	TEST_ASSERT(ret == -1 && errno == EINTR,
> +		    "Expected -EINTR on immediate_exit, got ret=%d errno=%d",
> +		    ret, errno);
> +	vcpu->run->immediate_exit = 0;
> +
> +	pre_fault(vcpu, TEST_MEM_GPA, TEST_MEM_SIZE);
> +	vcpu_run(vcpu);
> +	expect_ucall_done(vcpu);
> +	kvm_vm_free(vm);
> +
> +	if (!kvm_check_cap(KVM_CAP_ARM_SVE)) {
> +		pr_info("SVE not supported, skipping failed first KVM_RUN test\n");
> +		return;
>  	}
>  
> +	pr_info("Testing pre-fault after a failed first KVM_RUN\n");
> +	vm = setup_test_vm(false, true, guest_el1_touch_and_done, &vcpu);
> +	pre_fault(vcpu, TEST_MEM_GPA, vm->page_size);
> +
> +	ret = __vcpu_run(vcpu);
> +	TEST_ASSERT(ret == -1 && errno == EPERM,
> +		    "Expected -EPERM before SVE finalisation, got ret=%d errno=%d",
> +		    ret, errno);
> +
> +	pre_fault(vcpu, TEST_MEM_GPA + vm->page_size, vm->page_size);

[Severity: Medium]
Can these pre_fault() calls fail with -EINVAL on arm64 hosts with 16 KiB
or 64 KiB pages?

setup_test_vm() creates a VM with vm_create(1), which defaults to
VM_MODE_P40V48_4K (a 4 KiB vm->page_size) regardless of the host page
size.

kvm_vcpu_pre_fault_memory() requires both range->gpa and range->size to
be host PAGE_ALIGNED().  Passing vm->page_size as the size and
TEST_MEM_GPA + vm->page_size as the address returns -EINVAL and aborts
the test on 16 KiB and 64 KiB host kernels.

Using getpagesize() instead of vm->page_size (as pre_fault_memory_test.c
does) would keep the address and size aligned to the host page size.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204090914.459990-1-justin.he@arm.com?part=2

  reply	other threads:[~2026-12-04  9:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  9:09 [PATCH v2 0/2] KVM: arm64: Don't load hardware vCPU state before first run Jia He
2026-12-04  9:09 ` [PATCH v2 1/2] " Jia He
2026-12-04  9:38   ` sashiko-bot
2026-12-05  2:12     ` Justin He
2026-12-04  9:09 ` [PATCH v2 2/2] KVM: selftests: arm64: Test KVM_PRE_FAULT_MEMORY before first KVM_RUN Jia He
2026-12-04  9:25   ` sashiko-bot [this message]
2026-12-05  2:14     ` Justin He

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=sashiko-outbox-249501@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=justin.he@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.