From patchwork Thu Jun 16 06:06:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9179877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B514760776 for ; Thu, 16 Jun 2016 06:09:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6AB627BF7 for ; Thu, 16 Jun 2016 06:09:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AEDB27F07; Thu, 16 Jun 2016 06:09:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2ED8C27BF7 for ; Thu, 16 Jun 2016 06:09:45 +0000 (UTC) Received: from localhost ([::1]:46672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDQUq-0001O8-Bm for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Jun 2016 02:09:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDQRv-00079U-3m for qemu-devel@nongnu.org; Thu, 16 Jun 2016 02:06:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDQRp-0001Wq-0c for qemu-devel@nongnu.org; Thu, 16 Jun 2016 02:06:42 -0400 Received: from mga14.intel.com ([192.55.52.115]:39631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDQRo-0001UZ-7P for qemu-devel@nongnu.org; Thu, 16 Jun 2016 02:06:36 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 15 Jun 2016 23:06:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,478,1459839600"; d="scan'208";a="122830944" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.13.126]) by fmsmga004.fm.intel.com with ESMTP; 15 Jun 2016 23:06:33 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org Date: Thu, 16 Jun 2016 14:06:20 +0800 Message-Id: <20160616060621.30422-3-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160616060621.30422-1-haozhong.zhang@intel.com> References: <20160616060621.30422-1-haozhong.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.115 Subject: [Qemu-devel] [PATCH v4 2/3] target-i386: add migration support for Intel LMCE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , Tony Luck , rkrcmar@redhat.com, Eduardo Habkost , kvm@vger.kernel.org, "Michael S . Tsirkin" , Marcelo Tosatti , Andi Kleen , Paolo Bonzini , Ashok Raj , Boris Petkov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Migration is only allowed between VCPUs with the same lmce option. Signed-off-by: Haozhong Zhang --- target-i386/machine.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target-i386/machine.c b/target-i386/machine.c index cb9adf2..00375a3 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -347,6 +347,12 @@ static int cpu_post_load(void *opaque, int version_id) return -EINVAL; } + if (!cpu->enable_lmce && (env->mcg_cap & MCG_LMCE_P)) { + error_report("Config mismatch: VCPU has LMCE enabled, " + "but \"lmce\" option is disabled"); + return -EINVAL; + } + /* * Real mode guest segments register DPL should be zero. * Older KVM version were setting it wrongly. @@ -896,6 +902,24 @@ static const VMStateDescription vmstate_tsc_khz = { } }; +static bool mcg_ext_ctl_needed(void *opaque) +{ + X86CPU *cpu = opaque; + CPUX86State *env = &cpu->env; + return cpu->enable_lmce && env->mcg_ext_ctl; +} + +static const VMStateDescription vmstate_mcg_ext_ctl = { + .name = "cpu/mcg_ext_ctl", + .version_id = 1, + .minimum_version_id = 1, + .needed = mcg_ext_ctl_needed, + .fields = (VMStateField[]) { + VMSTATE_UINT64(env.mcg_ext_ctl, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + VMStateDescription vmstate_x86_cpu = { .name = "cpu", .version_id = 12, @@ -1022,6 +1046,7 @@ VMStateDescription vmstate_x86_cpu = { #ifdef TARGET_X86_64 &vmstate_pkru, #endif + &vmstate_mcg_ext_ctl, NULL } };