From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Graf Subject: [PATCH] fix CPUID handling Date: Mon, 25 Feb 2008 18:37:19 +0100 Message-ID: <47C2FCCF.8030109@csgraf.de> References: <10EA09EFD8728347A513008B6B0DA77A02CFD20F@pdsmsx411.ccr.corp.intel.com> <200802251731.57297.sheng.yang@intel.com> <47C28BA5.1010706@qumranet.com> <47C29C2F.4070907@qumranet.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090509000506070509030301" Cc: kvm-devel@lists.sourceforge.net To: Avi Kivity Return-path: In-Reply-To: <47C29C2F.4070907@qumranet.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org This is a multi-part message in MIME format. --------------090509000506070509030301 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit So this is a new version of the same patch. It should be rather safe now, as most cases are handled by gcc. Signed-off-by: Alexander Graf --------------090509000506070509030301 Content-Type: text/x-patch; name="cpuid.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cpuid.patch" diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c index 37354fb..3062d1b 100644 --- a/qemu/qemu-kvm-x86.c +++ b/qemu/qemu-kvm-x86.c @@ -427,36 +427,22 @@ static void host_cpuid(uint32_t function, uint32_t *eax, uint32_t *ebx, { uint32_t vec[4]; - vec[0] = function; - asm volatile ( -#ifdef __x86_64__ - "sub $128, %%rsp \n\t" /* skip red zone */ - "push %0; push %%rsi \n\t" - "push %%rax; push %%rbx; push %%rcx; push %%rdx \n\t" - "mov 8*5(%%rsp), %%rsi \n\t" - "mov (%%rsi), %%eax \n\t" - "cpuid \n\t" - "mov %%eax, (%%rsi) \n\t" - "mov %%ebx, 4(%%rsi) \n\t" - "mov %%ecx, 8(%%rsi) \n\t" - "mov %%edx, 12(%%rsi) \n\t" - "pop %%rdx; pop %%rcx; pop %%rbx; pop %%rax \n\t" - "pop %%rsi; pop %0 \n\t" - "add $128, %%rsp" +#if defined(__i386__) && defined(__PIC__) + /* We need to handle ebx manually, as PIC code requires it */ + asm volatile("movl %%ebx, %%esi \n\t" + "cpuid \n\t" + "movl %%ebx, %1 \n\t" + "movl %%esi, %%ebx" + : "=a" (vec[0]), "=r" (vec[1]), "=c" (vec[2]), "=d" (vec[3]) + : "0"(function) + : "esi", "cc"); #else - "push %0; push %%esi \n\t" - "push %%eax; push %%ebx; push %%ecx; push %%edx \n\t" - "mov 4*5(%%esp), %%esi \n\t" - "mov (%%esi), %%eax \n\t" - "cpuid \n\t" - "mov %%eax, (%%esi) \n\t" - "mov %%ebx, 4(%%esi) \n\t" - "mov %%ecx, 8(%%esi) \n\t" - "mov %%edx, 12(%%esi) \n\t" - "pop %%edx; pop %%ecx; pop %%ebx; pop %%eax \n\t" - "pop %%esi; pop %0 \n\t" + asm volatile("cpuid" + : "=a" (vec[0]), "=b" (vec[1]),"=c" (vec[2]), "=d" (vec[3]) + : "0"(function) + : "cc"); #endif - : : "rm"(vec) : "memory"); + if (eax) *eax = vec[0]; if (ebx) --------------090509000506070509030301 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ --------------090509000506070509030301 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel --------------090509000506070509030301--