From nobody Mon Feb 9 00:31:26 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 1DF3127AC57 for ; Tue, 6 Jan 2026 04:12:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767672783; cv=none; b=Yz2wfG83fP9J9XzmKaciTTYeJPwVjFhYwD17xQnVdfmA1XXcQ5pOj5Lx/c2ZBmjFXt1DLB91eTZ503E4xfXRk8bnPJZySR6oiKVczhKNGVpbZbC1ar0uTAcOmQgPhQ0jauaseRAvwuD7TtnZS6q7kWP3uT+S21eP66a6zI731uY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767672783; c=relaxed/simple; bh=JAlAEtdbo80N7OYe4Cu0PS/PpFRLFX2PISvANkzvpeA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tFs75dmIRHdZ6Ua6knOit9ADQVYQHRsH5gJzZ2iMeqygnHUuYJy1Uo7ZbCvRmjQtHr2ZjLkLBK39Q7YX2d/xTyORjoJSp/EurGS0RiBfZ7HubPlr7/HW0kZgZQxGaZO602hFpFCm0LLv2DLSiviOkFJjyH6bFED7l/o5hU/LULY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--chengkev.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=yhpbmgfU; arc=none smtp.client-ip=209.85.216.73 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--chengkev.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yhpbmgfU" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-34ac819b2f2so678776a91.0 for ; Mon, 05 Jan 2026 20:12:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767672779; x=1768277579; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6LH3hLDiZ3ov0lC1gcsWvC0RzXwXYlG/q9OQvvLs1Xs=; b=yhpbmgfUsqKvXbPlnBshw1dOVVj/BvWP2Cg69fM3fyqhdfln+9UoEHkl1l+A1/p0CO ys12fLjbCAYoZy0QQTDC9ssrnQTKZwgDTlPFe4xwhgMTkdBgHsfhAJ8th6cJnElRJloh G98IYlf3ak99wQ4YNrwYGGlhbcmz0O4fQE/H8yokgobVIFb1zD5soWWPXl7yVgPvQMo9 0qfuuSBpv2uF2vp7IPHNiBjxxmAlSN3miwYTjMChxGiCFKyj0OKZ5qqWypgBM/IbgsbH nF/p9NY/qnDKlyn0vH87b1WfQ4xAtKyaRd+F+3m4mQszzGB/spX1/2qgZDdveak8ihUj URhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767672779; x=1768277579; h=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; bh=6LH3hLDiZ3ov0lC1gcsWvC0RzXwXYlG/q9OQvvLs1Xs=; b=KBnfH0OQ8BCmXg/jC+G9Htp3GeZ7G5NU1ulSKyucvpO7Y7M5V98M/qNsBZZsei2lE/ yqC6MomitPJDZFqUMkDZqrbBq+hO3+7gntrLQsJyj/wCF8UkPuLeVFG8IvtyKF74ksfN QdTH/RLJKNti/l4vmiqa6GHCm/WYLu/qJcnoyFV1RWFN5uYimo8lMpWvn0q3BOUQ/qOB ENfNGUZ+WJLNkw1WgzHEm6t1B/Pso4OvIdHE3VKWoaJrszu427e7PltDgkJycvkoP94G l/peMCrD/larRU6r6NhFYoCXeczwveIIPOlYBBD5CL0T2ZnQEUoPwxUJEssnV6JkeKiz UEhw== X-Forwarded-Encrypted: i=1; AJvYcCVPvinxBtEB2wrLHbaXJ8/fVjuZb4aaJt+3dukeLWo8cXx6zJ+1Y88Xl7Jl4flra7WHN48HYGBdtPTWZPE=@vger.kernel.org X-Gm-Message-State: AOJu0YwY0l+SVoGGbjp0+B9yr4j4FjzfV9JLwsdXtsqGTjVEbA4LQv66 wFZcIUM4xukdFJYErFehzrjUio2fOFqoHV7dnlDpsjszSdE6nK1UyDxB0EapTFo33p5UrVXz/KS 1Bx0vG7DBLuhjpQ== X-Google-Smtp-Source: AGHT+IHcPJlLz/huni8seshB7udOPPqBmPg7WhGHOUJcqy2MpxEI82MXE0JD6sf8Tn4XFXiVjrrbfZ56BlB5Dg== X-Received: from pjbrs7.prod.google.com ([2002:a17:90b:2b87:b0:34a:bebf:c162]) (user=chengkev job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1f82:b0:33f:f22c:8602 with SMTP id 98e67ed59e1d1-34f5f32c3ffmr1274852a91.26.1767672779370; Mon, 05 Jan 2026 20:12:59 -0800 (PST) Date: Tue, 6 Jan 2026 04:12:50 +0000 In-Reply-To: <20260106041250.2125920-1-chengkev@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260106041250.2125920-1-chengkev@google.com> X-Mailer: git-send-email 2.52.0.351.gbe84eed79e-goog Message-ID: <20260106041250.2125920-3-chengkev@google.com> Subject: [PATCH 2/2] KVM: SVM: Raise #UD if VMMCALL instruction is not intercepted From: Kevin Cheng To: seanjc@google.com, pbonzini@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, yosry.ahmed@linux.dev, Kevin Cheng Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The AMD APM states that if VMMCALL instruction is not intercepted, the instruction raises a #UD exception. Create a vmmcall exit handler that generates a #UD if a VMMCALL exit from L2 is being handled by L0, which means that L1 did not intercept the VMMCALL instruction. Co-developed-by: Sean Christopherson Co-developed-by: Yosry Ahmed Signed-off-by: Kevin Cheng --- arch/x86/kvm/svm/svm.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index fc1b8707bb00c..482495ad72d22 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3179,6 +3179,20 @@ static int bus_lock_exit(struct kvm_vcpu *vcpu) return 0; } =20 +static int vmmcall_interception(struct kvm_vcpu *vcpu) +{ + /* + * If VMMCALL from L2 is not intercepted by L1, the instruction raises a + * #UD exception + */ + if (is_guest_mode(vcpu)) { + kvm_queue_exception(vcpu, UD_VECTOR); + return 1; + } + + return kvm_emulate_hypercall(vcpu); +} + static int (*const svm_exit_handlers[])(struct kvm_vcpu *vcpu) =3D { [SVM_EXIT_READ_CR0] =3D cr_interception, [SVM_EXIT_READ_CR3] =3D cr_interception, @@ -3229,7 +3243,7 @@ static int (*const svm_exit_handlers[])(struct kvm_vc= pu *vcpu) =3D { [SVM_EXIT_TASK_SWITCH] =3D task_switch_interception, [SVM_EXIT_SHUTDOWN] =3D shutdown_interception, [SVM_EXIT_VMRUN] =3D vmrun_interception, - [SVM_EXIT_VMMCALL] =3D kvm_emulate_hypercall, + [SVM_EXIT_VMMCALL] =3D vmmcall_interception, [SVM_EXIT_VMLOAD] =3D vmload_interception, [SVM_EXIT_VMSAVE] =3D vmsave_interception, [SVM_EXIT_STGI] =3D stgi_interception, --=20 2.52.0.351.gbe84eed79e-goog