From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (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 E242B28033B for ; Mon, 10 Aug 2026 13:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786369069; cv=none; b=F9RRAbp87f5Tg5Z3m2TZjYKRm1MQIYurjwF5mLvKtmkqcrr69HIlNwG0SrOUk1CktH8MSZbrkdxx6vpgguYNAoKu4MPHXY9m3KP2Z6HK9wjEXmgcwMBdsspfgUxIpt9XxFo5UZ9SR12ZprH1B2tnJphC7Ba9/9/btVWbcjJrCwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786369069; c=relaxed/simple; bh=q6FNZp3XFaqNHFhMl6+y/FDb5a1CEfUMMH6myO0ku7Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uB836is3U5PHS7Sc1MSqgE5qAoZ7kROBh6fE6wOSviGAuck9U3ytyTBwqqk4bprZAU5W+/bfc7EqAvwB/PFlGWN6rukT8l0u8fT1gAoUY383xoGCvZnjLNd8olQ5sv2hfc2IYAZYzghn9egL9+ODk+64pYnCeaH3OU1UoKAT5wk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sH/JUYIH; arc=none smtp.client-ip=209.85.215.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sH/JUYIH" Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cb4bd11ddf8so2393226a12.3 for ; Mon, 10 Aug 2026 06:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786369067; x=1786973867; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/OjVBVJfk4CwI9/GoWgBIfWW3MJVUID0+VTcUKcWM90=; b=sH/JUYIH7yf/OfLstBaHv1v3tygMHWKFFx95P2mEV94SMvLiNy+uFFU3luRo5Oc24J AU3QAnffU6rVvOqp0Rz6M2uXb5A+OkleVdfmxPZc391VHLA6iXSiJxZaSL9cktE/DWGI kkkb5nve9Wqv1AR5UFVcIdxoV+8/of2SnAQwHIOcYaKZw6J84pFrBoDBHB39pJobN926 xDrVkvWxEtLH9hhyeW/Z811olNL6fv/C/Bfv8F2PRdAVo9EdgsLiA9jBeaUKbCoM8z1g Kz3xINKIvEQnYfvdBS+xci3Gqs/IauvxD25CB55eRSVRWLo4IirG3vP7rDWQhHDzHqsF Em5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786369067; x=1786973867; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/OjVBVJfk4CwI9/GoWgBIfWW3MJVUID0+VTcUKcWM90=; b=HKKsuYWg61dw9OW/JOqynzg2z1DwZ8KCqZyoN0Mvn2wlZEU38gY/tX/dV54o/YfBQ/ 6WzG77Qj/EZ5bCxGVGmG+At2Ex7GipdjkOPkBKUD+TsCd8+FZcMQp2JHDY/8eI5J1nuz 4giR9jQPDj8IXMX4B4kzs20wPn0i+U8JXg2NFbFaUoMuoKGHeKKsOOqufHyvAntS+uvN 7Qh85n7ElUgDf1l0jkqpSs6FWJ7CmYFGvgEfxhcKEYwtPDQZN+2GXzZLkHIQZKDCzM9b vy9/eRFCKTRC1OHHb7MJZ0UrWnOM9pSMYKUjMZ1pshmn7IF/6Dh60ZaWCwzsfS55rBRM btZw== X-Forwarded-Encrypted: i=1; AHgh+Ro8eO5p5tccQFeAtdsgGor9xDfVINE0X3lKK4mKkVgRSNJ4x0gls62wvY9iFLK38TpycTN4m1uzZeLu2Qk=@vger.kernel.org X-Gm-Message-State: AOJu0YwvXlNjHstpP580Yo/6FFX75E+im5B/kV2K3w7i3n/x3BZtaY7Y HlNiXMw+B2+8bwBjS5mgSC580nsd+Ms5zhKNBD9LF/9N4OCuqdtEMfRHsvuLUUGW9b3YP0wvcnB 7ActvXg== X-Received: from pgii30.prod.google.com ([2002:a63:221e:0:b0:c9e:41e5:2eec]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:10a:b0:3c3:a140:9380 with SMTP id adf61e73a8af0-3cbce7fdeb0mr25171510637.16.1786369066622; Mon, 10 Aug 2026 06:37:46 -0700 (PDT) Date: Mon, 10 Aug 2026 06:37:46 -0700 In-Reply-To: <20260808081050.408657-3-gokul02k@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260808081050.408657-1-gokul02k@gmail.com> <20260808081050.408657-3-gokul02k@gmail.com> Message-ID: Subject: Re: [PATCH 2/2] KVM: selftests: Free the VM when NX hugepage disabling is denied From: Sean Christopherson To: Gokul K Cc: Paolo Bonzini , Shuah Khan , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Sat, Aug 08, 2026, Gokul K wrote: > run_test() returns as soon as it has confirmed that disabling NX huge > pages fails with -EPERM, without freeing the VM created a few lines > earlier. > > This is not an obscure path. FWIW, the relative obscurity of the path doesn't really matter. > nx_huge_pages_test.sh runs the test a > second time without CAP_SYS_BOOT for any non-root user, and main() calls > run_test() with disable_nx_huge_pages=true on its second invocation, so > an ordinary run of the wrapper script always takes it. > > Free the VM before returning. > > Fixes: b774da3f2e57 ("KVM: selftests: Test disabling NX hugepages on a VM") > Signed-off-by: Gokul K > --- > tools/testing/selftests/kvm/x86/nx_huge_pages_test.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c > index 70950067b989..49b70c05daec 100644 > --- a/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c > +++ b/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c > @@ -120,6 +120,7 @@ void run_test(int reclaim_period_ms, bool disable_nx_huge_pages, > } else { > TEST_ASSERT(r == -1 && errno == EPERM, > "This process should not have permission to disable NX huge pages"); > + kvm_vm_free(vm); > return; I think I'd prefer the same patter you used in patch 1? I.e. diff --git a/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c index 70950067b989..e3b20033a884 100644 --- a/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c +++ b/tools/testing/selftests/kvm/x86/nx_huge_pages_test.c @@ -120,7 +120,7 @@ void run_test(int reclaim_period_ms, bool disable_nx_huge_pages, } else { TEST_ASSERT(r == -1 && errno == EPERM, "This process should not have permission to disable NX huge pages"); - return; + goto done; } } @@ -213,6 +213,7 @@ void run_test(int reclaim_period_ms, bool disable_nx_huge_pages, check_2m_page_count(vm, disable_nx_huge_pages ? 3 : 2); check_split_count(vm, 0); +done: kvm_vm_free(vm); } > } > } > -- > 2.54.0 > >