From nobody Wed Apr 8 06:22:54 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 C47C73C9454 for ; Tue, 10 Mar 2026 21:18:46 +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=1773177527; cv=none; b=JGgnNWKeiQ6KR+PKJMk1R0lX1eiy5SbAT/o/Y48uebp0G7OWNjCuyPWA+jEaBUfV+iQ3EDMkKr5aZn23tZK8FSD1wfbsXcjTN0Vz4+pxwmiTbOXAy68wPTJW02nnZBw85osZgayOLuqmFzSt1EkO8vJFHdwd+2UWEMEJtQdfSfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773177527; c=relaxed/simple; bh=I6/K8Mr0bjHYxOECs28OHjZKcjEU5wZuhZrOi8DO2X0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JTdeo45Dzr26Oy5ce4jC0nOCFv04YKU8nLt4+bLrctimRiAmhD/Kw9I2dHdg3f/3iQ2R3I3+UDdh5U+QpOQOhjBh6Ktm2TwiZYkHCdKELE3pEPSokZyyajyypqb3fSkN1GZyj34FaRdg+ixMb8wY0BA8b2OeQGxGvw9fbiE1b/g= 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=W2Uo46m2; 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--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="W2Uo46m2" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-35979a03106so10551295a91.1 for ; Tue, 10 Mar 2026 14:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773177526; x=1773782326; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=7fUvP6PMmMjoOVXqU7ieGLMVIjfZdL4Sg65k3US/tM0=; b=W2Uo46m2NV2VA80fWZxXi4/suK+QcYoyrQfPilc/0/aXJnC4lK/xpEdu9N/7/AX8bt ErRKGjA1un6LBF2f9jfHR/MDEoG3v2qJ/CIpnAjmtl4bf0hiIsygPn4OJJTh8gH2htzL t91kUf71JC/rPq6h/j5OoCjYrOQTGm/eg60eeQBmkDMc7Mp7mD9BH4rkbmlX5/T0j7Fj 9C4XjH53gck+YLMRFKgEgAL4gSCXuiAqm9YFwaDwcwAcJwDZUG9i9/ATssPdSSgSXPhR ogY1SDy/kroc5UGh4Gvj0goIXD3bXKr94hJfNm92g9faJVppF+/FaljyEpOIGYFEIljs zjoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773177526; x=1773782326; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7fUvP6PMmMjoOVXqU7ieGLMVIjfZdL4Sg65k3US/tM0=; b=DJCsGhNMqDLXpTvTxrxfTAZj5csM6BW+uWbiX98POU9FvSeFf6VYmHcfM//3XsTh73 6YsaVxt/LO3I4SoLT9rISey6dGIaaOhDD0OX8fe2iCEXGs1A56QQfysEu372MjyzC3TL WuGWeE33a/+3ctcwSuylRIgxtz17TBmtdqiar6ubIKovMtv1GR5/QRi0fbgv/3tdF30j BL5H0HR/v1SGTtJTrU59+wCPOyKs0Om5AdaeHvedT0ruW/kru7C4N0v8Xzc/5JpRr+F1 XCM2uZlT6DvPHbyjvQXXhh62yjXcYBIO/HinIJl4kz9dUygxo7rJSezyDhm/1dHIzFXM 0KLg== X-Forwarded-Encrypted: i=1; AJvYcCUcD2uq44rDRKjJBDaD1roN8QjIqGHPUIvZD10UFXm4imYCaU87Ehx7YetmB8diQbcK1MTr1bOj/7jNMdU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4EQpfTETlUjcM5fszgQrG77Fqcq9/TQGXn8QdSaG+33tISUm9 cAARNNPGhURnMOmNizPXL947POQchCqsTFLKxP7XDwdPEtCq5n2PWbKOBLt4Sz7h+oKGV2SXTRt fw3DePg== X-Received: from pgki21.prod.google.com ([2002:a63:e455:0:b0:c73:9c8b:4186]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:6b8c:b0:398:7df5:2dae with SMTP id adf61e73a8af0-398c5e6067fmr65812637.9.1773177526121; Tue, 10 Mar 2026 14:18:46 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 10 Mar 2026 14:18:40 -0700 In-Reply-To: <20260310211841.2552361-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260310211841.2552361-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260310211841.2552361-2-seanjc@google.com> Subject: [PATCH 1/2] KVM: SEV: Don't set CR8 write intercept when disabling AVIC for SEV-ES guests From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Srikanth Aithal , Naveen N Rao Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Don't set the CR8 write intercept when disabling AVIC for SEV-ES vCPUs, as attempting to intercept CR8 will generate a #VC and in all likelihood kill the VM. Note! At first glance, one might think KVM's handling of CR8 write traps for SEV-ES is flawed, as KVM traps CR8 writes even when AVIC is enabled, despite the fact that hardware updates the AVIC backing page as well. But KVM unconditionally inhibits AVIC for SEV-ES guests as current hardware apparently can't support it (see c538dc792ff7 ("KVM: SVM: Do not activate AVIC for SEV-enabled guest")). However, KVM's overall handling of CR8 _is_ broken, as sync_cr8_to_lapic() will clobber with stale information from the unencrypted VMCB. That issue will be fixed separately. Reported-by: Srikanth Aithal Closes: https://lore.kernel.org/all/19935696-36cf-411b-af90-aabe6a98d7e7@am= d.com Fixes: e992bf67bcba ("KVM: SVM: Set/clear CR8 write interception when AVIC = is (de)activated") Cc: stable@vger.kernel.org Acked-by: Naveen N Rao (AMD) Signed-off-by: Sean Christopherson Tested-by: Srikanth Aithal --- arch/x86/kvm/svm/avic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index 13a4a8949aba..f7ec7914e3c4 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -226,7 +226,8 @@ static void avic_deactivate_vmcb(struct vcpu_svm *svm) vmcb->control.int_ctl &=3D ~(AVIC_ENABLE_MASK | X2APIC_MODE_MASK); vmcb->control.avic_physical_id &=3D ~AVIC_PHYSICAL_MAX_INDEX_MASK; =20 - svm_set_intercept(svm, INTERCEPT_CR8_WRITE); + if (!sev_es_guest(svm->vcpu.kvm)) + svm_set_intercept(svm, INTERCEPT_CR8_WRITE); =20 /* * If running nested and the guest uses its own MSR bitmap, there --=20 2.53.0.473.g4a7958ca14-goog