[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: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Dmitry Isaykin <isaikin-dmitry@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 21 Mar 2023 12:06:07 +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=MSchx/4MgpMuciJuO4p+NjH1X9ySZ+yhPNiUtH8k0PA=; b=kf12n19SOLtyclpyguGfZ6T5wuOn2ZpS7tscJ4+AJZjYHIO60OCZ7y4iMGMkRkL0hIplN615CJmG+EO4KdiAxXX4gNPYoC94+6JtL0nWKOK4MQL5yI6xMs8YlRb13VVQorme6YAhxU/ct2p3ljidAdpF9yxTgqxobtkLkjNqo1lCGf1afQnQWSpOs4eI0QZEfo5zIjSarhPFXNbEbQEzm79wyDEPs8keWw+y3tYoPptTALGE565/JfiKpnUFGp6bxA5e3sxdV6BWd9cW9oivjKFzuYeWio5lIL+zVsw3QVxaTLZ41GMgE/fUmJ1yxEaDmH6xFhc8vfdiW6YMNj4cog==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fxdCieTJ/z0tnAezdNgwz7nFIsp1i4zk4TAvMGx29mYRXwJkOgabKl+aBMPlR/dQ+uEs5BlFECpXAvJGXFDwsz1GcWcHW7I8Vou8R/Lxq1g/IJ9HHqWOUKWSFuRnXuoGLAAWhI5X96IKn7Xpp16prfqb0ANVp6f61QXVDRrEX+bxoFpJq2uYYiQw2O3xdqxEk2Z6X2YwLbxhmRUNiDRRo0X225iDZJ4oM23sH25tb8xh5lSOJlp3MzXnEiCWaEBgxBwZCY8PurT8/DV8sl5PInSET6c4lHgCr9mJnDKXb7Vq+j4MAvCnMYfPqiF7e/k7pNbW22VbvO34G5Upym6tRg==
  • 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>, 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 11:06:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21.03.2023 11:51, Andrew Cooper wrote:
> On 20/03/2023 9:56 pm, Dmitry Isaykin wrote:
>> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
>> index 00b531f76c..0b7a302928 100644
>> --- 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;
>> +    }
> 
> Sorry for the delay.  I've got the Intel side sorted now too with
> https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=f71f8e95c34fedb0d9ae21a100bfa9f012543abf
> 
> The rebase is:
> 
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index 78ac9ece6ff2..7233e805a905 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -4578,6 +4578,14 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
>          __vmread(EXIT_QUALIFICATION, &io_qual.raw);
>          bytes = io_qual.size + 1;
>  
> +        rc = hvm_monitor_io(io_qual.port, bytes,
> +                            io_qual.in ? IOREQ_READ : IOREQ_WRITE,

Here the conditional operator needs dropping; it just "io_qual.in" which
wants passing.

Jan

> +                            io_qual.str);
> +        if ( rc < 0 )
> +            goto exit_and_crash;
> +        if ( rc )
> +            break;
> +
>          if ( io_qual.str )
>          {
>              if ( !hvm_emulate_one_insn(x86_insn_is_portio, "port I/O") )
> 
> 
> ~Andrew




 


Rackspace

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