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

Re: [PATCH v2] nestedsvm: Fix multi-byte IO port intercept check


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Fri, 11 Sep 2026 15:50:31 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • 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=/jpyJrm+Y4hPYLcisIDwSz+P8gThpnV6HSgDuGY4RPY=; b=nMbpu8aZP9VlGe2CgcWBgwYxO8LLpDM6QBMn88m8wWxqD0z/emSjjhAAHAT5HFlaaWPa2mvwbTH3NuaknHe0mC4dc0RLoidB3lAAWIn6MVVfcAc3EiKUV3xSiu0QBqxZaIaw8j3YL1tcN8Tjc87EOfDvxeoIZlgO5Hx287GUKaq+9BWibOgiDfvFEMv00oWetpFCF6ehv3IeNeA5qjl0gOu9y1N/Qcr9tgtnR9nR1TBNVVG5LLK/VZA5epehikjwCTJWWPYzuoxLhUz4d8xaBUDmL3g7zqSYinvGgbdajMwJG2nMN8WSBNgfaYh/OKhDjaeeoNTBDBXnmNjAJdCVZQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QXVxVMDDbqX9KqMKKhaog6sWsoSjiGCyhegcCvOGQMzTJGCSI/TjTWk14PxhxUOvhsu3fMG94Tr1fvhZpiCQscxRuvigWV2843ot1keMbaxXy5CMxQ1fyyNW8rZBo0r8uW4MqUrSIB1Qvyhw1wp7xu24uSNJ6FjeG5lz1SfgEWwFKRc0kdcqRJo32ynkis26xp1jD0ilAmlrD8FfkhGPsLY64nn68/0W90fYlNmqh6/WamLJa4cO5ZP9vLa4MtdzHPgCGNL19MoEWU0Ay2nxgP8//fVp8L/hXzNGdCaI8Wd8GLZjck50RSFElWQmExQlANkPEPcVplam02CSKjibqg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Fri, 11 Sep 2026 14:50:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 9/11/26 2:36 PM, Andrew Cooper wrote:
On 11/09/2026 2:23 pm, Ross Lagerwall wrote:
For multi-byte IO port accesses, the APM says that SVM should intercept
if any of the corresponding permission bits are set. However, the code
has this backwards and only intercepts if all the permission bits are
set. Fix this and at the same time, make things safer by handling
mapping failures as intercepted. Also rename the 'enabled' variable to
make it clearer what it does.

This affects Hyper-V since it does not generally set all the permission
bits of the multi-byte ports it allows its root partition to access.
This results in an L2 root partition that cannot do PCI config space
accesses and therefore cannot access its NVMe disk to continue booting.

Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>

The reason I asked about 0xcf9 is because it's the one-byte PCH reset
register, which hides fully inside the normal 4 bytes at 0xcf8 for CFG
accesses.

Despite outward appearances, the x86 IO space is not one uniform space.
It's 3 orthogonal space (1,2 and 4-byte accesses) where the target
device gets to choose whether muti-byte values alias in the spaces, or
are entirely disjoint.

For the HyperV root partition specifically, I'd expect 0xcf9 to be
unintercepted so as not to interfere with the final steps of
shutdown/reboot from the main kernel.

The patch looks ok, but I think the second paragraph needs a bit more
explaining.  Are we saying that because 0xcf9 was permitted, we allowed
4b@0xcf8 to be permitted, changing L1's CFG index rather than changing
L2's CFG index, causing the subsequent 0xcfc access to produce garbage?


Yes. The incorrect trace shows:

L2 write 4b@0xcf8, permitted so it updates the L1 CFG index
L2 read  2b@0xcfc, VMEXITs to L1
L1 write 4b@0xcf8, updates the L1 CFG index to the wrong value (since it didn't
see the first L2 write)
L1 read  2b@0xcf8, reads the incorrect value from the device model in L0

How about this for the second paragraph?

This affects Hyper-V which for the root partition intercepts 0xcf8 and
0xcfc-0xcff. L2 issues 4 byte CFG index writes to 0xcf8 which are incorrectly
permitted and update the L1 CFG index. The subsequent L2 CFG data read at 0xcfc
is intercepted by L1, then resubmitted as a CFG index write followed by CFG
data read to L0. Since L1 doesn't see the CFG index write by L2, it uses the
wrong index and gets garbage back, ultimately leading to a failure to boot
since it cannot access its NVMe disk.

Ross



 


Rackspace

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