From: Jan Kiszka <jan.kiszka@siemens.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm <kvm@vger.kernel.org>, Bandan Das <bsd@redhat.com>
Subject: Re: [PATCH 5/5] VMX: Test behavior on set and cleared save/load debug controls
Date: Mon, 16 Jun 2014 13:28:52 +0200 [thread overview]
Message-ID: <539ED4F4.5090008@siemens.com> (raw)
In-Reply-To: <539ECEDD.3030902@redhat.com>
On 2014-06-16 13:02, Paolo Bonzini wrote:
> Il 15/06/2014 16:24, Jan Kiszka ha scritto:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> This particularly checks the case when debug controls are not to be
>> loaded/saved on host-guest transitions.
>>
>> We have to fake results related to IA32_DEBUGCTL as support for this MSR
>> is missing KVM. The test already contains all bits required once KVM
>> adds support.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>> x86/vmx.h | 2 ++
>> x86/vmx_tests.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 112 insertions(+)
>>
>> diff --git a/x86/vmx.h b/x86/vmx.h
>> index 38ec3c5..3c4830f 100644
>> --- a/x86/vmx.h
>> +++ b/x86/vmx.h
>> @@ -326,6 +326,7 @@ enum Reason {
>> #define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
>>
>> enum Ctrl_exi {
>> + EXI_SAVE_DBGCTLS = 1UL << 2,
>> EXI_HOST_64 = 1UL << 9,
>> EXI_LOAD_PERF = 1UL << 12,
>> EXI_INTA = 1UL << 15,
>> @@ -337,6 +338,7 @@ enum Ctrl_exi {
>> };
>>
>> enum Ctrl_ent {
>> + ENT_LOAD_DBGCTLS = 1UL << 2,
>> ENT_GUEST_64 = 1UL << 9,
>> ENT_LOAD_PAT = 1UL << 14,
>> ENT_LOAD_EFER = 1UL << 15,
>> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
>> index d0b67de..0f4cfc2 100644
>> --- a/x86/vmx_tests.c
>> +++ b/x86/vmx_tests.c
>> @@ -1406,6 +1406,114 @@ static int interrupt_exit_handler(void)
>> return VMX_TEST_VMEXIT;
>> }
>>
>> +static int dbgctls_init(struct vmcs *vmcs)
>> +{
>> + u64 dr7 = 0x402;
>> + u64 zero = 0;
>> +
>> + msr_bmp_init();
>> + asm volatile(
>> + "mov %0,%%dr0\n\t"
>> + "mov %0,%%dr1\n\t"
>> + "mov %0,%%dr2\n\t"
>> + "mov %1,%%dr7\n\t"
>> + : : "r" (zero), "r" (dr7));
>> + wrmsr(MSR_IA32_DEBUGCTLMSR, 0x1);
>> + vmcs_write(GUEST_DR7, 0x404);
>> + vmcs_write(GUEST_DEBUGCTL, 0x2);
>> +
>> + vmcs_write(ENT_CONTROLS, vmcs_read(ENT_CONTROLS) | ENT_LOAD_DBGCTLS);
>> + vmcs_write(EXI_CONTROLS, vmcs_read(EXI_CONTROLS) | EXI_SAVE_DBGCTLS);
>> +
>> + return VMX_TEST_START;
>> +}
>> +
>> +static void dbgctls_main(void)
>> +{
>> + u64 dr7, debugctl;
>> +
>> + asm volatile("mov %%dr7,%0" : "=r" (dr7));
>> + debugctl = rdmsr(MSR_IA32_DEBUGCTLMSR);
>> + debugctl = 0x2; /* KVM does not support DEBUGCTL so far */
>> + report("Load debug controls", dr7 == 0x404 && debugctl == 0x2);
>
> Please comment instead like this:
>
> report("Load debug controls", dr7 == 0x404 /* && debugctl == 0x2 */ );
>
>> + asm volatile("mov %%dr7,%0" : "=r" (dr7));
>> + debugctl = rdmsr(MSR_IA32_DEBUGCTLMSR);
>> + debugctl = 0x1; /* no KVM support */
>> + report("Guest=host debug controls", dr7 == 0x402 && debugctl == 0x1);
>
> Same here.
>
>> + if (dr7 == 0x400 && debugctl == 0 &&
>> + vmcs_read(GUEST_DR7) == 0x408 &&
>> + vmcs_read(GUEST_DEBUGCTL) == /* 0x3 no KVM support*/ 0x2)
>
> and here.
>
>> + set_stage(1);
>> + break;
>> + case 2:
>> + dr7 = 0x402;
>> + asm volatile("mov %0,%%dr7" : : "r" (dr7));
>> + wrmsr(MSR_IA32_DEBUGCTLMSR, 0x1);
>> + vmcs_write(GUEST_DR7, 0x404);
>> + vmcs_write(GUEST_DEBUGCTL, 0x2);
>> +
>> + vmcs_write(ENT_CONTROLS,
>> + vmcs_read(ENT_CONTROLS) & ~ENT_LOAD_DBGCTLS);
>> + vmcs_write(EXI_CONTROLS,
>> + vmcs_read(EXI_CONTROLS) & ~EXI_SAVE_DBGCTLS);
>> + break;
>> + case 3:
>> + if (dr7 == 0x400 && debugctl == 0 &&
>> + vmcs_read(GUEST_DR7) == 0x404 &&
>> + vmcs_read(GUEST_DEBUGCTL) == 0x2)
>
> and here too, even though it happens to work.
OK, no problem.
Jan
--
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2014-06-16 11:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-15 14:24 [PATCH 0/5] kvm-unit-tests: more instr. interceptions, debug control migration Jan Kiszka
2014-06-15 14:24 ` [PATCH 1/5] VMX: Add tests for CR3 and CR8 interception Jan Kiszka
2014-06-16 10:53 ` Paolo Bonzini
2014-06-16 11:31 ` Jan Kiszka
2014-06-15 14:24 ` [PATCH 2/5] VMX: Only use get_stage accessor Jan Kiszka
2014-06-16 17:19 ` Bandan Das
2014-06-15 14:24 ` [PATCH 3/5] VMX: Test both interception and execution of instructions Jan Kiszka
2014-06-15 14:24 ` [PATCH 4/5] VMX: Validate capability MSRs Jan Kiszka
2014-06-16 11:00 ` Paolo Bonzini
2014-06-16 11:26 ` Jan Kiszka
2014-06-15 14:24 ` [PATCH 5/5] VMX: Test behavior on set and cleared save/load debug controls Jan Kiszka
2014-06-16 11:02 ` Paolo Bonzini
2014-06-16 11:28 ` Jan Kiszka [this message]
2014-06-16 11:03 ` [PATCH 0/5] kvm-unit-tests: more instr. interceptions, debug control migration 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=539ED4F4.5090008@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=bsd@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.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