From patchwork Wed Apr 17 19:09:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 2455921 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 6168DDF23A for ; Wed, 17 Apr 2013 19:09:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965067Ab3DQTJT (ORCPT ); Wed, 17 Apr 2013 15:09:19 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:41881 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756580Ab3DQTJS (ORCPT ); Wed, 17 Apr 2013 15:09:18 -0400 Received: by mail-pd0-f176.google.com with SMTP id r11so1015721pdi.35 for ; Wed, 17 Apr 2013 12:09:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=Bb6vNeJ6WXqp9/o58zvc6CGzAAsCroSvbElrgMdSeng=; b=Jr7f4oLuhdroKCJQSXtrtej+4O7oDDB5jk2KP0v94xbAZ8A4Qf47bABpChdRmWFqdh NrsIrySNN3x4SZ0/cELNSXYgD9ns6HxzpjbgkGGnGb+057DY9AGdgC5KKmD8LE8dC5i7 A9H+EjYE9aBsVJun/C1kT/nGlDdhjmBqnALc7XgtnMjZx9jDklijDvcimYaP9gV+ZwCW B3f5pG5dkt4fZTn+RXzU3sEuIwl+dKWe8BZqAbkQ519A2nUUalVIbda44Z024VWxZPAd nioDFSLpHqfuqQqKopCLy6RJ+kml92dn7FsXksh6uqSqckjiTq58rX3lKR1isW2ktiew L53A== X-Received: by 10.66.72.3 with SMTP id z3mr10046406pau.125.1366225758306; Wed, 17 Apr 2013 12:09:18 -0700 (PDT) Received: from localhost.localdomain (c-67-169-183-77.hsd1.ca.comcast.net. [67.169.183.77]) by mx.google.com with ESMTPS id fq1sm7122194pbb.33.2013.04.17.12.09.16 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Apr 2013 12:09:17 -0700 (PDT) From: Christoffer Dall To: Linus Torvalds , Marcelo Tosatti , kvm@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, Marc Zyngier , Christoffer Dall Subject: [PATCH] ARM: KVM: fix unbalanced get_cpu() in access_dcsw Date: Wed, 17 Apr 2013 12:09:09 -0700 Message-Id: <1366225749-3054-1-git-send-email-cdall@cs.columbia.edu> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQk5PzGXNMUbI0lOEgM7Wf4ryCem0syPMVVsDHATlNXihwEWWhvP6cFAzAhBavXyn1M1KtdQ Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Marc Zyngier In the very unlikely event where a guest would be foolish enough to *read* from a write-only cache maintainance register, we end up with preemption disabled, due to a misplaced get_cpu(). Just move the "is_write" test outside of the critical section. Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/kvm/coproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c index 4ea9a98..7bed755 100644 --- a/arch/arm/kvm/coproc.c +++ b/arch/arm/kvm/coproc.c @@ -79,11 +79,11 @@ static bool access_dcsw(struct kvm_vcpu *vcpu, u32 val; int cpu; - cpu = get_cpu(); - if (!p->is_write) return read_from_write_only(vcpu, p); + cpu = get_cpu(); + cpumask_setall(&vcpu->arch.require_dcache_flush); cpumask_clear_cpu(cpu, &vcpu->arch.require_dcache_flush);