From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 3DA42318B92 for ; Mon, 9 Feb 2026 11:40:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770637206; cv=none; b=LnajLBqYfufw3h4HeBnPMhfe9D9WozwzTDApElS3WFoxndbJi8T5stB83pyyiUt+PIm+vCpIxea9nHP/S/FhJG7JaBMb9UpjsGbxvVETU+M6S/Dsau2gxfxwR4FhrLlNc+VnN5XcaE9RH/d6PmdT3wawnNZK8YwELKnIchtib/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770637206; c=relaxed/simple; bh=aYjEeCkMZHiuC5R4skkZ7Q04duQgzS9O7uRFGOAxUnE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VilKSHqy48x1JUzK+SH70u6A6870JtuZoAGmJMbeIQMworSXTy4Rmxv6S1N+f2uA9kTJUssvIcTADCJo00ABWyOmdnoPMAFgYVtvqLY37RFBFPrD8xdsxHT+z4Ift9edmvezhMkqRCHZMGXyQaqkgQ7W6jpOzO2ZMEqH/8sjAKo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=oV99INbT; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=OVqaJ/bI; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=oV99INbT; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=OVqaJ/bI; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="oV99INbT"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="OVqaJ/bI"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="oV99INbT"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="OVqaJ/bI" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5A6A15BD2B; Mon, 9 Feb 2026 11:40:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770637204; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFvENNphJJ02ND6rKpiGDYtX6p1T1DdwkEQYwe3cuOA=; b=oV99INbTOGLH52qRELpVbDI1t/HeVhWE7JKpyv8MlkdGbttpdwgBw5T5sbfos3mawHZXze S+UvYIIkLjABHJYqW0842UZQCIkJe7kpPn99rVKKTgrme6nZ2E8Uo8VRXkbjKi7U+ObolY vRjcQpZvIdQ8tqwa16VYvuIEbhdEUe4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770637204; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFvENNphJJ02ND6rKpiGDYtX6p1T1DdwkEQYwe3cuOA=; b=OVqaJ/bI+/WqS6BLF0rjwqVrci4G1NhU/woDtLBDQMXQ4JpDXCe+frnfu3a78VjT/pZbKJ G256pzszEWMRVhCw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=oV99INbT; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="OVqaJ/bI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1770637204; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFvENNphJJ02ND6rKpiGDYtX6p1T1DdwkEQYwe3cuOA=; b=oV99INbTOGLH52qRELpVbDI1t/HeVhWE7JKpyv8MlkdGbttpdwgBw5T5sbfos3mawHZXze S+UvYIIkLjABHJYqW0842UZQCIkJe7kpPn99rVKKTgrme6nZ2E8Uo8VRXkbjKi7U+ObolY vRjcQpZvIdQ8tqwa16VYvuIEbhdEUe4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1770637204; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFvENNphJJ02ND6rKpiGDYtX6p1T1DdwkEQYwe3cuOA=; b=OVqaJ/bI+/WqS6BLF0rjwqVrci4G1NhU/woDtLBDQMXQ4JpDXCe+frnfu3a78VjT/pZbKJ G256pzszEWMRVhCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AF7123EA63; Mon, 9 Feb 2026 11:40:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id glItKJPHiWnSEgAAD6G6ig (envelope-from ); Mon, 09 Feb 2026 11:40:03 +0000 Message-ID: Date: Mon, 9 Feb 2026 12:40:03 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] KVM: x86: synthesize TSA CPUID bits via SCATTERED_F() To: Jim Mattson , Borislav Petkov Cc: seanjc@google.com, kvm@vger.kernel.org, Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Babu Moger References: <20260208164233.30405-1-clopez@suse.de> <20260208182849.GAaYjV4Vh8i0kznTEK@fat_crate.local> <20260208211342.GBaYj8hhtYM-lYfq-X@fat_crate.local> From: =?UTF-8?Q?Carlos_L=C3=B3pez?= Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim,suse.de:mid]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Flag: NO X-Spam-Score: -4.51 X-Rspamd-Queue-Id: 5A6A15BD2B X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Level: Hi, On 2/9/26 6:48 AM, Jim Mattson wrote: > On Sun, Feb 8, 2026 at 1:14 PM Borislav Petkov wrote: >> >> On Sun, Feb 08, 2026 at 12:50:18PM -0800, Jim Mattson wrote: >>>> /* >>>> * Synthesized Feature - For features that are synthesized into boot_cpu_data, >>>> * i.e. may not be present in the raw CPUID, but can still be advertised to >>>> * userspace. Primarily used for mitigation related feature flags. >>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >>>> */ >>>> #define SYNTHESIZED_F(name) >>>> >>>>> + SCATTERED_F(TSA_SQ_NO), >>>>> + SCATTERED_F(TSA_L1_NO), >>>> >>>> And scattered are of the same type. >>>> >>>> Sean, what's the subtle difference here? >>> >>> SYNTHESIZED_F() sets the bit unconditionally. SCATTERED_F() propagates >>> the bit (if set) from the host's cpufeature flags. >> >> Yah, and I was hinting at the scarce documentation. >> >> SYNTHESIZED_F() is "Primarily used for mitigation related feature flags." >> SCATTERED_F() is "For features that are scattered by cpufeatures.h." > > Ugh. I have to rescind my Reviewed-by. IIUC, SCATTERED_F() implies a > logical and with hardware CPUID, which means that the current proposal > will never set the ITS_NO bits. Right, I see what you mean now. SCATTERED_F() will set kvm_cpu_caps correctly, but then this will clear the bits, because kvm_cpu_cap_synthesized is now 0: kvm_cpu_caps[leaf] &= (raw_cpuid_get(cpuid) | kvm_cpu_cap_synthesized); So to me it seems like SYNTHESIZED_F() is just wrong, since it always enables bits for KVM-only leafs. So how about the following (I think Binbin Wu suggests this in his other email): diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 819c176e02ff..5e863e213f54 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -769,7 +769,8 @@ do { \ */ #define SYNTHESIZED_F(name) \ ({ \ - kvm_cpu_cap_synthesized |= feature_bit(name); \ + if (boot_cpu_has(X86_FEATURE_##name)) \ + kvm_cpu_cap_synthesized |= feature_bit(name); \ F(name); \ })