From patchwork Thu Jun 20 17:47:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 11007551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC7CD1580 for ; Thu, 20 Jun 2019 17:49:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A45A428758 for ; Thu, 20 Jun 2019 17:49:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 963D1287AF; Thu, 20 Jun 2019 17:49:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3ABE328758 for ; Thu, 20 Jun 2019 17:49:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1he19Y-00015b-T0; Thu, 20 Jun 2019 17:47:16 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1he19X-00015S-Ma for xen-devel@lists.xenproject.org; Thu, 20 Jun 2019 17:47:15 +0000 X-Inumbo-ID: 6eafa8c8-9383-11e9-ba41-4327d1b8e17c Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 6eafa8c8-9383-11e9-ba41-4327d1b8e17c; Thu, 20 Jun 2019 17:47:12 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A0FFF360; Thu, 20 Jun 2019 10:47:11 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CFAE83F246; Thu, 20 Jun 2019 10:47:10 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Thu, 20 Jun 2019 18:47:06 +0100 Message-Id: <20190620174706.16657-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Subject: [Xen-devel] [PRE-4.12 PATCH] xen/arm: time: cycles_t should be an uint64_t and not unsigned long X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org, ian.jackson@eu.citrix.com, jbeulich@suse.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since commit ca73ac8e7d "xen/arm: Add an isb() before reading CNTPCT_EL0 to prevent re-ordering", get_cycles() is now returning the number of cycles and used in more callers. While the counter registers is always 64-bit, get_cycles() will only reutrn a 32-bit on Arm32 and therefore truncate the value. This will result to weird behavior by both Xen and the Guest as the timer will not be setup correctly. This could be resolved by switch cycles_t from unsigned long to unsigned int. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- This is only targeting xen 4.11 and earlier. Xen 4.12 and later have a correct definition of cycles_t thanks to da3d55ae67 "console: avoid printing no or null time stamps". This will hopefully unblock osstest on staging-4.10 and staging-4.11. This patch should be backported up to Xen 4.8. --- xen/include/asm-arm/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/asm-arm/time.h b/xen/include/asm-arm/time.h index ca30406669..bd7dc86d78 100644 --- a/xen/include/asm-arm/time.h +++ b/xen/include/asm-arm/time.h @@ -7,7 +7,7 @@ DT_MATCH_COMPATIBLE("arm,armv7-timer"), \ DT_MATCH_COMPATIBLE("arm,armv8-timer") -typedef unsigned long cycles_t; +typedef uint64_t cycles_t; static inline cycles_t get_cycles (void) {