From nobody Mon Dec 1 22:32:11 2025 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A8B1274FF5 for ; Thu, 27 Nov 2025 01:35:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764207320; cv=none; b=Sit2bZFRGfMEnAz/u9FUTOi0SamTj/3gjbd671ulLExe7sEadP3ZutuBbGt7chvo0zOLkIUpDzyUHBDc7enW9eSjqX0QYDBjkbDhsTC9MDru7B40fw69rgEUpvVUUbH/J2vzmYz3muJb7ue2UjSHq8Hk3GC8uDzYz20/Xi4VfWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764207320; c=relaxed/simple; bh=iov89OnzwSVvqHY9f1/B1XYffUPu1JAJnF9bRQI4HI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gMxIkKXjfUaiyP8efQ/Kwq9I8OrnorqPgcXEmu3V8rJoX3eWJPcTuHEFW8RviPGa7ma6zvhOHbAQzVsLjh9Uh+xPiJxsI+qtjTToT+REVa/uPnU+Q45wmPz/MG5/1mRb4jkvvA3AplImoxXYoODikXl4lsh7quCHWTRb3bHKgDc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=uSvzL6h4; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="uSvzL6h4" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1764207316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5f4Tl1oderqSVFxuqxAn2Fzh62L9qK3Bx3fdCjBdAZY=; b=uSvzL6h4Ue7vpSUiEM2G/Sef9dyVAe0Q70LfcrdQM3Qjt8Hlca6fGvTJ3PhRqg2nGDPEkz Bgcrh1OwBiRm/3o0v/O3vLI1VGPnyVkLAV/btX+2huWSWzq2ZTDVroZpQ62RlxnYIzDRz8 crvIveyZTewlvw0zKg/Z0u2kk9UXVOI= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [PATCH v3 12/16] KVM: selftests: Allow kvm_cpu_has_ept() to be called on AMD CPUs Date: Thu, 27 Nov 2025 01:34:36 +0000 Message-ID: <20251127013440.3324671-13-yosry.ahmed@linux.dev> In-Reply-To: <20251127013440.3324671-1-yosry.ahmed@linux.dev> References: <20251127013440.3324671-1-yosry.ahmed@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" In preparation for generalizing the nested dirty logging test, checking if either EPT or NPT is enabled will be needed. To avoid needing to gate the kvm_cpu_has_ept() call by the CPU type, make sure the function returns false if VMX is not available instead of trying to read VMX-only MSRs. No functional change intended. Signed-off-by: Yosry Ahmed --- tools/testing/selftests/kvm/lib/x86/vmx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/kvm/lib/x86/vmx.c b/tools/testing/self= tests/kvm/lib/x86/vmx.c index 4289c9eb61ff..f70d0d591d5a 100644 --- a/tools/testing/selftests/kvm/lib/x86/vmx.c +++ b/tools/testing/selftests/kvm/lib/x86/vmx.c @@ -380,6 +380,9 @@ bool kvm_cpu_has_ept(void) { uint64_t ctrl; =20 + if (!kvm_cpu_has(X86_FEATURE_VMX)) + return false; + ctrl =3D kvm_get_feature_msr(MSR_IA32_VMX_TRUE_PROCBASED_CTLS) >> 32; if (!(ctrl & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)) return false; --=20 2.52.0.158.g65b55ccf14-goog