From: Avi Kivity <avi@redhat.com>
To: KVM list <kvm@vger.kernel.org>,
Sheng Yang <sheng@linux.intel.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: Multiplexing RFLAGS.TF
Date: Thu, 29 Jul 2010 17:37:53 +0300 [thread overview]
Message-ID: <4C519241.2010706@redhat.com> (raw)
static int db_interception(struct vcpu_svm *svm)
{
struct kvm_run *kvm_run = svm->vcpu.run;
if (!(svm->vcpu.guest_debug &
(KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) &&
!svm->nmi_singlestep) {
kvm_queue_exception(&svm->vcpu, DB_VECTOR);
return 1;
}
if (svm->nmi_singlestep) {
svm->nmi_singlestep = false;
if (!(svm->vcpu.guest_debug & KVM_GUESTDBG_SINGLESTEP))
svm->vmcb->save.rflags &=
~(X86_EFLAGS_TF | X86_EFLAGS_RF);
update_db_intercept(&svm->vcpu);
}
This code assumes that either the guest is debugging itself, or
(nmi_singlestep | guest debugging). However if the guest is debugging
itself and takes an NMI, or if both host and guest are debugging the
guest, things will go wrong.
So we need an rflags_guest_owned_bits, usually set to -1ULL, but
sometimes (NMI, host debugging) clearing EFLAGS_TF. When we do that, we
need to intercept instructions that influence RFLAGS.TF (POPF, IRET,
INTn) and emulate them. Otherwise, the guest can disable tracing which
was enabled on behalf of the host.
We also need to drop the 'return 1' on the top of the function to allow
both guest and host tracing.
On Intel, the situation is harder. We can't trap POPF or IRET. What we
can do, is use the Monitor Trap Flag on hosts that have it.
Comments? Perhaps I missed something. Maybe I'll try writing a test
case to prove the brokenness, it's fashionable these days.
Jan, as this is your code, are you interested in doing this?
Sheng, the Intel bits?
--
error compiling committee.c: too many arguments to function
next reply other threads:[~2010-07-29 14:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-29 14:37 Avi Kivity [this message]
2010-08-02 1:17 ` Multiplexing RFLAGS.TF Jan Kiszka
2010-08-02 3:18 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C519241.2010706@redhat.com \
--to=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=sheng@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox