[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/2] libacpi: Prevent CPU hotplug AML from corrupting memory


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Thu, 11 Sep 2025 17:16:23 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XtZeKBnVGG3y7WD0wOdYIDiDdz8Dd88mQrLv83KFryQ=; b=XeLjQdSyC/S77kKIvcZANjD9QjOR3Uy9gztNICm7LbxTWPsKZqUJP8E5pz9Qw7D96gBnMuiYjkd73mOCJbh9+Zq63J6dy7XUA75cxAor756dFFITOyOocoA1M7JcgtSGi9/PjGLk+17Cv7emjoCz3A+0c+/lHemsFVtioTkIXcixVYow22AY/Ms5zT/4L4TB7NQ6aaZvdJPZ4d+ZU3iQtEP3illz8BJIjXFxMoC6MOEmrYvhHiVD96R2+o4sjVHDTiVev22rwP8XWCG1P/4PP7xLVQILq2sKnLl3LeE/YgjR0RSeeMK8PGf5kjG4ZKkI8s1ekv94VbLZMP2Tut5Otg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tDy52fDZFwBcin+hvN1bWOq31Tj8L3Y/q4odbDhub/Rz+9cansWh6QkwvJQ8S033CHBI9Y7Br3jqJZ8pXR/2gRfL5AxYJqLnJHBNWcGbTJk3QpQaLnaXUeqE2uvWOI5EoOlsHsP0BAlsAwvfnAdHT99VSkAucy3dnBBLP0a/meKswO9O49RedrNWYJsMjh8ROFJqQBkPCzc8tsyhhzR8RsK+9UGAfxe2gCsJN5EPTlRM0EOZXM4wFJu/3NL2yJ5xl2/WJTzh0werl4Bjv9iWPT+ia4IGnIPIPl0gJozROA8jMYEFUYH7ae7HWUdZnSsj32iKolTHzN/QsXH5yF5ySg==
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 11 Sep 2025 15:16:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu Sep 11, 2025 at 5:04 PM CEST, Jan Beulich wrote:
> 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 <grygorii_strashko@xxxxxxxx>
>>> Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
>>> ---
>>> 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

Very right. I got to that commit, but thought nr_processor_objects would match 
NCPUS. Wrong assumption.

That sorts out wich fixes tag to attribute this to.

Cheers,
Alejandro



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.