Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp36011lqt; Wed, 5 Jun 2024 16:20:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUAcDDq3rAA7eIh8SQoVHfjxd44OqKmfyFWItbIQo+UnmxvjuaTwplDxAGdU7hhmQyZPCvUIwueZ1sIs5cz3aASpo1nXiPyA91FUVMwHg== X-Google-Smtp-Source: AGHT+IG97QjRW9OoSbFPvQ1Wb9YMdtR+gy1SUh3FO76bin7GU+yZgBpAZWq9inVc2CJ9v9L0LsRj X-Received: by 2002:a05:6214:8e2:b0:6b0:41b3:c9a3 with SMTP id 6a1803df08f44-6b041b3c9ccmr27739076d6.19.1717629624621; Wed, 05 Jun 2024 16:20:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717629624; cv=pass; d=google.com; s=arc-20160816; b=XK8/Wh+RAhb94GtDgSXRW/FYoWEIWR98yBKNWyJaKF29N+tjDEQ12dwopV/MZRBljb 5z1ccMgDxalpKWucFw1/rqJ8QYu47V94SVXVhXVQou2YD5WI1nBiaWvHNHgBjDAtdyQN omStAqKUpA2iod91Hm931HUItFK1lCFhzY/Wl7BxyHIcyZupkDex2f9E/JVZ32YlkYdd VqbcGlxi1nrmv/tJngi8gi6DywBJSzozaUZiNMcfNjyX3K+angAU9HnyGzgzTkrQ5GUy K80ierCF3RCzSzEgYgVKGkq3AVSWPOUXWU1W5D58LcUZf8TslKjFR7IZMm/vsdSaQkUj SdMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=JbnJv6vDpUrRyVZhMkImU0pEXY4NZDKxZhfl/r6eM3A=; fh=d96ppYB8SsPLuH840kRFC0enwv1ssUoG6fdO1ztsAHE=; b=miGuTn5KZVhj3KKZWQhTuikoSsNZdSXhZsHr1rqVUJ777MLTAwT2IcxSMlkIiBlaCY EVVfn5KHzAuT3MpBA6YLP/2Q2YtzqjfU0dkgM775DPsTpxb2d4ArOnUXhXSYTXHnhWOd LVYUtF+/0YVstgP5R3x44ckWDq7nAIiK1T6IkgT9b1t2nwhbEuj8WNxFWhYBZ9O2tYG5 0uxCAjWK1HHGQgNuYsf67VjYn2UH0pfQ6b2EQxJmkofPxJcIimW4/jKLhlMBwBYVlRwU to/Hd1UEGYFpXyZtYjSqTeyWl5AMCWeD8geFuzn3YborQz/1DGiKyZpVBBvo7Kfmi8TD uHJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=phFCmQi0; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-203395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203395-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b04fa3a6ebsi1425846d6.517.2024.06.05.16.20.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 16:20:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=phFCmQi0; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-203395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203395-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5B68F1C222B4 for ; Wed, 5 Jun 2024 23:20:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0303716C86C; Wed, 5 Jun 2024 23:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="phFCmQi0" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 C71A916A383 for ; Wed, 5 Jun 2024 23:19:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717629570; cv=none; b=QgGWLFNxhhKxZchqWZZtgOD/vc+jFNXlFY2wmvlQtlDEBpDPgqj45QsM4M3L3lODHqLuQ/PLCsssgSpOtvvMbwtt37g/lsfDfFIQF77Xk91nWHcJItTES8SYM2X5GBT7ZqddNaSyJo8POu91g9R7XrSs+5pdl2TIaNMgb+H5eoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717629570; c=relaxed/simple; bh=vtWhHR8rCipCyVzNAFOmF7RFYT1AytVFYLp9pofdaVo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Xx3PKUliKCFB4ZQh1f+5GrKL1je+YAZm+/dIECCrgPi9AncbdPLtEEJSLDl54BvHTKpZole9yu7N4iu+OuAQtDptKkIhbjeKH72MUQ9ANo32cL4fKIJHiQgxR7hk+0yFnYXi3NsrMVEefXqgSSyQyW89TJ48k80wD9NYrT3cP5k= 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=phFCmQi0; arc=none smtp.client-ip=209.85.128.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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-629fe12b380so4991737b3.1 for ; Wed, 05 Jun 2024 16:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717629568; x=1718234368; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=JbnJv6vDpUrRyVZhMkImU0pEXY4NZDKxZhfl/r6eM3A=; b=phFCmQi0I2fG8dYIxhSk0AHuYzfInmJ7fL0WE6PpVzInR8vPnRggesC1fbk2YnOEKx yGDorjR4+5LZn54eeXMqwTTzazXMCj55T1RScmcGSG+cJVFPHL+5eLMoOJMs7WgoLAV6 P+Uqp2ejQpu6yIzuQJcOgQH0ilj61FiNBSIkyw3zBJ1HSfVF9HU7fFesVjFjSwOOFOzV EbXv3okpj3yuct4C+fiQRIkDfYkwiuDi8NFl6y6dWghVnHK5d2aRSoUiX8fBaNICp2IN JnQq3fABiLI882wlWACKY3tOvC6GIQ7h+aI344P5a02nTLY7jzGAvAHkch6HuYgrX4kW 5GZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717629568; x=1718234368; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JbnJv6vDpUrRyVZhMkImU0pEXY4NZDKxZhfl/r6eM3A=; b=RhGwMphKPPwkt9xE3ActP/Ui/t0YlOfL7C3pkPV1e1+1ScQe2oAnCBfcMh80N34j0S tJS3RmTg6KZGtQzc7FpnvZMcxD+kOPCEhCJTIx5qKO9DczPZp7/yQZkZMY0xpSiOz2/K RfkJh2qSbg7Zt+Ny+FTyNNDZUhWqdFJf1w0L8rMloslBz7WIqEHnLm4zBGM+iZsqhqFZ LhsMc5QYlEBou/1nMgWJGfraxomHll2TtgkERBx2pflBrojAuQy27v1YN+SFFTJqHinD zQoRI3tU98ATApf++0XMaEQc2lyjP9UE4CPnKvN85bB8b2me2/nZ6u/30pVdK1OonwuZ zd3w== X-Gm-Message-State: AOJu0YzfTjzAJZvwtncFQyBXJidiqRmvz2VywdLnnYy+rr0aUV1dSxl4 37JZRSFX0hvX2/SaMvk/LlIyQ8HWqrIJSOOukzh9n2l17FjxPQuNhtihV2bw6o/GA9YHpktgXYg tMA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:10:b0:627:a671:8805 with SMTP id 00721157ae682-62cbb4d8986mr12338967b3.3.1717629567792; Wed, 05 Jun 2024 16:19:27 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 5 Jun 2024 16:19:11 -0700 In-Reply-To: <20240605231918.2915961-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240605231918.2915961-1-seanjc@google.com> X-Mailer: git-send-email 2.45.1.467.gbab1589fc0-goog Message-ID: <20240605231918.2915961-4-seanjc@google.com> Subject: [PATCH v8 03/10] KVM: x86: Stuff vCPU's PAT with default value at RESET, not creation From: Sean Christopherson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Sean Christopherson , Paolo Bonzini , Andy Lutomirski , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Xiaoyao Li , Kai Huang , Jim Mattson , Shan Kang , Xin Li , Zhao Liu Content-Type: text/plain; charset="UTF-8" Move the stuffing of the vCPU's PAT to the architectural "default" value from kvm_arch_vcpu_create() to kvm_vcpu_reset(), guarded by !init_event, to better capture that the default value is the value "Following Power-up or Reset". E.g. setting PAT only during creation would break if KVM were to expose a RESET ioctl() to userspace (which is unlikely, but that's not a good reason to have unintuitive code). No functional change. Reviewed-by: Xiaoyao Li Reviewed-by: Kai Huang Reviewed-by: Jim Mattson Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4157602c964e..887d29db0e05 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -12226,8 +12226,6 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu); vcpu->arch.reserved_gpa_bits = kvm_vcpu_reserved_gpa_bits_raw(vcpu); - vcpu->arch.pat = MSR_IA32_CR_PAT_DEFAULT; - kvm_async_pf_hash_reset(vcpu); vcpu->arch.perf_capabilities = kvm_caps.supported_perf_cap; @@ -12393,6 +12391,8 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) if (!init_event) { vcpu->arch.smbase = 0x30000; + vcpu->arch.pat = MSR_IA32_CR_PAT_DEFAULT; + vcpu->arch.msr_misc_features_enables = 0; vcpu->arch.ia32_misc_enable_msr = MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL | MSR_IA32_MISC_ENABLE_BTS_UNAVAIL; -- 2.45.1.467.gbab1589fc0-goog