Skip to content

Commit d07898e

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86: Don't WARN if userspace mucks with RCX during string I/O exit
Replace a WARN with a comment to call out that userspace can modify RCX during an exit to userspace to handle string I/O. KVM doesn't actually support changing the rep count during an exit, i.e. the scenario can be ignored, but the WARN needs to go as it's trivial to trigger from userspace. Cc: [email protected] Fixes: 3b27de2 ("KVM: x86: split the two parts of emulator_pio_in") Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 777ab82 commit d07898e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/x86/kvm/x86.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7122,7 +7122,13 @@ static int emulator_pio_in(struct kvm_vcpu *vcpu, int size,
71227122
unsigned short port, void *val, unsigned int count)
71237123
{
71247124
if (vcpu->arch.pio.count) {
7125-
/* Complete previous iteration. */
7125+
/*
7126+
* Complete a previous iteration that required userspace I/O.
7127+
* Note, @count isn't guaranteed to match pio.count as userspace
7128+
* can modify ECX before rerunning the vCPU. Ignore any such
7129+
* shenanigans as KVM doesn't support modifying the rep count,
7130+
* and the emulator ensures @count doesn't overflow the buffer.
7131+
*/
71267132
} else {
71277133
int r = __emulator_pio_in(vcpu, size, port, count);
71287134
if (!r)
@@ -7131,7 +7137,6 @@ static int emulator_pio_in(struct kvm_vcpu *vcpu, int size,
71317137
/* Results already available, fall through. */
71327138
}
71337139

7134-
WARN_ON(count != vcpu->arch.pio.count);
71357140
complete_emulator_pio_in(vcpu, val);
71367141
return 1;
71377142
}

0 commit comments

Comments
 (0)