From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B92E93A7848 for ; Sat, 8 Aug 2026 08:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786176684; cv=none; b=ZISAfFW1ewVVh81919YiyxyDbJAmHTqr2eXD5bZ7rcTsGw/HINxPvGlDCQLBSeUAVxRvHvf3APbYg4h/jVzugwT/p26xAfBOWjJUrjLW2veNKN0ZxdSl0uoSSH+qncEiufBLYZOscSZwqmrkpuye7PvnuWfpxbwDL383kOHPrtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786176684; c=relaxed/simple; bh=kz5eF8EgHJZV4kT1Yjijkfp28Af36RtKI66Pm5tq4pQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hggCc/vlXoeWKs4Lj/0g8+SOGCq6Owkw6L8JaDvFbYVNljxCANjrO2bF+xM0MWCs+xjGRaHjNg2854qLyAzM2iNwfoDWUC2Uu1lNi5Bka3ekjwTmnAUJAeZ6oqOQ1AviDYYrZGL5x00ykIUK4zTr6QiyoysVRIvy5vVS1myeJmA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SRjWmcoJ; arc=none smtp.client-ip=209.85.215.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SRjWmcoJ" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-caf45fc5202so143519a12.1 for ; Sat, 08 Aug 2026 01:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786176682; x=1786781482; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8XV1qyiW1WN9UH6X3Jv/ZBqv2q+Lebe5phUQECTXzBc=; b=SRjWmcoJZDdTSWMc1KgFI003tZZFY9UHqKiudZzgwwHYlUfmT2I4vylEyI4jFCCmkd Gjy71Rb8UmuhaaGnP7F10PDbzVrqYN7i4/usN1kAJsScZEOmDpxWVOQd782znwuEMYPb IP3d7BbSn0ISI4zyjTLlbY14zEWls2xSlSG9+xaE3lL+fx1Px2Hj22GCFaROEdFUlVuM WBG83zjUXY9dRQCn6dcoFZy0A5MZwySHwaudrGxN3QPxKKWsJ5XCg/SWYJGKGC9/n+zt QFesoXVbUy2kial5ybp53Cbn+du8VfTbzyBy/udsUlHm+q++VSt1bLRNjMb5ORKtvdWI zVbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786176682; x=1786781482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=8XV1qyiW1WN9UH6X3Jv/ZBqv2q+Lebe5phUQECTXzBc=; b=iSS6kN4nEFXz2nMRuMBGn8+iOJiUuRKC3lrsqSn6eqWbd3tml/+Q90ntQNwb5W/+Za zFMi+IBUiNOFiFW08R06Y+E8c8qW63Hyh1G+SgKlkLD51kQQbTn7lYp2Qxdq/V98AWoy Au+x3KvDEKCodGAQ7544TsF7uR/p+j6+kyss5YSvXyiyAlgEAcEjgUv9lvYv95hJZhxJ tTUqBr6gsuXItf28lmgtDdVAqgLLJ0dyIplh8W1xR3p4ibO7D9B+B0bLp4aui6ZXT+Jn GzPE9a1qU09kEFiq0hdtUS9aWVsaBJHM4nm1WZFDGY6M5K7LT4xo0vfyOLr4Cr67Ds29 DTCg== X-Forwarded-Encrypted: i=1; AHgh+RoEOW1mGrANTBG4DklU4W6oUf6U5+aNeaDwPj/Z33ymNQCohcNo1mV5P4f4w0qjlVzPt+R+R7t1OTFL44U=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3xwS92lAuR0olKYKuX4Q4NP61JYkfLYndd85w4RiNwwLdxzsm MNU58j998AdKHiwvvcc2caWEGzRPGfti0IMYyyhJwfvKy2YW+8F/yCBj X-Gm-Gg: AR+sD11Ema5epRIeiqJjHB4Ibb7uAr/FiAp6+ZR1GxQQuFM85YrqVbCptVO3896vt1i 0yBxCOA92nZHTTDlHndOTcft4lEbrHQIny/sKO6E35hCyD1l+fZIA3QQRjRCSVQW+bYVCLDa3GI Gp2FUry+h61LeIBY/bVbD/1u/2+Yh/0luYCOuLlUEIVrDFJilRa6NvVt0zGu66csiCrlU1RI4a0 vsZZ9Qlz2HqAklFb1RihuN3IaN+vOc7KGJsL/8UYShZ9jH+1FwXpUJSrtAe5ZlHe4r9kDLPU6pF caZjuUNZWkB7ZmSP258dNjPSKfcLlkCJSxJ/YAnxwTom8Vw6OjriHEGTsTYIThgoMVA2WLItcKo Z4ud3fn0JfLpsoQPiS6EskbWzkbnTzOP71KKuUa7npj85QEJa7Gn2NL50HOcsO7FqjqWVxNFzgY /8gKv0pVeg3CpRO7Q4/mVe+i08badH+hWERrRiMvjxYE7o2w0Sh/K0njh5xNbWmIRYMbk9T3+Hy Q== X-Received: by 2002:a05:6a21:6197:b0:3c3:7891:6523 with SMTP id adf61e73a8af0-3cb85ffd1b7mr35612051637.34.1786176682050; Sat, 08 Aug 2026 01:11:22 -0700 (PDT) Received: from 10-86-27-207.ban-spse ([165.204.217.251]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-141019b4244sm13957833c88.4.2026.08.08.01.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Aug 2026 01:11:21 -0700 (PDT) From: Gokul K To: Sean Christopherson , Paolo Bonzini Cc: Shuah Khan , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] KVM: selftests: Free the VM when the SEV smoke test's guest completes Date: Sat, 8 Aug 2026 13:40:49 +0530 Message-ID: <20260808081050.408657-2-gokul02k@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260808081050.408657-1-gokul02k@gmail.com> References: <20260808081050.408657-1-gokul02k@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit test_sev() returns directly out of the UCALL_DONE case rather than leaving the loop, so the plain-SEV path skips the kvm_vm_free() at the end of the function. The SEV-ES path is unaffected; it breaks out of the loop and frees the VM correctly. main() invokes test_sev() once per supported SEV VM type, so a full run leaks a VM and its file descriptors. Nothing fails today because the process exits shortly afterwards, which is presumably why this was not noticed, but the leak also means the plain-SEV path never exercises VM teardown. Use a goto so UCALL_DONE joins the existing exit path. A plain break would only leave the switch statement and spin the loop again. Fixes: be250ff437fa ("KVM: selftests: Add a basic SEV smoke test") Signed-off-by: Gokul K --- tools/testing/selftests/kvm/x86/sev_smoke_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86/sev_smoke_test.c index 6b2cbe2a90b7..646ae93e3c46 100644 --- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c +++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c @@ -178,7 +178,7 @@ static void test_sev(void *guest_code, u32 type, u64 policy) case UCALL_SYNC: continue; case UCALL_DONE: - return; + goto done; case UCALL_ABORT: REPORT_GUEST_ASSERT(uc); default: @@ -187,6 +187,7 @@ static void test_sev(void *guest_code, u32 type, u64 policy) } } +done: kvm_vm_free(vm); } -- 2.54.0