From patchwork Mon Jun 25 12:26:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Caraman X-Patchwork-Id: 167071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id F35CB1008A9 for ; Mon, 25 Jun 2012 22:27:12 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756543Ab2FYM1K (ORCPT ); Mon, 25 Jun 2012 08:27:10 -0400 Received: from db3ehsobe002.messaging.microsoft.com ([213.199.154.140]:24811 "EHLO db3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756283Ab2FYM0u (ORCPT ); Mon, 25 Jun 2012 08:26:50 -0400 Received: from mail62-db3-R.bigfish.com (10.3.81.246) by DB3EHSOBE001.bigfish.com (10.3.84.21) with Microsoft SMTP Server id 14.1.225.23; Mon, 25 Jun 2012 12:25:11 +0000 Received: from mail62-db3 (localhost [127.0.0.1]) by mail62-db3-R.bigfish.com (Postfix) with ESMTP id E658A300662; Mon, 25 Jun 2012 12:25:10 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839hd24he5bhf0ah) Received: from mail62-db3 (localhost.localdomain [127.0.0.1]) by mail62-db3 (MessageSwitch) id 1340627109420360_20110; Mon, 25 Jun 2012 12:25:09 +0000 (UTC) Received: from DB3EHSMHS008.bigfish.com (unknown [10.3.81.239]) by mail62-db3.bigfish.com (Postfix) with ESMTP id 5AE092A0044; Mon, 25 Jun 2012 12:25:09 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB3EHSMHS008.bigfish.com (10.3.87.108) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 25 Jun 2012 12:25:09 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.298.5; Mon, 25 Jun 2012 07:26:45 -0500 Received: from mcaraman-VirtualBox.ea.freescale.net ([10.213.130.145]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q5PCQiaQ019379; Mon, 25 Jun 2012 05:26:45 -0700 Received: from mcaraman-VirtualBox.ea.freescale.net (localhost [127.0.0.1]) by mcaraman-VirtualBox.ea.freescale.net (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id q5PCQeXh011636; Mon, 25 Jun 2012 15:26:40 +0300 Received: (from mcaraman@localhost) by mcaraman-VirtualBox.ea.freescale.net (8.14.4/8.14.4/Submit) id q5PCQesl011635; Mon, 25 Jun 2012 15:26:40 +0300 From: Mihai Caraman To: , , , CC: Mihai Caraman Subject: [RFC PATCH 09/17] KVM: PPC64: booke: Hard disable interrupts when entering guest Date: Mon, 25 Jun 2012 15:26:27 +0300 Message-ID: <1340627195-11544-10-git-send-email-mihai.caraman@freescale.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1340627195-11544-1-git-send-email-mihai.caraman@freescale.com> References: <1340627195-11544-1-git-send-email-mihai.caraman@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.net Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org 64-bit host runs with lazy interrupt disabling, so local_irq_disable() does not disable interrupts right away and does not protect against preemption required by __kvmppc_vcpu_run(). Define a macro for 64-bit to use hard_irq_disable(). Signed-off-by: Mihai Caraman --- arch/powerpc/kvm/booke.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 93b48e0..db05692 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -45,6 +45,12 @@ unsigned long kvmppc_booke_handlers; #define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU +#ifdef CONFIG_64BIT +#define _hard_irq_disable() hard_irq_disable() +#else +#define _hard_irq_disable() local_irq_disable() +#endif + struct kvm_stats_debugfs_item debugfs_entries[] = { { "mmio", VCPU_STAT(mmio_exits) }, { "dcr", VCPU_STAT(dcr_exits) }, @@ -456,7 +462,7 @@ int kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu) local_irq_enable(); kvm_vcpu_block(vcpu); clear_bit(KVM_REQ_UNHALT, &vcpu->requests); - local_irq_disable(); + _hard_irq_disable(); kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS); r = 1; @@ -480,7 +486,7 @@ static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) if (need_resched()) { local_irq_enable(); cond_resched(); - local_irq_disable(); + _hard_irq_disable(); continue; } @@ -515,7 +521,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) return -EINVAL; } - local_irq_disable(); + _hard_irq_disable(); if (kvmppc_prepare_to_enter(vcpu)) { kvm_run->exit_reason = KVM_EXIT_INTR; ret = -EINTR; @@ -955,7 +961,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu, * aren't already exiting to userspace for some other reason. */ if (!(r & RESUME_HOST)) { - local_irq_disable(); + _hard_irq_disable(); if (kvmppc_prepare_to_enter(vcpu)) { run->exit_reason = KVM_EXIT_INTR; r = (-EINTR << 2) | RESUME_HOST | (r & RESUME_FLAG_NV);