From mboxrd@z Thu Jan 1 00:00:00 1970 From: Valentine Sinitsyn Subject: Re: Nested paging in nested SVM setup Date: Wed, 20 Aug 2014 12:46:24 +0600 Message-ID: <53F44440.6070408@gmail.com> References: <53A179C4.9060203@gmail.com> <53A18A6D.2050407@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit To: Jan Kiszka , kvm@vger.kernel.org Return-path: Received: from mail-lb0-f177.google.com ([209.85.217.177]:46959 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750745AbaHTGqa (ORCPT ); Wed, 20 Aug 2014 02:46:30 -0400 Received: by mail-lb0-f177.google.com with SMTP id s7so6190721lbd.8 for ; Tue, 19 Aug 2014 23:46:28 -0700 (PDT) In-Reply-To: <53A18A6D.2050407@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: Hi all, Please excuse me for bringing alive a two-month old thread, but I had time to investigate the issue a bit only recently. On 18.06.2014 18:47, Jan Kiszka wrote: > On 2014-06-18 13:36, Valentine Sinitsyn wrote: > If we want to provide useful nested SVM support, this must be feasible. > If there is a bug, it has to be fixed. Looks like it is a bug in KVM. I had a chance to run the same code bare-metal ([1], line 310 is uncommented for bare-metal case but present for nested SVM), and it seems to work as expected. However, When I trace it in nested SVM setup, after some successful APIC reads and writes, I get the following: > qemu-system-x86-1968 [001] 220417.681261: kvm_nested_vmexit: rip: 0xffffffff8104f5b8 reason: npf ext_inf1: 0x000000010000000f ext_inf2: 0x00000000fee00300 ext_int: > 0x00000000 ext_int_err: 0x00000000 > qemu-system-x86-1968 [001] 220417.681261: kvm_page_fault: address fee00300 error_code f > qemu-system-x86-1968 [001] 220417.681263: kvm_emulate_insn: 0:ffffffff8104f5b8:89 04 25 00 93 5f ff (prot64) > qemu-system-x86-1968 [001] 220417.681268: kvm_inj_exception: (0x23c) > qemu-system-x86-1968 [001] 220417.681269: kvm_entry: vcpu 0 > qemu-system-x86-1968 [001] 220417.681271: kvm_exit: reason rip 0xffffffff8104f5b8 info 0 0 You can see the problem here: the code tries to access APIC MMIO register, which is trapped by KVM's MMU code (at nested page table walk). During MMIO access emulation, KVM decides to inject 0x23c exception (which looks wrong, as there is no exception with this number defined). After that things become flawed (pay attention to empty reason in the last line; the VMCB is certainly not in the state KVM expects/supports). I'm no KVM expert, and will be grateful for debugging suggestions (or maybe even assistance). Many thanks for the help. 1. https://github.com/vsinitsyn/jailhouse/blob/amd-v/hypervisor/arch/x86/svm.c#L301 -- Regards, Valentine Sinitsyn