From patchwork Thu Jul 31 06:53:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PranavkumarSawargaonkar X-Patchwork-Id: 34570 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D426F20540 for ; Thu, 31 Jul 2014 06:56:00 +0000 (UTC) Received: by mail-oi0-f69.google.com with SMTP id h136sf10290615oig.4 for ; Wed, 30 Jul 2014 23:56:00 -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:subject:date:message-id:cc :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=/o5lYLdLBFad0nS2m6DKby6u3Vf8ALfu4pxfylb+ZyU=; b=OaGDBV77Trk55wxBrEQXPvq0enhUxP/WMaxpRPQpfI3b9crZ4LkKE3LwcSe7JF6I1U +5+A3cGQNIDMhQloghANMwrnjvxbAmIqoSsByMV6bOYxUlFFbTanJYJy21D+15TgxECe Fz1VQxVuOy8sYfIwWjDRq5vxOJnBLKzW6Wlm6Tu8clsIZSCpqhL0ZO7LDXKng9tYOTzW SFBT6Gn/0CfjuG1mKWF8m3Z1S1bvfRrjcBCgtDtfdnpK8kX2zZDGq9NsWMradqQn5v3T K/58lxt05dP2uorhrntnALNpElEuUm5htLC1hIBWIEnU0ttVVsTdA0nJJidRI7g9bk5Y Re5Q== X-Gm-Message-State: ALoCoQn53/q4nPcic+uUJl2th2pjSm4t6hK7DhvnlMMLq0Iwo4Y8QJIHU8PuXJQ8mPX2q/N9KLtr X-Received: by 10.50.57.111 with SMTP id h15mr4311128igq.3.1406789760412; Wed, 30 Jul 2014 23:56:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.226 with SMTP id r89ls781321qgd.44.gmail; Wed, 30 Jul 2014 23:56:00 -0700 (PDT) X-Received: by 10.220.187.134 with SMTP id cw6mr10555348vcb.3.1406789760321; Wed, 30 Jul 2014 23:56:00 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id ph6si3761413veb.76.2014.07.30.23.56.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jul 2014 23:56:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so3549985vcb.2 for ; Wed, 30 Jul 2014 23:56:00 -0700 (PDT) X-Received: by 10.220.173.134 with SMTP id p6mr10713366vcz.36.1406789759998; Wed, 30 Jul 2014 23:55:59 -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.221.37.5 with SMTP id tc5csp84163vcb; Wed, 30 Jul 2014 23:55:59 -0700 (PDT) X-Received: by 10.70.40.227 with SMTP id a3mr10199815pdl.36.1406789759109; Wed, 30 Jul 2014 23:55:59 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id qe5si4836276pac.103.2014.07.30.23.55.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 23:55:59 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XCkFo-0000S8-1k; Thu, 31 Jul 2014 06:54:20 +0000 Received: from mail-pd0-f172.google.com ([209.85.192.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XCkFl-0000NW-Jx for linux-arm-kernel@lists.infradead.org; Thu, 31 Jul 2014 06:54:18 +0000 Received: by mail-pd0-f172.google.com with SMTP id ft15so2915946pdb.31 for ; Wed, 30 Jul 2014 23:53:55 -0700 (PDT) X-Received: by 10.70.131.199 with SMTP id oo7mr1367726pdb.95.1406789635656; Wed, 30 Jul 2014 23:53:55 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id q9sm3638887pdj.2.2014.07.30.23.53.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jul 2014 23:53:55 -0700 (PDT) From: Pranavkumar Sawargaonkar To: kvmarm@lists.cs.columbia.edu Subject: [PATCH V2] ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU Date: Thu, 31 Jul 2014 12:23:23 +0530 Message-Id: <1406789604-10533-1-git-send-email-pranavkumar@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140730_235417_671878_A0A22B89 X-CRM114-Status: UNSURE ( 8.87 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.4 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.192.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.172 listed in wl.mailspike.net] Cc: Anup Patel , marc.zyngier@arm.com, patches@apm.com, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org, Pranavkumar Sawargaonkar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pranavkumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) 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 X-Gene u-boot runs in EL2 mode with MMU enabled hence we might have stale EL2 tlb enteris when we enable EL2 MMU on each host CPU. This can happen on any ARM/ARM64 board running bootloader in Hyp-mode (or EL2-mode) with MMU enabled. This patch ensures that we flush all Hyp-mode (or EL2-mode) TLBs on each host CPU before enabling Hyp-mode (or EL2-mode) MMU. Changelog: V2: - Flush Hyp-mode TLBs for both KVM ARM32 and KVM ARM64 at boot time V1: - Initial patch with only arm64 change Signed-off-by: Pranavkumar Sawargaonkar Signed-off-by: Anup Patel Reviewed-by: Christoffer Dall Reviewed-by: Marc Zyngier Acked-by: Marc Zyngier Tested-by: Mark Rutland --- arch/arm/kvm/init.S | 4 ++++ arch/arm64/kvm/hyp-init.S | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/arch/arm/kvm/init.S b/arch/arm/kvm/init.S index 1b9844d..ee4f744 100644 --- a/arch/arm/kvm/init.S +++ b/arch/arm/kvm/init.S @@ -98,6 +98,10 @@ __do_hyp_init: mrc p15, 0, r0, c10, c2, 1 mcr p15, 4, r0, c10, c2, 1 + @ Invalidate the stale TLBs from Bootloader + mcr p15, 4, r0, c8, c7, 0 @ TLBIALLH + dsb ish + @ Set the HSCTLR to: @ - ARM/THUMB exceptions: Kernel config (Thumb-2 kernel) @ - Endianness: Kernel config diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index d968796..c319116 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -80,6 +80,10 @@ __do_hyp_init: msr mair_el2, x4 isb + /* Invalidate the stale TLBs from Bootloader */ + tlbi alle2 + dsb sy + mrs x4, sctlr_el2 and x4, x4, #SCTLR_EL2_EE // preserve endianness of EL2 ldr x5, =SCTLR_EL2_FLAGS