From: Bandan Das <bandan.das@stratus.com>
To: "Nadav Har'El" <NYH@il.ibm.com>
Cc: Zachary Amsden <zamsden@gmail.com>,
Bandan Das <bandan.das@stratus.com>,
KVM Mailing List <kvm@vger.kernel.org>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: Nested VMX - L1 hangs on running L2
Date: Wed, 20 Jul 2011 16:42:29 -0400 [thread overview]
Message-ID: <20110720204229.GB1725@stratus.com> (raw)
In-Reply-To: <OF526F82DC.9E752594-ONC22578D3.00690341-C22578D3.006DB7B3@il.ibm.com>
On 0, Nadav Har'El <NYH@il.ibm.com> wrote:
> > No, both patches are wrong.
>
> Guys, thanks for looking into this bug. I'm afraid I'm still at a loss at
> why a TSC bug would even cause a guest lockup :(
>
> When Avi Kivity saw my nested TSC handling code he remarked "this is
> probably wrong". When I asked him where it was wrong, he basically said
> that he didn't know where, but TSC handling code is always wrong ;-)
> And it turns out he was right.
>
> > The correct fix is to make kvm_get_msr() return the L1 guest TSC at all
> times.
> > We are serving the L1 guest in this hypervisor, not the L2 guest, and so
>
> > should never read its TSC for any reason.
> ...
> > allows the L2 guest to overwrite the L1 guest TSC, which at first seems
> wrong,
> > but is in fact the correct virtualization of a security hole in the L1
> guest.
>
> I think I'm beginning to see the error in my ways...
>
> When L1 lets L2 (using the MSR bitmap) direct read/write access to the TSC,
> it doesn't want L0 to be "clever" and give L2 its own separate TSC (like
> I do now), but rather gives it full control over L1's TSC - so reading or
> writing it should actually return L1's TSC, and the TSC_OFFSET in vmcs12
> is to be ignored.
>
> So basically, if I understand correctly, what I need to change is
> in prepare_vmcs02(), if the MSR_IA32_TSC is on the MSR bitmap (read?
> write?), instead of doing
> vmcs_write64(TSC_OFFSET,
> vmx->nested.vmcs01_tsc_offset + vmcs12->tsc_offset);
> I just need to do
> vmcs_write64(TSC_OFFSET,
> vmx->nested.vmcs01_tsc_offset);
> thereby giving L2 exactly the same TSC that L1 had.
> Brandan, if I remember correctly you once tried this sort of fix and
> it actually worked?
That is correct. That is still my "workaround fix" that I have been using
on my systems. But as you have mentioned above (and below), I am still struggling
with two questions :
1. Why does L1 hang even if the TSC has wrong values.
2. I see this on a Dell R610 and I don't know why you and some others don't see this.
I assumed from the symptoms that this should be fairly easy to reproduce on any system.
Bandan
> Then, guest_read_tsc() will return (without need to change this code)
> the correct L1 TSC.
>
> And vmx_write_tsc_offset() should do in the is_guest_mode() not what
> it does now (vmcs12->tsc_offset is of no important when the TSC MSR
> is passed through) but rather set vmcs01_tsc_offset (which will be
> applied on the next exit to L1).
>
> Is my analysis correct? Or perhaps completely wrong? ;-)
> Am I missing anything else that should be change?
>
> In any case, I don't understand why on my machine I never encountered
> these problems, and nothing broke even if I replaced the TSC nesting
> code with randomly broken code. Are the people who are seeing this
> brakage actually passed the MSR from L1 to L2 - using the MSR bitmap -
> like I guessed above? Or am I missing something completely different?
>
> Sorry, but I'm really becoming confused by these TSC issues...
>
> Thanks,
> Nadav.
>
next prev parent reply other threads:[~2011-07-20 20:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-08 18:40 Nested VMX - L1 hangs on running L2 Bandan Das
2011-07-18 18:26 ` Marcelo Tosatti
2011-07-19 2:41 ` Bandan Das
2011-07-20 7:58 ` Jan Kiszka
2011-07-20 16:12 ` Marcelo Tosatti
2011-07-20 16:19 ` Jan Kiszka
2011-07-20 16:35 ` Marcelo Tosatti
[not found] ` <CAKiCmT00vyR5vRBDWFYK2Z8sgmjLBPwbYU5W8q2wAUTrxS1_tA@mail.gmail.com>
2011-07-20 19:52 ` Nadav Har'El
2011-07-20 20:42 ` Bandan Das [this message]
2011-07-21 2:49 ` Zachary Amsden
2011-07-27 11:51 ` Nadav Har'El
2011-07-29 9:01 ` Zachary Amsden
2011-07-29 10:21 ` Roedel, Joerg
2011-07-31 13:48 ` Nadav Har'El
2011-07-31 18:55 ` Zachary Amsden
2011-07-31 20:34 ` Nadav Har'El
2011-07-28 11:11 ` Nadav Har'El
2011-07-29 2:06 ` Matt McGill
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=20110720204229.GB1725@stratus.com \
--to=bandan.das@stratus.com \
--cc=NYH@il.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=zamsden@gmail.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