kvm: external module: fix preempt notifier emulation clash with hardware debug
there's a small glitch in the preempt notifier external module
emulation. The overloaded debug handler will not detect when a debug
exception has been generated by ptrace and it'll crash the host by
calling the preempt emulator like if this was a KVM preempt emulated
exception, instead of notifying userland.
To detect when the preempt emulation is needed and when the exception
should be bypassed to the original handler, I decided to use bit 10 of
db7 that can't be set to 1 by ptrace, the mask against the userland
passed db7 value is 0xfc00, so bit 10 is forbidden to be on unless it
was KVM setting it manually with 0x701 (kvm really only needs 0x301 to
get exact exception, dunno what 0x400 means, it's defined reserved,
but it doesn't matter what it means as long as ptrace can't set it ;).
Signed-off-by: Andrea Arcangeli <andrea@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>