From patchwork Tue Feb 27 11:15:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 129770 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1269910lja; Tue, 27 Feb 2018 03:18:21 -0800 (PST) X-Google-Smtp-Source: AG47ELtxBTlIJ/zV6TWSw+5FZzoHZnZOWfLI8sDr9j7x74Wl9TKf8u97EceVetXf772oW2Jd86bl X-Received: by 10.36.23.83 with SMTP id 80mr15997683ith.35.1519730301107; Tue, 27 Feb 2018 03:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519730301; cv=none; d=google.com; s=arc-20160816; b=su6J1YaV+07d57nsEa581Wodbn//seSVQgFS/xC/BM7P8FALbnCuP5NMMD10+ZcPas HxJQ71+gdXWTBix2sRRl3gRABHQ9xr06JxmYMVBGbef7OVjCZ54Pi4lsG8cD28qfux37 OFG8yEg62sgAFbr7FeVqdoTSYuolDbJ3XAIeDwvZd8Fp3mmOkRMirZfj+LJsu+v7pynq 6LCILkeE1SFUjurVW13ag36pa2s8YllwNAIBQJE2JBkrMexl3e65m74FQW++dMZH+EBM V0avmIfuKJsZiTacIc0yL6s2CghhjUWBz3GPZn46uW6AP85ViPeZzFyn5XDixyJfttcM MqLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:message-id:date:to:from :arc-authentication-results; bh=H8m8ihQWSmYc3Exgmh+u8chVu0Zpk+uK5MLX5Y4NiFQ=; b=mQQkMR5lOsKPpOT/RVrieQUtziITj1dMtIG2Kz2trnNS/sa35YbpQzocAIF96ENOcr 5uubuuAiayoLXGGwsf+RmE3d4pFKiwkw9XfuVGRcvJMRR4yy+Txbi5WCPCb8Apu2Ilbk 1d7iJJWyEhlB6g4k6RfB2x6bugKtJxijD6/NX+L6tmt3Romm0Qg7HOUBWVoNfxxPdtYv OoQwtCT6kjovviKdQZ7eLFesgGyUGSlqKGgHGFoCcPqIn5QVEJiV42CsokT8AJuRt6Ng PthyMw8YnH+RgFaZjv+fp74X2c+g47X3+KH5o/H11jivIvXjlWyxbk4MMAvAbJq3m67M iA4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id s66si6613981itd.32.2018.02.27.03.18.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 03:18:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eqdF8-0008Hh-3Q; Tue, 27 Feb 2018 11:16:22 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eqdF6-0008HY-IR for xen-devel@lists.xen.org; Tue, 27 Feb 2018 11:16:20 +0000 X-Inumbo-ID: 8050b27b-1baf-11e8-ba59-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 8050b27b-1baf-11e8-ba59-bc764e045a96; Tue, 27 Feb 2018 12:15:22 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 981E315AD; Tue, 27 Feb 2018 03:16:17 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6440D3F487; Tue, 27 Feb 2018 03:16:16 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 27 Feb 2018 11:15:57 +0000 Message-Id: <20180227111557.23920-1-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 Cc: Julien Grall , sstabellini@kernel.org, Iain Hunter , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH] xen/arm: Flush TLBs before turning on the MMU to avoid stale entries X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We don't know what is the state of the TLBs when booting Xen. To avoid stale entries, it is necessary to flush the TLBs before turning on the MMU. Reported-by: Iain Hunter Signed-off-by: Julien Grall --- xen/arch/arm/arm32/head.S | 7 +++++++ xen/arch/arm/arm64/head.S | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 43374e77c6..612fc8fc3c 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -360,6 +360,13 @@ virtphys_clash: 1: PRINT("- Turning on paging -\r\n") + /* + * The state of the TLBs is unknown before turning on the MMU. + * Flush them to avoid stale one. + */ + mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLBs */ + dsb nsh + ldr r1, =paging /* Explicit vaddr, not RIP-relative */ mrc CP32(r0, HSCTLR) orr r0, r0, #(SCTLR_M|SCTLR_C) /* Enable MMU and D-cache */ diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 35cf8e5cc9..5ba4832cf3 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -498,6 +498,13 @@ virtphys_clash: 1: PRINT("- Turning on paging -\r\n") + /* + * The state of the TLBs is unknown before turning on the MMU. + * Flush them to avoid stale one. + */ + tlbi alle2 /* Flush hypervisor TLBs */ + dsb nsh + ldr x1, =paging /* Explicit vaddr, not RIP-relative */ mrs x0, SCTLR_EL2 orr x0, x0, #SCTLR_M /* Enable MMU */