From patchwork Sat May 28 08:39:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 97774 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 21954B6F97 for ; Sat, 28 May 2011 18:39:29 +1000 (EST) Received: from localhost ([::1]:46409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQF3N-0006XJ-Nc for incoming@patchwork.ozlabs.org; Sat, 28 May 2011 04:39:25 -0400 Received: from eggs.gnu.org ([140.186.70.92]:48488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQF3F-0006Wj-Mn for qemu-devel@nongnu.org; Sat, 28 May 2011 04:39:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QQF3E-0001fR-GD for qemu-devel@nongnu.org; Sat, 28 May 2011 04:39:17 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:41381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQF3E-0001fH-2W for qemu-devel@nongnu.org; Sat, 28 May 2011 04:39:16 -0400 Received: from smtp01.web.de ( [172.20.0.243]) by fmmailgate02.web.de (Postfix) with ESMTP id 1AD381A0613B6; Sat, 28 May 2011 10:39:14 +0200 (CEST) Received: from [92.75.135.18] (helo=mchn199C.mchp.siemens.de) by smtp01.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1QQF3C-0007CN-00; Sat, 28 May 2011 10:39:14 +0200 Message-ID: <4DE0B4B1.1000407@web.de> Date: Sat, 28 May 2011 10:39:13 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: john cooper References: <4DDAD5CF.5050805@redhat.com> In-Reply-To: <4DDAD5CF.5050805@redhat.com> X-Enigmail-Version: 1.1.2 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX19uspIFUzIR8lwQe2+dAqBZvLzgv/hix3jpr2x5 y5w2ea1/Qaqwbc0im5rEQA/T4ZpdJrP16lG7hweNNkIUFvml2H rHpwmDP9M= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.227 Cc: "Roedel, Joerg" , Anthony Liguori , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH 3/7] cpu model bug fixes and definition corrections: Add kvm emulated x2apic flag to config defined cpu models X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 2011-05-23 23:46, john cooper wrote: > Add kvm emulated x2apic flag to config defined cpu models > and general support for such hypervisor emulated flags. > > In addition to checking user request flags against the host > we also selectively check against kvm for emulated flags. As you are already digging through this jungle, could you also check how much of this diff from qemu-kvm is obsolete now? case 0x80000003: If something is still missing in upstream, it should be ported - except for kvm_nested which should be controllable via '-cpu ...,+/-svm'. TIA! Jörg, how to deal with -enable-nesting in qemu-kvm to align behavior with upstream? Jan diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index e479a4d..091d812 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -1175,6 +1175,31 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx |= 1 << 1; /* CmpLegacy bit */ } } + if (kvm_enabled()) { + uint32_t h_eax, h_edx; + + host_cpuid(index, 0, &h_eax, NULL, NULL, &h_edx); + + /* disable CPU features that the host does not support */ + + /* long mode */ + if ((h_edx & 0x20000000) == 0 /* || !lm_capable_kernel */) + *edx &= ~0x20000000; + /* syscall */ + if ((h_edx & 0x00000800) == 0) + *edx &= ~0x00000800; + /* nx */ + if ((h_edx & 0x00100000) == 0) + *edx &= ~0x00100000; + + /* disable CPU features that KVM cannot support */ + + /* svm */ + if (!kvm_nested) + *ecx &= ~CPUID_EXT3_SVM; + /* 3dnow */ + *edx &= ~0xc0000000; + } break; case 0x80000002: