From patchwork Sat Apr 26 12:17:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 29155 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E7B07202E6 for ; Sat, 26 Apr 2014 12:19:01 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf17984014vcb.2 for ; Sat, 26 Apr 2014 05:19:01 -0700 (PDT) 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: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=abpC2L5TuBH52C4nJNGLOsEYZ2+hIPfoH+QxTae2bLI=; b=UN6OXCBeIfUUWgQUPxnDI7vSqcPl1ByNU1rvSWmuh86qfT+oJTubojlZX5csCcpS6W tXUnAdAjMMAt0N0O4shX012YArXez9/f42k5X2GoBmcZMAOrGYMLiaJjm5kR+agQdBhP sJF0UrENSW8PFHC+Dt3B7fVkR8TYaUFz1BIT08Iri2NidWKom09dIROqPsxnZ/Thaida 96c12oaSNaARwSfuB3CEr4Z2souWq2M7jbx945owiel1FdiSSB2mCpvcZ4idXZJ1wXLQ mFHhe4yNHowd28okqL7VQlJiVGJ/TnNHjaYYUleOOaaONuPx+UsUscVAeZldj1blGIUb agsA== X-Gm-Message-State: ALoCoQkkOE6sLOQ+5+Jy1jZw3VZmEBW4nJjwjH3vPkQNQJB6E77JmyVR/eeJDV918J9YBk5UOK5D X-Received: by 10.236.180.2 with SMTP id i2mr6099823yhm.4.1398514741644; Sat, 26 Apr 2014 05:19:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.40 with SMTP id m37ls490396qgd.18.gmail; Sat, 26 Apr 2014 05:19:01 -0700 (PDT) X-Received: by 10.58.230.103 with SMTP id sx7mr67102vec.28.1398514741498; Sat, 26 Apr 2014 05:19:01 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id tv3si2395143vdc.162.2014.04.26.05.19.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 26 Apr 2014 05:19:01 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id ij19so6204641vcb.10 for ; Sat, 26 Apr 2014 05:19:01 -0700 (PDT) X-Received: by 10.58.1.97 with SMTP id 1mr12339539vel.23.1398514741412; Sat, 26 Apr 2014 05:19:01 -0700 (PDT) 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.221.72 with SMTP id ib8csp164826vcb; Sat, 26 Apr 2014 05:19:01 -0700 (PDT) X-Received: by 10.15.24.201 with SMTP id j49mr270083eeu.99.1398514740624; Sat, 26 Apr 2014 05:19:00 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id t3si16484658eeg.271.2014.04.26.05.19.00 for ; Sat, 26 Apr 2014 05:19:00 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B5FF7A7445; Sat, 26 Apr 2014 14:18:31 +0200 (CEST) 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 24KI4gPz21Ed; Sat, 26 Apr 2014 14:18:31 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8F6E3A7418; Sat, 26 Apr 2014 14:17:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E190A4BFC1 for ; Sat, 26 Apr 2014 14:17:33 +0200 (CEST) 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 6ZdVBIqt0A0e for ; Sat, 26 Apr 2014 14:17:33 +0200 (CEST) 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 218D64BFC4 for ; Sat, 26 Apr 2014 14:17:25 +0200 (CEST) Received: from [2.125.202.75] (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 1We1Xj-0003DF-LE; Sat, 26 Apr 2014 14:17:19 +0200 From: Marc Zyngier To: u-boot@lists.denx.de Date: Sat, 26 Apr 2014 13:17:04 +0100 Message-Id: <1398514631-23956-4-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1398514631-23956-1-git-send-email-marc.zyngier@arm.com> References: <1398514631-23956-1-git-send-email-marc.zyngier@arm.com> X-SA-Exim-Connect-IP: 2.125.202.75 X-SA-Exim-Rcpt-To: u-boot@lists.denx.de, albert.u.boot@aribaud.net X-SA-Exim-Mail-From: marc.zyngier@arm.com X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Subject: [U-Boot] [PATCH v4 03/10] 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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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: