From: Avi Kivity <avi@redhat.com>
To: "Roedel, Joerg" <Joerg.Roedel@amd.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 0/9] KVM: Make the instruction emulator aware of Nested Virtualization
Date: Fri, 26 Nov 2010 10:28:38 +0200 [thread overview]
Message-ID: <4CEF6FB6.7090004@redhat.com> (raw)
In-Reply-To: <20101125182152.GB9411@amd.com>
On 11/25/2010 08:21 PM, Roedel, Joerg wrote:
> On Thu, Nov 25, 2010 at 10:15:43AM -0500, Avi Kivity wrote:
> > On 11/25/2010 01:46 PM, Roedel, Joerg wrote:
>
> > Eventually the emulator will be used outside kvm. We don't want to tie
> > the two together.
>
> Does any user outside of KVM care about nested virtualization?
No.
> > All that's needed is to read the svm chapter in the AMD manual; you
> > don't need to understand kvm or out nested svm implementation. On the
> > other hand, some information needs to be encoded in the emulator (the
> > order of the intercept check vs exception check) or we need to duplicate
> > checks. We also do a split decode.
>
> Is that person also required to read through the 500 pages of VMX
> documentation when nested VMX gets merged?
Yes.
> > So they get special treatment. Decode bits are for the general case.
> >
> > Let's see:
> >
> > CRx/DRx checks - need group mechanism extension, can use decode bits
>
> The CRx writes are mostly special because exceptions for validity of the
> values written take precedence over the intercept.
We can have three checks, controlled by the decode bits:
// decode instruction
if ((c->d & SvmMask) == SvmInterceptBefore)
... do intercept check
// do privivilge level checks
if ((c->d & SvmMask) == SvmInterceptAfterPriv)
... do intercept check
// fetch operands
if ((c->d & SvmMask) == SvmInterceptAfterMemory)
... do intercept check
> Implementing these
> checks also requires to put the intercept check into the kvm_set_crX
> functions, which, by themselves, needs to be reworked in an SVM specific
> way for this.
Add a kvm_x86_ops callback for this (vmx as usual is pretty complicated
here)
> > Selective CR0 - special
>
> Needs to be handled in the write-cr0 path
In the appropriate callback
> > LIDT/SIDT/LGDT/SGDT/LLDT/SLDT/LTR/STR - decode bits
>
> Check for a valid address before the intercept check. Thus special too.
See above - we can regularize it by encoding where the check takes place.
> > RDTSC/RDPMC/CPUID - decode bits
>
> RDTSC and RDPMC check all exceptions before the intercept too.
>
> > PUSHF/POPF/RSM/IRET/INTn - decode bits, + flag to check before exceptions
>
> Should work with decode-bits.
>
> > INVD /HLT/INVLPG/INVLPGA - decode bits
>
> Exceptions are only caused on cpl> 0 and take precedence over the
> intercept. Should work with decode bits.
>
>
> > VMRUN/VMLOAD/VMSAVE/VMMCALL/STGI/CLGI/SKINIT - decode bits (VMMCALL
> > preempts exceptions)
>
> VMRUN/VMLOAD/VMSAVE need to check rax for a valid physical address
> before the intercept is taken.
Add an SrcPhys/DstPhys decode, it becomes regular.
> All SVM instructions are not allowed in
> real-mode which needs to be checkd too. The realmode-check may be
> generic but with the address check this is harder. So at least
> VMRUN/VMLOAD/VMSAVE are special too.
>
> Further the SVM instructions are not implemented in the emulator at all
> (like some other instructions which can be intercepted). Proper
> emulation of these instructions would require new callbacks.
Sure.
> > RDTSCP/ICEBP/WBINVD/MONITOR/MWAIT - decode bits
>
> RDTSCP needs special handling like RDTSC.
Why?
> MONITOR is special too because
> it checks all exceptions before the intercept.
>
> All this can be done, but I doubt the result will look better or is
> better maintainable than the current the solution in this patch-set.
With proper infrastructure I think all the modifications needed will be
the three checks above and the decode bits (assuming the current
crx/drx/pio callbacks are in the right place).
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
prev parent reply other threads:[~2010-11-26 8:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-24 18:18 [PATCH 0/9] KVM: Make the instruction emulator aware of Nested Virtualization Joerg Roedel
2010-11-24 18:18 ` [PATCH 1/9] KVM: Add infrastructure to emulate instruction intercepts Joerg Roedel
2010-11-24 18:18 ` [PATCH 2/9] KVM: SVM: Add checks for CRx read and write intercepts Joerg Roedel
2010-11-24 18:18 ` [PATCH 3/9] KVM: SVM: Add checks for DRx " Joerg Roedel
2010-11-24 18:18 ` [PATCH 4/9] KVM: SVM: Add intercept checks for descriptor table accesses Joerg Roedel
2010-11-24 18:18 ` [PATCH 5/9] KVM: SVM: Add checks for all group 7 instructions Joerg Roedel
2010-11-24 18:18 ` [PATCH 6/9] KVM: SVM: Add intercept checks for remaining twobyte instructions Joerg Roedel
2010-11-24 18:18 ` [PATCH 7/9] KVM: SVM: Add intercept checks for one-byte instructions Joerg Roedel
2010-11-24 18:18 ` [PATCH 8/9] KVM: SVM: Add checks for IO instructions Joerg Roedel
2010-11-24 18:18 ` [PATCH 9/9] KVM: SVM: Remove nested sel_cr0_write handling code Joerg Roedel
2010-11-24 19:13 ` [PATCH 0/9] KVM: Make the instruction emulator aware of Nested Virtualization Avi Kivity
2010-11-25 11:46 ` Roedel, Joerg
2010-11-25 13:13 ` Roedel, Joerg
2010-11-25 15:17 ` Avi Kivity
2010-11-25 16:23 ` Roedel, Joerg
2010-11-29 17:23 ` Valdis.Kletnieks
2010-11-29 18:32 ` Joerg Roedel
2010-11-29 20:01 ` Valdis.Kletnieks
2010-11-30 8:47 ` Roedel, Joerg
2010-11-25 15:15 ` Avi Kivity
2010-11-25 18:21 ` Roedel, Joerg
2010-11-26 8:28 ` Avi Kivity [this message]
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=4CEF6FB6.7090004@redhat.com \
--to=avi@redhat.com \
--cc=Joerg.Roedel@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@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