From nobody Tue Feb 10 14:25:49 2026 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (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 6C12F38757A for ; Mon, 9 Feb 2026 19:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770666783; cv=none; b=ByPaMNYdbDDyPuTyCk5oPy/zyl0EyyVssblsPEleYkwTDKQP02f45s4LqOT254zlpGENCe1AVZZ5Pg9vd8b+vIcaa+AVBUyrjMWs20ycONUtz10j5e0sjEX+fmBCDC5ri/JME+CJRNlBT2j0qR8Py81b0h5Qei/ERzalx4v5LNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770666783; c=relaxed/simple; bh=6YZNN1UxcjX8gZNM775eAniWv8uktkNWbViC1mpDCyI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Is6yOWptniJNai9tvC4TernjT14Xmf10FR92Ko1SLeVxOoHDSL67+hdSAm959yoKp725rHz8DysBY3pu35TYZLtkiVjjH+nw0hTOK6hIskcUSIPtT3ONFxBTRI4mxKOD5uJMIS3IoEVegUF9VgzLe0ABWLrToKr13gAfqhyeKWM= 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=W1m5E17F; arc=none smtp.client-ip=95.215.58.189 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="W1m5E17F" 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=1770666781; 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=lvmdX8Wi8czgVl61TkPRJqdzEqIScTyuhi+2sPS7mLg=; b=W1m5E17FJJ1SmYTkI3uXv+vUpzyQJc7zyST+Kd+1wZhag/u1g5Rg76Bl9so7ReDnCa/GHh YrFqy3ZKkNbcCntX2qU5iaADywr1D5V5rud3suuVlbnf3oCOOznSwybieXxQjLyhqebhHi 1ssPdRNMXkoV42fUi8fsB13qgijIj3M= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [PATCH v2 1/2] KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2 Date: Mon, 9 Feb 2026 19:51:41 +0000 Message-ID: <20260209195142.2554532-2-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" KVM tracks when EFER.SVME is set and cleared to initialize and tear down nested state. However, it doesn't differentiate if EFER.SVME is getting toggled in L1 or L2+. If L2 clears EFER.SVME, and L1 does not intercept the EFER write, KVM exits guest mode and tears down nested state while L2 is running, executing L1 without injecting a proper #VMEXIT. According to the APM: The effect of turning off EFER.SVME while a guest is running is undefined; therefore, the VMM should always prevent guests from writing EFER. Since the behavior is architecturally undefined, KVM gets to choose what to do. Inject a triple fault into L1 as a more graceful option that running L1 with corrupted state. Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson Signed-off-by: Yosry Ahmed --- arch/x86/kvm/svm/svm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 5f0136dbdde6..ccd73a3be3f9 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -216,6 +216,17 @@ int svm_set_efer(struct kvm_vcpu *vcpu, u64 efer) =20 if ((old_efer & EFER_SVME) !=3D (efer & EFER_SVME)) { if (!(efer & EFER_SVME)) { + /* + * Architecturally, clearing EFER.SVME while a guest is + * running yields undefined behavior, i.e. KVM can do + * literally anything. Force the vCPU back into L1 as + * that is the safest option for KVM, but synthesize a + * triple fault (for L1!) so that KVM at least doesn't + * run random L2 code in the context of L1. + */ + if (is_guest_mode(vcpu)) + kvm_make_request(KVM_REQ_TRIPLE_FAULT, vcpu); + svm_leave_nested(vcpu); /* #GP intercept is still needed for vmware backdoor */ if (!enable_vmware_backdoor) --=20 2.53.0.rc2.204.g2597b5adb4-goog