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

Re: [PATCH for-4.21] x86/hvm: fix reading from 0xe9 IO port if port E9 hack is active


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Fri, 3 Oct 2025 11:34:30 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.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=Osmf/8z0OhDHqkBhgAH3FBUvpEN6KdlADdz5lFfzaFk=; b=RHkTRzEqaMY4Z+HN3d20JGzrsKh6qh1ZfiMNb9xkn0Jzf9/VUr0rOhHDBtUzKUQH9vibm9YqGOoXm8H7HSdmT+mHey8zBWBMbSM1uIEnrpMj8rVDHBr2W/BEEQSw7WpiHF9gQP2AX6h9nNAJNBX6gNnDfpAO7F0wYfgAMcAg1MFTTW2NNIyvQR6ONrDK8PfsYFhujxxxXrACa1zWxdQu2huhGQrByIr8AD/aXxngfGErumR0rhgLKq5C9608ZUhixotNh80CLylpoj8MtgKStLcpkwE8xqWdLY86xgcx4Uty8IkGVQbclLW5z7x5u5VbCRX8SvwvNrTw3MAGzvi1iQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xwRztlJ+tBzUp0Tvh1izpqg8KFu8/tdn64+/512CLjbbNlaBDXcN3aHv0a5CH+M6G9lliKUK4LyObhmew6G3tciU+RE+FgV5gG8YJpkD+0lBBgiysI108wqpFJppqybrjlM+50nxp/Psx1Yzlw9SduTNMYFGLKGQPEcrFb8AODzNyoYJ//22wLxp5QFcCW802POmA9tY59p2ZQPrauvRMDzF3+5BOOu5QFwkdqNbFZUtKgpp+JgS8D1aaoxZFm+BB4/oOFGZeDQbG3hXGRegCuE6cTOlG2yOZCPKbT86mZGR0MaFdxdnhkHvx4f7UwRq//RuE4pBq6OEvMdFB8gTVQ==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 03 Oct 2025 09:34:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri Oct 3, 2025 at 10:18 AM CEST, Roger Pau Monné wrote:
> On Thu, Oct 02, 2025 at 04:56:48PM +0200, Alejandro Vallejo wrote:
>> On Thu Oct 2, 2025 at 4:17 PM CEST, Roger Pau Monné wrote:
>> > On Thu, Oct 02, 2025 at 04:02:00PM +0200, Alejandro Vallejo wrote:
>> >> On Thu Oct 2, 2025 at 3:38 PM CEST, Roger Pau Monné wrote:
>> >> > On Thu, Oct 02, 2025 at 11:37:36AM +0100, Andrew Cooper wrote:
>> >> >> On 02/10/2025 11:22 am, Roger Pau Monne wrote:
>> >> >> > Reading from the E9 port if the emergency console is active should 
>> >> >> > return
>> >> >> > 0xe9 according to the documentation from Bochs:
>> >> >> >
>> >> >> > https://bochs.sourceforge.io/doc/docbook/user/bochsrc.html
>> >> >> >
>> >> >> > See `port_e9_hack` section description.
>> >> >> >
>> >> >> > Fix Xen so it also returns the port address.  OSes can use it to 
>> >> >> > detect
>> >> >> > whether the emergency console is available or not.
>> >> >> >
>> >> >> > Fixes: d1bd157fbc9b ("Big merge the HVM full-virtualisation 
>> >> >> > abstractions.")
>> >> >> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>> >> >> 
>> >> >> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>> >> >> 
>> >> >> That's been wrong for rather a long time.  How did you find it?
>> >> >
>> >> > I came across the documentation above and I didn't remember Xen
>> >> > returning any value for reads, which sadly was indeed true.
>> >> >
>> >> > This was because I had the intention to suggest Alejandro to (also?) use
>> >> > the port 0xe9 hack for printing from XTF, which should work for both
>> >> > Xen and QEMU.
>> >> 
>> >> QEMU doesn't support 0xE9 though?
>> >
>> > AFAICT it does:
>> >
>> > https://wiki.osdev.org/QEMU#The_debug_console
>> >
>> > However when running QEMU on Xen as a device model writes to 0xe9 are
>> > handled in the hypervisor, and never forwarded to any device model.
>> >
>> > Regards, Roger.
>> 
>> The more you know. I searched for it once upon a time and couldn't find it.
>> Thanks for the pointer.
>> 
>> Regardless, "-debugcon stdio" is functionally equivalent to "-serial stdio"
>> and the latter can be adapted to work on real hardware too.
>
> The emulated serial is possibly equivalent to the 0xe9 hack in QEMU,
> as I expect the serial is mostly setup to "just work".  On native you
> likely need to configure the baud rate &c, plus implement flow
> control?

You'd need to boot XTF via GRUB (or similar), which would've pre-configured
the serial port for you.

And baud rate, flow control and the like are ignored when emulated, so that's
all fine.

>
> Is there any testing XTF should do to ensure the serial is there,
> before blindly writing at 0x3f8?

Closest would be parsing the FADT for LEGACY_DEVICES being set, but if that was
clear we'd be out of options because there's nothing else to write to. I don't
intend to make XTF rock solid on real hardware, just "workable" on typical
everyday devices/servers with GRUB's help.

FWIW Xen just assumes it's there if com1= is given in the cmdline AFAICS. The
most likely case for COM1 not being there is on PV(H), which XTF already uses
the PV console for.

Cheers,
Alejandro



 


Rackspace

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