Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 E7D5723E25B for ; Tue, 24 Feb 2026 00:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771894522; cv=none; b=j6V51FxEaN1KfEIb337f6t2idwfPBgloO6BXK2G6VlVFuhRDQ0w/Mzfpi5gFhiglSXxqyIsJemUIV5NOqJ03n1DTSsksaCG9ss2qfr1gmTzXV2qL1qImB6WaCDpQDXkiOquXGoYU6eVjC57Bf/DVnCjDc4kFGhkwwSy1yQKLHjs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771894522; c=relaxed/simple; bh=KvLeiV0Vjji8SiyrDnRu5DIWGXhZccf7uaKSyEhILb4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aQ9d5MoFUss2QF6+6/9hx1qO+mnVBCyy3inxfA3Idd/LoKbCemez4Q07OfBOM9jRFg/c0KR57mzfc7jJaS3DSt+iUqDg4VWGVBzNWsnU/xqlKbK1dC4XzKaRYZOEk6Fz6xYQcUP1U3OLTHg5p/5LKBQ831dMNbFWfabqRi1UwRk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jmattson.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=k+kQ3/lq; arc=none smtp.client-ip=209.85.216.74 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--jmattson.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="k+kQ3/lq" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-354c0234c1fso4536663a91.2 for ; Mon, 23 Feb 2026 16:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771894519; x=1772499319; 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=bUKIiVYJTDw1mDZ4aEBlsw/+AO2q4TbZR44wBl/k5uE=; b=k+kQ3/lqZA6XjICx5lIKP6ZpehY9zGIj2KM4h9jUPkyDo9ClwPc876tL9OL/3nuogA Iy5VebPGyl8Nor/oRlpfi/kkfUBxBFAi7Gb9NomB0oG+dqpJm/C31/dVwrI2e1T1z8C0 YbSNAjywOsecqiGOxFjeLVPebZZNlwD45Z+tFVuBkVIAa6vF6SvgQemMbHHYTu4DhcCg awOnfvKci+W1ldsk/opbRQ6pnjnBZY5HB262LtllkVrzLk8bwPRD3WdSL//F1YN+sCP3 /nQpHe17wFKHjNerFvHAGgPaegLaytHfJXzTIqp+SU97E06JUivzDIUzON03unHKRquZ dRZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771894519; x=1772499319; 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=bUKIiVYJTDw1mDZ4aEBlsw/+AO2q4TbZR44wBl/k5uE=; b=RcbtiV/EAkgdJC6MitaZUWrnygHXiohGY8HzcL1ZmNqfhWY4n0e55EoIAOgurj2gjN M7RQprjbjsM9DCD1n2YpaH1klVuL6XyhZZ0dTJ+t2AH+G4TCqEl1FpnUTQ54iG9ls1c6 TzwWaBNExQ1hr3Ae+/x7N7Jg/hhqFD7Y8uoHw62ZAs1v96x1KLRAqYC3jIBB9Lbmyk4m 8unAXsWLh07rzoSpxtEEEsIwRH7ALQ9P2wup8gmyJ8imCELqikoB//c1jaB31x72Nn7s G689juSCZTwWoMlCSjv/RE8C4BSkpBR4CBoITTprt9GDwzeMCp6ryDkv/Dypk5pxxjkN 1VrQ== X-Forwarded-Encrypted: i=1; AJvYcCXvuESv2MQDzfte6WrHq9s+Be3xwacgMtHq5tb24J0WfG0evgZL4jN0/MP444/mKGg9mbk=@vger.kernel.org X-Gm-Message-State: AOJu0YzTmYwsY9RYVEJstpk2d93xPeXpehtUSCKlxqPNpFNRMhXKjs7L 6iv/aPzRK/iwh5GEF5cM54haoIK+S+ycXxJwZi/e63FRAvQVQL4dAUvShQtehTgJz/Q0LuQlXvf kWF+c03l9yrHgLQ== X-Received: from pjbmu3.prod.google.com ([2002:a17:90b:3883:b0:34c:34ab:8fd9]) (user=jmattson job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5864:b0:34c:635f:f855 with SMTP id 98e67ed59e1d1-358ae7ceb11mr9530118a91.7.1771894519240; Mon, 23 Feb 2026 16:55:19 -0800 (PST) Date: Mon, 23 Feb 2026 16:54:45 -0800 In-Reply-To: <20260224005500.1471972-1-jmattson@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260224005500.1471972-1-jmattson@google.com> X-Mailer: git-send-email 2.53.0.371.g1d285c8824-goog Message-ID: <20260224005500.1471972-8-jmattson@google.com> Subject: [PATCH v5 07/10] KVM: x86: nSVM: Save gPAT to vmcb12.g_pat on VMEXIT From: Jim Mattson To: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Yosry Ahmed Cc: Jim Mattson , Yosry Ahmed Content-Type: text/plain; charset="UTF-8" According to the APM volume 3 pseudo-code for "VMRUN," when nested paging is enabled in the vmcb, the guest PAT register (gPAT) is saved to the vmcb on emulated VMEXIT. When nested NPT is enabled, save the vmcb02 g_pat field to the vmcb12 g_pat field on emulated VMEXIT. Fixes: 15038e147247 ("KVM: SVM: obey guest PAT") Signed-off-by: Jim Mattson Reviewed-by: Yosry Ahmed --- arch/x86/kvm/svm/nested.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 69b577a4915c..26f758e294ab 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1312,6 +1312,9 @@ void nested_svm_vmexit(struct vcpu_svm *svm) vmcb12->save.dr6 = svm->vcpu.arch.dr6; vmcb12->save.cpl = vmcb02->save.cpl; + if (nested_npt_enabled(svm)) + vmcb12->save.g_pat = vmcb02->save.g_pat; + if (guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK)) { vmcb12->save.s_cet = vmcb02->save.s_cet; vmcb12->save.isst_addr = vmcb02->save.isst_addr; -- 2.53.0.371.g1d285c8824-goog