From patchwork Tue Jan 15 09:27:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 212070 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 0F6252C009F for ; Tue, 15 Jan 2013 21:25:13 +1100 (EST) Received: from localhost ([::1]:46104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv2pG-00040y-SZ for incoming@patchwork.ozlabs.org; Tue, 15 Jan 2013 04:28:58 -0500 Received: from eggs.gnu.org ([208.118.235.92]:58005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv2oU-0002kN-Mw for qemu-devel@nongnu.org; Tue, 15 Jan 2013 04:28:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tv2oQ-0000fK-Dm for qemu-devel@nongnu.org; Tue, 15 Jan 2013 04:28:10 -0500 Received: from cantor2.suse.de ([195.135.220.15]:41044 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv2oQ-0000f4-4n for qemu-devel@nongnu.org; Tue, 15 Jan 2013 04:28:06 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 6533DA51FE; Tue, 15 Jan 2013 10:28:05 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Tue, 15 Jan 2013 10:27:31 +0100 Message-Id: <1358242058-1404-14-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1358242058-1404-1-git-send-email-afaerber@suse.de> References: <1358242058-1404-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Eduardo Habkost , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH 13/20] target-i386: check/enforce: Check all feature words 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 From: Eduardo Habkost This adds the following feature words to the list of flags to be checked by kvm_check_features_against_host(): - cpuid_7_0_ebx_features - ext4_features - kvm_features - svm_features This will ensure the "enforce" flag works as it should: it won't allow QEMU to be started unless every flag that was requested by the user or defined in the CPU model is supported by the host. This patch may cause existing configurations where "enforce" wasn't preventing QEMU from being started to abort QEMU. But that's exactly the point of this patch: if a flag was not supported by the host and QEMU wasn't aborting, it was a bug in the "enforce" code. Signed-off-by: Eduardo Habkost Reviewed-by: Gleb Natapov Signed-off-by: Andreas Färber --- target-i386/cpu.c | 13 +++++++++++-- 1 Datei geändert, 11 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 8ec9929..9a48e3f 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1016,8 +1016,9 @@ static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask) return 0; } -/* best effort attempt to inform user requested cpu flags aren't making - * their way to the guest. +/* Check if all requested cpu flags are making their way to the guest + * + * Returns 0 if all flags are supported by the host, non-zero otherwise. * * This function may be called only if KVM is enabled. */ @@ -1035,6 +1036,14 @@ static int kvm_check_features_against_host(x86_def_t *guest_def) FEAT_8000_0001_EDX }, {&guest_def->ext3_features, &host_def.ext3_features, FEAT_8000_0001_ECX }, + {&guest_def->ext4_features, &host_def.ext4_features, + FEAT_C000_0001_EDX }, + {&guest_def->cpuid_7_0_ebx_features, &host_def.cpuid_7_0_ebx_features, + FEAT_7_0_EBX }, + {&guest_def->svm_features, &host_def.svm_features, + FEAT_SVM }, + {&guest_def->kvm_features, &host_def.kvm_features, + FEAT_KVM }, }; assert(kvm_enabled());