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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html