From patchwork Thu Jan 6 17:56:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 77752 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A788EB7082 for ; Fri, 7 Jan 2011 05:04:49 +1100 (EST) Received: from localhost ([127.0.0.1]:44264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PauCc-0003wP-PR for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2011 13:04:46 -0500 Received: from [140.186.70.92] (port=60993 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PauBB-0003sh-Ja for qemu-devel@nongnu.org; Thu, 06 Jan 2011 13:03:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PauB9-0006Zf-F0 for qemu-devel@nongnu.org; Thu, 06 Jan 2011 13:03:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23219) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PauB9-0006ZB-6f for qemu-devel@nongnu.org; Thu, 06 Jan 2011 13:03:15 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p06I3CUe005090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 6 Jan 2011 13:03:12 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p06I3BFr008764; Thu, 6 Jan 2011 13:03:12 -0500 Received: from amt.cnet (vpn1-4-164.ams2.redhat.com [10.36.4.164]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p06I39SF019099; Thu, 6 Jan 2011 13:03:10 -0500 Received: from amt.cnet (localhost.localdomain [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id CBE4968A223; Thu, 6 Jan 2011 15:57:45 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p06Hveq7011353; Thu, 6 Jan 2011 15:57:40 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Thu, 6 Jan 2011 15:56:14 -0200 Message-Id: <7946c528467ad128fe9f6f904125710cde00602e.1294336601.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Hidetoshi Seto , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, Jin Dongming Subject: [Qemu-devel] [PATCH 08/35] kvm: introduce kvm_inject_x86_mce_on X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jin Dongming Pass a table instead of multiple args. Note: kvm_inject_x86_mce(env, bank, status, mcg_status, addr, misc, abort_on_error); is equal to: struct kvm_x86_mce mce = { .bank = bank, .status = status, .mcg_status = mcg_status, .addr = addr, .misc = misc, }; kvm_inject_x86_mce_on(env, &mce, abort_on_error); Signed-off-by: Hidetoshi Seto Signed-off-by: Jin Dongming Signed-off-by: Marcelo Tosatti --- target-i386/kvm.c | 57 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 36 insertions(+), 21 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index ce01e18..9a4bf98 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -263,6 +263,23 @@ static void kvm_do_inject_x86_mce(void *_data) } } +static void kvm_inject_x86_mce_on(CPUState *env, struct kvm_x86_mce *mce, + int flag) +{ + struct kvm_x86_mce_data data = { + .env = env, + .mce = mce, + .abort_on_error = (flag & ABORT_ON_ERROR), + }; + + if (!env->mcg_cap) { + fprintf(stderr, "MCE support is not enabled!\n"); + return; + } + + run_on_cpu(env, kvm_do_inject_x86_mce, &data); +} + static void kvm_mce_broadcast_rest(CPUState *env); #endif @@ -278,21 +295,12 @@ void kvm_inject_x86_mce(CPUState *cenv, int bank, uint64_t status, .addr = addr, .misc = misc, }; - struct kvm_x86_mce_data data = { - .env = cenv, - .mce = &mce, - }; - - if (!cenv->mcg_cap) { - fprintf(stderr, "MCE support is not enabled!\n"); - return; - } if (flag & MCE_BROADCAST) { kvm_mce_broadcast_rest(cenv); } - run_on_cpu(cenv, kvm_do_inject_x86_mce, &data); + kvm_inject_x86_mce_on(cenv, &mce, flag); #else if (flag & ABORT_ON_ERROR) { abort(); @@ -1708,6 +1716,13 @@ static void hardware_memory_error(void) #ifdef KVM_CAP_MCE static void kvm_mce_broadcast_rest(CPUState *env) { + struct kvm_x86_mce mce = { + .bank = 1, + .status = MCI_STATUS_VAL | MCI_STATUS_UC, + .mcg_status = MCG_STATUS_MCIP | MCG_STATUS_RIPV, + .addr = 0, + .misc = 0, + }; CPUState *cenv; /* Broadcast MCA signal for processor version 06H_EH and above */ @@ -1716,9 +1731,7 @@ static void kvm_mce_broadcast_rest(CPUState *env) if (cenv == env) { continue; } - kvm_inject_x86_mce(cenv, 1, MCI_STATUS_VAL | MCI_STATUS_UC, - MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0, - ABORT_ON_ERROR); + kvm_inject_x86_mce_on(cenv, &mce, ABORT_ON_ERROR); } } } @@ -1767,15 +1780,17 @@ static void kvm_mce_inj_srao_memscrub(CPUState *env, target_phys_addr_t paddr) static void kvm_mce_inj_srao_memscrub2(CPUState *env, target_phys_addr_t paddr) { - uint64_t status; - - status = MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN - | MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S - | 0xc0; - kvm_inject_x86_mce(env, 9, status, - MCG_STATUS_MCIP | MCG_STATUS_RIPV, paddr, - (MCM_ADDR_PHYS << 6) | 0xc, ABORT_ON_ERROR); + struct kvm_x86_mce mce = { + .bank = 9, + .status = MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN + | MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S + | 0xc0, + .mcg_status = MCG_STATUS_MCIP | MCG_STATUS_RIPV, + .addr = paddr, + .misc = (MCM_ADDR_PHYS << 6) | 0xc, + }; + kvm_inject_x86_mce_on(env, &mce, ABORT_ON_ERROR); kvm_mce_broadcast_rest(env); }