From nobody Sun Apr 5 21:16:31 2026 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 E63A923C8C7 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-35678f99c6eso3411444a91.1 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=CpHMElP41q8a2n7nIpuu5oXRF1xmitLlA1YMcVdRB07DCx6W2d7wxiTi8AUCVs5AX8 ILZkyI3OBHPaHfXPDZoqWc38cC0o/vB92O2p3ZxdMvuJAAOfWyMMqIPoyMcQGUabL2cG C2biz8Vfv7abGNh3xklq5gCdpDHlFtDVxkWnrvnRETR5intwZv+M9Yj31Gq/AAKseTVg 4g7cVw5GfbOVM+R1zrK/irDTMWolFBZdjK64OTukMA1Lhfah7hWYbSiUNXqGbcimD6Ty Pxl33lV8EdYNxEN5sw8dWJQkI6a3bFCLVP6fV3HGg96vgZ6nKNSChKPVfv/OzKfoDj+Y HnuA== X-Forwarded-Encrypted: i=1; AJvYcCWrxJbdTYxcacAMWecM3APlWvihrmpL+odhidOJpKOfrl3a18l4ofq3ooAjmKGAk525O7px+z8q/dOXHlU=@vger.kernel.org X-Gm-Message-State: AOJu0YyxceGkEKEuEOPDwotgSUFWqrbK/3ydci71lAEVZvHeIQ9dyD1h k5atjjOdA8N+22KamIf/SnlctCoFI5PNjjOGZRHE2qhAVg8Iw0DazTrJRVDlxrYGZTLQ8pqGKTG 5Ksg3BDJU9ef6/w== 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: linux-kernel@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-Transfer-Encoding: quoted-printable 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 =3D svm->vcpu.arch.dr6; vmcb12->save.cpl =3D vmcb02->save.cpl; =20 + if (nested_npt_enabled(svm)) + vmcb12->save.g_pat =3D vmcb02->save.g_pat; + if (guest_cpu_cap_has(vcpu, X86_FEATURE_SHSTK)) { vmcb12->save.s_cet =3D vmcb02->save.s_cet; vmcb12->save.isst_addr =3D vmcb02->save.isst_addr; --=20 2.53.0.371.g1d285c8824-goog