From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v4 0/2] Basic nested VMX test suite Date: Wed, 17 Jul 2013 16:10:46 +0200 Message-ID: <51E6A5E6.4020605@redhat.com> References: <1374041153-32235-1-git-send-email-yzt356@gmail.com> <20130717062151.GJ8981@redhat.com> <51E64D59.5050307@redhat.com> <20130717090320.GS11772@redhat.com> <51E66FB4.9080100@redhat.com> <20130717103153.GA19599@redhat.com> <51E677E0.8070403@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]:34728 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755329Ab3GQOK5 (ORCPT ); Wed, 17 Jul 2013 10:10:57 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 17/07/2013 15:48, Arthur Chunqi Li ha scritto: > Actually, both structure are kind to me and except for some concerns > Gleb's solutions seems easier to read. > > The first concern is Gleb's way cannot set a seperate stack for > HOST_RSP, which I predefined this can be set by test suite's init > function. I have discussed with Jan and he said we don't have such > test cases. > > The second is huge function and more assembler codes, I will separate > vmx_handler codes and this is not important. > > I have another question, I write codes like this: > > asm volatile("vmlaunch;seta %0\n\t" : "=m"(ret)); Note that this asm needs a "memory" clobber too. This is what I referred to as "more complications in where to put compiler barriers" in my earlier message. In general, bypassing compiler optimizations is why I preferred your earlier solution. > /* Should not reach here */ > printf("%s : vmlaunch failed, ret=%d.\n", __func__, ret); > goto err; > > while(1) { > .... > } > > Then because we use -O1 optimization param for our test cases, all the > codes after "goto" are gone and I got the following error: > > /root/xelatex.kvm-unit-tests-vmx.git/x86/vmx.c:247: undefined > reference to `vmx_return' > collect2: ld returned 1 exit status > > So how could I disable the opt for this function or bypass such occasion? You can do something like ret = 0; asm volatile("vmlaunch;seta %0\n\t" : "=m"(ret) : : "memory"); /* Actually we go straight to the while(1) below if ret==0 */ if (ret) { printf("%s : vmlaunch failed, ret=%d.\n", __func__, ret); goto err; } while(1) { ... } or if you want to make it more explicit to the compiler: ret = 0; /* asm goto cannot have outputs :( */ asm volatile goto ("vmlaunch;seta (%0)\n\t" : : "r"(&ret) : "memory" : resume); printf("%s : vmlaunch failed, ret=%d.\n", __func__, ret); goto err; resume: while(1) { ... } Paolo