]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
KVM: X86: Disable hardware breakpoints unconditionally before kvm_x86->run()
authorLai Jiangshan <laijs@linux.alibaba.com>
Mon, 28 Jun 2021 17:26:32 +0000 (01:26 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 20 Sep 2021 13:39:36 +0000 (15:39 +0200)
commit8d5988f3eac1d0b5916ca6ff9191921a23a9ccd3
treeecfdcc0591c46ebc05377379e86cb41ea9706553
parente12bfd5753757d88e55fd5d59c68b0f0fd4b3238
KVM: X86: Disable hardware breakpoints unconditionally before kvm_x86->run()

BugLink: https://bugs.launchpad.net/bugs/1939738
commit f85d40160691881a17a397c448d799dfc90987ba upstream.

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.

This however violates the non-instrumentable nature around VM entry
and exit; for example, when a host breakpoint is set on vcpu->arch.cr2,

Another issue is consistency.  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 what the guest is doing.

To fix the problems, we clear %db7 unconditionally before kvm_x86->run()
if the host has set any breakpoints, no matter if the guest is using
them or not.

Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
Message-Id: <20210628172632.81029-1-jiangshanlai@gmail.com>
Cc: stable@vger.kernel.org
[Only clear %db7 instead of reloading all debug registers. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/x86/kvm/x86.c