From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 A7DAB32AAC6 for ; Wed, 14 Jan 2026 21:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768425966; cv=none; b=hfw0yVLPwYm5M6h7MXNHh110qB4ZdpunkJxsdwr6Yng3ySoYDabokyvRdPeX6ETa8yVIgxlQc0xLAjbsGX2heyZxk0Yg0DrHmlW7EegPoIy6FENB+K+suk40JQ0CMB/MLmV4kTADeGV9LMPnsd5LYRT+xJ6Kdmu+FK9kdvzRJWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768425966; c=relaxed/simple; bh=tS2p1VVtTwfSm29+9nvecEVJH3haKiQXRr8i3I2E2Q8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XxDvwGjTG7VYti7SYHAElLGkHSi7VJ77KVrlehn63ByPlSBZgPeN2IZvUmkbeHFaOvI8WnqTrdHrz0cH5JgOWPKsrJpZPMC1IkBVeCH7SmZGWi8TlYr1mlHVFrD0FMb1n8HbGuGVy+T1br3HJQM7RToJNpwbCI8AUy3fld/viNE= 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=J4wPT2eU; arc=none smtp.client-ip=209.85.215.202 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="J4wPT2eU" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c52779e9e65so223886a12.0 for ; Wed, 14 Jan 2026 13:26:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768425964; x=1769030764; 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=CYLcqn8bUj4LB8zfvp84Gv8TOn5CHv63OjVbPqApIWI=; b=J4wPT2eUzTVkwe/tz9phKjg1By6FxEczC9CLVFbdUXsBueo5SqbkQ1zpL05PM2XZp0 69eZpuQoGGEU/ZpLnvjpwQLGLrLnqHpEf4LFwgDtM727gMkc0HbSaGprGHtKz9se4ZYE oe6WlBmPD+RwsgP4M05vMAYaxGGyAuFnAQSfJj3gcseiOF5VpAv5vGQ9mrJ661vZ1LKK 5iwubYNYzwr/7sizX+uaH88EryUmgcs95X7oJqgOUbukQr20o7fnEXOl26ASKs8Pz3mq 35pjloGw8jIgmksKbr+mlygNes6iLEjRmkSDxEtKY8KuRQlQUE71C/r9u9KvmpoI/AQB MErg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768425964; x=1769030764; 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=CYLcqn8bUj4LB8zfvp84Gv8TOn5CHv63OjVbPqApIWI=; b=E5RE1/63ozr065iVMxzG0Zp5CEasXv+jcIyyOt1a8uWV+/jE1HtPEk7VmljoI+LhW6 u0Nzfd7kYFAeODClyNMOQOQKStbvKC02ni/Ukl1/4fmCsIkDd62u7Ch0rUIgx8h6/1xM qrVWtAM0yJ/xczqnEalJB2WrinZpKSUw80Ox5WosurH2ayEAMO5FoAartEIL66Aoihdl HMM4zKNEAkvqRvpxIJHfY136F8Rb6pHI5bd7GoKF0Hax6M6+OLwJCFyScLY762AmiZir 8hZ3Aui7jGqS6aB2vNhB9X9+K/DdPBGzIwF50/F14YSzz7EuQNAJCnml7goWbXXW4hlE uaXA== X-Forwarded-Encrypted: i=1; AJvYcCVtDEO8Hx4snkxAd9yqroCroOvvv/6BJK/mRip1LfL457PYQqc/a+OfrmYTru8Dk9ylxFx8TjrMSAz4U68=@vger.kernel.org X-Gm-Message-State: AOJu0YwJQCar0sTSFm9fCk1mqcLxYh3fIuNSuYLpUoW6IGdVIPf4ZCYD f7ewOckN6PcekFrWOYUYhyGxqi6EwGALUF3iRKgq20YCpM7zJySok5RwwUobJ/BlZzLlkjDppKU bsr3HuQ== X-Received: from pgdj16.prod.google.com ([2002:a05:6a02:5210:b0:b55:70c6:bece]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:9145:b0:376:2a3e:e758 with SMTP id adf61e73a8af0-38befaad7d0mr3819410637.28.1768425963761; Wed, 14 Jan 2026 13:26:03 -0800 (PST) Date: Wed, 14 Jan 2026 13:26:02 -0800 In-Reply-To: <20260113003016.3511895-5-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> <20260113003016.3511895-5-jmattson@google.com> Message-ID: Subject: Re: [PATCH 04/10] KVM: x86: nSVM: Restore L1's PAT on emulated #VMEXIT from L2 to L1 From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , Joerg Roedel , Avi Kivity , Alexander Graf , "Radim =?utf-8?B?S3LEjW3DocWZ?=" , David Hildenbrand , Cathy Avery , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Mon, Jan 12, 2026, Jim Mattson wrote: > 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); > > + /* > + * 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. Wrap closer to 80 chars. > + */ > + if (nested_npt_enabled(svm)) > + vcpu->arch.pat = vmcb01->save.g_pat; > + > svm->vcpu.arch.dr7 = DR7_FIXED_1; > kvm_update_dr7(&svm->vcpu); > > -- > 2.52.0.457.g6b5491de43-goog >