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

Re: [XTF PATCH v2 2/2] x86: Allow exiting QEMU in TCG/QEMU


  • To: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 2 Oct 2025 16:22:36 +0200
  • 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=B39u6vWf36fBC6j/NoGl2hqaTwuGiTh64pHOMIfnQsk=; b=Nc4qk6WUWPbSOImYQEeXAaqPDoYHjBjrERdB7ENtHi9+pKX40lYo5jAQc8XLMqS2FWxGdqUuddCEs99IYZfuAmtcC0plqdx1umB1GJTtmEFQdOiWtZbw83vpjU+40y6nyE8f8zXcaMkDOJKGpKuF1T28R5j5JJBlpWnni0DoOYS/vbpl0lSh2XlvvywJit7YDbWTt6Sg6xXv3hMztLBoWpqbHOwFmbQcVIe+fdXhzpKeGvGTv6L1ePDiHoUDy0pjFgo2xWwRjnJ+agHw6nwkhPHFqyTrv+JaiuQ23Dsr5VZl9l2T5GzWDFBYp4MewJBrqINreAZchr3Zo8hCSArwPA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BT7WNOF9+fJOI3p6YYjtYeSYoY1g7UhWidoHo8xNxwHBDWbOH9Ep/BICgf+Y1NGpzzj5oJmpwrJTqys9tGPZKXVWFQVGfjt9EXhtcdC77DJ4FFeGn3K2BZ3IU0a/ZUI8cKcJWEN0+gW1hJk8aJbZMiw+cgWuGQ153fLSG1RVVrkSafx71b72XiOlPF2ZugrGyRSaOFlxQP1aahJWlOuui+OcIMyh8D/15xw/7pcIKsxP2bb9Cs8+pE6KNk8NsF73pM4vy3Qiw6YG2vSdxi8rG7gAhrZQE7u3ML4DJ3iWRRwlmFItOv3rfoHvRxfZlGy2sE++4IrlvxxlB/yz1ZOFjg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Thu, 02 Oct 2025 14:22:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Oct 02, 2025 at 03:55:34PM +0200, Alejandro Vallejo wrote:
> If QEMU has a debug isa-debug-exit device, we can simply write to it
> to exit rather than spinning after a failed hypercall.
> 
> While at it, reorder an out-of-order include.
> 
> Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
> ---
>  arch/x86/hvm/traps.c    | 16 +++++++++++++++-
>  arch/x86/pv/traps.c     |  5 +++++
>  common/lib.c            |  2 +-
>  common/report.c         |  8 +++++---
>  include/xtf/framework.h |  3 +++
>  5 files changed, 29 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/hvm/traps.c b/arch/x86/hvm/traps.c
> index ad7b8cb..b8c4d0c 100644
> --- a/arch/x86/hvm/traps.c
> +++ b/arch/x86/hvm/traps.c
> @@ -1,5 +1,6 @@
> -#include <xtf/traps.h>
> +#include <xtf/hypercall.h>
>  #include <xtf/lib.h>
> +#include <xtf/traps.h>
>  
>  #include <arch/idt.h>
>  #include <arch/lib.h>
> @@ -139,6 +140,19 @@ void arch_init_traps(void)
>                 virt_to_gfn(__end_user_bss));
>  }
>  
> +void arch_shutdown(unsigned int reason)
> +{
> +    hypercall_shutdown(reason);

This relies on the hypercall page being poised with `ret`, which is
IMO fragile.  I would rather have it poisoned with `int3` and prevent
such stray accesses in the first place.

> +
> +    /*
> +     * Not running under Xen. Attempt exit via the QEMU ISA debug exit 
> device on
> +     * its default port.
> +     *
> +     * QEMU's rc is (reason << 1) | 1, if "-device isa-debug-exit" is set.
> +     */
> +    outb(reason, 0x501);

That's kind of weird?  So even if we pass reason == 0, the exit code
from QEMU will be 1 (and error)?

Isn't there anyway to signal a clean shutdown, and hence QEMU exit
code being 0?

Thanks, Roger.



 


Rackspace

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