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

Re: [XEN PATCH v4] x86/monitor: Add new monitor event to catch I/O instructions


  • To: Dmitry Isaykin <isaikin-dmitry@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 21 Mar 2023 09:08:19 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=q2/AOBkMmISvTuLIzyxYbeTH30ey/d2N7zX6Zcu19sI=; b=bin0p+S04XoMd8swnuX+mdt/fdCA0AzHG83qto3LF2DXf+2AolO0K5rSaFdcgeUEGlPwr3rEWadBYPJdwyf6pK0BxzhYIa502gYUfQmomUe+W1u6BlApWs/7RAs6duWLN19SC+sSSUdN6svrsN+j86KjsUOcfaSdIC0nabDObTSqAfMRSIacTWoe74J9gHey0RRv7N/x6n6b/61Z8up+tbEEtM/ULALbrSuRbl/7XiJxXvvdfINnnzTV5+YUVtoJT5oSMTjzolTqN8TaspGDp47kxyS9rak49XXtfu/pLsBjnlkWM/G1tEFBfMQ7sg/d9Kc8bafPG6Vw/GAqQDZdFg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lu57ijytlLtm91SPZXOUrKKlnY+Y0onhBScWivPLYjAAvh2cpsGSStZUwuhdx7g11KYyVoYOlQOIc2cH2c6YLpQihTb1bJU1DH0OzNbLXycGnieay8XVL51XaLLgKhG7LJ3sd72tKp6mdyZcYqXjCE0uEBoRaonx2gGYGK3FS1yI1h5bW/VU6jiy6r/VER+G78xr+xewsx5dzN4+NtEkC7mZArEbu9H1jqQVQSJiDtzP9aLLTGEzzNcGXatJ/1R5zmXVGD+p32m129xwQDQT2Dtw5cCITJ0TOjcqEX2jKeWobJbYoK20Y/fxrA+PXP0W+0nBT+lgrayqr2GCmrR+dQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>, Alexandru Isaila <aisaila@xxxxxxxxxxxxxxx>, Petre Pircalabu <ppircalabu@xxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Anton Belousov <abelousov@xxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 21 Mar 2023 08:08:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.03.2023 22:56, Dmitry Isaykin wrote:
> Adds monitor support for I/O instructions.
> 
> Signed-off-by: Dmitry Isaykin <isaikin-dmitry@xxxxxxxxx>
> Signed-off-by: Anton Belousov <abelousov@xxxxxxxxxxxxxx>

LGTM now FWIW, but this part ...

> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -4560,8 +4560,24 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
>          break;
>  
>      case EXIT_REASON_IO_INSTRUCTION:
> +    {
> +        unsigned int port, bytes;
> +        bool in, str;
> +        int rc;
> +
>          __vmread(EXIT_QUALIFICATION, &exit_qualification);
> -        if ( exit_qualification & 0x10 )
> +
> +        port = (exit_qualification >> 16) & 0xFFFF;
> +        bytes = (exit_qualification & 0x07) + 1;
> +        in = (exit_qualification & 0x08);
> +        str = (exit_qualification & 0x10);
> +        rc = hvm_monitor_io(port, bytes, in, str);
> +        if ( rc < 0 )
> +            goto exit_and_crash;
> +        if ( rc )
> +            break;
> +
> +        if ( str )
>          {
>              /* INS, OUTS */
>              if ( !hvm_emulate_one_insn(x86_insn_is_portio, "port I/O") )
> @@ -4570,13 +4586,11 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
>          else
>          {
>              /* IN, OUT */
> -            uint16_t port = (exit_qualification >> 16) & 0xFFFF;
> -            int bytes = (exit_qualification & 0x07) + 1;
> -            int dir = (exit_qualification & 0x08) ? IOREQ_READ : IOREQ_WRITE;
> -            if ( handle_pio(port, bytes, dir) )
> +            if ( handle_pio(port, bytes, in ? IOREQ_READ : IOREQ_WRITE) )
>                  update_guest_eip(); /* Safe: IN, OUT */
>          }
>          break;
> +    }

... would preferably be re-based over Andrew's change to use bitfields here
as well (just like was already done by him for SVM).

Jan



 


Rackspace

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