From patchwork Mon May 6 16:20:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 241724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B76CD2C00F9 for ; Tue, 7 May 2013 02:59:41 +1000 (EST) Received: from localhost ([::1]:42591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZO9v-00013a-21 for incoming@patchwork.ozlabs.org; Mon, 06 May 2013 12:21:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZO9I-0000v8-In for qemu-devel@nongnu.org; Mon, 06 May 2013 12:20:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZO9G-0004WA-IS for qemu-devel@nongnu.org; Mon, 06 May 2013 12:20:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42094) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZO9G-0004Vt-9i for qemu-devel@nongnu.org; Mon, 06 May 2013 12:20:22 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r46GKLhH011237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 May 2013 12:20:21 -0400 Received: from localhost (vpn1-4-90.gru2.redhat.com [10.97.4.90]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r46GKKN9012980; Mon, 6 May 2013 12:20:21 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 6 May 2013 13:20:08 -0300 Message-Id: <1367857209-22215-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1367857209-22215-1-git-send-email-ehabkost@redhat.com> References: <1367857209-22215-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: libvir-list@redhat.com, Igor Mammedov Subject: [Qemu-devel] [PATCH qom-cpu-next 2/3] target-i386: Introduce X86CPU.filtered_features field 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 This field will contain the feature bits that were filtered out because of missing host support. Signed-off-by: Eduardo Habkost Reviewed-by: Eric Blake --- Changes v11 -> v12: * Rebase on top of qom-cpu-next (commit bd87d2a - target-i386: Use FeatureWord loop on filter_features_for_kvm()) --- target-i386/cpu-qom.h | 3 +++ target-i386/cpu.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index f890f1c..849cedf 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -65,6 +65,9 @@ typedef struct X86CPU { /*< public >*/ CPUX86State env; + + /* Features that were filtered out because of missing host capabilities */ + uint32_t filtered_features[FEATURE_WORDS]; } X86CPU; static inline X86CPU *x86_env_get_cpu(CPUX86State *env) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 3857514..38793bc 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1698,9 +1698,12 @@ static void filter_features_for_kvm(X86CPU *cpu) for (w = 0; w < FEATURE_WORDS; w++) { FeatureWordInfo *wi = &feature_word_info[w]; - env->features[w] &= kvm_arch_get_supported_cpuid(s, wi->cpuid_eax, - wi->cpuid_ecx, - wi->cpuid_reg); + uint32_t host_feat = kvm_arch_get_supported_cpuid(s, wi->cpuid_eax, + wi->cpuid_ecx, + wi->cpuid_reg); + uint32_t requested_features = env->features[w]; + env->features[w] &= host_feat; + cpu->filtered_features[w] = requested_features & ~env->features[w]; } } #endif