Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1FDE6CAC58E for ; Thu, 11 Sep 2025 15:04:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1120388.1465340 (Exim 4.92) (envelope-from ) id 1uwiqF-0000pj-9m; Thu, 11 Sep 2025 15:04:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1120388.1465340; Thu, 11 Sep 2025 15:04:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uwiqF-0000pc-6O; Thu, 11 Sep 2025 15:04:07 +0000 Received: by outflank-mailman (input) for mailman id 1120388; Thu, 11 Sep 2025 15:04:06 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uwiqE-0000pV-9j for xen-devel@lists.xenproject.org; Thu, 11 Sep 2025 15:04:06 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8efe49ef-8f20-11f0-9d13-b5c5bf9af7f9; Thu, 11 Sep 2025 17:04:05 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-b04271cfc3eso107013666b.3 for ; Thu, 11 Sep 2025 08:04:05 -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 a640c23a62f3a-b07b32dd0fdsm147535466b.50.2025.09.11.08.04.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Sep 2025 08:04:04 -0700 (PDT) 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" X-Inumbo-ID: 8efe49ef-8f20-11f0-9d13-b5c5bf9af7f9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757603044; x=1758207844; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=8iCpDT/tx/mro9DOysbu9Xqq5zQA2MGoutiWSGpk8mY=; b=CZtS2Q7wce/dL3ZOp2YA1hLY96loQjbauPap8iq7UxuB6x2Yaqh2D/FYe06cDWTNc2 KeYdSk6uvPpEiQj/kzpTpiyrrvqS5IZ739L9YZfJaOQQArh+af5vht9pUdpaDILNVGYJ GmBeXgywinqbk4P2qvp0EKcWhuhOftdLXw5slvwOZGsnnzdZlz6HeN2iX81cboO0Lvh6 45lvCnH7Bh/iM2HCHpc5m1pj07N8+/5qZ5tvjHUzea1oAduSLgl0z+2amplUVemjCJe+ RAGP7DgJJeP72s4iIEaD6z0gdsDOEfdNHihL3DtzeoHgzhNyfQdXRZvmoAMsd1tHoIdn wUYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757603044; x=1758207844; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8iCpDT/tx/mro9DOysbu9Xqq5zQA2MGoutiWSGpk8mY=; b=FEs6RNS2X6A5sViDH5z5UgvHuwZdzHh7b9IxSAx2V8xspD0b5fXMmCTWWB7+Rc5Caf 16HuKGgMl9CJNVK8Y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ezJeRwIDfWt/w== X-Received: by 2002:a17:907:807:b0:b04:7a92:c7cb with SMTP id a640c23a62f3a-b04b1687dc3mr1807994366b.37.1757603044310; Thu, 11 Sep 2025 08:04:04 -0700 (PDT) Message-ID: Date: Thu, 11 Sep 2025 17:04:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] libacpi: Prevent CPU hotplug AML from corrupting memory To: Andrew Cooper , Alejandro Vallejo Cc: Anthony PERARD , Grygorii Strashko , xen-devel@lists.xenproject.org References: <20250911115308.16580-1-alejandro.garciavallejo@amd.com> <20250911115308.16580-2-alejandro.garciavallejo@amd.com> <42bf6ed7-3a6b-4021-9a53-1891117ff2ba@citrix.com> Content-Language: en-US From: Jan Beulich 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: <42bf6ed7-3a6b-4021-9a53-1891117ff2ba@citrix.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11.09.2025 14:03, Andrew Cooper wrote: > On 11/09/2025 12:53 pm, Alejandro Vallejo wrote: >> CPU hotplug relies on the online CPU bitmap being provided on PIO 0xaf00 >> by the device model. The GPE handler checks this and compares it against >> the "online" flag on each MADT LAPIC entry, setting the flag to its >> related bit in the bitmap and adjusting the table's checksum. >> >> The bytecode doesn't, however, stop at NCPUS. It keeps comparing until it >> reaches 128, even if that overflows the MADT into some other (hopefully >> mapped) memory. The reading isn't as problematic as the writing though. >> >> If an "entry" outside the MADT is deemed to disagree with the CPU bitmap >> then the bit where the "online" flag would be is flipped, thus >> corrupting that memory. And the MADT checksum gets adjusted for a flip >> that happened outside its range. It's all terrible. >> >> Note that this corruption happens regardless of the device-model being >> present or not, because even if the bitmap holds 0s, the overflowed >> memory might not at the bits corresponding to the "online" flag. >> >> This patch adjusts the DSDT so entries >=NCPUS are skipped. >> >> Fixes: c70ad37a1f7c("HVM vcpu add/remove: setup dsdt infrastructure...") >> Reported-by: Grygorii Strashko >> Signed-off-by: Alejandro Vallejo >> --- >> Half RFC. Not thoroughly untested. Pipeline is green, but none of this is tested >> there. >> >> v2: >> * New patch with the general fix for HVM too. Turns out the correction >> logic was buggy after all. > > Hmm, this does sound rather more serious.  I have a nagging feeling that > until recently we always wrote 128 MADT entries. Not exactly recently, but looks like that's my fault then: 0875433389240 ("hvmloader: limit CPUs exposed to guests"). Jan