From: Nadav Amit <namit@cs.technion.ac.il>
To: pbonzini@redhat.com
Cc: gleb@kernel.org, tglx@linutronix.de, mingo@redhat.com,
x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Nadav Amit <namit@cs.technion.ac.il>
Subject: [PATCH kvm-unit-tests] x86: Check DR6.RTM is writable
Date: Tue, 15 Jul 2014 17:41:56 +0300 [thread overview]
Message-ID: <1405435316-9506-1-git-send-email-namit@cs.technion.ac.il> (raw)
In-Reply-To: <1405435066-8936-1-git-send-email-namit@cs.technion.ac.il>
Recently discovered bug shows DR6.RTM is fixed to one. The bug is only apparent
when the host emulates the MOV-DR instruction or when the host debugs the
guest kernel. This patch tests whether DR6.RTM is indeed accessible according
to RTM support as reported by cpuid.
Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
x86/emulator.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/x86/emulator.c b/x86/emulator.c
index 1fd0ca6..f68882f 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -3,6 +3,7 @@
#include "libcflat.h"
#include "desc.h"
#include "types.h"
+#include "processor.h"
#define memset __builtin_memset
#define TESTDEV_IO_PORT 0xe0
@@ -870,6 +871,19 @@ static void test_nop(uint64_t *mem, uint8_t *insn_page,
report("nop", outregs.rax == inregs.rax);
}
+static void test_mov_dr(uint64_t *mem, uint8_t *insn_page,
+ uint8_t *alt_insn_page, void *insn_ram)
+{
+ bool rtm_support = cpuid(7).b & (1 << 11);
+ unsigned long dr6_fixed_1 = rtm_support ? 0xfffe0ff0ul : 0xffff0ff0ul;
+ inregs = (struct regs){ .rax = 0 };
+ MK_INSN(mov_to_dr6, "movq %rax, %dr6\n\t");
+ trap_emulator(mem, alt_insn_page, &insn_mov_to_dr6);
+ MK_INSN(mov_from_dr6, "movq %dr6, %rax\n\t");
+ trap_emulator(mem, alt_insn_page, &insn_mov_from_dr6);
+ report("mov_dr6", outregs.rax == dr6_fixed_1);
+}
+
static void test_crosspage_mmio(volatile uint8_t *mem)
{
volatile uint16_t w, *pw;
@@ -1072,6 +1086,7 @@ int main()
test_movabs(mem, insn_page, alt_insn_page, insn_ram);
test_smsw_reg(mem, insn_page, alt_insn_page, insn_ram);
test_nop(mem, insn_page, alt_insn_page, insn_ram);
+ test_mov_dr(mem, insn_page, alt_insn_page, insn_ram);
test_crosspage_mmio(mem);
test_string_io_mmio(mem);
--
1.9.1
next prev parent reply other threads:[~2014-07-15 14:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 14:37 [PATCH] KVM: x86: DR6/7.RTM cannot be written Nadav Amit
2014-07-15 14:41 ` Nadav Amit [this message]
2014-07-21 15:20 ` [PATCH kvm-unit-tests] x86: Check DR6.RTM is writable Paolo Bonzini
2014-07-21 15:20 ` [PATCH] KVM: x86: DR6/7.RTM cannot be written Paolo Bonzini
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=1405435316-9506-1-git-send-email-namit@cs.technion.ac.il \
--to=namit@cs.technion.ac.il \
--cc=gleb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®