From: "Radim Krčmář" <rkrcmar@redhat.com>
To: charls chap <chapcharls@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: tlb flush after each vm_exit, also virtual interrupts injection
Date: Thu, 28 Jul 2016 15:25:58 +0200 [thread overview]
Message-ID: <20160728132558.GA9119@potion> (raw)
In-Reply-To: <CAA6eV_QkYrYHntZyOOn6x+BPwaneUXnkDjc_=vUYG8MUi1tj7w@mail.gmail.com>
2016-07-27 13:19+0300, charls chap:
> Hello List,
>
> 1)
> I've seen some slides, back in 08, in which it is described
> that the use of VPID, will solve the problem of TLB flush after each VM_EXIT.
VPID solves a problem of excessive TLB flushing by tagging TLB entries
with VPID.
VMX without VPID features flushes TLB on transitions (entry/exit),
because the hardware cannot tell what is valid in current context.
> But, i see from the code that it actually does a flush after a VM_EXIT.
Please quote the code you are seeing.
> Obviously, i am wrong. So I need some help,
> Where to look, i mean which lines of code, in order to figure out, what is
> happening with TLB flush and VM_EXITS
I don't know what you know, so I can only recommend:
1) read SDM for a while
2) git grep -W -i 'tlb\|vpid' arch/x86/kvm virt/kvm
3) goto (1)
> 2) system call from ing 0 (non-root), to ring 0(root)
> Could guest os, do a system call to host os?
Somewhat, there are many ways how to communicate, it would not be a
system call in linux terminology, though.
Maybe you are thinking about hypercalls?
(In any case, KVM was not designed for sharing host kernel
infrastructure with programs running in non-root ring 0.)
> 3) what is the mechanism of virtual interrupt injection
> What is the mechanism that is used for a virtual interrupt injection,
> in full virtualization?
Every interrupt delivery starts by configuring data structures that
depends on the chosen method. There are two main categories of methods:
1) Hardware can be configured while the guest is running.
These methods usually send a special interrupt to the physical CPU
that evaluates the configured data structures.
Hardware can also be the one that configures data structures, so
there is no need for a hypervisor intervention for sending the
interrupt.
2) Hardware cannot be configured while the guest is running.
Configured data structures are evaluated on guest entry.
(The interrupt might also be postponed until guest state allows it,
e.g. TPR.)
Hardware will deliver both interrupts using the guest state.
> Host injects an interrupt to guest, HOW? eg. hardware interrupt?
Same as above.
> to which point of guest? guest complete_bh?
The guest shouldn't be able to tell a difference, so at any point that
is possible in the host (also a subset of them).
> 4)
> I've seen from bibliography, that KVM operates in protection ring -1.
> What doe it mean? Is there HW implementation for that ring?
>
> Why not in ring 0?
If we are taking about VMX, ring -1 is an analogy.
Host (KVM) operates with CPL 0 in VMX root mode, which was likely called
ring -1 by the authors. A guest operates with CPL 0 too, but it is in
VMX non-root mode, so called ring 0.
(VMX can also operate in dual monitor mode, so the analogy could be
extended to call VMX operating in SMM as ring -2.)
prev parent reply other threads:[~2016-07-28 13:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-27 10:19 tlb flush after each vm_exit, also virtual interrupts injection charls chap
2016-07-28 8:20 ` Fwd: " Charls D. Chap
2016-08-02 17:33 ` Paolo Bonzini
2016-08-03 14:43 ` Charls D. Chap
2016-08-03 15:56 ` Paolo Bonzini
2016-08-05 11:29 ` Charls D. Chap
2016-08-05 11:59 ` Paolo Bonzini
2016-08-25 9:12 ` Wanpeng Li
2016-08-29 9:55 ` Paolo Bonzini
2016-08-29 10:22 ` Wanpeng Li
2016-08-29 16:39 ` Paolo Bonzini
2016-08-30 0:39 ` Wanpeng Li
2016-07-28 13:25 ` Radim Krčmář [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=20160728132558.GA9119@potion \
--to=rkrcmar@redhat.com \
--cc=chapcharls@gmail.com \
--cc=kvm@vger.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;
as well as URLs for NNTP newsgroup(s).