From patchwork Fri Oct 17 09:32:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhuyijun X-Patchwork-Id: 38849 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8776A202DB for ; Fri, 17 Oct 2014 09:33:09 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id d1sf329291wiv.2 for ; Fri, 17 Oct 2014 02:33:08 -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:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=aws4i/5zWRO98bEbDOBSbDdtkfbFDVOiizJciNDW6ds=; b=ltoSfHs+RTjJajSYP5G5VXU1gCyU8rMlK7eMTQq1EAGia388aegEVZFoy7nyt3miiX VJfMgXcVbrqykM6m1z8LSGu4ETOY6OeTmjP8Fn6u0wkB81wyUk9Duyutw/UOjGtdhL4p X2pVjBR8xCHUBmqWIEFjiUQL22Ixj2UUKEmsUV/qwgOsB4TzWNkBOA3KQJo8QYjeQYtn aNmqCJT4Yieci3zd8mb65vn4A9gS5dyHoGg76rQA2yJDUHj6iedZtZ/DgYQkrCemigux 1tTfVx7XnzPk1Is1NAq/5/cTapA4HrSNv/9WAxhFTaxeBKm6vNb5waLY+pIlHKNshFsv Na9w== X-Gm-Message-State: ALoCoQnnbwsLAEikmhHEyHksheiSr5tKxciZI+MaAH6kpAaGi84Rzq7dbff82hc/li1ZiWK9h65u X-Received: by 10.112.137.202 with SMTP id qk10mr228901lbb.11.1413538388395; Fri, 17 Oct 2014 02:33:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.101 with SMTP id l5ls219110lam.103.gmail; Fri, 17 Oct 2014 02:33:08 -0700 (PDT) X-Received: by 10.112.169.106 with SMTP id ad10mr7446648lbc.13.1413538388144; Fri, 17 Oct 2014 02:33:08 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id bn10si1126968lbc.108.2014.10.17.02.33.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 02:33:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id w7so352931lbi.36 for ; Fri, 17 Oct 2014 02:33:08 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr7378265lbc.23.1413538388021; Fri, 17 Oct 2014 02:33:08 -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.112.84.229 with SMTP id c5csp192944lbz; Fri, 17 Oct 2014 02:33:07 -0700 (PDT) X-Received: by 10.70.49.105 with SMTP id t9mr7369828pdn.58.1413538386294; Fri, 17 Oct 2014 02:33:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi14si571593pdb.245.2014.10.17.02.33.05 for ; Fri, 17 Oct 2014 02:33:06 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751073AbaJQJdF (ORCPT + 1 other); Fri, 17 Oct 2014 05:33:05 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:22038 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194AbaJQJdE (ORCPT ); Fri, 17 Oct 2014 05:33:04 -0400 Received: from 172.24.2.119 (EHLO szxeml462-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CCZ30718; Fri, 17 Oct 2014 17:32:36 +0800 (CST) Received: from localhost (10.177.25.253) by szxeml462-hub.china.huawei.com (10.82.67.205) with Microsoft SMTP Server id 14.3.158.1; Fri, 17 Oct 2014 17:32:30 +0800 From: zhuyijun To: CC: , Pranavkumar Sawargaonkar , , Anup Patel , Christoffer Dall Subject: [PATCH 01/20] ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU Date: Fri, 17 Oct 2014 17:32:05 +0800 Message-ID: <1413538344-11920-2-git-send-email-zhuyijun@huawei.com> X-Mailer: git-send-email 1.8.5.2.msysgit.0 In-Reply-To: <1413538344-11920-1-git-send-email-zhuyijun@huawei.com> References: <1413538344-11920-1-git-send-email-zhuyijun@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.25.253] X-CFilter-Loop: Reflected Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@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.217.177 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Pranavkumar Sawargaonkar 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. Cc: Tested-by: Mark Rutland Reviewed-by: Marc Zyngier Signed-off-by: Pranavkumar Sawargaonkar Signed-off-by: Anup Patel Signed-off-by: Christoffer Dall --- arch/arm/kvm/init.S | 4 ++++ arch/arm64/kvm/hyp-init.S | 4 ++++ 2 files changed, 8 insertions(+), 0 deletions(-) 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