From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.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 0B9673542D1 for ; Tue, 7 Apr 2026 19:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775589875; cv=none; b=TU5bsTV7ilZfhj254bePLhHV3pRYtKoXvmUs6TTt2dORIP3/zcZ9rV7jGaP1Z+VEmwU2erAP3aoRVBdKT73gl+qHSsyjuryILFwrNxyokt7lFfAdakVQkGr6SO1TeRxBqlKCQ1rlF863vAiB/IFZQeaKazpYaXApCd1UNV1vEc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775589875; c=relaxed/simple; bh=dE58CN+5pXsLJfZ7un3dRhyZAs4NnQnCZRafu7/oZ+A=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OAIO7odJRwdYTz8YN3bENFIHTOAs9Kh3k7S/+Uzmin2vrtf84uby9ZGnaUC0melJtsd1tC90bcKS4tnMeMXNHQsL1l/hhOY2BbONDgrPyY9YWFCFz54duspK+Z9GPJy7nF+Jy/D3t92hu6m2EqawIv0cCV+4pEF0EEZoX6Zukn8= 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=u04P3Yjf; arc=none smtp.client-ip=209.85.210.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="u04P3Yjf" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-82cd9fa609aso3334422b3a.3 for ; Tue, 07 Apr 2026 12:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775589873; x=1776194673; 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=7wtvvz53Lt7PgkZRoHfUIRVyXND3bHhDv8n3Lk1Ll8Q=; b=u04P3Yjf8H1IW9ka1QTHanRsghO0/EckAAmNRH1/lTjmLXL7HRhSoX4Tge3KKqdoKH LhEX5Mj2XvqDs9oiH7jMb3RmRojpN8clCPOFanXhKsSj/72iFC9SUSmqiqZ3LY8us0I8 8OPEt+2nxQ8WuDy2Ac8EHCIoKt4lIx2gNZuguJRFr1WkxGW8zftUmAQFZXI02jNIp6hr 41hVR9hVS9HAhii0MZmi4E8gToEVLovSEcY8dkoi4egwLgFyx2Jy30AKxQPIa9lP/9iP I8j/KIV0/J1rT9SV5HaLrclMbJLBOW4NYqZnCoJJfH+l8RHE9+R+HoGlpiT4A8tUpgu9 jXhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775589873; x=1776194673; 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=7wtvvz53Lt7PgkZRoHfUIRVyXND3bHhDv8n3Lk1Ll8Q=; b=qYo0N9Dc5GhozxYfbuSxYWT+7uWNI4kdjyCH3dDuQnFNCb1xzcFiQe8bbcxs9A3WxD yf/0pHcRjNEqkJ29jGevCNawLfXS75DKfTUfjgQNTxt1dN8jzICjhOYfgMO2Y7g3caGA X+MTUHsvqqbg015Gr5srDE0rUqImLS0atqkpT4hCVr0eJC3Sp5P5rRu9Dl+t8KPd9Tua aBqD8NfHWGZp7zaYq9/AwVJmDycpE/Uh1MmwamWiwA6Om7l3hXxDtFCLnZEy6FnDGVIW nNK423nzYdKS4Z9fOQdvyQrEtnmEPdhtD0zGKuRVkd00BMOS+JsuUxXK/mghz73Yp4vw /ygw== X-Forwarded-Encrypted: i=1; AJvYcCXvJJbDNtBsR7FSMB8pg7WzySvJmWbUmsgMkBHCH6isixnXOrX925KNLciJx0QjOzHGE0r81tzsWMT+IoI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0Whyvpq1g3FQp9S8WbMIVo0XvK/NyfF/6UPBXYX0NwYhS9U9C woqGNOK45GrrQQk/3BzfUmx7VcPHTrmKeuA2fX5FqJ4zIIRqqLEanfF+evXFG5PCcsOCvVaZ7gO l8nl/7Q== X-Received: from pfqf9.prod.google.com ([2002:aa7:9d89:0:b0:82c:ed07:26b]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:aa7:88cd:0:b0:827:2ee0:411f with SMTP id d2e1a72fcca58-82d0da46a75mr16920069b3a.4.1775589873116; Tue, 07 Apr 2026 12:24:33 -0700 (PDT) Date: Tue, 7 Apr 2026 12:24:31 -0700 In-Reply-To: <20260407190343.325299-6-jmattson@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260407190343.325299-1-jmattson@google.com> <20260407190343.325299-6-jmattson@google.com> Message-ID: Subject: Re: [PATCH] KVM: x86: nSVM: Redirect IA32_PAT accesses to either hPAT or gPAT From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , Jonathan Corbet , Shuah Khan , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Type: text/plain; charset="us-ascii" On Tue, Apr 07, 2026, Jim Mattson wrote: > When KVM_X86_QUIRK_NESTED_SVM_SHARED_PAT is disabled and the vCPU is in > guest mode with nested NPT enabled, guest accesses to IA32_PAT are > redirected to the gPAT register, which is stored in VMCB02's g_pat field. > > Non-guest accesses (e.g. from userspace) to IA32_PAT are always redirected > to hPAT, which is stored in vcpu->arch.pat. > > Directing host-initiated accesses to hPAT ensures that KVM_GET/SET_MSRS and > KVM_GET/SET_NESTED_STATE are independent of each other and can be ordered > arbitrarily during save and restore. gPAT is saved and restored separately > via KVM_GET/SET_NESTED_STATE. > > Use WARN_ON_ONCE to flag any host-initiated accesses originating from KVM > itself rather than userspace. > > Use pr_warn_once to flag any use of the common MSR-handling code (now > shared by VMX and TDX) for IA32_PAT by a vCPU that is SVM-capable. Changelog is stale, but otherwise this LGTM. I'll fixup the changelog when applying (in a few weeks).