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é <[email protected]>

Reviewed-by: Andrew Cooper <[email protected]>

That's been wrong for rather a long time.  How did you find it?

CC-ing Oleksii as you've tagged this for 4.21.

> ---
>  xen/arch/x86/hvm/hvm.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 23bd7f078a1d..0c60faa39d7b 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -567,9 +567,15 @@ static int cf_check hvm_print_line(
>  
>      ASSERT(bytes == 1 && port == XEN_HVM_DEBUGCONS_IOPORT);
>  
> -    /* Deny any input requests. */
> -    if ( dir != IOREQ_WRITE )
> -        return X86EMUL_UNHANDLEABLE;
> +    if ( dir == IOREQ_READ )
> +    {
> +        /*
> +         * According to Bochs documentation, reading from the E9 port should
> +         * return 0xE9 if the "port E9 hack" is implemented.
> +         */
> +        *val = XEN_HVM_DEBUGCONS_IOPORT;
> +        return X86EMUL_OKAY;
> +    }
>  
>      if ( !is_console_printable(c) )
>          return X86EMUL_OKAY;


Reply via email to