From nobody Sun Feb 8 21:47:06 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 B81AC2727E2 for ; Tue, 13 Jan 2026 00:30:42 +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=1768264244; cv=none; b=qELndYubPZHnXqS835U73M+64Lkr5f8ed3JQ9PdVb74La1Bc397Qe8/SHQ8D3Vs7F6idx1us+vEYWPw3tfbvecNUdfqFnKE6lFqI9pN9N6Ots2ABJ7RU4zcwluQIR83gf79yUTHMy42ezRRgD1I4z0Yfi4pNIyUqfR3aTApwjxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768264244; c=relaxed/simple; bh=VkCjLytO1ux9i8uRqJqOp4y4po1Gg2Hc+qogiSAqt9g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=PKSTbw3cWaJTLDNYR8Hz4dqrDA82oSOpTp8NRTsm/3IuQqaWNYSzqQXQrWae+ge0eulyIHLMWpC1/w4r0utISmm8QYxCye5icdxRbCLfG+yUDRtvjTN8HXD+nyODT8xS9oSVoDpqlYd7KRKTPSu4DH+yleeph69Q9QHjFudj/Ls= 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=0B9k/6pi; 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="0B9k/6pi" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-34c387d3eb6so5110645a91.2 for ; Mon, 12 Jan 2026 16:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768264242; x=1768869042; 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=ugtMeXQoG/v0gmSJ0kvlm0/hksPZ0j77UnWX+eyrz3Y=; b=0B9k/6piZusNp3ndTRRDmKtE+u2KbU5pt6QypwX4OMnbw9tPVUx+DC+K8mHhzEB8eV a07re7QBe2l41DgIVGueTX1/WXBUxm+WQpNqxLv1lzU9A9ofUNCNB7APJnHG7IUc+kLu HfWzLPtQC1fLYs4dzKKVNNjxws9WzE3le31Ujj8aPzRcCEiLxpRhDx+EmN0V0PIUbfCz nDPLAAJ0YBHlpL2b++IALna8c1LeBTXqdOML+rOUu0CqdHbV591ZNR7koNOCvHGHz4sf L4sVh4rb98bCahIhoVGaBADZROLrGHci2481TqFfm6/SRsha1jxog8XSSitcdsf1TD89 6Jgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768264242; x=1768869042; 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=ugtMeXQoG/v0gmSJ0kvlm0/hksPZ0j77UnWX+eyrz3Y=; b=Atf0MotXTH5jMvwdlWZYNvZ4nQ2Q7GWSD+uWZoePKQ6AaP5v8tHj+22byVUy1hO2dH UNbtY3Ikwd52NHqAfAJJVVLrBvFv9pyGfKStMO5QJCGwtiZaf8dO/AfHxCPMnVwVmKGf KXLneUelVISHAEBglVV6o+WM3fuBFHwMJ+6erW2TJaMnAtiSbVlRS56vDMJwEWjDYcK4 PrL56PuOZ9lgM1JDKg3IRL7v0RmwCKPsRSd4Bd8aLZf6DlhiFUSGAGjXbDwWPj/g91jy C18lmWFvP8Xl7/ZHb53xj29zgLTUwHNwebYHqhi7oSSkyKGx9rI+6Yu03ZFrOdH58wQ1 PTzQ== X-Forwarded-Encrypted: i=1; AJvYcCX+OJ2RH/Hkj/c4td5m5ajOaJ0+Lo1AeQU835n8kbatn0mCSJ2PvBH7Xj+RWKNwwxuRCxTlbzuCU6MeSt4=@vger.kernel.org X-Gm-Message-State: AOJu0YwBO+8dKzhxh8MMs+sH0QhX206/FASlKOyd4ywg5AC9F/oPKJVr QNyqrIeK0GvFREJO6XGBPB3AI9c5bXtqd6XVIr9xZ4V9z7Z4P29mSaDd1TBnq/raCrpqiJ+Fg9l RE3TtCh2ShzCoxg== X-Google-Smtp-Source: AGHT+IEccbNQ4GcGL8d7NNWxCrtOXIcCLpkLBB9GNgvN+JQUSY8qIxF0CgKlAWtcyBdkdr3anPQUtQ+G072f4Q== X-Received: from pjbfa5.prod.google.com ([2002:a17:90a:f0c5:b0:34c:bdf1:2a21]) (user=jmattson job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2251:b0:33e:30e8:81cb with SMTP id 98e67ed59e1d1-34f68b65ff0mr15680469a91.13.1768264242031; Mon, 12 Jan 2026 16:30:42 -0800 (PST) Date: Mon, 12 Jan 2026 16:29:59 -0800 In-Reply-To: <20260113003016.3511895-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: <20260113003016.3511895-1-jmattson@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260113003016.3511895-5-jmattson@google.com> Subject: [PATCH 04/10] KVM: x86: nSVM: Restore L1's PAT on emulated #VMEXIT from L2 to L1 From: Jim Mattson To: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , Joerg Roedel , Avi Kivity , Alexander Graf , "=?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?=" , David Hildenbrand , Cathy Avery , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Jim Mattson Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" KVM doesn't implement a separate G_PAT register to hold the guest's PAT in guest mode with nested NPT enabled. Consequently, L1's IA32_PAT MSR must be restored on emulated #VMEXIT from L2 to L1. Note: if L2 uses shadow paging, L1 and L2 share the same IA32_PAT MSR. Signed-off-by: Jim Mattson --- arch/x86/kvm/svm/nested.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index c751be470364..9aec836ac04c 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1292,6 +1292,16 @@ int nested_svm_vmexit(struct vcpu_svm *svm) kvm_rsp_write(vcpu, vmcb01->save.rsp); kvm_rip_write(vcpu, vmcb01->save.rip); =20 + /* + * KVM doesn't implement a separate guest PAT + * register. Instead, the guest PAT lives in vcpu->arch.pat + * while in guest mode with nested NPT enabled. Hence, the + * IA32_PAT MSR has to be restored from the vmcb01 g_pat at + * #VMEXIT. + */ + if (nested_npt_enabled(svm)) + vcpu->arch.pat =3D vmcb01->save.g_pat; + svm->vcpu.arch.dr7 =3D DR7_FIXED_1; kvm_update_dr7(&svm->vcpu); =20 --=20 2.52.0.457.g6b5491de43-goog