From patchwork Thu Oct 30 15:57:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 5198631 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6B75F9F30B for ; Thu, 30 Oct 2014 15:57:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A513420172 for ; Thu, 30 Oct 2014 15:57:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2C5C20117 for ; Thu, 30 Oct 2014 15:57:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161157AbaJ3P5Q (ORCPT ); Thu, 30 Oct 2014 11:57:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46308 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161146AbaJ3P5Q (ORCPT ); Thu, 30 Oct 2014 11:57:16 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9UFv6BS019500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Oct 2014 11:57:06 -0400 Received: from hawk.usersys.redhat.com (dhcp-1-153.brq.redhat.com [10.34.1.153]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9UFv9BO027960; Thu, 30 Oct 2014 11:57:12 -0400 From: Andrew Jones To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: christoffer.dall@linaro.org, pbonzini@redhat.com Subject: [PATCH 1/6] arm: fix crash on cubietruck Date: Thu, 30 Oct 2014 16:57:00 +0100 Message-Id: <1414684625-9445-2-git-send-email-drjones@redhat.com> In-Reply-To: <1414684625-9445-1-git-send-email-drjones@redhat.com> References: <1414684625-9445-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cubietruck seems to be more sensitive than my Midway when attempting to use [ldr|str]ex instructions without caches enabled (mmu disabled). Fix this by making the spinlock implementation (currently the only user of *ex instructions) conditional on the mmu being enabled. Signed-off-by: Andrew Jones --- lib/arm/asm/mmu.h | 11 +++++++++++ lib/arm/spinlock.c | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 lib/arm/asm/mmu.h diff --git a/lib/arm/asm/mmu.h b/lib/arm/asm/mmu.h new file mode 100644 index 0000000000000..987928b2c432c --- /dev/null +++ b/lib/arm/asm/mmu.h @@ -0,0 +1,11 @@ +#ifndef __ASMARM_MMU_H_ +#define __ASMARM_MMU_H_ +/* + * Copyright (C) 2014, Red Hat Inc, Andrew Jones + * + * This work is licensed under the terms of the GNU LGPL, version 2. + */ + +#define mmu_enabled() (0) + +#endif /* __ASMARM_MMU_H_ */ diff --git a/lib/arm/spinlock.c b/lib/arm/spinlock.c index d8a6d4c3383d6..e2bb1ace43c4e 100644 --- a/lib/arm/spinlock.c +++ b/lib/arm/spinlock.c @@ -1,12 +1,19 @@ #include "libcflat.h" #include "asm/spinlock.h" #include "asm/barrier.h" +#include "asm/mmu.h" void spin_lock(struct spinlock *lock) { u32 val, fail; dmb(); + + if (!mmu_enabled()) { + lock->v = 1; + return; + } + do { asm volatile( "1: ldrex %0, [%2]\n"