mirror of
https://github.com/Droid-VM/crosvm.git
synced 2026-11-17 06:58:03 +00:00
hypervisor: kvm: handle INS/OUTS VM exits
When the guest executes a repeated string I/O instruction like REP INSB or REP OUTSB, crosvm would previously treat this as one giant I/O, combining the size of the access (1 for INSB, 2 for INSW, etc.) and the count (the CX/ECX register when using the REP prefix) into a single size and called the BusDevice's read() or write() function with this combined size. However, this doesn't match the expected behavior for the repeated string I/O instructions - they copy each data unit to/from sequential memory locations, but they should repeatedly access the *same* port rather than a series of sequential ports. This information was lost in the original implementation since `count` was multiplied into `size`. The broken behavior can be reproduced when using the Linux kernel's fw_cfg driver, which calls the `ioread8_rep()` function that uses a `REP INSB` instruction on x86. With the previous crosvm implementation, when the guest tries to read (for example) 4 sequential bytes from I/O port 0x511, the crosvm fw_cfg device's read() implementation would be called with size = 4, even though the data register is only meant to be a single byte wide. This patch changes the behavior so that I/O exits with count > 1 will call the device's read()/write() function repeatedly with the same address (`count` times), always using the original `size`, e.g. 1 byte for REP INSB. The hypervisor code handles copying the data into the right part of memory, so the device implementations don't need to do anything special to handle the repeated access (it will appear to be several individual IN/OUT accesses from the device's point of view). BUG=b:283990685 TEST=tools/dev_container tools/presubmit TEST=Access fw_cfg sysfs files using crrev.com/c/4702071 Change-Id: If8e520cb3f32a3e0a664a09bfd8884fd92521a67 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4701634 Reviewed-by: Sebastian Hereu <sebastianhereu@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
parent
0fb46cb6fa
commit
063708084c
1 changed files with 30 additions and 26 deletions
Loading…
Add table
Add a link
Reference in a new issue