From nobody Thu Apr 2 20:10:52 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 29B543A0EB3 for ; Thu, 26 Mar 2026 18:18:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774549113; cv=none; b=B0DFvT1dr6SyPFiuXyeg4iqrRe+KrHYSRlt9QF/NzBo4HW2un9JgnI8rCmr5szW1DPz8wPAd6YoXG5KMzrBM6mnlQDnOp+Y6pb+uhHz3+DhLyMaHOq+BAyT514YuO8lmTtajKP7HJ1zoyQOhsJ6LqxIYB1bTmQbNaNHDLqKuG4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774549113; c=relaxed/simple; bh=bCeunf4aD6VnWOdwN1AXGMHgrohJ0mEw507F8rqPwnQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UDVFLoHlJNBCjiIKu2YD82HF+0AI45O/1fKfqeSka4sUg1xg05qKKtTv8Nxq8enZ4mZGBCx3KyUZatq3jzI2dJ6FdMotK3kOpuYzQp7F8yQSohUyG+b/ie22RpSJqCjVxvycgLI7dILmh9/+APK+C91ry/p88i04pitH57jRTWA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=E7NB6JwC; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=gNLlGdq1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E7NB6JwC"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="gNLlGdq1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774549111; 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=jHVbX3hFS+vC3v0LRpnVDXrZsOhD+5Tu40Fbv1jZAKo=; b=E7NB6JwCqAGS1QeJYA1H3x3px9yf+HnmXA/DPkGfHTf18SDdAyTExP2sQLRiCZVGfGaOTB 6oMGkqBXvl+lTgHhYmMriGL0jGVVyb0J8VCj74E0/YpF7ytA1iKydi6p42nUdfdwWQ4n01 o7tSCW6zaoiJ9lbD/uMqxsMAYiCUq04= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-LJhUIt1APxiVzsRtmHF-BQ-1; Thu, 26 Mar 2026 14:18:29 -0400 X-MC-Unique: LJhUIt1APxiVzsRtmHF-BQ-1 X-Mimecast-MFC-AGG-ID: LJhUIt1APxiVzsRtmHF-BQ_1774549108 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-487219e0800so7522705e9.2 for ; Thu, 26 Mar 2026 11:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1774549107; x=1775153907; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jHVbX3hFS+vC3v0LRpnVDXrZsOhD+5Tu40Fbv1jZAKo=; b=gNLlGdq14vkHCZDf0OQc3n2ai2oBwqTF/2hXUMIkPrXnS7m9Uih1UGFp5ftC1QJqHK mT98vbmsYbMD55IHqTjpZNk+6IBN363FtxPZ1rmiqv1xJYdbELD6cbngGFm70qynVR+/ mO37MCbQMOf91zXp9s62CXidiP/V7Wwl31cMrCMt+0gHycsRUJRquyqdfGdsxU7zA1Dh o3HzillrCwYXRYjkerDK1nxVcfQFYkaXVQ3wNACnacalHVLmRDxyVOp0nGxLoOMNXuR6 +yG9fgJ9wZhiVCUcXA3U5MaVayCpPzp0sxxC/hylZXHEPSImnj5mu++q3+Wh1BHXDrXX ojkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774549107; x=1775153907; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jHVbX3hFS+vC3v0LRpnVDXrZsOhD+5Tu40Fbv1jZAKo=; b=MnE0Z3GG1K+z3XNuktwhQiJiJL9I5/5MatB8qIB1lcBJKjcN6J/NuN7gIpSjagLHvR 0yq/lA6Fv5B0/IA5rupMvakOxYgn60Z4tqEnektfQxY5NhZKw5N2Lr5RbapLc+FjOpy2 +R3tgtKGBwPKKAEQRLyHQFGLJYLUxJ3YGJg88zDYZnf+s4tNNmIMtGhYPC0sCY13epVt FKE6REjJoia4tfPSs5AZHrpoXxTv2Yp9woxuJqt+x2oDJ5TUo2fTBpXM81r7dFjsQKvD TvrWR/2SCwguxpR1DF8qgQMW8K0wqVkZgxSVI73YLR513c63Ol3bnD7vnEprrMhe6kzc snrg== X-Gm-Message-State: AOJu0YxxkfdB/q510p9JbBeTiJ0JMFsch16NlfGne2PZ3dKcvEdip53u NtAnnn/zJ3zP9c7dDk3LMe/KoYIA2ty9KMN9NWHJuaJgVf+ueaTO5n8UkticnvwlBwNQGgfNJYE tImoH84bMmI+Ti0uDBr/+YS/7sjz7FWhk06978ji2ErqKSiQpT9obL49+TvawB6CwZ41TGG+EdQ dONIrOdJP08EbQAyDu1p5tQ273SgoAEI0LJdLbymHg2Q7eA0MTXQ== X-Gm-Gg: ATEYQzwoytn5Hw0fwggcUmeWJTPfDNY6+vfq8wpNMawrQ7MAeLLCxu8qQXjzJB+/RSh pEA2Zjt7YS/fptwyTMmEGwEB5KsdrXrSrhNTWraJWjvYObAY6FO7S8gt4bRuh10mARJmApPx+fU 0CGfcqYBxu3dpaGLIgrESfDNghLZSMQSll1GJAEFIRJ3nidCBzlVc/mdGa9JojAmVWPOiYV/Dw4 LLt2YLMfmeem2d7YNosVhYzPKvI/1LasgZpC4JZ2TS5sswAtds/tmiRaxFFCKphLAb3+x8DqMMV KfGnBeXFDsuLf9naQedPl60Kijh3Emw7qBUm3pMg86aYZABX2fnkkNWJWdE9XCQqQxZasPA2SEF CpCCsTrZPuSifh0Y2lwhTZnkkGMeFMNopzB00sSm1ljDrku7eQH0QvKfrUl1hlUZ4KigleooSqb T6qUpLUDW3veUezlVaOtUspHaJ X-Received: by 2002:a05:600c:a010:b0:487:4cb:2fe4 with SMTP id 5b1f17b1804b1-487160bccf1mr136109075e9.33.1774549107349; Thu, 26 Mar 2026 11:18:27 -0700 (PDT) X-Received: by 2002:a05:600c:a010:b0:487:4cb:2fe4 with SMTP id 5b1f17b1804b1-487160bccf1mr136108355e9.33.1774549106779; Thu, 26 Mar 2026 11:18:26 -0700 (PDT) Received: from [192.168.10.48] ([151.49.85.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48722c6b105sm87552805e9.1.2026.03.26.11.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 11:18:25 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Jon Kohler , Nikunj A Dadhania , Amit Shah , Sean Christopherson , Marcelo Tosatti Subject: [PATCH 23/24] KVM: SVM: work around errata 1218 Date: Thu, 26 Mar 2026 19:17:21 +0100 Message-ID: <20260326181723.218115-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260326181723.218115-1-pbonzini@redhat.com> References: <20260326181723.218115-1-pbonzini@redhat.com> 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 Content-Type: text/plain; charset="utf-8" According to AMD, the hypervisor may not be able to determine whether a fault was a GMET fault or an NX fault based on EXITINFO1, and software "must read the relevant VMCB to determine whether a fault was a GMET fault or an NX fault". The APM further details that they meant the CPL field. KVM uses the page fault error code to distinguish the causes of a nested page fault, so recalculate the PFERR_USER_MASK bit of the vmexit information. Only do it for fetches and only if GMET is in use, because KVM does not differentiate based on PFERR_USER_MASK for other nested NPT page faults. Signed-off-by: Paolo Bonzini --- 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 1705e3cafcb0..700090c3408c 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1957,6 +1957,17 @@ static int npf_interception(struct kvm_vcpu *vcpu) } } =20 + if ((svm->vmcb->control.nested_ctl & SVM_NESTED_CTL_GMET_ENABLE) && + (error_code & PFERR_FETCH_MASK)) { + /* + * Work around errata 1218: EXITINFO1[2] May Be Incorrectly Set + * When GMET (Guest Mode Execute Trap extension) is Enabled + */ + error_code |=3D PFERR_USER_MASK; + if (svm_get_cpl(vcpu) =3D=3D 0) + error_code &=3D ~PFERR_USER_MASK; + } + if (sev_snp_guest(vcpu->kvm) && (error_code & PFERR_GUEST_ENC_MASK)) error_code |=3D PFERR_PRIVATE_ACCESS; =20 --=20 2.53.0