From patchwork Sat Feb 15 13:36:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 24676 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0061D20967 for ; Sat, 15 Feb 2014 14:12:58 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id lx4sf27969456iec.10 for ; Sat, 15 Feb 2014 06:12:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=mWvEr3oa0mQk9lGUMLbBFGFOaNhDj3yRB4I/r4ArzF0=; b=CNe1pIo76RZhU1qoIfvGXv8Mh/04HBa9U0NjHd1hcPyyQAltecZYuFEhiKSchzIJas KRvBOzWFlG8X/KWSbGToo3RD5MPICgWrVvCHRKkj7eSgU5TVQZpiv9OfLEWRj30y/55W sDDtUpqRdfAULWNgEV/DPgNaGSOuuOOj6fWWbxaxMCwZc+Tz+s6g4nDw+VBz1NCZ7k3z StNGq9EqjAF0cGl6tEa9+pyZp+VHRwcdt60ND+tGHn13MptU9uqLD7UjP8QeNr4km3PV wW3xlNjj0A4ENV42nxhE1zRWJpxn3DCe/j+6ocnNXR/ERcBgqfehM579zUySYBs+0MDf BtzA== X-Gm-Message-State: ALoCoQl8RIJ2a0OQW0eKzTbufodrCT1xsvHa5I1g4h02eyMKEGNJphCf52tuJadrcrx65Ca0Na4F X-Received: by 10.183.3.36 with SMTP id bt4mr5875784obd.29.1392473578156; Sat, 15 Feb 2014 06:12:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.148 with SMTP id h20ls379947qgd.36.gmail; Sat, 15 Feb 2014 06:12:58 -0800 (PST) X-Received: by 10.220.88.204 with SMTP id b12mr9447676vcm.3.1392473578038; Sat, 15 Feb 2014 06:12:58 -0800 (PST) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id x7si2926526vel.114.2014.02.15.06.12.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 15 Feb 2014 06:12:58 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id db12so10763709veb.11 for ; Sat, 15 Feb 2014 06:12:58 -0800 (PST) X-Received: by 10.52.104.68 with SMTP id gc4mr7946811vdb.2.1392473577935; Sat, 15 Feb 2014 06:12:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp19957vcz; Sat, 15 Feb 2014 06:12:56 -0800 (PST) X-Received: by 10.15.24.136 with SMTP id j8mr15345467eeu.1.1392473575978; Sat, 15 Feb 2014 06:12:55 -0800 (PST) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id 43si18654939eeh.10.2014.02.15.06.12.55 for ; Sat, 15 Feb 2014 06:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF0404B714; Sat, 15 Feb 2014 15:12:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iIUm+ihtkB6N; Sat, 15 Feb 2014 15:12:42 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 51E124B755; Sat, 15 Feb 2014 15:11:52 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A40D94B739 for ; Sat, 15 Feb 2014 15:11:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0xVZQcAGWN6G for ; Sat, 15 Feb 2014 15:11:36 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from inca-roads.misterjones.org (inca-roads.misterjones.org [213.251.177.50]) by theia.denx.de (Postfix) with ESMTPS id 7C87B4B70B for ; Sat, 15 Feb 2014 15:11:21 +0100 (CET) Received: from [176.250.132.24] (helo=why.wild-wind.fr.eu.org) by cheepnis.misterjones.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA256:128) (Exim 4.80) (envelope-from ) id 1WEfQI-00038M-Dp; Sat, 15 Feb 2014 14:36:50 +0100 From: Marc Zyngier To: u-boot@lists.denx.de, linux-sunxi@googlegroups.com Date: Sat, 15 Feb 2014 13:36:27 +0000 Message-Id: <1392471397-2158-4-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1392471397-2158-1-git-send-email-marc.zyngier@arm.com> References: <1392471397-2158-1-git-send-email-marc.zyngier@arm.com> X-SA-Exim-Connect-IP: 176.250.132.24 X-SA-Exim-Rcpt-To: u-boot@lists.denx.de, linux-sunxi@googlegroups.com, maxime.ripard@free-electrons.com, ijc@hellion.org.uk, andre@andrep.de, henrik@henriknordstrom.net, maz@misterjones.org X-SA-Exim-Mail-From: marc.zyngier@arm.com X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Cc: Andre Przywara , maz@misterjones.org, Ian Campbell Subject: [U-Boot] [PATCH v3 03/13] ARM: non-sec: reset CNTVOFF to zero X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: marc.zyngier@arm.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Before switching to non-secure, make sure that CNTVOFF is set to zero on all CPUs. Otherwise, kernel running in non-secure without HYP enabled (hence using virtual timers) may observe timers that are not synchronized, effectively seeing time going backward... Signed-off-by: Marc Zyngier --- arch/arm/cpu/armv7/nonsec_virt.S | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm/cpu/armv7/nonsec_virt.S b/arch/arm/cpu/armv7/nonsec_virt.S index 12de5c2..b5c946f 100644 --- a/arch/arm/cpu/armv7/nonsec_virt.S +++ b/arch/arm/cpu/armv7/nonsec_virt.S @@ -38,10 +38,10 @@ _secure_monitor: bic r1, r1, #0x4e @ clear IRQ, FIQ, EA, nET bits orr r1, r1, #0x31 @ enable NS, AW, FW bits -#ifdef CONFIG_ARMV7_VIRT mrc p15, 0, r0, c0, c1, 1 @ read ID_PFR1 and r0, r0, #CPUID_ARM_VIRT_MASK @ mask virtualization bits cmp r0, #(1 << CPUID_ARM_VIRT_SHIFT) +#ifdef CONFIG_ARMV7_VIRT orreq r1, r1, #0x100 @ allow HVC instruction #endif @@ -52,7 +52,14 @@ _secure_monitor: mrceq p15, 0, r0, c12, c0, 1 @ get MVBAR value mcreq p15, 4, r0, c12, c0, 0 @ write HVBAR #endif + bne 1f + @ Reset CNTVOFF to 0 before leaving monitor mode + mrc p15, 0, r0, c0, c1, 1 @ read ID_PFR1 + ands r0, r0, #CPUID_ARM_GENTIMER_MASK @ test arch timer bits + movne r0, #0 + mcrrne p15, 4, r0, r0, c14 @ Reset CNTVOFF to zero +1: movs pc, lr @ return to non-secure SVC _hyp_trap: