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

[PATCH] x86/vmx: Provide named fields for IO exit qualification


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 20 Mar 2023 18:20:52 +0000
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Mon, 20 Mar 2023 18:21:13 +0000
  • Ironport-data: A9a23:s0hAPq6EESZUaL0TGCG1tgxRtFbHchMFZxGqfqrLsTDasY5as4F+v jMfUT+HM/uONzDyKNlyaI6wpEgB6J7Xy4BrGQBl/nxnHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvynTraCYnsrLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9VU+7JwehBtC5gZlPasR5AeH/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5m6 +YkNWAVfgy6hv/u/emLWO51gNZyFZy+VG8fkikIITDxCP8nRdbIQrnQ5M8e1zA17ixMNa+AP YxDM2MpNUmeJUQVYT/7C7pn9AusrlD5fydVtxS+oq0v7nKI5AdwzKLsIJzefdniqcB9xx7C/ jqerzWgav0cHP3ClQOc8FyLvL7SmA/0RNwDG5qo1PE/1TV/wURMUUZLBDNXu8KRlUqWS99Zb UsO9UIGrqUs9UrtUtj0WTW5pmKJulgXXN84O/037kSBx7TZ5y6dB3MYVXhRZdo+rsg0SDc2k FiTkLvBJxZirbmUQnK17aqPoHW5Pi19EIMZTXZaF01fuYCl+dxtyEuVFb6PDZJZkPXrAw3tk yiasBE/mu0u1v4Z0Ly97wH+1mfESofycuIl2unGdjv7sVIhPtP9ONzABUvztqgZctvAJrWVl D1dwpXFsrhTZX2YvHbVKNjhCo1F8Bps3Nf0pVd0V6cs+D22k5JIVdABuWouTKuF3yttRNMIX KMwkVkLjHOrFCH2BZKbmb5d9uxwlfSwfTgaahwkRoUXOcUgHON21CpveVSRzwjQraTYqolmY c3zWZ/1XR4n5VFPkGLeb/0DyoUi2i1W7TqVHfgXOTz7i+vBDJNUIJ9ZWGazghcRtf3U+VqJq I0BbKNnCXx3CYXDX8UeyqZLRXhiEJTxLcqeRxB/HgJbHjdbJQ==
  • Ironport-hdrordr: A9a23:4F9A+aFzr2eqgFxPpLqEOceALOsnbusQ8zAXPidKOH5om62j5q OTdZEgvnXJYVkqNU3I5urwX5VoLUmxyXcX2+ks1NWZMjUO0VHARL2KhrGC/9SPIULDH+dmpM FdWrk7ANniSUJ8l4L/7BOjG9gthNmLmZrY4Nv23jNkSRIvcaZ7qx1kARyQCU1uWQlBAt4wD5 303Lsimwad
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This removes most of the opencoded bit logic on the exit qualification.
Unfortunately, size is 1-based not 0-based, so need adjusting in a separate
variable.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Kevin Tian <kevin.tian@xxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vmx.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 00b531f76cbf..a96c601efded 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4560,23 +4560,37 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
         break;
 
     case EXIT_REASON_IO_INSTRUCTION:
-        __vmread(EXIT_QUALIFICATION, &exit_qualification);
-        if ( exit_qualification & 0x10 )
+    {
+        union {
+            unsigned long raw;
+            struct {
+                uint32_t size:3;
+                bool     in:1;
+                bool     str:1;
+                bool     rep:1;
+                bool     imm:1;
+                uint32_t :9;
+                uint16_t port;
+            };
+        } io_qual;
+        unsigned int bytes;
+
+        __vmread(EXIT_QUALIFICATION, &io_qual.raw);
+        bytes = io_qual.size + 1;
+
+        if ( io_qual.str )
         {
-            /* INS, OUTS */
             if ( !hvm_emulate_one_insn(x86_insn_is_portio, "port I/O") )
                 hvm_inject_hw_exception(TRAP_gp_fault, 0);
         }
         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(io_qual.port, bytes,
+                            io_qual.in ? IOREQ_READ : IOREQ_WRITE) )
                 update_guest_eip(); /* Safe: IN, OUT */
         }
         break;
+    }
 
     case EXIT_REASON_INVD:
     case EXIT_REASON_WBINVD:
-- 
2.30.2




 


Rackspace

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