Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Gokul K <gokul02k@gmail.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org
Cc: Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, Peter Gonda <pgonda@google.com>,
	Jing Zhang <jingzhangos@google.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 0/3] KVM: selftests: Fix three leaked resources
Date: Tue,  1 Dec 2026 14:36:29 +0530	[thread overview]
Message-ID: <20261201090632.2482795-1-gokul02k@gmail.com> (raw)

Three resource leaks found while auditing the selftests, all on paths
that run normally rather than on error paths.

Patches 1 and 2 are both /dev/sev descriptors. The first is the one that
matters: every SEV VM opens /dev/sev into vm->arch.sev_fd and nothing
ever closes it, because x86 never provided a kvm_arch_vm_release(). arm64 is the only architecture
that overrides that hook today. The second is sev_init2_tests.c opening
the device once per KVM_SEV_INIT2 ioctl and keeping none of them.

Patch 3 is unrelated to SEV: kvm_binary_stats_test.c loses the id string
when the kernel reports no stats descriptors.

Compile-tested and run on an AMD host without SEV, so patches 1 and 2
are compile-tested only - the paths they touch need an SEV-capable
machine. kvm_binary_stats_test passes 4/4 before and after patch 3. Nine
x86 selftests were run with and without patch 1, which touches the
library every x86 test links, and gave identical results:
set_memory_region_test and x86/state_test fail both ways, as this host's
kernel is older than the tree, and x86/kvm_clock_test skips.

Gokul K (3):
  KVM: selftests: Close /dev/sev when an SEV VM is released
  KVM: selftests: Close the SEV fd opened for each KVM_SEV_INIT2 ioctl
  KVM: selftests: Free the stats id string when no stats are defined

 tools/testing/selftests/kvm/kvm_binary_stats_test.c | 1 +
 tools/testing/selftests/kvm/lib/x86/processor.c     | 6 ++++++
 tools/testing/selftests/kvm/x86/sev_init2_tests.c   | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

-- 
2.51.0



             reply	other threads:[~2026-12-01  9:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:06 Gokul K [this message]
2026-12-01  9:06 ` [PATCH 1/3] KVM: selftests: Close /dev/sev when an SEV VM is released Gokul K
2026-12-01  9:06 ` [PATCH 2/3] KVM: selftests: Close the SEV fd opened for each KVM_SEV_INIT2 ioctl Gokul K
2026-12-01  9:06 ` [PATCH 3/3] KVM: selftests: Free the stats id string when no stats are defined Gokul K
2026-12-01  9:12   ` sashiko-bot

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=20261201090632.2482795-1-gokul02k@gmail.com \
    --to=gokul02k@gmail.com \
    --cc=jingzhangos@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox