From nobody Sat Jul 4 21:04:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1783059991; cv=none; d=zohomail.com; s=zohoarc; b=l2dU+I/Rdi5rWH/hRNSpL1VwDLr74x1OV9bcAWfWv5vukDYr6HzwyJh1Dyz8IbtyKcaxlmJiUbr2xErLrYNynOQirQ8X/vG8tU6vTaI544R/bYf7PF0FVpAkbGL9RopYtT6MN9F0WRvjjP2kb/QdMpX/JYNf9aSjOHel+WPfRbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783059991; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Osy0sYEvcEVc3wSdb+rsl4BwKV2b8jJ9NOV+BOqJ2/M=; b=PeadqAY7fPgNwTdurP8eQcWCIPeAfzrCy11II2HzlBK56VzthzCDsK+1fOQSU8sTHGV91d3nOdfYTtojf5vvwLNgG1YyyMg6Vpy6YDRwX46rwvkYhap63dqdq0TCAvSj6jhrs0riQ/VKFiEfG5vc2UhL/IVf7dGJcFhx7+4ne5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1783059991653833.3653819278522; Thu, 2 Jul 2026 23:26:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1352856.1609167 (Exim 4.92) (envelope-from ) id 1wfXLk-0005ya-2j; Fri, 03 Jul 2026 06:26:08 +0000 Received: by outflank-mailman (output) from mailman id 1352856.1609167; Fri, 03 Jul 2026 06:26:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wfXLj-0005yT-Vd; Fri, 03 Jul 2026 06:26:07 +0000 Received: by outflank-mailman (input) for mailman id 1352856; Fri, 03 Jul 2026 06:26:06 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wfXLi-0005yM-3D for xen-devel@lists.xenproject.org; Fri, 03 Jul 2026 06:26:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wfXLg-00H54x-Nj for xen-devel@lists.xenproject.org; Fri, 03 Jul 2026 08:26:04 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4755e0-bab6-0a2a0a5309dd-0a2a4505e232-36 for ; Fri, 03 Jul 2026 08:26:04 +0200 Received: from [209.85.221.45] (helo=mail-wr1-f45.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4755fc-3cb2-0a2a45050019-d155dd2dbdc8-3 for ; Fri, 03 Jul 2026 08:26:04 +0200 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4798bea72f9so123583f8f.1 for ; Thu, 02 Jul 2026 23:26:04 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-477de3dd53fsm14981470f8f.37.2026.07.02.23.26.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jul 2026 23:26:03 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Autocrypt:Content-Language:Cc:To:Subject:From:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1783059964; x=1783664764; darn=lists.xenproject.org; h=content-transfer-encoding:autocrypt:content-language:cc:to:subject :from:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=Osy0sYEvcEVc3wSdb+rsl4BwKV2b8jJ9NOV+BOqJ2/M=; b=JhsZ66IHs7razkBPCBqxKrm2z13cwm1yKuThK02Hjkj0veJcbWRGtGT2eRbdmqQc+n YIovpar/WfTZjUURimhV1xOiBep82Y2AlFs2EvqpWKYIpspce2UDe70Iop/Dr33qb6CC WkwJBHdUKFbcTxKgaTE87gwT2ZFXQ4MYV10rmii03ZZnsl9jXimganjIVNr6G8xTMTG+ 0aTpqW78RwZ706j8hfcnTlHXvsFA+giAdJJBAd7gf0gfCxeYI8QG7MT6dLV1obilepsA 8h5eTqIUgv4nGWhZn/aiTxw3avnL/LtS5R4x7QYCVeu8EuGDRRzrmJsgnaYCtdgrNbuN 4qeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783059964; x=1783664764; h=content-transfer-encoding:autocrypt:content-language:cc:to:subject :from:user-agent:mime-version:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Osy0sYEvcEVc3wSdb+rsl4Bw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0:10b0:46d:9871:1a44 with SMTP id ffacd0b85a97d-4775a0fcd6dmr9531248f8f.32.1783059963849; Thu, 02 Jul 2026 23:26:03 -0700 (PDT) Message-ID: Date: Fri, 3 Jul 2026 08:26:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Jan Beulich Subject: [PATCH v2 for-4.22] x86/cpu-policy: set up host policy earlier To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Marek Marczykowski , Teddy Astie , Oleksii Kurochko Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1783059964-15F0F2B8-52C46047/0/0 X-purgate-type: clean X-purgate-size: 3274 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1783059993035158500 In order to use cpu_has_* expanding to host_cpu_policy.*, the host policy needs setting up alongside boot_cpu_data.x86_capability[]. Arrange for that towards the end of identify_cpu(). Then make sure .x86_capability[] and host policy remain in sync when setup_{force,clear}_cpu_cap() are used. Rename the function now it's no longer static. Fixes: 894bd7617924 ("x86/Intel: use host CPU policy for ARAT checking") Reported-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Jan Beulich --- This really was part of one of the XSTATE cleanup patches at the head of the AMX series. This explains the specific placement ahead of the call to xstate_init()). Likely anything from there downwards shouldn't really live in identify_cpu() anyway. --- v2: Call calculate_host_cpu_policy() from setup_{force,clear}_cpu_cap() instead of from init_guest_cpu_policies(). --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -66,8 +66,10 @@ void __init setup_clear_cpu_cap(unsigned __clear_bit(cap, boot_cpu_data.x86_capability); dfs =3D x86_cpu_policy_lookup_deep_deps(cap); =20 - if (!dfs) + if (!dfs) { + calculate_host_cpu_policy(); return; + } =20 for (i =3D 0; i < FSCAPINTS; ++i) { cleared_caps[i] |=3D dfs[i]; @@ -78,6 +80,8 @@ void __init setup_clear_cpu_cap(unsigned __builtin_return_address(0), i, forced_caps[i] & dfs[i]); } + + calculate_host_cpu_policy(); } =20 void __init setup_force_cpu_cap(unsigned int cap) @@ -92,6 +96,8 @@ void __init setup_force_cpu_cap(unsigned } =20 __set_bit(cap, boot_cpu_data.x86_capability); + + calculate_host_cpu_policy(); } =20 bool __init is_forced_cpu_cap(unsigned int cap) @@ -586,6 +590,8 @@ void identify_cpu(struct cpuinfo_x86 *c) } =20 /* Now the feature flags better reflect actual CPU features! */ + if (c =3D=3D &boot_cpu_data) + calculate_host_cpu_policy(); =20 xstate_init(c); =20 --- a/xen/arch/x86/cpu-policy.c +++ b/xen/arch/x86/cpu-policy.c @@ -359,11 +359,18 @@ void calculate_raw_cpu_policy(void) /* Was already added by probe_cpuid_faulting() */ } =20 -static void __init calculate_host_policy(void) +void __init calculate_host_cpu_policy(void) { struct cpu_policy *p =3D &host_cpu_policy; unsigned int max_extd_leaf; =20 + /* + * Bail if the raw policy wasn't set up yet. At least recalculate_xsta= te() + * can't be used yet in that case. + */ + if ( !raw_cpu_policy.basic.max_leaf ) + return; + *p =3D raw_cpu_policy; =20 p->basic.max_leaf =3D @@ -904,8 +911,6 @@ static void __init calculate_hvm_def_pol =20 void __init init_guest_cpu_policies(void) { - calculate_host_policy(); - if ( IS_ENABLED(CONFIG_PV) ) { calculate_pv_max_policy(); --- a/xen/arch/x86/include/asm/cpu-policy.h +++ b/xen/arch/x86/include/asm/cpu-policy.h @@ -30,4 +30,10 @@ void recalculate_cpuid_policy(struct dom */ void calculate_raw_cpu_policy(void); =20 +/* + * Collect the host CPU policy. Called after collecting enough CPUID outp= ut, + * and again after all feature overrides have been put in place. + */ +void calculate_host_cpu_policy(void); + #endif /* X86_CPU_POLICY_H */