Skip to content
  • Volker Rümelin's avatar
    ff6e1624
    pckbd: don't update OBF flags if KBD_STAT_OBF is set · ff6e1624
    Volker Rümelin authored
    
    
    Don't update the OBF flags in the status register and the cor-
    responding IRQ lines if KBD_STAT_OBF is set. Otherwise this
    may change the PS/2 event type. If the guest ISR was already
    scheduled, the changed event type will be rather surprising for
    the guest.
    
    This fixes a mouse event stream corruption. To reproduce the
    problem start a FreeDOS 1.2 guest with -machine pc,accel=kvm
    and -display gtk. The KVM in-kernel irqchip has to be enabled.
    Now open a text file with edit.exe in the guest and hold down
    the cursor right key and at the same time move the mouse around.
    You will quickly notice erratic mouse movements and unexpected
    mouse clicks.
    
    A trace file shows the mouse event stream corruption. Guest
    rip 0xce93 (f000:ce93) is the in al,0x60 instruction in the
    seabios mouse ISR, guest rip 0xceca (f000:ceca) is the
    in al,0x60 instruction in the seabios keyboard ISR.
    
    qemu-system-x86-5659  [007] ....   280.971116:
     tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
     # gtk queues a mouse event
    
    qemu-system-x86-5665  [000] ....   280.971121:
     kvm_exit: reason EXTERNAL_INTERRUPT rip 0x22da info 0 800000fd
    qemu-system-x86-5665  [000] d..1   280.971122:
     kvm_entry: vcpu 0, rip 0x22da
    qemu-system-x86-5665  [000] ....   280.971123:
     kvm_exit: reason EXTERNAL_INTERRUPT rip 0x22da info 0 800000fd
    qemu-system-x86-5665  [000] d..1   280.971124:
     kvm_entry: vcpu 0, rip 0x22da
    qemu-system-x86-5665  [000] ....   280.971126:
     kvm_exit: reason IO_INSTRUCTION rip 0x110c8c info 640008 0
    qemu-system-x86-5665  [000] ....   280.971176:
     tracing_mark_write: pckbd_kbd_read_status 0x3d
     # KBD_STAT_OBF and KBD_STAT_MOUSE_OBF set, the mouse ISR will
     # read data from the PS/2 controller.
    
    qemu-system-x86-5665  [000] d..1   280.971180:
     kvm_entry: vcpu 0, rip 0x110c8d
    qemu-system-x86-5665  [000] ....   280.971191:
     kvm_exit: reason EXTERNAL_INTERRUPT rip 0x110c8d info 0 800000f6
    qemu-system-x86-5665  [000] d..1   280.971191:
     kvm_entry: vcpu 0, rip 0x110c8d
    qemu-system-x86-5665  [000] ....   280.971193:
     kvm_exit: reason IO_INSTRUCTION rip 0xce93 info 600048 0
     # the mouse ISR wants to read data from the PS/2 controller
    
    qemu-system-x86-5659  [007] ....   280.971231:
     tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
    qemu-system-x86-5659  [007] ....   280.971238:
     tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
     # gtk queues a keyboard event 0xe0 0x4d (key right)
    
    qemu-system-x86-5665  [000] ....   280.971257:
     tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
    qemu-system-x86-5665  [000] ....   280.971262:
     tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
     # ps2_read_data() deasserts and reasserts the keyboard IRQ
    
    qemu-system-x86-5665  [000] ....   280.971266:
     tracing_mark_write: pckbd_kbd_read_data 0xe0 kbd
     # -> the mouse ISR receives keyboard data
    
    qemu-system-x86-5665  [000] d..1   280.971268:
     kvm_entry: vcpu 0, rip 0xce95
    qemu-system-x86-5665  [000] ....   280.971269:
     kvm_exit: reason IO_INSTRUCTION rip 0xe828 info a00040 0
    qemu-system-x86-5665  [000] ....   280.971270:
     kvm_ack_irq: irqchip PIC slave pin 12
    qemu-system-x86-5665  [000] d..1   280.971270:
     kvm_entry: vcpu 0, rip 0xe82a
    qemu-system-x86-5665  [000] ....   280.971271:
     kvm_exit: reason IO_INSTRUCTION rip 0xe82a info 200040 0
    qemu-system-x86-5665  [000] ....   280.971271:
     kvm_ack_irq: irqchip PIC master pin 2
    qemu-system-x86-5665  [000] d..1   280.971271:
     kvm_entry: vcpu 0, rip 0xe82c
    qemu-system-x86-5665  [000] ....   280.971272:
     kvm_exit: reason PENDING_INTERRUPT rip 0x22da info 0 0
    qemu-system-x86-5665  [000] d..1   280.971273:
     kvm_entry: vcpu 0, rip 0x22da
    qemu-system-x86-5665  [000] ....   280.971274:
     kvm_exit: reason IO_INSTRUCTION rip 0x110c8c info 640008 0
    qemu-system-x86-5665  [000] ....   280.971275:
     tracing_mark_write: pckbd_kbd_read_status 0x1d
    qemu-system-x86-5665  [000] d..1   280.971276:
     kvm_entry: vcpu 0, rip 0x110c8d
    qemu-system-x86-5665  [000] ....   280.971277:
     kvm_exit: reason IO_INSTRUCTION rip 0xceca info 600048 0
     # the keyboard ISR wants to read data from the PS/2 controller
    
    qemu-system-x86-5665  [000] ....   280.971279:
     tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
    qemu-system-x86-5665  [000] ....   280.971282:
     tracing_mark_write: pckbd_kbd_read_data 0x4d kbd
     # the keyboard ISR receives the second byte of the keyboard event
    
    Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
    Message-Id: <20210525181441.27768-5-vr_qemu@t-online.de>
    
    [ kraxel: add missing include ]
    
    Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
    ff6e1624
    pckbd: don't update OBF flags if KBD_STAT_OBF is set
    Volker Rümelin authored
    
    
    Don't update the OBF flags in the status register and the cor-
    responding IRQ lines if KBD_STAT_OBF is set. Otherwise this
    may change the PS/2 event type. If the guest ISR was already
    scheduled, the changed event type will be rather surprising for
    the guest.
    
    This fixes a mouse event stream corruption. To reproduce the
    problem start a FreeDOS 1.2 guest with -machine pc,accel=kvm
    and -display gtk. The KVM in-kernel irqchip has to be enabled.
    Now open a text file with edit.exe in the guest and hold down
    the cursor right key and at the same time move the mouse around.
    You will quickly notice erratic mouse movements and unexpected
    mouse clicks.
    
    A trace file shows the mouse event stream corruption. Guest
    rip 0xce93 (f000:ce93) is the in al,0x60 instruction in the
    seabios mouse ISR, guest rip 0xceca (f000:ceca) is the
    in al,0x60 instruction in the seabios keyboard ISR.
    
    qemu-system-x86-5659  [007] ....   280.971116:
     tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
     # gtk queues a mouse event
    
    qemu-system-x86-5665  [000] ....   280.971121:
     kvm_exit: reason EXTERNAL_INTERRUPT rip 0x22da info 0 800000fd
    qemu-system-x86-5665  [000] d..1   280.971122:
     kvm_entry: vcpu 0, rip 0x22da
    qemu-system-x86-5665  [000] ....   280.971123:
     kvm_exit: reason EXTERNAL_INTERRUPT rip 0x22da info 0 800000fd
    qemu-system-x86-5665  [000] d..1   280.971124:
     kvm_entry: vcpu 0, rip 0x22da
    qemu-system-x86-5665  [000] ....   280.971126:
     kvm_exit: reason IO_INSTRUCTION rip 0x110c8c info 640008 0
    qemu-system-x86-5665  [000] ....   280.971176:
     tracing_mark_write: pckbd_kbd_read_status 0x3d
     # KBD_STAT_OBF and KBD_STAT_MOUSE_OBF set, the mouse ISR will
     # read data from the PS/2 controller.
    
    qemu-system-x86-5665  [000] d..1   280.971180:
     kvm_entry: vcpu 0, rip 0x110c8d
    qemu-system-x86-5665  [000] ....   280.971191:
     kvm_exit: reason EXTERNAL_INTERRUPT rip 0x110c8d info 0 800000f6
    qemu-system-x86-5665  [000] d..1   280.971191:
     kvm_entry: vcpu 0, rip 0x110c8d
    qemu-system-x86-5665  [000] ....   280.971193:
     kvm_exit: reason IO_INSTRUCTION rip 0xce93 info 600048 0
     # the mouse ISR wants to read data from the PS/2 controller
    
    qemu-system-x86-5659  [007] ....   280.971231:
     tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
    qemu-system-x86-5659  [007] ....   280.971238:
     tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
     # gtk queues a keyboard event 0xe0 0x4d (key right)
    
    qemu-system-x86-5665  [000] ....   280.971257:
     tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
    qemu-system-x86-5665  [000] ....   280.971262:
     tracing_mark_write: pckbd_kbd_update_irq kbd=1 aux=0
     # ps2_read_data() deasserts and reasserts the keyboard IRQ
    
    qemu-system-x86-5665  [000] ....   280.971266:
     tracing_mark_write: pckbd_kbd_read_data 0xe0 kbd
     # -> the mouse ISR receives keyboard data
    
    qemu-system-x86-5665  [000] d..1   280.971268:
     kvm_entry: vcpu 0, rip 0xce95
    qemu-system-x86-5665  [000] ....   280.971269:
     kvm_exit: reason IO_INSTRUCTION rip 0xe828 info a00040 0
    qemu-system-x86-5665  [000] ....   280.971270:
     kvm_ack_irq: irqchip PIC slave pin 12
    qemu-system-x86-5665  [000] d..1   280.971270:
     kvm_entry: vcpu 0, rip 0xe82a
    qemu-system-x86-5665  [000] ....   280.971271:
     kvm_exit: reason IO_INSTRUCTION rip 0xe82a info 200040 0
    qemu-system-x86-5665  [000] ....   280.971271:
     kvm_ack_irq: irqchip PIC master pin 2
    qemu-system-x86-5665  [000] d..1   280.971271:
     kvm_entry: vcpu 0, rip 0xe82c
    qemu-system-x86-5665  [000] ....   280.971272:
     kvm_exit: reason PENDING_INTERRUPT rip 0x22da info 0 0
    qemu-system-x86-5665  [000] d..1   280.971273:
     kvm_entry: vcpu 0, rip 0x22da
    qemu-system-x86-5665  [000] ....   280.971274:
     kvm_exit: reason IO_INSTRUCTION rip 0x110c8c info 640008 0
    qemu-system-x86-5665  [000] ....   280.971275:
     tracing_mark_write: pckbd_kbd_read_status 0x1d
    qemu-system-x86-5665  [000] d..1   280.971276:
     kvm_entry: vcpu 0, rip 0x110c8d
    qemu-system-x86-5665  [000] ....   280.971277:
     kvm_exit: reason IO_INSTRUCTION rip 0xceca info 600048 0
     # the keyboard ISR wants to read data from the PS/2 controller
    
    qemu-system-x86-5665  [000] ....   280.971279:
     tracing_mark_write: pckbd_kbd_update_irq kbd=0 aux=1
    qemu-system-x86-5665  [000] ....   280.971282:
     tracing_mark_write: pckbd_kbd_read_data 0x4d kbd
     # the keyboard ISR receives the second byte of the keyboard event
    
    Signed-off-by: default avatarVolker Rümelin <vr_qemu@t-online.de>
    Message-Id: <20210525181441.27768-5-vr_qemu@t-online.de>
    
    [ kraxel: add missing include ]
    
    Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Loading