From nobody Wed Feb 11 02:05:38 2026 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (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 D93B9428471 for ; Mon, 9 Feb 2026 19:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770666786; cv=none; b=INOZZLz6/43ZIMH0Y8T/lyBb7CquygVmwyo7vU8DL1lJJUqYIxmAjnadiy35Zx+I2UCSffE5b46HOWEY8CfM9yIwpHfDfR0AwrISkMP+2fgPj2RmJpy9tRDe121poL7btMAa3kpqyW3XfPKI7LeFNdR7sQ/YNVWZ1XpOpDvVtwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770666786; c=relaxed/simple; bh=kwLeHpwXB93kA2kA5PIFCI7gv/QvpkmOePSGl8gjVtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FGzVXiJlw6Uh7Gg1j5Pc5LXe3hlpu4Q5RSCvE+tKzG//BeKyJhpqUS99wZ4aAkyAH0ZPpku7OxXYEp2SvRFhQMa2Ga0iOsUoWFKABWXh3VMhyyEjtd0bCTLcaWimM72N5j61RJx/83rLwBCqFs5mExieLwEahaodvtnC9nibxo4= 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=evffC1a1; arc=none smtp.client-ip=95.215.58.179 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="evffC1a1" 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=1770666784; 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=LOFUFZtvZUm4eoRVpzHMdMVSi4TwGR8WtU1V2w4bGMU=; b=evffC1a1MhTnu23JcYQGN1RyeqGeLKAaR2bqfScWcq84xt//i3+LKtSYtia/tPaRwYwh+v BktKFA+p8vP7o1URcW0SYo2l72l6vvu+s1VhMeFiJ7QVBTo+nXl7ca9wMTBhdAW1Dqbjce XJWMa6j+HP3NmOIVY9BciTyujUPqnAc= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [PATCH v2 2/2] KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept Date: Mon, 9 Feb 2026 19:51:42 +0000 Message-ID: <20260209195142.2554532-3-yosry.ahmed@linux.dev> In-Reply-To: <20260209195142.2554532-1-yosry.ahmed@linux.dev> References: <20260209195142.2554532-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" Add a test that verifies KVM's newly introduced behavior of synthesizing a triple fault in L1 if L2 clears EFER.SVME without an L1 interception (which is architecturally undefined). Signed-off-by: Yosry Ahmed --- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../kvm/x86/svm_nested_clear_efer_svme.c | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tools/testing/selftests/kvm/x86/svm_nested_clear_efer_s= vme.c diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selft= ests/kvm/Makefile.kvm index 58eee0474db6..89ba5d6ee741 100644 --- a/tools/testing/selftests/kvm/Makefile.kvm +++ b/tools/testing/selftests/kvm/Makefile.kvm @@ -110,6 +110,7 @@ TEST_GEN_PROGS_x86 +=3D x86/state_test TEST_GEN_PROGS_x86 +=3D x86/vmx_preemption_timer_test TEST_GEN_PROGS_x86 +=3D x86/svm_vmcall_test TEST_GEN_PROGS_x86 +=3D x86/svm_int_ctl_test +TEST_GEN_PROGS_x86 +=3D x86/svm_nested_clear_efer_svme TEST_GEN_PROGS_x86 +=3D x86/svm_nested_shutdown_test TEST_GEN_PROGS_x86 +=3D x86/svm_nested_soft_inject_test TEST_GEN_PROGS_x86 +=3D x86/tsc_scaling_sync diff --git a/tools/testing/selftests/kvm/x86/svm_nested_clear_efer_svme.c b= /tools/testing/selftests/kvm/x86/svm_nested_clear_efer_svme.c new file mode 100644 index 000000000000..a521a9eed061 --- /dev/null +++ b/tools/testing/selftests/kvm/x86/svm_nested_clear_efer_svme.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2026, Google LLC. + */ +#include "kvm_util.h" +#include "vmx.h" +#include "svm_util.h" +#include "kselftest.h" + + +#define L2_GUEST_STACK_SIZE 64 + +static void l2_guest_code(void) +{ + unsigned long efer =3D rdmsr(MSR_EFER); + + /* generic_svm_setup() initializes EFER_SVME set for L2 */ + GUEST_ASSERT(efer & EFER_SVME); + wrmsr(MSR_EFER, efer & ~EFER_SVME); + + /* Unreachable, L1 should be shutdown */ + GUEST_ASSERT(0); +} + +static void l1_guest_code(struct svm_test_data *svm) +{ + unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE]; + + generic_svm_setup(svm, l2_guest_code, + &l2_guest_stack[L2_GUEST_STACK_SIZE]); + run_guest(svm->vmcb, svm->vmcb_gpa); + + /* Unreachable, L1 should be shutdown */ + GUEST_ASSERT(0); +} + +int main(int argc, char *argv[]) +{ + struct kvm_vcpu *vcpu; + struct kvm_vm *vm; + vm_vaddr_t nested_gva =3D 0; + + TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SVM)); + + vm =3D vm_create_with_one_vcpu(&vcpu, l1_guest_code); + + vcpu_alloc_svm(vm, &nested_gva); + vcpu_args_set(vcpu, 1, nested_gva); + + vcpu_run(vcpu); + TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_SHUTDOWN); + + kvm_vm_free(vm); + return 0; +} --=20 2.53.0.rc2.204.g2597b5adb4-goog