From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [RFC PATCH] kvm-unit-tests : Basic architecture of VMX nested test case Date: Wed, 24 Jul 2013 08:48:25 +0200 Message-ID: <51EF78B9.9090908@redhat.com> References: <1374087242-6125-1-git-send-email-yzt356@gmail.com> <51E78295.2010700@redhat.com> <20130718072652.GB11772@redhat.com> <51E7C7D2.5040303@redhat.com> <20130718110639.GA26173@redhat.com> <51E7DAD3.8000906@redhat.com> <20130718195712.GN13732@redhat.com> <51E8DFCC.8060108@redhat.com> <20130719094027.GY13732@redhat.com> <51E92BE2.1080600@redhat.com> <51EF76E2.2030201@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , kvm , Jan Kiszka To: Arthur Chunqi Li Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34780 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752360Ab3GXGsl (ORCPT ); Wed, 24 Jul 2013 02:48:41 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 24/07/2013 08:46, Arthur Chunqi Li ha scritto: > On Wed, Jul 24, 2013 at 2:40 PM, Paolo Bonzini wrote: >> Il 24/07/2013 08:11, Arthur Chunqi Li ha scritto: >>> >>> static int vmx_run() >>> { >>> u32 eax; >>> bool ret; >>> >>> vmcs_write(HOST_RSP, get_rsp()); >>> ret = vmlaunch(); >> >> The compiler can still change rsp between here... >> >>> while (!ret) { >>> asm volatile( >>> "vmx_return:\n\t" >> >> ... and here. >> >> If you want to write it in C, the only thing that can be after >> vmlaunch/vmresume is "exit()". Else it has to be asm. > Actually, you mean we need to write all the codes in asm to avoid > changing to rsp, right? Not necessarily all the code. It is also ok to use setjmp/longjmp with a small asm trampoline, because this method won't care about the exact rsp values that are used. But if you want to do as Gleb said, and put vmx_return just after vmlaunch, it has to be all asm as in KVM's arch/x86/kvm/vmx.c. Paolo