From patchwork Fri Apr 24 05:27:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47529 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ABFF220553 for ; Fri, 24 Apr 2015 05:33:49 +0000 (UTC) Received: by layy10 with SMTP id y10sf9426134lay.0 for ; Thu, 23 Apr 2015 22:33:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=DUdyHYocsvPjKYkJw3zZ6xXfOko1ACtVuB1dDEJf82I=; b=Rnk84RnYPLjKXith1Jh0zU0wo2OIVvz5q+4WHwl3izfS/9L9anVYiOmDc0mxBPuXwz ms3RYjOwcOVyu46uE714SeUFmwkYgn7TWzMAaarQCmhyrK/9vUV4zHqkNtenB8oVFNoE 0MsIFd4Vv2OJODeqvD836yJj/fKTxtuqeP8bubaQLOHedCXj3tFATXNLJeYZZeWN7t7b oTBbsAeCkPW2f+YhAWBPlspkXZx2NaY7MO5hLNP/YbcnuCeh3VvZvBQlhEnOjRNFm7GK 96QQ91p7XGt+a0kz+zG4xYWSKEOukmVutKPrKV0HbcurTnEpSJBlhkUBBp1RRNT7K5Pb gZXA== X-Gm-Message-State: ALoCoQmK1shOp27VF5KJOamRIK9XKLH5uBoJ/SLBkW7I2t3CbkJsz2udupJQzDdary+IrVbUDbJv X-Received: by 10.152.87.140 with SMTP id ay12mr3214162lab.8.1429853628274; Thu, 23 Apr 2015 22:33:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.10 with SMTP id p10ls450525lag.29.gmail; Thu, 23 Apr 2015 22:33:48 -0700 (PDT) X-Received: by 10.112.204.199 with SMTP id la7mr5380180lbc.114.1429853628129; Thu, 23 Apr 2015 22:33:48 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id v6si7473402lav.62.2015.04.23.22.33.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:33:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbcga7 with SMTP id ga7so28638042lbc.1 for ; Thu, 23 Apr 2015 22:33:48 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr5360100lak.29.1429853628024; Thu, 23 Apr 2015 22:33:48 -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.67.65 with SMTP id l1csp978547lbt; Thu, 23 Apr 2015 22:33:47 -0700 (PDT) X-Received: by 10.66.137.2 with SMTP id qe2mr11490501pab.77.1429853626286; Thu, 23 Apr 2015 22:33:46 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd10si15800741pdb.178.2015.04.23.22.33.45; Thu, 23 Apr 2015 22:33:46 -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 S1754561AbbDXFdp (ORCPT + 2 others); Fri, 24 Apr 2015 01:33:45 -0400 Received: from mail-ob0-f177.google.com ([209.85.214.177]:36677 "EHLO mail-ob0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754554AbbDXFdo (ORCPT ); Fri, 24 Apr 2015 01:33:44 -0400 Received: by obbeb7 with SMTP id eb7so30153524obb.3 for ; Thu, 23 Apr 2015 22:33:44 -0700 (PDT) X-Received: by 10.60.101.195 with SMTP id fi3mr5746385oeb.65.1429853624193; Thu, 23 Apr 2015 22:33:44 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id m42sm4024720oik.3.2015.04.23.22.33.42 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:33:43 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Pranavkumar Sawargaonkar , Anup Patel Subject: [PATCH for 3.12.y stable 44/63] ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU Date: Fri, 24 Apr 2015 13:27:42 +0800 Message-Id: <1429853281-6136-45-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> References: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> 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: shannon.zhao@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.181 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 commit f6edbbf36da3a27b298b66c7955fc84e1dcca305 upstream. 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 Signed-off-by: Shannon Zhao --- 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 ba84e67..e9c87e5 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -74,6 +74,10 @@ __do_hyp_init: msr mair_el2, x4 isb + /* Invalidate the stale TLBs from Bootloader */ + tlbi alle2 + dsb sy + mov x4, #SCTLR_EL2_FLAGS msr sctlr_el2, x4 isb