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 B6BF31D6187 for ; Thu, 29 Jan 2026 15:03:05 +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=1769698986; cv=none; b=Z+JoYN2vQnyw6p5wGQHwilF4MvmWVxVOt7ET9ePpclGZZIn8VGmusn513Afc3wrktQKodM7uf4NE9EiNwJcpifZ6l/5WeS4aTCsQUgm5ysl2FovkuNtY24MJeF81CpDzw5UX36LtOHS4PgXKljQJ+H0eYyscBbxIx0rmSPVsJkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769698986; c=relaxed/simple; bh=RLrR5vZu1hse1rtaEo4YuhDR0aPp1tqT50orJU6D6JA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NKn8CZ9CY/Z6RVMUg4EggDoQP4OLVe4zVUbkztOnETn/AH0Yg+XmQVfGr0V/bypRI1JAqcZJyw3pX/MQpLiIbrzQXK/tyeh6RWkO2WLqkUMpC2SfiA9Ut+tqf8UDc4oM4h2J7CG9iztDvD1n8WvNvniCB5r/Qyd3i3WFdz1HXV8= 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=IWzT3OeV; 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="IWzT3OeV" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b630b4d8d52so703536a12.3 for ; Thu, 29 Jan 2026 07:03:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769698985; x=1770303785; 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=+5vZNLrr7nRtWhRyWO6FkaZdOZiRAk95CNQQuZ+PLjs=; b=IWzT3OeVUkg/V6EzmGU4h2We07X2gXQYEGHFfCzOsvgMKTF0dPkZV8hPMBNsv9ad9j qITp1hoD+pfBWzBGPlNBioPBvkdujkA4QZ1335L3ja7lsejsrBWSXdLDpWD/QJ8i1F0V gJwYpovQcER/TUs6TL0rnfo1RXLqUhsTm3QbiwVw29uTa27ezpBJF5yJkxxcR6RoaIdv O42ZkULFyrMof4XSEPECXnMRboFR4yAy8Y/Z1pk5z2VZV49MxPO9z4xSJm/wQSicrxp8 MS1Z4hL3M1I46uvdj48RWd/hCX80yjNf4slOQBqBN3H7ryJHeElmqfE4oJn6Jxckz4Kr wAIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769698985; x=1770303785; 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=+5vZNLrr7nRtWhRyWO6FkaZdOZiRAk95CNQQuZ+PLjs=; b=oaqI0Xj1KzWmqpBVNQqnfqkmthvn9tASBOeoQLtF16us47z/xURdfuJ04V/sUHNqml pg+9vLrTf8MkDCSqWH62mtk14JzFc6tyLtHYHL7rL01FCphZxOWgx1eNm7mhhReBYFxE QbEnNLtAWRCg+SJg7DfH+fTHVxyJVert0L2KT4gek4roMnpRp5Yr5PSHkIS/tuxP5VUy A/BCJg3Jg6uWZjvcFaJVQsyzEHDt35C3DzwxIHX5oizmivyyngFAueszZQdK09x8xVJp QWOtzO3ni/aqmOZF3L4xIbAyInOqBKR9I7yh0Dev/xTghFv7p31x9yhrWAd7+4Dl7t53 p2Xg== X-Forwarded-Encrypted: i=1; AJvYcCUFLFZI7oME3xZUTakpCVvW9eXvIsSCp2VM+HsG1qQsh0bFd2R4VpmYEl3MUeT6QDht4BVcELFoK2cBXDA=@vger.kernel.org X-Gm-Message-State: AOJu0YySviemC7TZyaMbc2pTk/NSYAmdRUXgohPoHgwa+/RvKkAZqz1d /9ow2oB5VfVIC2NjEu93tN8jp6NkxuZb98/hEacfxOu0M7FCMdXaaB8leCJdtn5dwyDPS6/MI99 GFDJaAg== X-Received: from pgac22.prod.google.com ([2002:a05:6a02:2956:b0:c61:380f:996e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:398e:b0:366:14b0:4b10 with SMTP id adf61e73a8af0-38ec658140amr8781777637.76.1769698984978; Thu, 29 Jan 2026 07:03:04 -0800 (PST) Date: Thu, 29 Jan 2026 07:03:03 -0800 In-Reply-To: <0eff82fe-e3e9-43bb-907f-3279163489f0@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260128014310.3255561-1-seanjc@google.com> <20260128014310.3255561-2-seanjc@google.com> <0eff82fe-e3e9-43bb-907f-3279163489f0@intel.com> Message-ID: Subject: Re: [PATCH v2 1/3] KVM: x86: Explicitly configure supported XSS from {svm,vmx}_set_cpu_caps() From: Sean Christopherson To: Xiaoyao Li Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Mathias Krause , John Allen , Rick Edgecombe , Chao Gao , Binbin Wu , Jim Mattson Content-Type: text/plain; charset="us-ascii" On Thu, Jan 29, 2026, Xiaoyao Li wrote: > On 1/28/2026 9:43 AM, Sean Christopherson wrote: > > Explicitly configure KVM's supported XSS as part of each vendor's setup > > flow to fix a bug where clearing SHSTK and IBT in kvm_cpu_caps, e.g. due > > to lack of CET XFEATURE support, makes kvm-intel.ko unloadable when nested > > VMX is enabled, i.e. when nested=1. The late clearing results in > > nested_vmx_setup_{entry,exit}_ctls() clearing VM_{ENTRY,EXIT}_LOAD_CET_STATE > > when nested_vmx_setup_ctls_msrs() runs during the CPU compatibility checks, > > ultimately leading to a mismatched VMCS config due to the reference config > > having the CET bits set, but every CPU's "local" config having the bits > > cleared. > > > > Note, kvm_caps.supported_{xcr0,xss} are unconditionally initialized by > > kvm_x86_vendor_init(), before calling into vendor code, and not referenced > > between ops->hardware_setup() and their current/old location. > > I'm thinking whether to move the initialization of supported_xss from > kvm_x86_vendor_init() to kvm_setup_xss_caps(). Anyway it can be a separate > patch, if we agree to make the change. Hmm, I definitely don't want to do that, because then we'll end up with asymmetric initialization of kvm_caps.*, and I don't want to move that initialization under {svm,vmx}_set_cpu_caps() because it's pretty much guaranteed to lead to different ordering issues. One idea would be to call the new API kvm_finalize_xss_caps() instead of kvm_setup_xss_caps(), but I'm not sure I like that idea. Or maybe kvm_constrain_xss_caps()? That feels awkward and unintuitive though. All in all, I agree that having a "setup" API rely on prior initialization is a bit wonky, but I don't love any of the alternatives either. :-/