From patchwork Wed Jun 5 23:19:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13687653 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 B90A716938D for ; Wed, 5 Jun 2024 23:19:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717629570; cv=none; b=eIupASkCIeTShwyXnC6kwUEIt+D6J1ablSu3/CPg8ytZnbKgw7PfNNp+QBf6JrpMwjtHh9Wz1x9ldGoCUG26b31c+5MSQNr1qTeHPsqxojr5rz3ymSFXayTXcRMMyTbdtYlDu6H2mwnTRG8/6CT/3spLlx6v0LVLAiSqOJTOTX0= 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.201 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="phFCmQi0" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-62c823393a4so3790227b3.2 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=ANLBUfAwlxJ0MzxTJ3vTT1InO5nWblk3B2HJEnA+hsEpnYs5OGoDGRt2ACD2cBtav1 Iz87t4h0JkCvseGf5c4h+dKL/PyubvsfO8rnAghj1myvAFAbYZBZ8CLZY4H/CQXu6YA4 dU+GJkJSfdIgm0ncol4vAH2zC6MVBu/xzecnD8rqfARHMFcBKFh92IS8wSVvQFL/1Hak GuL2lxjLVhbgGwpS2BSlZtOmKlZmE63ZrETTgvLjWR7CxP1eXti9jly1s4Qhs20kjpHl Sd0dg9Rjjhkcp6IF8yCKFkuwiLm6jwAKmZ6IfrFeWa/7AwZ6/w5rjUUkIb7fmGxTMJvb OfcQ== X-Forwarded-Encrypted: i=1; AJvYcCWqA/01a3kkAimGt4eiR7MVCGZv4UkUHUrHU6yOpISugZRsARSKkaPonISJzGarXafUPpk86POtlKAX7GeBPuyCdYKK X-Gm-Message-State: AOJu0YyTCKgkjR/jLwnDuTL7oMcJTr3aLcPcq9Sh1ZMP50Sagis1nC/0 cq4bjGqwGj2opkTTieu33ItH3z9ONAcKqgyj+Z+et3ygiQEAcWEPdec6ryCh/cj0BmCdAbHcsPn qPA== X-Google-Smtp-Source: AGHT+IGT3X5M7VkVP46RRq6pl4m8P42cLEg9GfqDkINN+MTO1zovJ38lv62i90wYIsCXK1EryfZOAVoe7p4= 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: kvm@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 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;