From nobody Mon Feb 9 04:14:41 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 64BB53BC4C9 for ; Thu, 15 Jan 2026 17:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498473; cv=none; b=mlAcX+w6woi9kxzi19K0L4BRtsZc7tfExneqYoLVrqM4RrwkoU7VuGOsQNJZpnm5FipAl697F8HbpGlnJz0j6OOpKUCgISXqpJHCf3BPYXOq93zZErMTWUQD0Pxemcpdr/FZRIV1+fHvVDd3xI/ASElTXdqGTNC4Hyqr5M7lpbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498473; c=relaxed/simple; bh=lfQFiFquXqqUjK0GK5LCQjQGJHjS+fT5W9fknUTJy3E=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DEmKS5gOImd9Zeazvvwp6hgaCpTuDtTl6fmmS6gGN85fScGxbOG3T+Lr8NQheYu+SDkcI+25EgHetDtIWtLwC6XdtBEt+jMj1ExSdXRO+j2yU6ekNbfFksoYRvx2flMx5NLTpKktZqZZFaYOZs6PECE9eC2n60iise0bshSlCq8= 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=JXUOsJZ7; arc=none smtp.client-ip=209.85.214.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="JXUOsJZ7" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2a0fe4ade9eso10944605ad.0 for ; Thu, 15 Jan 2026 09:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768498472; x=1769103272; 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=vvhxNkHgD+GbG8VVPHPONdN8yxtGJ2U9E5Vry3vEwiU=; b=JXUOsJZ7ngjzn/UB7Q319pZzux8w4KoDVJL9Igx0jSt1b6QcfUmLEhw3uH81xEkjSz BB775Jt4fjyrXgKn7BKDZzI/xwSufXnqnOOB0rslx//YhuzpMBABz/tHx7/VbT8UoXM8 lofWxZmO2jsv+E8+nXLhsUtjhWm20YF3wGHk4ngFllDupwBnKJsw22GUqtxSyHbngwK3 ez4O0VzBWv8z4PL237Le5p8RWdF43qHe/okUwAxFn9pmKHRyfJh4LRyrOPLwPlmXg4mB a4lT2EZxZt4tGMJojiXZQM34c8xbo+KT6Asznap6mVjtTBrAZNUgOHDqrotzHI9zVNaR vY4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768498472; x=1769103272; 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=vvhxNkHgD+GbG8VVPHPONdN8yxtGJ2U9E5Vry3vEwiU=; b=e5KbpaNyisDeUWYZONMlz712NOckK1uAETaxJD/4VxXF9VxPH3c6asdWCr7SywiXo1 3m3x1BVGxeXzzhYp2daayzJdNQo88yjkdQyCeh2luZ4mR1sh8+M+j1ukZUTJUFF0gRuK Zoce37gfcErihgoyqKWwD8vrShyfJjuTMfmCXzZWS8vkADMTlFCLUb8Rlhe2IfLLJHKf d1T/ONPMpArQKWJksmpuoO4FilpOwc6sCopxyQuF5EZJ+oduu++1sRO954NOviV4zkzd 30+gB3UxgGS4VpoRDRKwGrzxZaCC/JmvaS10h+/t+f/ROo3uQKr6nhlBxt4JBNrx2+Jw Wukw== X-Forwarded-Encrypted: i=1; AJvYcCXeLaJ1nKDa7j4LmDqUFAquuca8yXofLakTitmI0uGEW1pIfDVjiJ9G8X2pnxnpj53a7YTTeFF2dYjd65w=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2S7xj1dRZ54LkR3dgCMfRF3031xjH7/qU6QSFOntbO8V8jAa8 zOFViajQNuDq3+jrKLF/YzG7Y+K0mPxmPvZAdbUmCkRL6U8lFhwP0zP/fjJ3dCkepHq7Aj4lmWi aWoEieA== X-Received: from plwh22.prod.google.com ([2002:a17:902:f7d6:b0:2a1:5f23:7ddd]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:40cc:b0:2a1:388d:8ef3 with SMTP id d9443c01a7336-2a71754385emr3351055ad.18.1768498471672; Thu, 15 Jan 2026 09:34:31 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 15 Jan 2026 09:34:24 -0800 In-Reply-To: <20260115173427.716021-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: <20260115173427.716021-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260115173427.716021-2-seanjc@google.com> Subject: [PATCH v4 1/4] KVM: nVMX: Setup VMX MSRs on loading CPU during nested_vmx_hardware_setup() From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Chao Gao , Xin Li , Yosry Ahmed Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move the call to nested_vmx_setup_ctls_msrs() from vmx_hardware_setup() to nested_vmx_hardware_setup() so that the nested code can deal with ordering dependencies without having to straddle vmx_hardware_setup() and nested_vmx_hardware_setup(). Specifically, an upcoming change will sanitize the vmcs12 fields based on hardware support, and that code needs to run _before_ the MSRs are configured, because the lovely vmcs_enum MSR depends on the max support vmcs12 field. No functional change intended. Reviewed-by: Xiaoyao Li Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 2 ++ arch/x86/kvm/vmx/vmx.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 66a3eaca6817..76b08ea7c109 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -7367,6 +7367,8 @@ __init int nested_vmx_hardware_setup(int (*exit_handl= ers[])(struct kvm_vcpu *)) { int i; =20 + nested_vmx_setup_ctls_msrs(&vmcs_config, vmx_capability.ept); + if (!cpu_has_vmx_shadow_vmcs()) enable_shadow_vmcs =3D 0; if (enable_shadow_vmcs) { diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 9e6c78a22b10..27acafd03381 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -8846,8 +8846,6 @@ __init int vmx_hardware_setup(void) * can hide/show features based on kvm_cpu_cap_has(). */ if (nested) { - nested_vmx_setup_ctls_msrs(&vmcs_config, vmx_capability.ept); - r =3D nested_vmx_hardware_setup(kvm_vmx_exit_handlers); if (r) return r; --=20 2.52.0.457.g6b5491de43-goog