From patchwork Wed Feb 15 18:21:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 6805 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 392F323DE1 for ; Wed, 15 Feb 2012 18:22:24 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 01DFAA18A24 for ; Wed, 15 Feb 2012 18:22:23 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id z7so2426084iab.11 for ; Wed, 15 Feb 2012 10:22:23 -0800 (PST) Received: by 10.50.189.137 with SMTP id gi9mr43786389igc.29.1329330143764; Wed, 15 Feb 2012 10:22:23 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.80.19 with SMTP id r19cs2748ibk; Wed, 15 Feb 2012 10:22:23 -0800 (PST) Received: by 10.181.13.113 with SMTP id ex17mr37164555wid.15.1329330142513; Wed, 15 Feb 2012 10:22:22 -0800 (PST) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id y50si3152718wec.75.2012.02.15.10.22.21 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 15 Feb 2012 10:22:22 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) smtp.mail=dave.martin@linaro.org Received: by mail-we0-f178.google.com with SMTP id b12so1120243wer.37 for ; Wed, 15 Feb 2012 10:22:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.136.138 with SMTP id w10mr3014213wei.33.1329330141372; Wed, 15 Feb 2012 10:22:21 -0800 (PST) Received: from localhost.localdomain ([213.123.120.124]) by mx.google.com with ESMTPS id ga1sm11784894wib.5.2012.02.15.10.22.19 (version=SSLv3 cipher=OTHER); Wed, 15 Feb 2012 10:22:20 -0800 (PST) From: Dave Martin To: Rusty Russell Cc: patches@linaro.org, Peter Maydell , Marc Zyngier , Dave Martin Subject: [PATCH 1/2] monitor: Make sure SCR.NS=1 before trying to access hyp config regs Date: Wed, 15 Feb 2012 18:21:37 +0000 Message-Id: <1329330098-31636-2-git-send-email-dave.martin@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1329330098-31636-1-git-send-email-dave.martin@linaro.org> References: <1329330098-31636-1-git-send-email-dave.martin@linaro.org> X-Gm-Message-State: ALoCoQngC/D17WsFeJpj4y9Ee96smgAhSYitxyVlXHgjSpAFZJNayMPfKyFKOcurFh5zDFqi5FbM The architecture says that registers such as VTTBR and HVBAR are only accessible from the Secure World if in Monitor mode and with SCR.NS = 1. Myabe some versions of the model don't enforce this, but the one I have does, and it appears to be an architectural requirement. This patch avoids the resulting #undefs. Signed-off-by: Dave Martin --- monitor.S | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/monitor.S b/monitor.S index 052ab1e..334186e 100644 --- a/monitor.S +++ b/monitor.S @@ -25,7 +25,7 @@ @ 1: ldr sp, =_monitor_stack - push {r11, r12} + push {r10-r12,lr} cmp r7, #0xffffffff beq _non_sec @@ -36,16 +36,19 @@ movnes pc, lr and r12, r7, #0xf cmp r12, #0x0 - popgt {r11, r12} - movgts pc, lr + ldmgtfd sp!, {r10-r12,pc}^ @ Check the VMID is 0 + mrc p15, 0, r10, c1, c1, 0 @ SCR + orr r11, r10, #1 @ SCR.NS = 1 + mcr p15, 0, r11, c1, c1, 0 + isb mrrc p15, 6, r12, r11, c2 + mcr p15, 0, r10, c1, c1, 0 @ Restore SCR lsr r11, r11, #16 and r11, r11, #0xff cmp r11, #0 - popne {r11, r12} - movnes pc, lr + ldmnefd sp!, {r10-r12,pc}^ @ Jump to the right function and r12, r7, #0xf @@ -68,16 +71,18 @@ _non_sec: ldr r11, =0x131 orr r12, r12, r11 mcr p15, 0, r12, c1, c1, 0 - pop {r11, r12} - movs pc, lr + ldmfd sp!, {r10-r12,pc}^ @ @ Read/Write HVBAR @ _write_hvbar: + orr r11, r10, #1 @ SCR.NS = 1 (r10 already = SCR) + mcr p15, 0, r11, c1, c1, 0 + isb mcr p15, 4, r0, c12, c0, 0 - pop {r11, r12} - movs pc, lr + mcr p15, 0, r10, c1, c1, 0 @ Restore SCR + ldmfd sp!, {r10-r12,pc}^ .ltorg