From patchwork Sat Apr 3 09:37:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 49332 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 771F6B7CEF for ; Sat, 3 Apr 2010 20:38:31 +1100 (EST) Received: from localhost ([127.0.0.1]:53126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nxzo8-0007G9-A9 for incoming@patchwork.ozlabs.org; Sat, 03 Apr 2010 05:38:24 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NxznK-0007G4-0D for qemu-devel@nongnu.org; Sat, 03 Apr 2010 05:37:34 -0400 Received: from [140.186.70.92] (port=34836 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NxznI-0007Fv-Al for qemu-devel@nongnu.org; Sat, 03 Apr 2010 05:37:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NxznF-0004YO-N5 for qemu-devel@nongnu.org; Sat, 03 Apr 2010 05:37:32 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40683 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NxznF-0004YA-HM for qemu-devel@nongnu.org; Sat, 03 Apr 2010 05:37:29 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 8C9965FC9F; Sat, 3 Apr 2010 11:37:26 +0200 (CEST) From: Alexander Graf To: qemu-devel@nongnu.org Date: Sat, 3 Apr 2010 11:37:26 +0200 Message-Id: <1270287446-3904-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: Subject: [Qemu-devel] [PATCH] [PPC] Make cpu_get_real_ticks use mfspr 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 PowerPC CPUs have had two ways to read the time base for quite some time now. They provide it using the mfspr instruction or - if a special bit is set in that opcode - using mftb. For timekeeping we're currently using mftb. While trying to get Qemu up and running on an e500v2 system, I stumbled over the CPU not supporting mftbu. It just throws an illegal instruction trap. So let's read the SPR values instead. All PPC CPUs should support them anyways. I tested this patch on an e500v2 system where it makes qemu work and on my 970MP system with 32-bit user space where everything still works with this patch applied. Signed-off-by: Alexander Graf --- qemu-timer.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu-timer.h b/qemu-timer.h index a7eac98..d2e15f4 100644 --- a/qemu-timer.h +++ b/qemu-timer.h @@ -98,9 +98,9 @@ static inline int64_t cpu_get_real_ticks(void) #else /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ unsigned long junk; - __asm__ __volatile__ ("mftbu %1\n\t" - "mftb %L0\n\t" - "mftbu %0\n\t" + __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */ + "mfspr %L0,268\n\t" /* mftb */ + "mfspr %0,269\n\t" /* mftbu */ "cmpw %0,%1\n\t" "bne $-16" : "=r" (retval), "=r" (junk));