From: sashiko-bot@kernel.org
To: "Tarun Sahu" <tarunsahu@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 9/9] selftests: kvm: Add guest_memfd_preservation_test
Date: Mon, 22 Jun 2026 19:13:26 +0000 [thread overview]
Message-ID: <20260622191327.22B591F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260622184851.2309827-10-tarunsahu@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Stage 2 test failure due to re-creation of preserved KVM resources (memslots and vCPU)
--
commit 323482e513bb6a4836ceedaaec02c412bc10f974
Author: Tarun Sahu <tarunsahu@google.com>
selftests: kvm: Add guest_memfd_preservation_test
This commit adds a new KVM selftest to verify that guest memory backed
by guest_memfd is preserved properly across kexec via LUO. It introduces
a two-stage test to save state before kexec and verify it afterwards.
> diff --git a/tools/testing/selftests/kvm/guest_memfd_preservation_test.c b/tools/testing/selftests/kvm/guest_memfd_preservation_test.c
> new file mode 100644
> index 0000000000000..c0a20e788ba79
> --- /dev/null
> +++ b/tools/testing/selftests/kvm/guest_memfd_preservation_test.c
[ ... ]
> +static void run_stage_2(int luo_fd, int state_session_fd)
> +{
> + int retrieved_vm_fd, retrieved_gmem_fd, session_fd, stage;
> + struct vm_shape shape = VM_SHAPE_DEFAULT;
> + const uint64_t gpa = SZ_4G;
> + struct kvm_vcpu *vcpu;
> + const int slot = 1;
> + struct kvm_vm *vm;
[ ... ]
> + retrieved_gmem_fd = luo_session_retrieve_fd(session_fd, GMEM_TOKEN);
> + TEST_ASSERT(retrieved_gmem_fd >= 0, "Failed to retrieve guest_memfd file descriptor");
> +
> + vm = vm_create_from_fd(retrieved_vm_fd, shape);
> +
> + u64 nr_pages = 2048; /* 8MB is plenty for slot0 pages */
> +
> + vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, 0, 0, nr_pages, 0);
[Severity: High]
Does this ioctl fail with -EINVAL because slot 0 already exists in the
preserved KVM VM with a different size? The preserved VM from stage 1 retains
its kernel-side state, which we attempt to blindly re-create here without
respecting the preserved state.
> + kvm_vm_elf_load(vm, program_invocation_name);
> +
> + for (int i = 0; i < NR_MEM_REGIONS; i++)
> + vm->memslots[i] = 0;
> +
> + struct userspace_mem_region *slot0 = memslot2region(vm, 0);
> +
> + ucall_init(vm, slot0->region.guest_phys_addr + slot0->region.memory_size);
> +
> + vm_set_user_memory_region2(vm, slot, KVM_MEM_GUEST_MEMFD, gpa, GMEM_SIZE, NULL,
> + retrieved_gmem_fd, 0);
[Severity: High]
Could this fail with -EINVAL because modifying an existing private
KVM_MEM_GUEST_MEMFD memslot is explicitly forbidden by KVM?
> +
> + for (size_t i = 0; i < GMEM_SIZE; i += page_size)
> + virt_pg_map(vm, gpa + i, gpa + i);
> +
> + vcpu = vm_vcpu_add(vm, 0, guest_code_phase2);
[Severity: High]
Will this call fail with -EEXIST since vCPU ID 0 was already created
in Stage 1 and remains preserved within the retrieved KVM VM?
> + kvm_arch_vm_finalize_vcpus(vm);
> +
> + vcpu_args_set(vcpu, 3, gpa, GMEM_SIZE, DATA_SIZE);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260622184851.2309827-1-tarunsahu@google.com?part=9
next prev parent reply other threads:[~2026-06-22 19:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 18:48 [PATCH v3 0/9] liveupdate: kvm: guest_memfd preservation Tarun Sahu
2026-06-22 18:48 ` [PATCH v3 1/9] liveupdate: Add LIVEUPDATE_GUEST_MEMFD config option Tarun Sahu
2026-06-22 18:48 ` [PATCH v3 2/9] kvm: Prepare core VM structs and helpers for LUO support Tarun Sahu
2026-06-22 19:01 ` sashiko-bot
2026-06-22 18:48 ` [PATCH v3 3/9] kvm: kvm_luo: Allow kvm preservation with LUO Tarun Sahu
2026-06-22 19:06 ` sashiko-bot
2026-06-22 18:48 ` [PATCH v3 4/9] kvm: guest_memfd: Move internal definitions and helper to new header Tarun Sahu
2026-06-22 18:48 ` [PATCH v3 5/9] kvm: guest_memfd: Add support for freezing and unfreezing mappings Tarun Sahu
2026-06-22 19:01 ` sashiko-bot
2026-06-22 18:48 ` [PATCH v3 6/9] kvm: guest_memfd_luo: add support for guest_memfd preservation Tarun Sahu
2026-06-22 19:08 ` sashiko-bot
2026-06-22 18:48 ` [PATCH v3 7/9] docs: add documentation for guest_memfd preservation via LUO Tarun Sahu
2026-06-22 18:54 ` sashiko-bot
2026-06-22 19:04 ` tarunsahu
2026-06-22 18:48 ` [PATCH v3 8/9] selftests: kvm: Split ____vm_create() to expose init helpers Tarun Sahu
2026-06-22 18:48 ` [PATCH v3 9/9] selftests: kvm: Add guest_memfd_preservation_test Tarun Sahu
2026-06-22 19:13 ` sashiko-bot [this message]
2026-06-22 18:55 ` [PATCH v3 0/9] liveupdate: kvm: guest_memfd preservation tarunsahu
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=20260622191327.22B591F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tarunsahu@google.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.