All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	kvm@vger.kernel.org
Subject: Re: Nested paging in nested SVM setup
Date: Thu, 21 Aug 2014 14:48:16 +0600	[thread overview]
Message-ID: <53F5B250.3000206@gmail.com> (raw)
In-Reply-To: <53F59192.3070500@gmail.com>

On 21.08.2014 12:28, Valentine Sinitsyn wrote:
> KVM seems to work properly (no weird exceptions injected), although my
> code now freezes (quick look on the trace suggests it's looping reading
> APIC). Not sure whose bug is it, will look further.
Looks like the problem is that if nested page tables maps some GPA to 
0xfee00000 HPA, it's really mapped to this HPA, and not intercepted with 
KVM's virtual LAPIC implementation. Consider the following trace:

>  qemu-system-x86-344   [000]   644.974072: kvm_entry:            vcpu 0
>  qemu-system-x86-344   [000]   644.974075: kvm_exit:             reason npf rip 0xffffffff8104e883 info 10000000d fee000f0
>  qemu-system-x86-344   [000]   644.974075: kvm_page_fault:       address fee000f0 error_code d
>  qemu-system-x86-344   [000]   644.974077: kvm_emulate_insn:     0:ffffffff8104e883:8b 87 00 b0 5f ff (prot64)
>  qemu-system-x86-344   [000]   644.974078: kvm_apic:             apic_read APIC_SPIV = 0xf
>  qemu-system-x86-344   [000]   644.974079: kvm_mmio:             mmio read len 4 gpa 0xfee000f0 val 0x72007200000000f
>  qemu-system-x86-344   [000]   644.974081: kvm_entry:            vcpu 0
Here, I set up NPT so that any access to 0xfee00000 nested guest 
physical address cause VM exit. Then, my code writes or reads register 
that is mapped to 0xfee00000 KVM's GPA. kvm_apic is called, and 
everything works as expected.

However, if I set up NTP to make 0xfee00000 nested guest physical 
address reads don't cause nested VM exit (by simply clearing U/S flag in 
the NPTE), I get:

>  qemu-system-x86-1066  [003]  1105.864286: kvm_exit:             reason npf rip 0xffffffff8104eaa4 info 10000000f fee00310
>  qemu-system-x86-1066  [003]  1105.864287: kvm_nested_vmexit:    rip: 0xffffffff8104eaa4 reason: npf ext_inf1: 0x000000010000000f ext_inf2: 0x00000000fee00310 ext_int: 0x00000000 ext_int_err: 0x00000000
>  qemu-system-x86-1066  [003]  1105.864287: kvm_page_fault:       address fee00310 error_code f
>  qemu-system-x86-1064  [001]  1105.864288: kvm_exit:             reason npf rip 0xffffffff8104e876 info 10000000f fee000b0
>  qemu-system-x86-1066  [003]  1105.864289: kvm_emulate_insn:     0:ffffffff8104eaa4:89 14 25 10 b3 5f ff (prot64)
>  qemu-system-x86-1064  [001]  1105.864289: kvm_nested_vmexit:    rip: 0xffffffff8104e876 reason: npf ext_inf1: 0x000000010000000f ext_inf2: 0x00000000fee000b0 ext_int: 0x00000000 ext_int_err: 0x00000000
>  qemu-system-x86-1064  [001]  1105.864289: kvm_page_fault:       address fee000b0 error_code f
>  qemu-system-x86-1064  [001]  1105.864291: kvm_emulate_insn:     0:ffffffff8104e876:89 b7 00 b0 5f ff (prot64)
>  qemu-system-x86-1066  [003]  1105.864292: kvm_inj_exception:    e (0x2)
>  qemu-system-x86-1066  [003]  1105.864293: kvm_entry:            vcpu 3
>  qemu-system-x86-1064  [001]  1105.864294: kvm_inj_exception:    e (0x2)
>  qemu-system-x86-1064  [001]  1105.864295: kvm_entry:            vcpu 1

No kvm_apic: after NPTs are set up, no page faults caused by register 
read (error_code: d), to trap and emulate APIC access.

So I'm returning to my original question: is this an intended behavior 
of KVM that APIC access on nested page tables level are not trapped, or 
is this a bug?

Valentine

  reply	other threads:[~2014-08-21  8:48 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 11:36 Nested paging in nested SVM setup Valentine Sinitsyn
2014-06-18 12:47 ` Jan Kiszka
2014-06-18 16:59   ` Valentine Sinitsyn
2014-06-19  9:32     ` Paolo Bonzini
2014-06-19  5:03   ` Valentine Sinitsyn
2014-08-20  6:46   ` Valentine Sinitsyn
2014-08-20  6:55     ` Paolo Bonzini
2014-08-20  7:37       ` Valentine Sinitsyn
2014-08-20  8:11         ` Paolo Bonzini
2014-08-20  9:49           ` Valentine Sinitsyn
2014-08-21  6:28           ` Valentine Sinitsyn
2014-08-21  8:48             ` Valentine Sinitsyn [this message]
2014-08-21 11:04               ` Paolo Bonzini
2014-08-21 11:06                 ` Jan Kiszka
2014-08-21 11:12                   ` Valentine Sinitsyn
2014-08-21 11:16                 ` Valentine Sinitsyn
2014-08-21 11:24               ` Paolo Bonzini
2014-08-21 12:28                 ` Valentine Sinitsyn
2014-08-21 12:38                   ` Valentine Sinitsyn
2014-08-21 13:40                   ` Valentine Sinitsyn
2014-09-01 17:41                   ` Paolo Bonzini
2014-09-01 19:21                     ` Valentine Sinitsyn
2014-09-02  8:25                       ` Paolo Bonzini
2014-09-02  9:16                         ` Valentine Sinitsyn
2014-09-02 11:21                           ` Paolo Bonzini
2014-09-02 11:26                             ` Valentine Sinitsyn
2014-08-21 17:35                 ` Valentine Sinitsyn
2014-08-21 20:31                   ` Paolo Bonzini
2014-08-22  4:33                     ` Valentine Sinitsyn
2014-08-22  8:53                       ` Paolo Bonzini
2014-09-01 16:11                       ` Paolo Bonzini
2014-09-01 17:04     ` Paolo Bonzini
2014-09-02  6:09       ` Valentine Sinitsyn
2014-09-02  6:21         ` Valentine Sinitsyn
2014-09-02  9:45         ` Paolo Bonzini
2014-09-02  9:53           ` Valentine Sinitsyn
2014-09-02 11:48             ` Paolo Bonzini
2014-09-02 10:31           ` Valentine Sinitsyn

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=53F5B250.3000206@gmail.com \
    --to=valentine.sinitsyn@gmail.com \
    --cc=jan.kiszka@siemens.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.