target/i386: disable/enable breakpoints on vmentry/vmexit
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 29 May 2024 13:41:56 +0000 (15:41 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 8 Jun 2024 08:33:38 +0000 (10:33 +0200)
commit8aa76496dfaac0d7b0dd34793359680c90d9aea0
tree73c7b2c20e9f2e3148dc7f7dfbed854fdc540040
parent57f8dbdbe94a502301f51809e8b282b02df43370
target/i386: disable/enable breakpoints on vmentry/vmexit

If the required DR7 (either from the VMCB or from the host save
area) disables a breakpoint that was enabled prior to vmentry
or vmexit, it is left enabled and will trigger EXCP_DEBUG.
This causes a spurious #DB on the next crossing of the breakpoint.

To disable it, vmentry/vmexit must use cpu_x86_update_dr7
to load DR7.

Because cpu_x86_update_dr7 takes a 32-bit argument, check
reserved bits prior to calling cpu_x86_update_dr7, and do the
same for DR6 as well for consistency.

This scenario is tested by the "host_rflags" test in kvm-unit-tests.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/tcg/sysemu/svm_helper.c