From patchwork Mon Sep 19 17:36:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bdegraaf@codeaurora.org X-Patchwork-Id: 9340281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F863607D0 for ; Mon, 19 Sep 2016 17:47:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8535729602 for ; Mon, 19 Sep 2016 17:47:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79B7C2960F; Mon, 19 Sep 2016 17:47:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 09D2C29602 for ; Mon, 19 Sep 2016 17:47:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bm2d4-0002qU-Tb; Mon, 19 Sep 2016 17:45:18 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bm2VV-0002RX-1I for linux-arm-kernel@lists.infradead.org; Mon, 19 Sep 2016 17:37:41 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A69EE61650; Mon, 19 Sep 2016 17:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1474306627; bh=9IA8PRYYyalosG5VQXaNdXxulIGC5gjCBahyWwjza98=; h=From:To:Cc:Subject:Date:From; b=ilfPw/XjPwtja+fXGU+v1IxY+Tp+fAHmuMo+AzNvR5HH9vE8HxU/swdT4iiiktoTt /8ecl+m7DUE5heHe8gbvJZhFoCQIlvexNcXgoh0jQUGqPHuLM0hKGAm6OLadwr5Bw3 WdIQJ/SD+vKmqDQL+QrH/hWMYGQLhXvWSGD1CvBs= Received: from southpoint.qualcomm.com.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bdegraaf@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A9B3261650; Mon, 19 Sep 2016 17:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1474306627; bh=9IA8PRYYyalosG5VQXaNdXxulIGC5gjCBahyWwjza98=; h=From:To:Cc:Subject:Date:From; b=ilfPw/XjPwtja+fXGU+v1IxY+Tp+fAHmuMo+AzNvR5HH9vE8HxU/swdT4iiiktoTt /8ecl+m7DUE5heHe8gbvJZhFoCQIlvexNcXgoh0jQUGqPHuLM0hKGAm6OLadwr5Bw3 WdIQJ/SD+vKmqDQL+QrH/hWMYGQLhXvWSGD1CvBs= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org A9B3261650 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=bdegraaf@codeaurora.org From: Brent DeGraaf To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [RFC] arm64: Ensure proper addressing for ldnp/stnp Date: Mon, 19 Sep 2016 13:36:26 -0400 Message-Id: <1474306586-25118-1-git-send-email-bdegraaf@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160919_103729_774289_5BCB267B X-CRM114-Status: GOOD ( 10.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, jungseoklee85@gmail.com, Brent DeGraaf , andre.przywara@arm.com, timur@codeaurora.org, linux-kernel@vger.kernel.org, james.morse@arm.com, apinski@cavium.com, labbott@redhat.com, linux-arm-kernel@lists.infradead.org, cov@codeaurora.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP According to section 6.3.8 of the ARM Programmer's Guide, non-temporal loads and stores do not verify that address dependency is met between a load of an address to a register and a subsequent non-temporal load or store using that address on the executing PE. Therefore, context switch code and subroutine calls that use non-temporally accessed addresses as parameters that might depend on a load of an address into an argument register must ensure that ordering requirements are met by introducing a barrier prior to the successive non-temporal access. Add appropriate barriers whereever this specific situation comes into play. Signed-off-by: Brent DeGraaf --- arch/arm64/kernel/entry.S | 1 + arch/arm64/lib/copy_page.S | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 441420c..982c4d3 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -679,6 +679,7 @@ ENTRY(cpu_switch_to) ldp x27, x28, [x8], #16 ldp x29, x9, [x8], #16 ldr lr, [x8] + dmb nshld // Existence of instructions with loose load-use dependencies (e.g. ldnp/stnp) make this barrier necessary mov sp, x9 and x9, x9, #~(THREAD_SIZE - 1) msr sp_el0, x9 diff --git a/arch/arm64/lib/copy_page.S b/arch/arm64/lib/copy_page.S index 4c1e700..21c6892 100644 --- a/arch/arm64/lib/copy_page.S +++ b/arch/arm64/lib/copy_page.S @@ -47,6 +47,8 @@ alternative_endif ldp x14, x15, [x1, #96] ldp x16, x17, [x1, #112] + dmb nshld // In case x0 (for stnp) is dependent on a load + mov x18, #(PAGE_SIZE - 128) add x1, x1, #128 1: