From: "Roedel, Joerg" <Joerg.Roedel@amd.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH 3/4] test: Add mode-switch test for nested svm
Date: Mon, 2 Aug 2010 16:11:46 +0200 [thread overview]
Message-ID: <20100802141146.GB25471@amd.com> (raw)
In-Reply-To: <4C56CE5E.2080908@redhat.com>
On Mon, Aug 02, 2010 at 09:55:42AM -0400, Avi Kivity wrote:
> On 08/02/2010 04:33 PM, Joerg Roedel wrote:
> > +static void test_mode_switch(struct test *test)
> > +{
> > + asm volatile(" cli\n"
> > + " ljmp *1f\n" /* jump to 32-bit code segment */
> > + "1:\n"
> > + " .long 2f\n"
> > + " .long 40\n"
> > + ".code32\n"
> > + "2:\n"
> > + " movl %%cr0, %%eax\n"
> > + " btcl $31, %%eax\n" /* clear PG */
> > + " movl %%eax, %%cr0\n"
> > + " movl $0xc0000080, %%ecx\n" /* EFER */
> > + " rdmsr\n"
> > + " btcl $8, %%eax\n" /* clear LME */
> > + " wrmsr\n"
> > + " movl %%cr4, %%eax\n"
> > + " btcl $5, %%eax\n" /* clear PAE */
> > + " movl %%eax, %%cr4\n"
> > + " movw $64, %%ax\n"
> > + " movw %%ax, %%ds\n"
> > + " ljmpl $56, $3f\n" /* jump to 16 bit protected-mode */
> > + ".code16\n"
> > + "3:\n"
> > + " movl %%cr0, %%eax\n"
> > + " btcl $0, %%eax\n" /* clear PE */
> > + " movl %%eax, %%cr0\n"
> > + " ljmpl $0, $4f\n" /* jump to real-mode */
> > + "4:\n"
> > + " vmmcall\n"
> > + " movl %%cr0, %%eax\n"
> > + " btsl $0, %%eax\n" /* set PE */
> > + " movl %%eax, %%cr0\n"
> > + " ljmpl $40, $5f\n" /* back to protected mode */
> > + ".code32\n"
> > + "5:\n"
> > + " movl %%cr4, %%eax\n"
> > + " btsl $5, %%eax\n" /* set PAE */
> > + " movl %%eax, %%cr4\n"
> > + " movl $0xc0000080, %%ecx\n" /* EFER */
> > + " rdmsr\n"
> > + " btsl $8, %%eax\n" /* set LME */
> > + " wrmsr\n"
> > + " movl %%cr0, %%eax\n"
> > + " btsl $31, %%eax\n" /* set PG */
> > + " movl %%eax, %%cr0\n"
> > + " ljmpl $8, $6f\n" /* back to long mode */
> > + ".code64\n\t"
> > + "6:\n"
> > + " vmmcall\n"
> > + ::: "rax", "rbx", "rcx", "rdx", "memory");
> > +}
> > +
>
> What is this testing exactly? There is no svm function directly
> associated with mode switch. In fact, most L1s will intercept cr and
> efer access and emulate the mode switch, rather than letting L2 perform
> the mode switch directly.
This is testing the failure case without the nested-svm efer patch I
submitted last week. The sequence above (which switches from long mode
to real mode and back to long mode) fails without this patch.
Joerg
--
AMD Operating System Research Center
Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
next prev parent reply other threads:[~2010-08-02 14:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-02 13:33 [PATCH 0/4] qemu-kvm: Add some nested svm tests Joerg Roedel
2010-08-02 13:33 ` [PATCH 1/4] test: Run tests with asid 1 Joerg Roedel
2010-08-02 13:33 ` [PATCH 2/4] test: Add nested svm next_rip test Joerg Roedel
2010-08-02 13:33 ` [PATCH 3/4] test: Add mode-switch test for nested svm Joerg Roedel
2010-08-02 13:55 ` Avi Kivity
2010-08-02 14:11 ` Roedel, Joerg [this message]
2010-08-02 14:24 ` Avi Kivity
2010-08-02 14:56 ` Roedel, Joerg
2010-08-02 13:33 ` [PATCH 4/4] test: Add test to check if asid 0 is allowed Joerg Roedel
2010-08-02 14:44 ` [PATCH 0/4] qemu-kvm: Add some nested svm tests 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=20100802141146.GB25471@amd.com \
--to=joerg.roedel@amd.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@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