[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>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Tue, 21 Mar 2023 10:51:30 +0000
- 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=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=NuO4yvFDd0U8oYpY90zXZiyXZhPKJMpiGHyQ7KKGbzs=; b=L+ZIFN+HasQMCKm23HbjdQKvOETTkFgKmfmkyBlN0pfVB+ddUveGu1I9obp/kcUMZMi9lr3AKWgVH36Zn+pZOnP+YyuGZUUNwdzkLcclj3PAViW1Jrsjh7Rex5QG4kjVm6xekpdVFR9dN+1QZYdlf6P8U7QWWvZ119ndVY9z3HTrvvvymuM66nLPqJlVcUpgpPK2KdVhWYXVk+4oJ9qrnUChEAbEal+XjHHG0KpnYKatNlr2oLhlVNs0xWlahVO9DUEpohRdIgjO/61aJ9VoIfeBlo/vvtU1uVRChFMUkMaEkwH7geYcdpow0brr6j30Hp99soJoyjyAy381503Zuw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kks2GbL/NCXvSl4mWY5/YGwe1chpJcNv0ndbDcHD26P6Rlfg718E9Yka2zYNsmpkisV2fT1z8PTAOd3uE8Xo+jo6b7ySeqDVTPRF2p6qP26RdA6q9kHpOSFntEdRDrdLKx1++6aI9aKSnDSCl9kD2V0CViSBr6gwawSmr/Nhr1+s0Wx20FVkvVWNq0zD6GF3J9n66aFesi3EntNBU6BI0sb5ZSvuynourJ1yduQ2x0JjNcLoJq7dpPV/Ti+zAl93OPR4tD5PKhPXIKW/MNgR0ePNK/FBh0nXwph7Yim8wCIsDiN5GIXykbMm34JNB0qMSCl07p/2KxtwrcGc7qlFuw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, 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>
- Delivery-date: Tue, 21 Mar 2023 10:52:06 +0000
- Ironport-data: A9a23:b6dXt6wG9TyE1UEyLld6t+c+xirEfRIJ4+MujC+fZmUNrF6WrkUPy GsbCmGEaf7bNmrycoonYIW+8RsF75WGnNFhGwFo/iAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw//F+UMHUMja4mtC5QRlP6kT5TcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KTkX5 9kTdCgAVUqkpeGT5pObR8p1pst2eaEHPKtH0p1h5RfwKK56BLrlE+DN79Ie2yosjMdTG/qYf 9AedTdkcBXHZVtIJ0sTD5U92uyvgxETcRUB8A7T+fVxvDSVkFIZPLvFabI5fvSjQ8lPk1nej WXB52njWTkRNcCFyCrD+XWp7gPKtXqjBNtKTeLlr5aGhnXPm1ZNJww2SWGaqKLhl23jA4JjB FELr39GQa8asRbDosPGdxyjqX+HvxhZV99RD/crwBCEzKbZ80CDGwAsXjNHLdArqsIybTgrz UOS2cPkAyR1t7+YQm7b8a2bxRutPQAFIGlEYjULJSMH7MPku5oblQ/UQ5BoF6vdpt//FCz0w juKhDMjnLhVhskOv4254FTGjjSEtpXPCAkv6W3/RXm55wl0YIqkYY2A6lXB6/tEaoGDQTGpo HEBktO28OMKAJeChSGJBu4KGdmB7veeOTzYiHZlHoUt+jqg/XKuZ8Zb5zQWDF9xM9wPcDvga lL7swJN6JJdMX2mYLUxaIW0Y+wo0K6mE93mX/LVa9NmY55teQvB9yZrDWaT0n7slg4wkKg5E ZadbcuoS30dDMxPxTC7Q+AAyrg17jgi3m7YWIr60wXh2r2bDEN5Up8AOVqKK+o/vKWNpV2J9 84Fb5fUjRJCTOf5fy/bt5YJKkwHJmQ6ApawrNFLcumEIUxtH2RJ5+Lt/I7NsrdNx8x9/tokN FnnMqOE4DITXUH6FDg=
- Ironport-hdrordr: A9a23:fUBB66nRG11mAsPJLSZFL/uO7o7pDfIT3DAbv31ZSRFFG/FwWf re5cjztCWE8Ar5PUtLpTnuAtjkfZqxz+8W3WBVB8bAYOCEggqVxeNZnO/fKlTbckWUygce78 ddmsNFebrN5DZB/KDHCcqDf+rIAuPrzEllv4jjJr5WIz1XVw==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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,
+ 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
|