From nobody Sat May 30 11:15:02 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=1778600148; cv=none; d=zohomail.com; s=zohoarc; b=kqAF336IfGiiukUoEcTW33NX0A41Y4FFI7wbbIAblNxsYwhxAU/mJX6LPX1R2J0ma/WI1o6lV+msi5Jdm4mD+yCXFW9vgctm4Iyp9GO2Sr+V0pmYBBpCGX45DaDIaNpeVwDnlakcMEGXcqSxJ/Zrt9vG/suj229Kuwctx7sAAuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778600148; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+F18zTQ2tYhuJeL6OBgVxAMYMHPNiYmv6o58vYh8r4k=; b=mO/Q0hYK7DX9h3caSBlTx5TzIT49SASqTPTtXb8SYB1wCYmV2Q3vpTTshEngfIVB/TG3eT4/me1tCPFUjZaiPmu6LlXkTDzSAUKUlfFRAXVNY590+hUMrvFt6xVz9MXQHAWYYrj55466GrRZZMJ7Mh7fmleiMTtcjtlIpmLmmJI= 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 1778600148599998.3361220853197; Tue, 12 May 2026 08:35:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1306994.1578719 (Exim 4.92) (envelope-from ) id 1wMp8z-0002wn-3t; Tue, 12 May 2026 15:35:37 +0000 Received: by outflank-mailman (output) from mailman id 1306994.1578719; Tue, 12 May 2026 15:35:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMp8z-0002wg-13; Tue, 12 May 2026 15:35:37 +0000 Received: by outflank-mailman (input) for mailman id 1306994; Tue, 12 May 2026 15:35:36 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMp8y-0002wY-7F for xen-devel@lists.xenproject.org; Tue, 12 May 2026 15:35:36 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMp8x-00HGoL-Gh for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:35:35 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a0348c3-e002-0a2a0a5209dd-0a2a450794fc-26 for ; Tue, 12 May 2026 17:35:35 +0200 Received: from [209.85.221.51] (helo=mail-wr1-f51.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a0348c7-229c-0a2a45070019-d155dd33b8ad-3 for ; Tue, 12 May 2026 17:35:35 +0200 Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-43d76dd4ee8so5264888f8f.2 for ; Tue, 12 May 2026 08:35:35 -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-45491304505sm33585782f8f.22.2026.05.12.08.35.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 08:35:34 -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:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778600135; x=1779204935; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=+F18zTQ2tYhuJeL6OBgVxAMYMHPNiYmv6o58vYh8r4k=; b=OQKxYwGUB1j7rijXPZQ+DtPbrw+MKIcVxEZfMOjEU6xrBy2ogOVxlTJ1f4CSAolZjO VKp5plf/1Ridv+XFQDbfprO7192DMp80DiDkEwk1TPKtBJz/6D//GL7FFqCqynAwZXUg fexPyqelIRthaFPi9v33EqwgclBy5jCCGgVZLFHAW6k/u1O9s78Q5dysVE571zqlAFD9 MX/dwIwIyEF7x6YkHRGMC1f6sU/bKdfsaKivV5dmdyZXeiyzHmkQdB0vfZmSnv2afJbz HzlZOvHd1g+2kSmdp7vEkKyxeZ36IcUL7eFmzKj2PHsaWYXDFBF6Dx6xXraI00cJwE7H FXwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778600135; x=1779204935; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+F18zTQ2tYhuJeL6OBgVxAMYMHPNiYmv6o58vYh8r4k=; b=GclHBz0L4AO2XV2QVUGbDYDkjNBJTk7vM7qcIXom5NRIQov2WFNXLnOwYLZrau4VLK abAyAe/lz6tvZaKeea93d3yjZ+sRWYcDrX6i+MOYccmU6h+5L71DwgVxl5H4WLrZVKuJ JpJMLubqL5kUGYvpTDxeBWGTw+Orb74nlKOk5JMuS04KHLwb01Gb213WDxj3v/4zXwQm lcFuVQdrv9UpYdfnL7bO377SQKGJuXkxhAEPbwpg2AJVbtMaIjMubmhSRdN3cWREtgP7 F2zrUcbQ7XjtjXauBLvDFvOxNYMNx8RXcAjTTYKZnDGqRjKisQxHTDntjqU92agueF/v zjZQ== X-Gm-Message-State: AOJu0YxMJVY7H33s5nSoxbrcmb637zedoJY2rmgOGoGym53K8mSbgHm4 ftgMxXwlVcKJziCn1VxRXSYKdqO+iFDEYbOgh180opOpPj3Iqq5/I6cm1RAnGXmeYBTBmHR0Av0 BFcw= X-Gm-Gg: Acq92OGZE7dgxLd4Q+UinBrGfYwqEQyCJ5ZN7cTgxspUInG2/Vi6Kudekjj2aTtjrFg PX5jqx75Kp1C6sOhHIe+4Fnu1IojE5Lwx8FCt8fFmpkkdbDpJvCwxQQEahh/Z+GXXzRRt05QdOf 7AnEFiFYubFFI8KshTi+lL6JIr2y1qUblrjYKueiO4dFKClUEaSx+7fiexd7tLZFKKxNx1JdQZ8 yvGct3n+ZV6RUzZbGkKaMslyZrM37DNHcIbobrQ7xTHMFDJD9hzP1roOclHsLl8p1owom985Z0C JOTr9Fo1lJThZIja4XH+BPKDOV/07j/L7+S7/JocxcRjXGJsewLCTTHqhSj8/AFJybFp75M3ONJ LR5livL5aPeQRhOX65CkM2WE7krd87dCjZQ6YX+sRiVGMu7BkJmK0CNs+Z+EeMiin4o+z1jWOIC E4m3aDZGGri4yvYTY2i0wxZzQrgzbSb2nYKmzvsIpM9OguuT5wUWM2ZRmqkwH+/W87DiUi4Q8+X 4yHXftFhC+H8yM= X-Received: by 2002:a05:6000:3113:b0:456:15fa:9eba with SMTP id ffacd0b85a97d-456a4daccb9mr21661640f8f.43.1778600134763; Tue, 12 May 2026 08:35:34 -0700 (PDT) Message-ID: <5c66cfb1-e234-4efa-9a01-88acb284e414@suse.com> Date: Tue, 12 May 2026 17:35:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.22 v2 1/8] x86/mwait-idle: arrange for BSP MSR adjustments during S3 resume From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> 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 In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1778600135-0AB70C48-33CB9FDF/0/0 X-purgate-type: clean X-purgate-size: 3124 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778600150767158500 Content-Type: text/plain; charset="utf-8" mwait_idle_cpu_init() is only called for APs, yet MSR writes will typically need re-doing post-S3 even for the BSP. When multiple cores / threads are present (and to come back online) in a package, for package scope MSRs this may be covered by APs doing the writes, but we can't rely on that. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- a/xen/arch/x86/acpi/power.c +++ b/xen/arch/x86/acpi/power.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -299,6 +300,7 @@ static int enter_state(u32 state) acpi_sleep_post(state); if ( hvm_cpu_up() ) BUG(); + mwait_idle_resume(); cpufreq_add_cpu(0); =20 enable_cpu: --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -1677,6 +1677,28 @@ static int __init mwait_idle_probe(void) return 0; } =20 +static void mwait_idle_cpu_tweak(unsigned int cpu) +{ + if (icpu->auto_demotion_disable_flags) + on_selected_cpus(cpumask_of(cpu), auto_demotion_disable, NULL, 1); + + if (icpu->byt_auto_demotion_disable_flag) + on_selected_cpus(cpumask_of(cpu), byt_auto_demotion_disable, NULL, 1); + + switch (icpu->c1e_promotion) { + case C1E_PROMOTION_DISABLE: + on_selected_cpus(cpumask_of(cpu), c1e_promotion_disable, NULL, 1); + break; + + case C1E_PROMOTION_ENABLE: + on_selected_cpus(cpumask_of(cpu), c1e_promotion_enable, NULL, 1); + break; + + case C1E_PROMOTION_PRESERVE: + break; + } +} + static int cf_check mwait_idle_cpu_init( struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -1759,24 +1781,7 @@ static int cf_check mwait_idle_cpu_init( dev->count++; } =20 - if (icpu->auto_demotion_disable_flags) - on_selected_cpus(cpumask_of(cpu), auto_demotion_disable, NULL, 1); - - if (icpu->byt_auto_demotion_disable_flag) - on_selected_cpus(cpumask_of(cpu), byt_auto_demotion_disable, NULL, 1); - - switch (icpu->c1e_promotion) { - case C1E_PROMOTION_DISABLE: - on_selected_cpus(cpumask_of(cpu), c1e_promotion_disable, NULL, 1); - break; - - case C1E_PROMOTION_ENABLE: - on_selected_cpus(cpumask_of(cpu), c1e_promotion_enable, NULL, 1); - break; - - case C1E_PROMOTION_PRESERVE: - break; - } + mwait_idle_cpu_tweak(cpu); =20 return NOTIFY_DONE; } @@ -1808,6 +1813,14 @@ int __init mwait_idle_init(struct notifi return err; } =20 +void mwait_idle_resume(void) +{ + if (!icpu) + return; + + mwait_idle_cpu_tweak(smp_processor_id()); +} + /* Helper function for HPET. */ bool __init mwait_pc10_supported(void) { --- a/xen/arch/x86/include/asm/mwait.h +++ b/xen/arch/x86/include/asm/mwait.h @@ -14,9 +14,12 @@ #define MWAIT_ECX_INTERRUPT_BREAK 0x1 =20 void mwait_idle_with_hints(unsigned int eax, unsigned int ecx); + #ifdef CONFIG_INTEL +void mwait_idle_resume(void); bool mwait_pc10_supported(void); #else +static inline void mwait_idle_resume(void) {} static inline bool mwait_pc10_supported(void) { return false; From nobody Sat May 30 11:15:02 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=1778600187; cv=none; d=zohomail.com; s=zohoarc; b=kdfuABQzikNK92ZIdhVFoQ71n2xfmGpXA6KScMfK0+G8OkkKhFuTySPfbPP/1nFZHMPvyWO0WkYLeXAtr0+RMeYd4JZ/o0xVZ3clVQ1LUljkwyfZjeXtqj73sHp8YUWM0Tr2eCSiGB2c1G0dMuaWtEA5hMyrGUin0/QCcsgcblY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778600187; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9ZzX9y9DzM/pf6lRtwdmKQ1uBuLJ5k1HbTo5s1srMNQ=; b=KDZSLp8ZzW43PpjynhurRAdp24TjfZzNHRC4oHg5ze8SjDr0hDFzG1N5JJkHYkXBTzDjPjnKcBldGYaDdWiVzPawvjvG3PME9NF7PP/FT9S8ALfgKKA8ySs2xJ6lTdJsQYtaSdPMyFaiEuoI+ikBZlXkgxLF+9uf7EL1sjOKGwA= 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 1778600187387115.99024001069517; Tue, 12 May 2026 08:36:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1306999.1578729 (Exim 4.92) (envelope-from ) id 1wMp9W-0003Nc-Bk; Tue, 12 May 2026 15:36:10 +0000 Received: by outflank-mailman (output) from mailman id 1306999.1578729; Tue, 12 May 2026 15:36:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMp9W-0003NV-7x; Tue, 12 May 2026 15:36:10 +0000 Received: by outflank-mailman (input) for mailman id 1306999; Tue, 12 May 2026 15:36:08 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMp9U-0003NH-QH for xen-devel@lists.xenproject.org; Tue, 12 May 2026 15:36:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMp9U-00AQXI-6u for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:36:08 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a0348dc-bab6-0a2a0a5309dd-0a2a4503a70c-40 for ; Tue, 12 May 2026 17:36:08 +0200 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a0348e8-672d-0a2a45030019-d1558032c526-3 for ; Tue, 12 May 2026 17:36:08 +0200 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-488af9fdaa7so32813645e9.1 for ; Tue, 12 May 2026 08:36:08 -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 5b1f17b1804b1-48e8f410558sm41030815e9.5.2026.05.12.08.36.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 08:36:07 -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:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778600167; x=1779204967; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=9ZzX9y9DzM/pf6lRtwdmKQ1uBuLJ5k1HbTo5s1srMNQ=; b=O5yNjw6fI55+fKspXzZ/e+w7J1NmeGG8U48oFiwJSM6Caejs5QX4IN/qWtOLdQSbBa 5ROnXXrVgMzrqUl9TWEsmwADvA44QZr16xQCuFgYqXH6wkm8qUHLhPV6G/T/KjCgezw7 Acm6TC2CuOH7WAKMbhPLkdd8xmgYBt/w4R1ktKX76yDOHDkoFewTREcqxgvXGGDKBque 0irBF2D+Dt4Vwoz+0xrMFL/GQvcOPCLeeseEM9O4+lb3xRl33tjMYI/amKzmJDMkKh17 yPaBiIlkE0CJvhWp5Y6BzSl3i7YlMO7YMP27xCim3m1O9DcB+TodBHLoxc07Nc1OZFMA ELlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778600167; x=1779204967; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9ZzX9y9DzM/pf6lRtwdmKQ1uBuLJ5k1HbTo5s1srMNQ=; b=ZYZXXT3hfMhYbKgL8LdTQArA6jUnOcmgc33QFfBvV2dp7qCjNkoVWpLJnW1dB2NXec r0wElmH9bKcIfaPbJh8CW34X9r8uQWXp41DuuDgrWbGLd0rBSm540E9ISZk/decqsuij jKUEzRS6vbftJUkaCjCR6RhRXwz75ahe9mkcgvifGXq+SzcxmU0ejb6/IT5wrj7E6J92 jYA8tPoyLRyPtnImvlPHIVRdISkqET7vNrJeWhMVW6Ogjj00OuaMg/sdvfGiUnb8jjmV VxcvoiQHly6eBskQE5zscXmuv8ZJKp86rihpBcUZoAWwlTkkVUg8/LVGDRBtIJ3ed5hs 8x8Q== X-Gm-Message-State: AOJu0Yx78e7x68lknRzLHQ/MuSSyIW9nonEf65N+UUuh98cFeFKPVmrO 95KQGsSvDhNkcDu6IM9jOpUAPqlQOBKwPBKlKTdYrsx3f4YCpZd6jxGbkEoM+RURtID8b4HRTZL Vzcw= X-Gm-Gg: Acq92OHEii2EF9xfHLw3m5hHD0zQFl1Co9ATmHvYK4cmn0fRZMh07Q2DK2XL0Wx30jD Mbnrlv2ujerRAaIWqMh1U0WtwNjpNZ8h0reGRJsjCMuHK3WqM11M+fom4TJiDgTA8h/M6/D4NdO 4XTjzWiytd6xmvgeFNSDeoXMjvTc+kRHuhcg4jvOEZR3IDCJap4czdgkR3VjHk30CihkiKA0W+U A/mwcVRrSKzW3DHcQJtcCiAG9AMHiLJSrBTcr968ah/wLKe76Lhfss0MJARmKokw4VzP2ldoN4f mRVUqUZiuLokYvPo/RPvfuQ8VvVhuSv/B7tZwcWdmWglhc7neouLU6TjknobSqHMiqk2juhlma8 Qx23rj/eS/TBdOznuHkuHRf4uxAvagVL84SkWztD2nm0apXB3wrdqdZifxXUn4zyv8UU7xIirer fQhfcg4HYAh1t9NgROCXACy5Ir+kDl//a6AWE5oTsYFLQN/eu2OtRh5ZCkBGc5jOs8+zJGuXmAn zo/PoLZAJt47VQ= X-Received: by 2002:a05:600c:3e88:b0:48a:55d8:7882 with SMTP id 5b1f17b1804b1-48e8fe5494bmr53983685e9.9.1778600167550; Tue, 12 May 2026 08:36:07 -0700 (PDT) Message-ID: Date: Tue, 12 May 2026 17:36:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.22 v2 2/8] x86/mwait-idle: clean up BYT/CHT auto demotion disable From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> 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 In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1778600168-3B96D938-1DFE7A89/0/0 X-purgate-type: clean X-purgate-size: 3850 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778600189130158500 Content-Type: text/plain; charset="utf-8" Bay Trail (BYT) and Cherry Trail (CHT) platforms have a very specific way of disabling auto-demotion via specific MSR bits. Clean up the code so that BYT/CHT-specifics do not show up in the common 'struct idle_cpu' data structure. Remove the 'byt_auto_demotion_disable_flag' flag from 'struct idle_cpu', because a better coding pattern is to avoid very case-specific fields like 'bool byt_auto_demotion_disable_flag' in a common data structure, which is used for all platforms, not only BYT/CHT. The code is just more readable when common data structures contain only commonly used fields. Instead, match BYT/CHT in the 'intel_idle_init_cstates_icpu()' function, and introduce a small helper to take care of BYT/CHT auto-demotion. This is consistent with how platform-specific things are done for other platforms. No intended functional changes. Inspired by (and description largely taken from) Linux'es c93d13b661a6 ("intel_idle: clean up BYT/CHT auto demotion disable"). Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- v2: Init "first" to "true" in mwait_idle_cpu_init(). --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -103,7 +103,6 @@ struct idle_cpu { * Indicate which enable bits to clear here. */ unsigned long auto_demotion_disable_flags; - bool byt_auto_demotion_disable_flag; enum c1e_promotion c1e_promotion; }; =20 @@ -1144,7 +1143,7 @@ static void cf_check auto_demotion_disab wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); } =20 -static void cf_check byt_auto_demotion_disable(void *dummy) +static void byt_cht_auto_demotion_disable(void) { wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0); wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0); @@ -1195,13 +1194,11 @@ static const struct idle_cpu idle_cpu_sn static const struct idle_cpu idle_cpu_byt =3D { .state_table =3D byt_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, - .byt_auto_demotion_disable_flag =3D true, }; =20 static const struct idle_cpu idle_cpu_cht =3D { .state_table =3D cht_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, - .byt_auto_demotion_disable_flag =3D true, }; =20 static const struct idle_cpu idle_cpu_ivb =3D { @@ -1677,14 +1674,11 @@ static int __init mwait_idle_probe(void) return 0; } =20 -static void mwait_idle_cpu_tweak(unsigned int cpu) +static void mwait_idle_cpu_tweak(unsigned int cpu, bool bsp) { if (icpu->auto_demotion_disable_flags) on_selected_cpus(cpumask_of(cpu), auto_demotion_disable, NULL, 1); =20 - if (icpu->byt_auto_demotion_disable_flag) - on_selected_cpus(cpumask_of(cpu), byt_auto_demotion_disable, NULL, 1); - switch (icpu->c1e_promotion) { case C1E_PROMOTION_DISABLE: on_selected_cpus(cpumask_of(cpu), c1e_promotion_disable, NULL, 1); @@ -1697,12 +1691,24 @@ static void mwait_idle_cpu_tweak(unsigne case C1E_PROMOTION_PRESERVE: break; } + + /* Pkg-scope MSRs on 1-socket-only systems need writing only once. */ + if (!bsp) + return; + + switch (boot_cpu_data.vfm) { + case INTEL_ATOM_SILVERMONT: + case INTEL_ATOM_AIRMONT: + byt_cht_auto_demotion_disable(); + break; + } } =20 static int cf_check mwait_idle_cpu_init( struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu =3D (unsigned long)hcpu, cstate; + static bool first =3D true; struct acpi_processor_power *dev =3D processor_powers[cpu]; =20 switch (action) { @@ -1781,7 +1787,8 @@ static int cf_check mwait_idle_cpu_init( dev->count++; } =20 - mwait_idle_cpu_tweak(cpu); + mwait_idle_cpu_tweak(cpu, first); + first =3D false; =20 return NOTIFY_DONE; } @@ -1818,7 +1825,7 @@ void mwait_idle_resume(void) if (!icpu) return; =20 - mwait_idle_cpu_tweak(smp_processor_id()); + mwait_idle_cpu_tweak(smp_processor_id(), true); } =20 /* Helper function for HPET. */ From nobody Sat May 30 11:15:02 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=1778600205; cv=none; d=zohomail.com; s=zohoarc; b=k3bK7fR17h1/PIz5qVUjiLVoIrVPv2zqgbNbDUydGT+EAx7TFvmHUpJIaEM/Nhwj6Qy9JNzSniIifJJerhxmbiHbGIVGbwAFu9OBrbyA6vigWMZ3StyRrloVoOwNNZsMv40/41Bt2Bums7Pb0dwhYv8me8UeoDdzo7cI0xtKmfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778600205; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+p/Ij2CgQ3Fd9f/uexuTOqD95AbabIMcKqaBQDpzCqU=; b=FDF89m6lYL4USH7X/GLtztacu1u4sfB2YB8UWRzvnvJaACcTyqKC0sSsHmtkY5zvsZx/m/mYalbcPsBOvDOiDPhxsjjUWqW4wSkEWfJdZWAnxHCJ7dzgNxi6FKn9LTUas2EIObluEt6Fz9b2RQvYSMKwJpfcrby1RgpQGTfmpBQ= 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 1778600205050773.6077745638945; Tue, 12 May 2026 08:36:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1307004.1578737 (Exim 4.92) (envelope-from ) id 1wMp9s-0003lj-HG; Tue, 12 May 2026 15:36:32 +0000 Received: by outflank-mailman (output) from mailman id 1307004.1578737; Tue, 12 May 2026 15:36:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMp9s-0003lc-EX; Tue, 12 May 2026 15:36:32 +0000 Received: by outflank-mailman (input) for mailman id 1307004; Tue, 12 May 2026 15:36:30 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMp9q-0003lF-NC for xen-devel@lists.xenproject.org; Tue, 12 May 2026 15:36:30 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMp9q-00AQbz-47 for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:36:30 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a0348fa-bab6-0a2a0a5309dd-0a2a4501acb2-8 for ; Tue, 12 May 2026 17:36:30 +0200 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a0348fd-c1f2-0a2a45010019-d1558032d188-3 for ; Tue, 12 May 2026 17:36:30 +0200 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-48d146705b4so69766415e9.3 for ; Tue, 12 May 2026 08:36:30 -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 5b1f17b1804b1-48fc8d15e09sm5644885e9.3.2026.05.12.08.36.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 08:36:29 -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:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778600189; x=1779204989; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=+p/Ij2CgQ3Fd9f/uexuTOqD95AbabIMcKqaBQDpzCqU=; b=KvNEsXF1uAgYhkqcMYcyThaf1izdepbk4naGvQxLb57cyuU9sm5dDY8RTnLU9Dw/zP xT7Nma28BGCWIO1Qv/T6GtARH6RuSNGOVy3Wlz9dwvtPSReMVENN/zJWFDwVGreQ48+6 3GclYMYPU7QYRdu5ToKu85OsEWZgW/L0cAazVr1XzX6NzwuTY7OdaBjU6c+vGJdBlli3 TtZqyXCGp7ctxCowTqPRiDTCT4cG8cXdDwZ+e+/MshQh/vgpctjBkPSiceonrw9zxrpW bB8VyAgdOybuheHfT6TNjgEQzQoYfV86pQmssW8gAv9fB2aGHF7IWuAqsz99NIw1XtTd POlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778600189; x=1779204989; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+p/Ij2CgQ3Fd9f/uexuTOqD95AbabIMcKqaBQDpzCqU=; b=dVxXUvM5X8x/dMNFXVV9P8Zah6TSWhd1NtWGMdgUcS2Yl02AXrl7RlW491AIYypSQz xi1E9XSQV7sgCS75H4LeMNpd5gQuQ4OmiozG922gNwVVzm+wtQl6vW3LRFhvQUU7LJww qm2PluVgw0JhqC5GKvMYHVDOH5bCmPvxqNHtZR2kwuJn0BYlB/EXtRYNSVu3LM7S94By wxgPvYL0qFIk3bcf7WJZgE9Y9NNNfGd81rd26G6Q+gyElI4YtuAl9vfAzMNVgdaRchRt 254vGkIaeHxaxLayTQYWkQdIy0XneSDVL3Dg43b7lw8My5o5rdauBfDyH8RiqFt29YVy S/Sw== X-Gm-Message-State: AOJu0YzOzC65rb1ScutTyfBT9xm2xqKwQp0Ag0Kca3vYD5WmZfWsBH2p d5hMJTHO9mBKXY3a0Jb+lICKngdJvyY7HwvHLiSFo+Va3AUbsvuSUOYo/Sly/1MnqjhQhiQWW1g cAno= X-Gm-Gg: Acq92OF6pDSVNM4JNsUzhA8JFpTDRuzw5s8J7MlLb/nFf4uRsdzLv0zLbqdAeqUsIjS Pvk1oMsQg6nN+x2RZd5Etg6rDOBiOKffJCdmXFpGnt3zl/hBthZMLcFBUpqOCocFC3us1SfPEtH +AMItInbLDf2jWq2peRHkxpulUYOOmsdQA4YTL48jq1SIfpxEt4YtAb5Ifj5tIX8jiwOrkzxsq8 T7hWX+JA5hn2y+NbLjqUttHe1stpCFUDtzGuz4LsvXx7psSyRyhoy3CH67KqfzsxRF88Zkkyrje bBdhQjSyXiMnV2Ss1dYc1elf0JnjCqxhzC7VvFuFRF8Mc5U/96ilHMQezMu5h6UojisS+ClU0Qk 6KcnGZFxIR8hLB4pWAeyhOUDdWX059uRdSnCIRz/2GSoY58DQ5ZbqZKr/UQaOJO2EmarR2pBY4Y ope6ShIYQ39bDgC6I66Una+saOwJiuzMcU328ds0Dj5kNopC4kP8dXdA1O6ukRaJma7egVRLmSc +FiPWr23eHFqDNWh4l2rII5IA== X-Received: by 2002:a05:600c:3e0e:b0:48a:52f2:a0f1 with SMTP id 5b1f17b1804b1-48e8fe73355mr58352175e9.18.1778600189596; Tue, 12 May 2026 08:36:29 -0700 (PDT) Message-ID: <696b4fe5-d8a5-4768-9b24-5c2d2975e686@suse.com> Date: Tue, 12 May 2026 17:36:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.22 v2 3/8] x86/mwait-idle: latch struct idle_cpu contents From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> 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 In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1778600190-B695FFF4-1EE8C1D0/0/0 X-purgate-type: clean X-purgate-size: 5850 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778600206517154100 Rather than storing a pointer (and needing to keep all struct instances in memory post-init), and rather than (like the Linux counterpart has it) keeping individual variables, simply copy the respective structure instance. By implication, subsequent updates now need doing to the copy. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -106,14 +106,14 @@ struct idle_cpu { enum c1e_promotion c1e_promotion; }; =20 -static const struct idle_cpu *__ro_after_init icpu; +static struct idle_cpu __ro_after_init icpu; =20 -static const struct cpuidle_state { +struct cpuidle_state { char name[16]; unsigned int flags; unsigned int exit_latency; /* in US */ unsigned int target_residency; /* in US */ -} *__ro_after_init cpuidle_state_table; +}; =20 #define CPUIDLE_FLAG_DISABLED 0x1 /* @@ -1097,7 +1097,7 @@ static void cf_check mwait_idle(void) * leave_mm() to avoid costly and often unnecessary wakeups * for flushing the user TLB's associated with the active mm. */ - if (cpuidle_state_table[].flags & CPUIDLE_FLAG_TLB_FLUSHED) + if (icpu.state_table[].flags & CPUIDLE_FLAG_TLB_FLUSHED) leave_mm(cpu); #endif =20 @@ -1139,7 +1139,7 @@ static void cf_check auto_demotion_disab u64 msr_bits; =20 rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); - msr_bits &=3D ~(icpu->auto_demotion_disable_flags); + msr_bits &=3D ~icpu.auto_demotion_disable_flags; wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); } =20 @@ -1371,10 +1371,10 @@ static void __init ivt_idle_state_table_ /* 1 and 2 socket systems use default ivt_cstates */ break; case 2: case 3: - cpuidle_state_table =3D ivt_cstates_4s; + icpu.state_table =3D ivt_cstates_4s; break; default: - cpuidle_state_table =3D ivt_cstates_8s; + icpu.state_table =3D ivt_cstates_8s; break; } } @@ -1525,14 +1525,12 @@ static void __init adl_idle_state_table_ adl_l_cstates[1].flags |=3D CPUIDLE_FLAG_DISABLED; =20 /* Disable C1E by clearing the "C1E promotion" bit. */ - idle_cpu_adl.c1e_promotion =3D C1E_PROMOTION_DISABLE; - idle_cpu_adl_l.c1e_promotion =3D C1E_PROMOTION_DISABLE; + icpu.c1e_promotion =3D C1E_PROMOTION_DISABLE; return; } =20 /* Make sure C1E is enabled by default */ - idle_cpu_adl.c1e_promotion =3D C1E_PROMOTION_ENABLE; - idle_cpu_adl_l.c1e_promotion =3D C1E_PROMOTION_ENABLE; + icpu.c1e_promotion =3D C1E_PROMOTION_ENABLE; } =20 /* @@ -1593,6 +1591,7 @@ static int __init mwait_idle_probe(void) { unsigned int eax, ebx, ecx; const struct x86_cpu_id *id; + const struct idle_cpu *idle_cpu; const char *str; =20 if (boot_cpu_data.vendor !=3D X86_VENDOR_INTEL) @@ -1627,8 +1626,8 @@ static int __init mwait_idle_probe(void) =20 pr_debug(PREFIX "MWAIT substates: %#x\n", mwait_substates); =20 - icpu =3D id->driver_data; - cpuidle_state_table =3D icpu->state_table; + idle_cpu =3D id->driver_data; + icpu =3D *idle_cpu; =20 if (boot_cpu_has(X86_FEATURE_XEN_ARAT)) lapic_timer_reliable_states =3D LAPIC_TIMER_ALWAYS_RELIABLE; @@ -1644,7 +1643,7 @@ static int __init mwait_idle_probe(void) const char *ss; =20 do { - const struct cpuidle_state *state =3D icpu->state_table; + const struct cpuidle_state *state =3D idle_cpu->state_table; unsigned int bit =3D 1; =20 ss =3D strchr(str, ','); @@ -1676,10 +1675,10 @@ static int __init mwait_idle_probe(void) =20 static void mwait_idle_cpu_tweak(unsigned int cpu, bool bsp) { - if (icpu->auto_demotion_disable_flags) + if (icpu.auto_demotion_disable_flags) on_selected_cpus(cpumask_of(cpu), auto_demotion_disable, NULL, 1); =20 - switch (icpu->c1e_promotion) { + switch (icpu.c1e_promotion) { case C1E_PROMOTION_DISABLE: on_selected_cpus(cpumask_of(cpu), c1e_promotion_disable, NULL, 1); break; @@ -1732,11 +1731,11 @@ static int cf_check mwait_idle_cpu_init( =20 dev->count =3D 1; =20 - for (cstate =3D 0; cpuidle_state_table[cstate].target_residency; ++cstate= ) { + for (cstate =3D 0; icpu.state_table[cstate].target_residency; ++cstate) { unsigned int num_substates, hint, state; struct acpi_processor_cx *cx; =20 - hint =3D flg2MWAIT(cpuidle_state_table[cstate].flags); + hint =3D flg2MWAIT(icpu.state_table[cstate].flags); state =3D MWAIT_HINT2CSTATE(hint) + 1; =20 if (state > max_cstate()) { @@ -1752,10 +1751,10 @@ static int cf_check mwait_idle_cpu_init( continue; =20 /* if state marked as disabled, skip it */ - if (cpuidle_state_table[cstate].flags & + if (icpu.state_table[cstate].flags & CPUIDLE_FLAG_DISABLED) { printk(XENLOG_DEBUG PREFIX "state %s is disabled\n", - cpuidle_state_table[cstate].name); + icpu.state_table[cstate].name); continue; } =20 @@ -1773,15 +1772,15 @@ static int cf_check mwait_idle_cpu_init( cx->type =3D state; cx->address =3D hint; cx->entry_method =3D ACPI_CSTATE_EM_FFH; - cx->latency =3D cpuidle_state_table[cstate].exit_latency; + cx->latency =3D icpu.state_table[cstate].exit_latency; cx->target_residency =3D - cpuidle_state_table[cstate].target_residency; - if ((cpuidle_state_table[cstate].flags & + icpu.state_table[cstate].target_residency; + if ((icpu.state_table[cstate].flags & CPUIDLE_FLAG_IRQ_ENABLE) && /* cstate_restore_tsc() needs to be a no-op */ boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) cx->irq_enable_early =3D true; - if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IBRS) + if (icpu.state_table[cstate].flags & CPUIDLE_FLAG_IBRS) cx->ibrs_disable =3D true; =20 dev->count++; @@ -1822,7 +1821,7 @@ int __init mwait_idle_init(struct notifi =20 void mwait_idle_resume(void) { - if (!icpu) + if (!icpu.state_table) return; =20 mwait_idle_cpu_tweak(smp_processor_id(), true); From nobody Sat May 30 11:15:02 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=1778600243; cv=none; d=zohomail.com; s=zohoarc; b=hyXnDWm3gdrTD83jQAdHIIVZpr7iiox3ApQizW3t0kh+Fkjvv03vOOtpUI5ciP9ARbr9ZfLU5asAzRpqMdXlToBZDWqCgnyldtbQhvS2MKFH03fdNE0qacBfZ+iH0RkR+lNBNVGBow2dNFmGDu/rm+fTnS9xYuiS+xoevNkDHOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778600243; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Oi+Og7lmHi8fzPQHLlkJ8CT1xlB+s06Eq97nVFSpVO8=; b=hEz8bJx3mjgbQzo2ixAn3CN+H2fpJNjVo8e6rrPrV6xViVbho/ftC1lkzrcEAuMceRrlhBB5WCB2GE85hRmbJ4jBl0V7OQ6S2zNH4iwpOdXpd0p8g82OtLX4hHffrypzhHMM5rDlhMoObAAtPAVK28ydByS8rbY2Ep5Kc56YeKQ= 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 1778600243894453.6743358412623; Tue, 12 May 2026 08:37:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1307009.1578747 (Exim 4.92) (envelope-from ) id 1wMpAB-0004Gq-S7; Tue, 12 May 2026 15:36:51 +0000 Received: by outflank-mailman (output) from mailman id 1307009.1578747; Tue, 12 May 2026 15:36:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpAB-0004Gj-Og; Tue, 12 May 2026 15:36:51 +0000 Received: by outflank-mailman (input) for mailman id 1307009; Tue, 12 May 2026 15:36:50 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpAA-0004G2-47 for xen-devel@lists.xenproject.org; Tue, 12 May 2026 15:36:50 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMpA9-00AM4u-H4 for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:36:49 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a034911-bab6-0a2a0a5309dd-0a2a4508c200-0 for ; Tue, 12 May 2026 17:36:49 +0200 Received: from [209.85.128.41] (helo=mail-wm1-f41.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a034911-63b5-0a2a45080019-d1558029e984-3 for ; Tue, 12 May 2026 17:36:49 +0200 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4891d7164ddso32279685e9.3 for ; Tue, 12 May 2026 08:36:49 -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 5b1f17b1804b1-48fc8d15e09sm5653765e9.3.2026.05.12.08.36.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 08:36:48 -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:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778600209; x=1779205009; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=Oi+Og7lmHi8fzPQHLlkJ8CT1xlB+s06Eq97nVFSpVO8=; b=IeH7ecdVEaaBi/1qTxUZOeRvkKadcscVEzGutApZIKleWkrxDQwM64SWyfQKny54z9 9QQA7WxJFgh81G5NUFcMo7xdxtCjkN6Ao7YAG1MTDEgrwFb6egSmclvbryI+cHDRCuyA q7gA93TxmF8UANSu8rWdPxQsHe2M2+kOS/SyODjPAt/4w8/4AAd+w7B7AesxLnnEJ4Fr 1DPhiYHsIMtBHJ3kBWjcSFrI4r8FI64lXf5C1Sx77X5w111bdSPve7OjLtWNJQY8E2BE fwrfN3B7PWk52RR9lG7SMrA+LmAMfsMQ2OYiU2ff2AO9H4zr6wtPOKbjm9MNbFXUegXa XdiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778600209; x=1779205009; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Oi+Og7lmHi8fzPQHLlkJ8CT1xlB+s06Eq97nVFSpVO8=; b=LWvEFBwEjjz4puR9jTHvcUhfJ2O8Y+MQN2494cBwqesK28GDWgvUTgtZ+Z0MVWVtQj BIdASPpspN6Il+sKsZrZbEagt1U8mj9oDZlDViFy+elLplN6RWMePQf1vQRsh266MDbT bT8IqpoAD5mo60axpyxk3RU8i3M8ehUHEZkqpkuAws8KbfwH9odhQt+FaqG52KPLRkYc cp5S/X0SrVEtxQ3gCswuG75ne41PVvYv+mGF9n986qhqOMOKqhPs4zW4VXTyXEaMPeuB WnKUTnxGJ1eduZPbQetbCqXniM7hElF1BPTyHsj3ifraQ3bG4B9GMBWfxr37RtW5pxxG 9xWA== X-Gm-Message-State: AOJu0YyP+RTAsCj+B8BnD8bsfOElgEw/Gxve1pS4COocYqaHXyxNpTAB jF5/Oie2Yiy20QREWNMTpeEfdiaZ94YZyfAo/vOqHNq3azq65/AgMAiMFTw/yU27WC6Ht89pGTU CqFk= X-Gm-Gg: Acq92OHJ5mNRsb+xXimGwQK4jajjFqT/XTCjgMHDvknrmNv+i8cmROCylWVZw4hs4sR HvJgG9xJNmePgoaKLsem9smjLhnT7EstxLzQUdDoLeXZCGjSStqHNTS3zMqO/KVtFilH7VHUtpO Whn0EU5WRhSYgLSfyWVZjEfknhWQW5cFgywDc8vCtk8wNkSeszbEzKJ4+op5BZFlVSn1IjIgdei hRBq3phHua1PjrXHPgv9E/tz8DYMjLMYttfqtt/mY2sTUH/8prUJnTQLk213idnho8h+fSRgvfE 7pZyB8ETaG4bAWWBCYc4XM9el5iK0OMzsUG/QaIlLtIQVY8DBa5YMa29xVQPZgfCJ2tLbWnq/4K qt4aiIYkLk/k1ikt1hEYJCkTcvfTDFKuWujQeHdvIiaeGVXHtSlqx/vGK9IapL/hZQOVSzF88+9 zEi86jw7OgFzBeBEQ178ddHzfOmLca0ZegSNxvSxMzzR8Tl+CD7CAZGGpEA8s3fYPL9sivV5UL2 PoZizrmvu6T+og= X-Received: by 2002:a05:600c:6290:b0:485:3f30:6250 with SMTP id 5b1f17b1804b1-48e51f3fd58mr510167455e9.20.1778600208885; Tue, 12 May 2026 08:36:48 -0700 (PDT) Message-ID: <2e8a4a74-fae9-4c75-aa98-f4b0dc7ac6bf@suse.com> Date: Tue, 12 May 2026 17:36:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.22 v2 4/8] x86/mwait-idle: move pre-initialized struct idle_cpu instances From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> 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 In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1778600209-BCD63DB1-4E30620E/0/0 X-purgate-type: clean X-purgate-size: 5568 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778600246327154100 Now that they're not referenced anymore post-init, they can themselves move into .init.rodata. (idle_cpu_adl{,_l} can also become const in the first place.) Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -1167,132 +1167,132 @@ static void cf_check c1e_promotion_disab wrmsrl(MSR_IA32_POWER_CTL, msr_bits); } =20 -static const struct idle_cpu idle_cpu_nehalem =3D { +static const struct idle_cpu __initconstrel idle_cpu_nehalem =3D { .state_table =3D nehalem_cstates, .auto_demotion_disable_flags =3D NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_atom =3D { +static const struct idle_cpu __initconstrel idle_cpu_atom =3D { .state_table =3D atom_cstates, }; =20 -static const struct idle_cpu idle_cpu_tangier =3D { +static const struct idle_cpu __initconstrel idle_cpu_tangier =3D { .state_table =3D tangier_cstates, }; =20 -static const struct idle_cpu idle_cpu_lincroft =3D { +static const struct idle_cpu __initconstrel idle_cpu_lincroft =3D { .state_table =3D atom_cstates, .auto_demotion_disable_flags =3D ATM_LNC_C6_AUTO_DEMOTE, }; =20 -static const struct idle_cpu idle_cpu_snb =3D { +static const struct idle_cpu __initconstrel idle_cpu_snb =3D { .state_table =3D snb_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_byt =3D { +static const struct idle_cpu __initconstrel idle_cpu_byt =3D { .state_table =3D byt_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_cht =3D { +static const struct idle_cpu __initconstrel idle_cpu_cht =3D { .state_table =3D cht_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_ivb =3D { +static const struct idle_cpu __initconstrel idle_cpu_ivb =3D { .state_table =3D ivb_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_ivt =3D { +static const struct idle_cpu __initconstrel idle_cpu_ivt =3D { .state_table =3D ivt_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_hsw =3D { +static const struct idle_cpu __initconstrel idle_cpu_hsw =3D { .state_table =3D hsw_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_bdw =3D { +static const struct idle_cpu __initconstrel idle_cpu_bdw =3D { .state_table =3D bdw_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_skl =3D { +static const struct idle_cpu __initconstrel idle_cpu_skl =3D { .state_table =3D skl_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_skx =3D { +static const struct idle_cpu __initconstrel idle_cpu_skx =3D { .state_table =3D skx_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_icx =3D { +static const struct idle_cpu __initconstrel idle_cpu_icx =3D { .state_table =3D icx_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static struct idle_cpu __ro_after_init idle_cpu_adl =3D { +static const struct idle_cpu __initconstrel idle_cpu_adl =3D { .state_table =3D adl_cstates, }; =20 -static struct idle_cpu __ro_after_init idle_cpu_adl_l =3D { +static const struct idle_cpu __initconstrel idle_cpu_adl_l =3D { .state_table =3D adl_l_cstates, }; =20 -static const struct idle_cpu idle_cpu_mtl_l =3D { +static const struct idle_cpu __initconstrel idle_cpu_mtl_l =3D { .state_table =3D mtl_l_cstates, }; =20 -static const struct idle_cpu idle_cpu_gmt =3D { +static const struct idle_cpu __initconstrel idle_cpu_gmt =3D { .state_table =3D gmt_cstates, }; =20 -static const struct idle_cpu idle_cpu_spr =3D { +static const struct idle_cpu __initconstrel idle_cpu_spr =3D { .state_table =3D spr_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_gnr =3D { +static const struct idle_cpu __initconstrel idle_cpu_gnr =3D { .state_table =3D gnr_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_gnrd =3D { +static const struct idle_cpu __initconstrel idle_cpu_gnrd =3D { .state_table =3D gnrd_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_avn =3D { +static const struct idle_cpu __initconstrel idle_cpu_avn =3D { .state_table =3D avn_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_bxt =3D { +static const struct idle_cpu __initconstrel idle_cpu_bxt =3D { .state_table =3D bxt_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_dnv =3D { +static const struct idle_cpu __initconstrel idle_cpu_dnv =3D { .state_table =3D dnv_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_snr =3D { +static const struct idle_cpu __initconstrel idle_cpu_snr =3D { .state_table =3D snr_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_grr =3D { +static const struct idle_cpu __initconstrel idle_cpu_grr =3D { .state_table =3D grr_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; =20 -static const struct idle_cpu idle_cpu_srf =3D { +static const struct idle_cpu __initconstrel idle_cpu_srf =3D { .state_table =3D srf_cstates, .c1e_promotion =3D C1E_PROMOTION_DISABLE, }; From nobody Sat May 30 11:15:02 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=1778600254; cv=none; d=zohomail.com; s=zohoarc; b=bEUcd0B6clGASL9APW2iE6iZO+xi64sZslzKnRlHGveFldOtXhP0Kz9WhL0+dc9R5KEVF2E3EEZR7L8qlmi7+feqYWSG3H0GsVpYo/3wlPeRzA61WkK3TroY2NCW2aqj1UkCZ+4vhx+f4a3ZVxLHJeqLBLJ4tHHoRrM2LiyJEH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778600254; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/VtB2qT+5tGhAJA0XOdWRU5yzj8hriXeFmDZ5tClNyo=; b=RpYO+7We0zsXT3RQboGw1pm5f7AQakXUeyrZC3sfvEUqnifuzm4Br0le8g5RfGJekZch95+O+kNgKs938BH+oSZrvY89Z1+MZmwyeliZOqp1iV3+DCOBUp1OOjqKpvPhLfvaq9uf4Y+cm8kifLJLquCWILLyyKpnV/vnBhU1HW0= 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 1778600254492444.65987806821045; Tue, 12 May 2026 08:37:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1307018.1578756 (Exim 4.92) (envelope-from ) id 1wMpAZ-0004r9-2k; Tue, 12 May 2026 15:37:15 +0000 Received: by outflank-mailman (output) from mailman id 1307018.1578756; Tue, 12 May 2026 15:37:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpAY-0004r2-Vq; Tue, 12 May 2026 15:37:14 +0000 Received: by outflank-mailman (input) for mailman id 1307018; Tue, 12 May 2026 15:37:14 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpAY-0004oR-0U for xen-devel@lists.xenproject.org; Tue, 12 May 2026 15:37:14 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMpAX-00AQoL-D1 for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:37:13 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a034925-2eae-0a2a0a5409dd-0a2a4503e522-12 for ; Tue, 12 May 2026 17:37:13 +0200 Received: from [209.85.221.46] (helo=mail-wr1-f46.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a034929-672d-0a2a45030019-d155dd2ed03a-3 for ; Tue, 12 May 2026 17:37:13 +0200 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-44ccbd3290aso4535273f8f.2 for ; Tue, 12 May 2026 08:37:13 -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-4548bb51d40sm32522460f8f.0.2026.05.12.08.37.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 08:37:12 -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:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778600233; x=1779205033; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=/VtB2qT+5tGhAJA0XOdWRU5yzj8hriXeFmDZ5tClNyo=; b=eyMCK0YumD1+VYVREb5HreMpqJbHb940yNpvNgkyh/rJeAiJn2SNnOlMWnJ+Hpek4N s+/UbCfcgLbQAMnjNItYvBzd1QNgAt6yTmDCT7Pdk4bZYDO9zbCYI2/Hijm+eMhzoN+B n7/xZ58Aa8v334+sQiXtVg07nUMw7SsXbB5k9wOFwFPL9b9SBTJ1veCVjIb9Fex+yJTt ipojpEDqJtBCOz8dPqIXPmfl39kXvf1JOvoR5/5XJhKDvoezP8odlT5K56SaQDvHsU2k PCKrGEnAQe0vac1au7oAU8WnnBgiVVvBjoCkdKTZjxYijrENNzMnuOwLnvTKouQxPOwb HqGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778600233; x=1779205033; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/VtB2qT+5tGhAJA0XOdWRU5yzj8hriXeFmDZ5tClNyo=; b=mjb0yhYSoFNNFnVWGHygU2AuqGGpnCwY33x+LNw9+hcQYsI3wRgdV2wapy70y/LjpF YM2zDL0ceT6YjEib+3iSHmd3nNE14vqbus3g18eU7L/v1/ZU8N+1zBST6+pE64JexOwC 1fJZ97SQidEsNyV63hGytCpFUxLEYK7K8suPrZYOHfWZ3kp250tDx8WxNf0dzlr46S/G iV02tmOAJ5TEVr861KUnKQmvzOjzRBAhnpCQzrirefSuynNWVNWnHLLbUMbTPgj0QFg0 QGN7aGNVsw7lxN8Wd6BGNMGdMg4+vinueeuYpePY8luLb+ZUPjFeavX7ZDL/uFlq9e1V y57Q== X-Gm-Message-State: AOJu0Yz+Y8bxkZajTMiR+FNOi+0FgPNOz0T1UeTXXqKdka9gjeTGuHHv RJGejv8Ao7wzBz4iXDdxtL4B7ebzDEBmnzTWsXNYwXIidfwDlDNwNYED8XLyHwswKSxkLNM9zTX sEcw= X-Gm-Gg: Acq92OE9FxajBBCWYTZo1QAr1DilxCxAp15wzWuQ8MTqj0U2k+lzHRWpBQGS8VXN4Yj T4AUJIDDkfMOaMZA6IuR3CKraACJDHVzBndrnISZ9OcNM6rzdUNTVNhgeJO/N60DkS/IES1km1z mVYLCnJmrxVoiSntG7n14hPp1A6JhwaeE+3IWeSoTmvbY843pNBDN3w+ifxiZ/jXkhick2ZJe4q ZBNe9tcqaKI20LUKwBrdX2XBu+4bmeJRI56LCGpM0FFoaqG1DAa+qKaIzOAuZw6f2zb/cDphYg7 ihsBdHXlkg/Fsf5cnsDpwplFOJLsq3Cv+vFd6FnfYkl2RXvRoBSat6lq/YRilQzdWnsqZiKXDY+ bz3eDRgd42VyHnhfMO4xbcIy+Kvm9z02uePyEbN28mcl1SbBYJ/unUf3fLJCetPAIaqwfGsMLJP s/sxzZA9EYwiS6zDYwdWDYCyfzeeRbWudaaL9SxDGYp4fFrytSTedOhCvRblehrlyIIYjLduC8I t/CTmiepLf730nYMABt1WcQPA== X-Received: by 2002:a05:6000:4287:b0:43d:70de:1c70 with SMTP id ffacd0b85a97d-45b13e55369mr4966799f8f.32.1778600232697; Tue, 12 May 2026 08:37:12 -0700 (PDT) Message-ID: <70787b38-b656-4259-a496-0d0545fa98ba@suse.com> Date: Tue, 12 May 2026 17:37:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.22 v2 5/8] x86/mwait-idle: Remove the 'preferred_cstates' parameter From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> 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 In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1778600233-3B161938-09C28C5E/0/0 X-purgate-type: clean X-purgate-size: 5567 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778600256767158500 From: Artem Bityutskiy Remove the 'preferred_cstates' module parameter as it is not really useful. The parameter currently only affects Alder Lake, where it controls C1/C1E preference, with C1E being the default. The parameter does not support any other platform. For example, Meteor Lake has a similar C1/C1E limitation, but the parameter does not support Meteor Lake. This indicates that the parameter is not very useful. Generally, independent C1 and C1E are important for server platforms where low latency is key. However, they are not as important for client platforms, like Alder Lake, where C1E providing better energy savings is generally preferred. The parameter was originally introduced for Sapphire Rapids Xeon: da0e58c038e6 intel_idle: add 'preferred_cstates' module argument Later it was added to Alder Lake: d1cf8bbfed1ed ("intel_idle: Add AlderLake support") But it was removed from Sapphire Rapids when firmware fixed the C1/C1E limitation: 1548fac47a114 ("intel_idle: make SPR C1 and C1E be independent") So Alder Lake is the only platform left where this parameter has any effect. Remove this parameter to simplify the driver and reduce maintenance burden. Signed-off-by: Artem Bityutskiy Link: https://patch.msgid.link/20251215111300.132803-1-dedekind1@gmail.com Signed-off-by: Rafael J. Wysocki Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a3= 6dc37b5672 Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2071,12 +2071,6 @@ compression is selected at build time fr ### ple_window (Intel) > `=3D ` =20 -### preferred-cstates (x86) -> `=3D ( | List of ( C1 | C1E | C2 | ... )` - -This is a mask of C-states which are to be used preferably. This option is -applicable only on hardware were certain C-states are exclusive of one ano= ther. - ### probe-port-aliases (x86) > `=3D ` =20 --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -72,19 +72,6 @@ boolean_param("mwait-idle", opt_mwait_id =20 static unsigned int mwait_substates; =20 -/* - * Some platforms come with mutually exclusive C-states, so that if one is - * enabled, the other C-states must not be used. Example: C1 and C1E on - * Sapphire Rapids platform. This parameter allows for selecting the - * preferred C-states among the groups of mutually exclusive C-states - the - * selected C-states will be registered, the other C-states from the mutua= lly - * exclusive group won't be registered. If the platform has no mutually - * exclusive C-states, this parameter has no effect. - */ -static unsigned int __ro_after_init preferred_states_mask; -static char __initdata preferred_states[64]; -string_param("preferred-cstates", preferred_states); - #define LAPIC_TIMER_ALWAYS_RELIABLE 0xFFFFFFFF /* Reliable LAPIC Timer States, bit 1 for C1 etc. Default to only C1. */ static unsigned int lapic_timer_reliable_states =3D (1 << 1); @@ -1512,28 +1499,6 @@ static void __init skx_idle_state_table_ } =20 /* - * adl_idle_state_table_update - Adjust AlderLake idle states table. - */ -static void __init adl_idle_state_table_update(void) -{ - /* Check if user prefers C1 over C1E. */ - if ((preferred_states_mask & BIT(1, U)) && - !(preferred_states_mask & BIT(2, U))) { - adl_cstates[0].flags &=3D ~CPUIDLE_FLAG_DISABLED; - adl_cstates[1].flags |=3D CPUIDLE_FLAG_DISABLED; - adl_l_cstates[0].flags &=3D ~CPUIDLE_FLAG_DISABLED; - adl_l_cstates[1].flags |=3D CPUIDLE_FLAG_DISABLED; - - /* Disable C1E by clearing the "C1E promotion" bit. */ - icpu.c1e_promotion =3D C1E_PROMOTION_DISABLE; - return; - } - - /* Make sure C1E is enabled by default */ - icpu.c1e_promotion =3D C1E_PROMOTION_ENABLE; -} - -/* * spr_idle_state_table_update - Adjust Sapphire Rapids idle states table. */ static void __init spr_idle_state_table_update(void) @@ -1579,11 +1544,6 @@ static void __init mwait_idle_state_tabl case INTEL_EMERALDRAPIDS_X: spr_idle_state_table_update(); break; - case INTEL_ALDERLAKE: - case INTEL_ALDERLAKE_L: - case INTEL_ATOM_GRACEMONT: - adl_idle_state_table_update(); - break; } } =20 @@ -1592,7 +1552,6 @@ static int __init mwait_idle_probe(void) unsigned int eax, ebx, ecx; const struct x86_cpu_id *id; const struct idle_cpu *idle_cpu; - const char *str; =20 if (boot_cpu_data.vendor !=3D X86_VENDOR_INTEL) return -ENODEV; @@ -1635,39 +1594,6 @@ static int __init mwait_idle_probe(void) pr_debug(PREFIX "lapic_timer_reliable_states %#x\n", lapic_timer_reliable_states); =20 - str =3D preferred_states; - if (isdigit(str[0])) - preferred_states_mask =3D simple_strtoul(str, &str, 0); - else if (str[0]) - { - const char *ss; - - do { - const struct cpuidle_state *state =3D idle_cpu->state_table; - unsigned int bit =3D 1; - - ss =3D strchr(str, ','); - if (!ss) - ss =3D strchr(str, '\0'); - - for (; state->name[0]; ++state) { - bit <<=3D 1; - if (!cmdline_strcmp(str, state->name)) { - preferred_states_mask |=3D bit; - break; - } - } - if (!state->name[0]) - break; - - str =3D ss + 1; - } while (*ss); - - str -=3D str =3D=3D ss + 1; - } - if (str[0]) - printk("unrecognized \"preferred-cstates=3D%s\"\n", str); - mwait_idle_state_table_update(); =20 return 0; From nobody Sat May 30 11:15:02 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=1778600288; cv=none; d=zohomail.com; s=zohoarc; b=QAx2TjuSksfcB4UzPZERgpgS2fdMkVg1l3fb/+1zpsjsw/5F+3DHVvvAHEqIOLhqUuRT2q2bf1h2ZIcp17V8gL/TK3yMVLOS/6q76oTcncdKlnRdO5WtyCCyIVuWk6y8ykzZ+PNFBaH19o4q3APUmmU5vvJueiDwYzGMWKb3C1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778600288; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xN4esOL29pmrNzImPmRnozsyDtFvl0psKxBdCZmg1fA=; b=Ycnj9XzA5eGS7h6iKAhonp5aM67iGZUsNgZ/kakmOE5PF1WVMeMPI9btZzGwbXUqMn5zxseHRtKheSjEJwU+OE0hm3onfodl8iBEAA9LJx8NXtMDp0DEUd6vPdNJy5oF8ca23RXS7ECW+7NbL6/RHQuNL69DLme41Bif4/wFp+I= 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 1778600288930272.95868945389725; Tue, 12 May 2026 08:38:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1307026.1578764 (Exim 4.92) (envelope-from ) id 1wMpAx-0005Tb-9k; Tue, 12 May 2026 15:37:39 +0000 Received: by outflank-mailman (output) from mailman id 1307026.1578764; Tue, 12 May 2026 15:37:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpAx-0005TU-6k; Tue, 12 May 2026 15:37:39 +0000 Received: by outflank-mailman (input) for mailman id 1307026; Tue, 12 May 2026 15:37:38 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpAw-0005Ov-5K for xen-devel@lists.xenproject.org; Tue, 12 May 2026 15:37:38 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMpAv-00BBxs-I1 for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:37:37 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a034938-bab6-0a2a0a5309dd-0a2a45098220-34 for ; Tue, 12 May 2026 17:37:37 +0200 Received: from [209.85.221.50] (helo=mail-wr1-f50.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a034941-2497-0a2a45090019-d155dd32c877-3 for ; Tue, 12 May 2026 17:37:37 +0200 Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-43d77f6092eso3543632f8f.2 for ; Tue, 12 May 2026 08:37:37 -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-454922715b9sm35519829f8f.36.2026.05.12.08.37.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 08:37:36 -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:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778600257; x=1779205057; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=xN4esOL29pmrNzImPmRnozsyDtFvl0psKxBdCZmg1fA=; b=TEPcNpsP4D6Z4BnCyhRYfgAm/HsA5F83A53KIdnq0ABQn5gjUXgSkH2n5CtE718BoZ pdB/K6ODzbXjfG217/EraXCRP9JFoLsxvsFI4Uv+jc8YmFUD5J9ea1LyluHubGQ+SP8V BC/cx1LYN2tDUjsrhqva/Ry49ofTOZ5tk3lDShv4BSh+p2A2mYzu+iy8rW3uL5sGHKCx 2tiDUpIKQC6aI4Qr1VdDBBY8v8ZsFjRBf2cV2jXUjqew2viqQmoT07mskTLKiJ7ylDO8 goPT2HHZZWocH1CZfsUtesfwIjRKu6QDIn6LCKVM4FpI5Th1kkrWimC0rPuxq3JUyfG7 YQzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778600257; x=1779205057; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xN4esOL29pmrNzImPmRnozsyDtFvl0psKxBdCZmg1fA=; b=DUarif0K5Ow6oW1xtLK8sWXBr0LuYVx/pP0JZ/RpuJanONKClvPK1oJ3bjPI5GmQCT 0ub7xzM28dNcvA17xLaa9hG4xjK+ZOp1s1G4QzznVbGvfeQue/Flx1F6GtVuthAJNghN Sh5fhHURARpqX/HaeeRQAypgi8Zy1URKvkOwoVB8eKVInbEOV+GB0XDwHhPZ7MPqQFHb rsT1ypez/B0Z/F0nUw8TI8RSmfQYcIKBRfpEmy/GrUd9oECkIw5FdGaHvS1elc7bsIv4 F5+nmEcqUgn0g6TieC/zP83h4yWpNTA9miLuiL+6qZhF5P759cot4oayrRuEY66XDti4 3kIg== X-Gm-Message-State: AOJu0Yynb9aIxh/BJi33E94Jx2GAQMA6yrvKwYgIU4IbxZx3+Fn7pj1z Lr7HDVknYKXJ62STAqIxejo4M5tQX+qD/xHJgp8wPXxma2a2vh9MZWgkV0s47PMjteXRxkgovYr 8G00= X-Gm-Gg: Acq92OH/afjSxEDlK3aVGXyM7xvSWOu/QvYomDJmAScT5djr/DHPITpTEfB2iNJ1wrw Ji509PSGe+Bzh94/5HVh+vUZ7HBxU7KZSCaAqxhkUd0qPhZkI24FrIVI4Hnf/U5jTPhygRray7O by+a3m7uv53ohOZjhrdZgJnGwBQBUnnKuilAdTjiA0ya47qBeDpZ41Epk/MKwzSJeqAVEUqrAZf /fbhm6Ytr7WnQczG7t6hUx35DFP/8AFJmlAWMGpiivq7ZRHQ8DQJBHU5nCMFsWtlJLmvARxRMBh GELIfwttTREaCJpYwa5hODu6oBRh8UJdlMIQQq6duqFzqaIVsngMAjpf+J11cWaU8W6aP/bub2k 8qQffUUy15SXHw8+9qRJ6NjA+toDxlPhviqYVpkbgtrTW5VqmJESx7xQ1joFmXaY4jgbM+FBVJ2 LrMBrmeuXJI7+Z5HBEH7VtolggTp7FdRRicqpvDD9JIJN8/YccRk3u2z/4TjU8iBncz0YiXA0QC i+dAL7iNLj6FcY= X-Received: by 2002:a5d:5e01:0:b0:43f:dc54:9493 with SMTP id ffacd0b85a97d-45b14adc2cemr5530776f8f.21.1778600256958; Tue, 12 May 2026 08:37:36 -0700 (PDT) Message-ID: Date: Tue, 12 May 2026 17:37:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.22 v2 6/8] x86/mwait-idle: drop const from struct cpuidle_state arrays From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> 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 In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1778600257-40D67A53-BB1F923F/0/0 X-purgate-type: clean X-purgate-size: 6280 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778600291192158500 A subsequent change will want to be able to alter them based on a new command line option. (Note that some were __ro_after_init already.) Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -83,7 +83,7 @@ enum c1e_promotion { }; =20 struct idle_cpu { - const struct cpuidle_state *state_table; + struct cpuidle_state *state_table; =20 /* * Hardware C-state auto-demotion may not always be optimal. @@ -139,7 +139,7 @@ struct cpuidle_state { * which is also the index into the MWAIT hint array. * Thus C0 is a dummy. */ -static const struct cpuidle_state nehalem_cstates[] =3D { +static struct cpuidle_state __ro_after_init nehalem_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -167,7 +167,7 @@ static const struct cpuidle_state nehale {} }; =20 -static const struct cpuidle_state snb_cstates[] =3D { +static struct cpuidle_state __ro_after_init snb_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -201,7 +201,7 @@ static const struct cpuidle_state snb_cs {} }; =20 -static const struct cpuidle_state byt_cstates[] =3D { +static struct cpuidle_state __ro_after_init byt_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -235,7 +235,7 @@ static const struct cpuidle_state byt_cs {} }; =20 -static const struct cpuidle_state cht_cstates[] =3D { +static struct cpuidle_state __ro_after_init cht_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -269,7 +269,7 @@ static const struct cpuidle_state cht_cs {} }; =20 -static const struct cpuidle_state ivb_cstates[] =3D { +static struct cpuidle_state __ro_after_init ivb_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -303,7 +303,7 @@ static const struct cpuidle_state ivb_cs {} }; =20 -static const struct cpuidle_state ivt_cstates[] =3D { +static struct cpuidle_state __ro_after_init ivt_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -331,7 +331,7 @@ static const struct cpuidle_state ivt_cs {} }; =20 -static const struct cpuidle_state ivt_cstates_4s[] =3D { +static struct cpuidle_state __ro_after_init ivt_cstates_4s[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -359,7 +359,7 @@ static const struct cpuidle_state ivt_cs {} }; =20 -static const struct cpuidle_state ivt_cstates_8s[] =3D { +static struct cpuidle_state __ro_after_init ivt_cstates_8s[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -387,7 +387,7 @@ static const struct cpuidle_state ivt_cs {} }; =20 -static const struct cpuidle_state hsw_cstates[] =3D { +static struct cpuidle_state __ro_after_init hsw_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -439,7 +439,7 @@ static const struct cpuidle_state hsw_cs {} }; =20 -static const struct cpuidle_state bdw_cstates[] =3D { +static struct cpuidle_state __ro_after_init bdw_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -565,7 +565,7 @@ static struct cpuidle_state __ro_after_i {} }; =20 -static const struct cpuidle_state icx_cstates[] =3D { +static struct cpuidle_state __ro_after_init icx_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00) | CPUIDLE_FLAG_IRQ_ENABLE, @@ -665,7 +665,7 @@ static struct cpuidle_state __ro_after_i {} }; =20 -static const struct cpuidle_state mtl_l_cstates[] =3D { +static struct cpuidle_state __ro_after_init mtl_l_cstates[] =3D { { .name =3D "C1E", .flags =3D MWAIT2flg(0x01), @@ -687,7 +687,7 @@ static const struct cpuidle_state mtl_l_ {} }; =20 -static const struct cpuidle_state gmt_cstates[] =3D { +static struct cpuidle_state __ro_after_init gmt_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00) | CPUIDLE_FLAG_DISABLED, @@ -743,7 +743,7 @@ static struct cpuidle_state __ro_after_i {} }; =20 -static const struct cpuidle_state gnr_cstates[] =3D { +static struct cpuidle_state __ro_after_init gnr_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -771,7 +771,7 @@ static const struct cpuidle_state gnr_cs {} }; =20 -static const struct cpuidle_state gnrd_cstates[] =3D { +static struct cpuidle_state __ro_after_init gnrd_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -799,7 +799,7 @@ static const struct cpuidle_state gnrd_c {} }; =20 -static const struct cpuidle_state atom_cstates[] =3D { +static struct cpuidle_state __ro_after_init atom_cstates[] =3D { { .name =3D "C1E", .flags =3D MWAIT2flg(0x00), @@ -827,7 +827,7 @@ static const struct cpuidle_state atom_c {} }; =20 -static const struct cpuidle_state tangier_cstates[] =3D { +static struct cpuidle_state __ro_after_init tangier_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -861,7 +861,7 @@ static const struct cpuidle_state tangie {} }; =20 -static const struct cpuidle_state avn_cstates[] =3D { +static struct cpuidle_state __ro_after_init avn_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -923,7 +923,7 @@ static struct cpuidle_state __ro_after_i {} }; =20 -static const struct cpuidle_state dnv_cstates[] =3D { +static struct cpuidle_state __ro_after_init dnv_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -949,7 +949,7 @@ static const struct cpuidle_state dnv_cs * Note, depending on HW and FW revision, SnowRidge SoC may or may not sup= port * C6, and this is indicated in the CPUID mwait leaf. */ -static const struct cpuidle_state snr_cstates[] =3D { +static struct cpuidle_state __ro_after_init snr_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -971,7 +971,7 @@ static const struct cpuidle_state snr_cs {} }; =20 -static const struct cpuidle_state grr_cstates[] =3D { +static struct cpuidle_state __ro_after_init grr_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), @@ -993,7 +993,7 @@ static const struct cpuidle_state grr_cs {} }; =20 -static const struct cpuidle_state srf_cstates[] =3D { +static struct cpuidle_state __ro_after_init srf_cstates[] =3D { { .name =3D "C1", .flags =3D MWAIT2flg(0x00), From nobody Sat May 30 11:15:02 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=1778600315; cv=none; d=zohomail.com; s=zohoarc; b=RuwQI7FUZiLKFn5zblFNQqRVtifIkboQNtZmupEL1IDfPBU0Hy6hqBfiUA+ZQzCxYn1R2GAo3jlEW1BCHV5krBF8m/HJ+y8kG0yQrwqVZ7a6UNtgHieADTKbO/fp84SnYlZ8+ecU8xQ3Q60e9dqzrs5fbWnnV0Ion6j6RpiHi2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778600315; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h9wUOSHCkf5lnhgbGUcgfm3/6j74fw4Q/KRVFYcRtW4=; b=c7MfhiLR1mJiM8sucOBCJw1U6UmYunEP7QlfIX7Fve8u9AZYfTYsNsIl2CyK9sxtHmrudguR4mqe8aHqeFr0KLQDofjuU3660RipG5nOgtSKjXRS5p2syNdKzkgbM8+R2ktx/dendRVac9qOqaPUvnLflw4y7bKco4yoOQ3GAZo= 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 1778600315725864.5442902837402; Tue, 12 May 2026 08:38:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1307035.1578774 (Exim 4.92) (envelope-from ) id 1wMpBT-0006PN-Jf; Tue, 12 May 2026 15:38:11 +0000 Received: by outflank-mailman (output) from mailman id 1307035.1578774; Tue, 12 May 2026 15:38:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpBT-0006PF-Gw; Tue, 12 May 2026 15:38:11 +0000 Received: by outflank-mailman (input) for mailman id 1307035; Tue, 12 May 2026 15:38:10 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpBS-0006Ni-GJ for xen-devel@lists.xenproject.org; Tue, 12 May 2026 15:38:10 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMpBR-00F2s1-TJ for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:38:09 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a03495f-2eae-0a2a0a5409dd-0a2a45048ee0-10 for ; Tue, 12 May 2026 17:38:09 +0200 Received: from [209.85.128.41] (helo=mail-wm1-f41.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a034961-1dec-0a2a45040019-d1558029ad43-3 for ; Tue, 12 May 2026 17:38:09 +0200 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4891c0620bcso40444275e9.1 for ; Tue, 12 May 2026 08:38:09 -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 5b1f17b1804b1-48fc8d1f669sm5321055e9.4.2026.05.12.08.38.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 08:38:08 -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:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778600289; x=1779205089; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=h9wUOSHCkf5lnhgbGUcgfm3/6j74fw4Q/KRVFYcRtW4=; b=cLAvyYBmOb7ukEJtmSwWtAWeOhvmFQcVIb+xdJEi1898IqK8ob1j5lWF0yItfMhLPI 5DoRsnPhfwmLHfoC9hf47T5CNfpMlLpCrLIw7H6mk7SCG5UJ0SB40VxP9P7dhZ8f3Vbm 3xZenzr6pCOx2qmddfUG9Qa6lo25VglXNYLZNjASItyU2IXAViGvKgcnVEYRpMdbWIE3 6WX/ecwKJ5Ize1Y845CUxfKz0qbMmXi8mcBJ+V0hcnzfSgQd8ojckJ9oLdBth7YyIJl5 82RoJGQjR2oTwmBJUmkyYtyk588FWBIFwPpFWWoLCmYFTdFm0awlVnFGhuayq+5oDiFV YTSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778600289; x=1779205089; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=h9wUOSHCkf5lnhgbGUcgfm3/6j74fw4Q/KRVFYcRtW4=; b=gq5oshrLWfwrYi31lKzXiTKqU4NIVXC/nd1FVaYIB6nVT9d0EnK6tV7kfWP6/RnGu1 fpkFweheIp6TbLELk4dgjwQoki4OG2iQ7Etz7AN4SZhzNbqg1AoKugjM8gcznDqqQEzk V8WCytXgxs8dTvSB87rbvUr68WBu3t+GwaWybSISVlSFIljqRksAAg7He4cRqi0/JSbw gxTrbdKx/s8rREAJnIeOBDAqdhKs2PFppmLIQDcOPAEp33PlJC9Dj6GlnkYMuDX6uRzh IUlELJKENj5am7Lveqh8kbtCZp33czd/xo72UOTnOi5KKbqkkO+QaLCvfAEPzmdQHCwl Uz8Q== X-Gm-Message-State: AOJu0YwYaFFwZIcExL8hbSJWfEmjvHNJJ2OeaM0/0T95IbXKxSr8vq84 tb6MP+WQgAi9eGPi+nOafpuSPCP0W6FSq4e96s5tWf3CF2zof+4yc1n4ttzurSG79N4y+IsRvct GuS0= X-Gm-Gg: Acq92OFP3MZBVJpLYIGS/2rsu7WEdzJpDwBNrwts8SL/96LYscEcqz+bE00GunT5YIS qQ9tedrSewW9sYkXwQhf18S5oD3N9BtPEZJqL7+SDxBWEmxqrKowj2PMLMwBqk7cCb1K3pNwGpF ReEd+VqYSL+OKCsvdiDj+Hyk9v+GEscPSsi2gOZordgEUhtI1TVQHpK+xmFL0cO367FafE/wHXq Wpc0j9CjOfZk5iaG0fyefcRRgY5cC1UiWAnHJlqffyiSGnnZmeh3EwIv/9OicHIuud8GANXObpV r016vnVIlZG8OI/oRNiMvpj5NPFyjgOPLJgFORH9HKohdv4Pflt/GmOLDRfXl18kV3tZeBoi3yJ 6rnGg2RcXVBBrOe75sCoEYgKRL52ol2WPGezAvx5FxdWiolG1ujomgg6RScPOIq6i8f16yjDHv7 K6M61Dvwhd1dkPtYt2r/t01ISzY+5S468R+lAD6ej1DyWzB0mXlm7MvqmaHjV6Qy9FMaEpu34HD j66aNfR2Zlf4doEuJ/lA+4ZtQ== X-Received: by 2002:a05:600c:a412:b0:48a:525b:e148 with SMTP id 5b1f17b1804b1-48e6748a724mr195782845e9.4.1778600289165; Tue, 12 May 2026 08:38:09 -0700 (PDT) Message-ID: <8c46fedd-f1f3-4cad-91fb-1b3b8d58db50@suse.com> Date: Tue, 12 May 2026 17:38:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.22 v2 7/8] x86/mwait-idle: Add cmdline option to adjust C-states table From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> 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 In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1778600289-4217E3FF-6158878D/0/0 X-purgate-type: clean X-purgate-size: 8619 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778600317829158500 Content-Type: text/plain; charset="utf-8" From: Artem Bityutskiy Add a new module parameter that allows adjusting the C-states table used by the driver. Currently, the C-states table is hardcoded in the driver based on the CPU model. The goal is to have good enough defaults for most users. However, C-state characteristics, such as exit latency and residency, can vary between different variants of the same CPU model and BIOS settings. Moreover, different platform usage models and user preferences may benefit from different C-state target_residency values. Provide a way for users to adjust the C-states table via a module parameter "table". The general format is: "state1:latency1:target_residency1,state2:latency2:target_residency2,..." In other words, represent each C-state by its name, exit latency (in microseconds), and target residency (in microseconds), separated by colons. Separate multiple C-states by commas. For example, suppose a CPU has 3 C-states with the following characteristics: C1: exit_latency=3D1, target_residency=3D2 C1E: exit_latency=3D10, target_residency=3D10 C6: exit_latency=3D100, target_residency=3D500 Users can specify a custom C-states table as follows: 1. intel_idle.table=3D"C1:2:2,C1E:5:20,C6:150:600" Result: C1: exit_latency=3D2, target_residency=3D2 C1E: exit_latency=3D5, target_residency=3D20 C6: exit_latency=3D150, target_residency=3D600 2. intel_idle.table=3D"C6::400" Result: C1: exit_latency=3D1, target_residency=3D2 (unchanged) C1E: exit_latency=3D10, target_residency=3D10 (unchanged) C6: exit_latency=3D100, target_residency=3D400 (only target_residency changed) Signed-off-by: Artem Bityutskiy Link: https://patch.msgid.link/20251216080402.156988-3-dedekind1@gmail.com Signed-off-by: Rafael J. Wysocki Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 11= 1f77a23348 Add __init to get_cmdline_field(). Put cmdline_table_str[] in .init.data. Other adjustments to fit our env. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- For the initial attempt, I've left the new option as a standalone one. It may be worth integrating with "mwait-idle", but I think much of the parsing would then want doing differently. It'll then likely be much harder to apply future Linux changes there. --- v2: Correct example in cmdline doc. --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1916,6 +1916,23 @@ Print boot time MTRR state. Use the MWAIT idle driver (with model specific C-state knowledge) instead of the ACPI based one. =20 +### mwait-idle.table (x86) +> `=3D ` + + Define the C-states table from a user input string. Expected format is + 'name:latency:residency', where: + - name: The C-state name. + - latency: The C-state exit latency in us. + - residency: The C-state target residency in us. + + Multiple C-states can be defined by separating them with commas: + 'name1:latency1:residency1,name2:latency2:residency2' + + Example: mwait-idle.table=3DC1:1:1,C1E:5:10,C6:100:600 + + To leave latency or residency unchanged, use an empty field, for example: + 'C1:1:1,C1E::10' - leaves C1E latency unchanged. + ### nmi (x86) > `=3D ignore | dom0 | fatal` =20 --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -70,6 +70,11 @@ static __initdata bool opt_mwait_idle =3D true; boolean_param("mwait-idle", opt_mwait_idle); =20 +/* The maximum allowed length for the 'table' module parameter */ +#define MAX_CMDLINE_TABLE_LEN 256 +static char cmdline_table_str[MAX_CMDLINE_TABLE_LEN] __initdata; +string_param("mwait-idle.table", cmdline_table_str); + static unsigned int mwait_substates; =20 #define LAPIC_TIMER_ALWAYS_RELIABLE 0xFFFFFFFF @@ -122,6 +127,9 @@ struct cpuidle_state { */ #define CPUIDLE_FLAG_IBRS 0x20000 =20 +/* C-states data from the 'mwait-idle.table' cmdline parameter */ +static struct cpuidle_state cmdline_states[ACPI_PROCESSOR_MAX_POWER] __ini= tdata; + /* * MWAIT takes an 8-bit "hint" in EAX "suggesting" * the C-state (top nibble) and sub-state (bottom nibble) @@ -1547,6 +1555,161 @@ static void __init mwait_idle_state_tabl } } =20 + /** + * get_cmdline_field - Get the current field from a cmdline string. + * @args: The cmdline string to get the current field from. + * @field: Pointer to the current field upon return. + * @sep: The fields separator character. + * + * Examples: + * Input: args=3D"C1:1:1,C1E:2:10", sep=3D':' + * Output: field=3D"C1", return "1:1,C1E:2:10" + * Input: args=3D"C1:1:1,C1E:2:10", sep=3D',' + * Output: field=3D"C1:1:1", return "C1E:2:10" + * Ipnut: args=3D"::", sep=3D':' + * Output: field=3D"", return ":" + * + * Return: The continuation of the cmdline string after the field or NULL. + */ +static char *__init get_cmdline_field(char *args, char **field, char sep) +{ + unsigned int i; + + for (i =3D 0; args[i] && !isspace(args[i]); i++) { + if (args[i] =3D=3D sep) + break; + } + + *field =3D args; + + if (args[i] !=3D sep) + return NULL; + + args[i] =3D '\0'; + return args + i + 1; +} + +/** + * cmdline_table_adjust - Adjust the C-states table with data from cmdline. + * + * Adjust the C-states table with data from the 'mwait-idle.table' paramet= er + * (if specified). + */ +static void __init cmdline_table_adjust(void) +{ + char *args =3D cmdline_table_str; + struct cpuidle_state *state; + unsigned int i, state_count; + + if (args[0] =3D=3D '\0') + /* The 'mwait-idle.table' module parameter was not specified */ + return; + + /* Create a copy of the C-states table */ + for (i =3D 0; + i < ARRAY_SIZE(cmdline_states) && icpu.state_table[i].name[0]; + i++) + cmdline_states[i] =3D icpu.state_table[i]; + + state_count =3D i; + + /* + * Adjust the C-states table copy with data from the 'mwait-idle.table' + * module parameter. + */ + while (args) { + char *fields, *name, *val; + + /* + * Get the next C-state definition, which is expected to be + * '::'. Treat "empty" + * fields as unchanged. For example, + * '::' leaves the latency unchanged. + */ + args =3D get_cmdline_field(args, &fields, ','); + + /* name */ + fields =3D get_cmdline_field(fields, &name, ':'); + if (!fields) + goto error; + + /* Find the C-state by its name */ + state =3D NULL; + for (i =3D 0; i < state_count; i++) { + if (!strcmp(name, cmdline_states[i].name)) { + state =3D &cmdline_states[i]; + break; + } + } + + if (!state) { + printk(XENLOG_ERR PREFIX "C-state '%s' was not found\n", + name); + continue; + } + + /* Latency */ + fields =3D get_cmdline_field(fields, &val, ':'); + if (!fields) + goto error; + + if (*val) { + const char *end; + unsigned long n =3D simple_strtoul(val, &end, 0); + + state->exit_latency =3D n; + if (*end || state->exit_latency !=3D n) + goto error; + } + + /* Target residency */ + fields =3D get_cmdline_field(fields, &val, ':'); + + if (*val) { + const char *end; + unsigned long n =3D simple_strtoul(val, &end, 0); + + state->target_residency =3D n; + if (*end || state->target_residency !=3D n) + goto error; + } + + /* + * Allow for 3 more fields, but ignore them. Helps to make + * possible future extensions of the cmdline format backward + * compatible. + */ + for (i =3D 0; fields && i < 3; i++) { + fields =3D get_cmdline_field(fields, &val, ':'); + if (!fields) + break; + } + + if (fields) { + printk(XENLOG_ERR PREFIX + "Too many fields for C-state '%s'\n", + state->name); + goto error; + } + + printk(XENLOG_INFO PREFIX + "C-state from cmdline: name=3D%s, latency=3D%u, residency=3D%u\n", + state->name, state->exit_latency, state->target_residency); + } + + /* Copy the adjusted C-states table back */ + for (i =3D 0; i < state_count; i++) + icpu.state_table[i] =3D cmdline_states[i]; + + printk(XENLOG_INFO PREFIX + "Adjusted C-states with data from 'mwait-idle.table'\n"); + return; + + error: + printk(PREFIX + "Failed to adjust C-states with data from 'mwait-idle.table'\n"); +} + static int __init mwait_idle_probe(void) { unsigned int eax, ebx, ecx; @@ -1596,6 +1759,8 @@ static int __init mwait_idle_probe(void) =20 mwait_idle_state_table_update(); =20 + cmdline_table_adjust(); + return 0; } From nobody Sat May 30 11:15:02 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=1778600333; cv=none; d=zohomail.com; s=zohoarc; b=XasEYTJaTy8X7FTSfpjlJZu0xIYFNGf6HfdXFT8yAPDpKL+M5AeiML/oIHkGlSPse/oklNRw+8LvFpuKn4mpxbl7X1avklSIyV2hKuEJuxeDb5rtXWetkvD1VNTVfSRefiyK11veYQ342Yx90EELs6enni2oA/oeXKEluZjfQiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778600333; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WzBd3MuuDBK0yJ9aRas8h0fwt5fLexFcIS7F696osWI=; b=OPCwEWn/SRtji8RLJOx4wTLKcU1r2Uy+9kR0y0IS0Fskf6H/IzrlQUU2oJcIXJErVHgfvzx6+g4QtZpwsH0PC8Ila0mt+NdMZgksel3WxlecwIA5y6mY8tqgJB/5sgSGVMSb6i41RRwEIScllwKxQZl5R62ntNeEUcXVtpOAw1U= 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 1778600333938831.6594199753705; Tue, 12 May 2026 08:38:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1307041.1578782 (Exim 4.92) (envelope-from ) id 1wMpBs-0006yV-Rw; Tue, 12 May 2026 15:38:36 +0000 Received: by outflank-mailman (output) from mailman id 1307041.1578782; Tue, 12 May 2026 15:38:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpBs-0006xs-Oz; Tue, 12 May 2026 15:38:36 +0000 Received: by outflank-mailman (input) for mailman id 1307041; Tue, 12 May 2026 15:38:35 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wMpBr-0006ve-1f for xen-devel@lists.xenproject.org; Tue, 12 May 2026 15:38:35 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wMpBq-004MKj-Eh for xen-devel@lists.xenproject.org; Tue, 12 May 2026 17:38:34 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a03495d-5cb7-0a2a0a5109dd-0a2a4505e454-42 for ; Tue, 12 May 2026 17:38:34 +0200 Received: from [209.85.128.52] (helo=mail-wm1-f52.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a03497a-aaa8-0a2a45050019-d1558034dc9f-3 for ; Tue, 12 May 2026 17:38:34 +0200 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-48909558b3aso58479815e9.0 for ; Tue, 12 May 2026 08:38:34 -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 5b1f17b1804b1-48fc8d624fbsm13356605e9.10.2026.05.12.08.38.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 08:38:33 -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:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778600314; x=1779205114; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=WzBd3MuuDBK0yJ9aRas8h0fwt5fLexFcIS7F696osWI=; b=DQI62Jfa+Khb/WlloCeKmxta1Hm9KDkNjkG+laZ84Oje+rI7RZJFZuiQ9u/zpGsmHQ L52D6TTSMAJhbWjMA0VGzHgsRxLjFMqwfMoUKOakjFfoW/FsifnlBO9UZaiNdcvf3C84 9khpFIXy6L4Ppm4sraA8z2x+tRfBFrcVBnjW2O1YLK07Qz6+OrBpkuO/xVdhBa9RfkR2 uJgkO3L1oYCzt52p8RJxK2ATKMiPLAZFIzp677URNEHoaYpWOskD2Tt4WDnnsAWdXt/O IjKC3+UxWiDwrEwYcaArMcFjEcUEOwB7+s+T8ZDU6AuLIiUh6NTTNUDmGxZHy0YT9F+I ABFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778600314; x=1779205114; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WzBd3MuuDBK0yJ9aRas8h0fwt5fLexFcIS7F696osWI=; b=F5BVthsC4F9qEkECefiSW1Uv/wqyP/V8LX9biqy3C5LiPdM4LZsEXVV65qSwAXkqqS C8UIn46CHwc1WNXO5bpLCf8M5NbgU89wONj4SC731U+4a0TNkDeu3d+5+ftrZh5/hbJz 6+wcrOJqc94aX+NvZWVDu9HqaS2g7h7gRdJG1GQSANyiMr/053r/LlAwBzD1NvNyh4nF TXEdA9JmsFHM46fQy9Dr7DOsArlvFSc5tN5Q39FCp5C6UPGISB5Xk0Q9b/p9YHDQk+I+ gvSP5XWfi7JOEQJeX9+/seOOU2TXPLa8se3gzHoW5UUwjdj0rNzdNQOa/6i9px0vNl4U SXEA== X-Gm-Message-State: AOJu0YwcESzmK20jOtRpRlvZ7zkHm62BmX4DvWRZzZ9atbzpT3cK5teH tsyBuycQSuAf0/xJHiBW3Vvg6gOEFBLyj/gSTNKfHcEIZG6WqFueMhI/NO0EJtztQAMGoolaPfl mnJ4= X-Gm-Gg: Acq92OHISxxLp0VGvxBHufzxYfIaOhMYWG7tZMT7czpDxcFNCPZpHjgLC5hgZXigmsV E1m0o35fJyLUQp0idWupFjLuQlTpmnTQpUDDj2CAHUPgkMGbHvAGNuD864r/BIlBfw049qhnqNy nURFxDT1Gq7SVI0TVK+wfw7Km/8LFyGCbLNSzVlGRG2Lx04c99eRyt/qa52qkVN38l970JLPM16 Bm1NFLkJWSmAjos1rtQm9wCPiXhMe9nXqByRzYzKoO1XVACy7GaU53ekA/I6zjLiug0pCuc4vhZ Hi63e4NeVzPsklMcK99I3osmMQUwE4N1DPEP62GQSrwvrMDP3QtXP4q8501Acpccd8jFJ3QSbRQ SAWrJpJSkt7xiqMo/p8nRTvwB78VDum5ehvoE2gSH6xI0cW75ZikUY6vugtWo+Xx2YzDTqzM0cH TPVwJzR6K9Co0gRBLcd2idc9h7BaMol5pZMh3bRCPrPB9koicnDITVZwYWMiP3sBDsCLm85e2Hk EpD6AMzWuGaefHlJFmMazcnUw== X-Received: by 2002:a05:600c:c094:b0:488:b14f:b8ed with SMTP id 5b1f17b1804b1-48e51dd89ffmr336736725e9.0.1778600313756; Tue, 12 May 2026 08:38:33 -0700 (PDT) Message-ID: Date: Tue, 12 May 2026 17:38:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH for-4.22 v2 8/8] x86/mwait-idle: Add C-states validation From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> 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 In-Reply-To: <178739fe-fa41-4ff7-b16e-67c4b2a99b38@suse.com> Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1778600314-DAD6F443-93512BCA/0/0 X-purgate-type: clean X-purgate-size: 3148 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778600336464154101 Content-Type: text/plain; charset="utf-8" From: Artem Bityutskiy Add validation for C-states specified via the "table=3D" module parameter. Treat this module parameter as untrusted input and validate it thoroughly. Signed-off-by: Artem Bityutskiy Link: https://patch.msgid.link/20251216080402.156988-4-dedekind1@gmail.com Signed-off-by: Rafael J. Wysocki Origin: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git be= 6a150829b3 Add __init to validate_cmdline_cstate(). Other adjustments to fit our env. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- v2: Const-ify validate_cmdline_cstate()'s parameters. --- a/xen/arch/x86/cpu/mwait-idle.c +++ b/xen/arch/x86/cpu/mwait-idle.c @@ -72,6 +72,11 @@ boolean_param("mwait-idle", opt_mwait_id =20 /* The maximum allowed length for the 'table' module parameter */ #define MAX_CMDLINE_TABLE_LEN 256 +/* Maximum allowed C-state latency */ +#define MAX_CMDLINE_LATENCY_US (5 * 1000 /* USEC_PER_MSEC */) +/* Maximum allowed C-state target residency */ +#define MAX_CMDLINE_RESIDENCY_US (100 * 1000 /* USEC_PER_MSEC */) + static char cmdline_table_str[MAX_CMDLINE_TABLE_LEN] __initdata; string_param("mwait-idle.table", cmdline_table_str); =20 @@ -1590,6 +1595,41 @@ static char *__init get_cmdline_field(ch } =20 /** + * validate_cmdline_cstate - Validate a C-state from cmdline. + * @state: The C-state to validate. + * @prev_state: The previous C-state in the table or NULL. + * + * Return: 0 if the C-state is valid or -EINVAL otherwise. + */ +static int __init validate_cmdline_cstate(const struct cpuidle_state *stat= e, + const struct cpuidle_state *prev_state) +{ + if (state->exit_latency =3D=3D 0) + /* Exit latency 0 can only be used for the POLL state */ + return -EINVAL; + + if (state->exit_latency > MAX_CMDLINE_LATENCY_US) + return -EINVAL; + + if (state->target_residency > MAX_CMDLINE_RESIDENCY_US) + return -EINVAL; + + if (state->target_residency < state->exit_latency) + return -EINVAL; + + if (!prev_state) + return 0; + + if (state->exit_latency <=3D prev_state->exit_latency) + return -EINVAL; + + if (state->target_residency <=3D prev_state->target_residency) + return -EINVAL; + + return 0; +} + +/** * cmdline_table_adjust - Adjust the C-states table with data from cmdline. * * Adjust the C-states table with data from the 'mwait-idle.table' paramet= er @@ -1697,6 +1737,21 @@ static void __init cmdline_table_adjust( state->name, state->exit_latency, state->target_residency); } =20 + /* Validate the adjusted C-states */ + for (i =3D 0; i < state_count; i++) { + struct cpuidle_state *prev_state; + + state =3D &cmdline_states[i]; + prev_state =3D i ? &cmdline_states[i - 1] : NULL; + + if (validate_cmdline_cstate(state, prev_state)) { + printk(XENLOG_ERR PREFIX + "C-state '%s' validation failed\n", + state->name); + goto error; + } + } + /* Copy the adjusted C-states table back */ for (i =3D 0; i < state_count; i++) icpu.state_table[i] =3D cmdline_states[i];