On 28/06/21 19:26, Lai Jiangshan wrote:
From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
When the host is using debug registers but the guest is not using them
nor is the guest in guest-debug state, the kvm code does not reset
the host debug registers before kvm_x86->run(). Rather, it relies on
the hardware vmentry instruction to automatically reset the dr7 registers
which ensures that the host breakpoints do not affect the guest.
But there are still problems:
o The addresses of the host breakpoints can leak into the guest
and the guest may use these information to attack the host.
I don't think this is true, because DRn reads would exit (if they don't, switch_db_regs would be nonzero). But otherwise it makes sense to do at least the DR7 write, and we might as well do all of them.
o It violates the non-instrumentable nature around VM entry and
exit. For example, when a host breakpoint is set on
vcpu->arch.cr2, #DB will hit aftr kvm_guest_enter_irqoff().
Beside the problems, the logic is not consistent either. When the guest
debug registers are active, the host breakpoints are reset before
kvm_x86->run(). But when the guest debug registers are inactive, the
host breakpoints are delayed to be disabled. The host tracing tools may
see different results depending on there is any guest running or not.
More precisely, the host tracing tools may see different results depending on what the guest is doing.
Queued (with fixed commit message), thanks!
Paolo