From patchwork Thu Apr 9 11:28:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46941 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F073221416 for ; Thu, 9 Apr 2015 11:29:34 +0000 (UTC) Received: by lamp14 with SMTP id p14sf26350495lam.3 for ; Thu, 09 Apr 2015 04:29:34 -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:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=lKGXEmgd4Wwv4Decw5fLL1z3ggHoUd+3AIo85uqtnAA=; b=gD2tozheB/psO/AwdE0dC7F4mUOPQ05ysHaKECPb4fi46OZm3lqOrMNa4UFhgsvrEl OQgLFJOYpvs9IAJc3o6bbiYmeUggeBFZqpVu835BmLLmiuDeundzmsdM5IlQAFs4dTdH 0gxX9dTCbkMC042Id8D9lEGCaddcXQkgFJPXMQgtyxA+xjCX5uu7E6Or9gCveJG+yvuz 0jxaTXG2NJs+rW/nO0tcrGOmftEdxN9eT0Zk3aWINbSjGVnKb21BJwhjgX/Rcrg4uMox S9gVskXNCILPvfINZS8YrLPQaGER9lEfY3nBU+b4T3Ht1DddTweVi3UvJ8QLsEj0TsLO lGhQ== X-Gm-Message-State: ALoCoQmlbFYGKk/eFtgI5UW6nMJ6H8BfEuzrLeqFw7SgFucpWei+BwKtdym4zBBeOOeevv7Pn/Jk X-Received: by 10.180.106.136 with SMTP id gu8mr507450wib.6.1428578973937; Thu, 09 Apr 2015 04:29:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.225.134 with SMTP id rk6ls298835lac.83.gmail; Thu, 09 Apr 2015 04:29:33 -0700 (PDT) X-Received: by 10.112.210.230 with SMTP id mx6mr27839629lbc.64.1428578973771; Thu, 09 Apr 2015 04:29:33 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id ew9si7644605lac.87.2015.04.09.04.29.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 04:29:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labbd9 with SMTP id bd9so75689063lab.2 for ; Thu, 09 Apr 2015 04:29:33 -0700 (PDT) X-Received: by 10.112.184.70 with SMTP id es6mr27268498lbc.117.1428578973661; Thu, 09 Apr 2015 04:29:33 -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 l1csp411782lbt; Thu, 9 Apr 2015 04:29:32 -0700 (PDT) X-Received: by 10.50.111.168 with SMTP id ij8mr19216755igb.43.1428578966973; Thu, 09 Apr 2015 04:29:26 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id mv8si2224498igb.62.2015.04.09.04.29.26 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 09 Apr 2015 04:29:26 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YgAe5-000448-Na; Thu, 09 Apr 2015 11:29:17 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YgAe4-000443-J9 for edk2-devel@lists.sourceforge.net; Thu, 09 Apr 2015 11:29:16 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.182 as permitted sender) client-ip=209.85.212.182; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f182.google.com; Received: from mail-wi0-f182.google.com ([209.85.212.182]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YgAe3-0002bs-1m for edk2-devel@lists.sourceforge.net; Thu, 09 Apr 2015 11:29:16 +0000 Received: by wiun10 with SMTP id n10so94004149wiu.1 for ; Thu, 09 Apr 2015 04:29:09 -0700 (PDT) X-Received: by 10.194.123.67 with SMTP id ly3mr59955776wjb.105.1428578949068; Thu, 09 Apr 2015 04:29:09 -0700 (PDT) Received: from ards-macbook-pro.local ([90.174.5.113]) by mx.google.com with ESMTPSA id l10sm19692348wje.15.2015.04.09.04.29.06 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Apr 2015 04:29:08 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com Date: Thu, 9 Apr 2015 13:28:50 +0200 Message-Id: <1428578932-24079-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1428578932-24079-1-git-send-email-ard.biesheuvel@linaro.org> References: <1428578932-24079-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1YgAe3-0002bs-1m Subject: [edk2] [PATCH v4 3/5] ArmPkg: remove cache maintenance by VA operation range size threshold X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@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.215.51 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 This removes the range size threshold for virtual address based cache maintenance instructions that operate on VA ranges to be 'promoted' to use set/way instructions. Doing so is unsafe: set/way operations are fundamentally different from VA operations, and really only suitable for cleaning or invalidating a cache when turning it on or off. To quote the ARM ARM (DDI0487A_d G3.4): """ Since the set/way instructions are performed only locally, there is no guarantee of the atomicity of cache maintenance between different PEs, even if those different PEs are each performing the same cache maintenance instructions at the same time. Since any cacheable line can be allocated into the cache at any time, it is possible for [a] cache line to migrate from an entry in the cache of one PE to the cache of a different PE in a manner that the cache line avoids being affected by set/way based cache maintenance. Therefore, ARM strongly discourages the use of set/way instructions to manage coherency in coherent systems. """ Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-By: Olivier Martin Signed-off-by: Ard Biesheuvel --- ArmPkg/ArmPkg.dec | 3 +-- ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c | 29 +++++++++++------------------ ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf | 3 --- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.inf | 3 --- ArmPkg/Library/ArmLib/AArch64/AArch64LibPrePi.inf | 3 --- ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf | 3 --- ArmPkg/Library/ArmLib/Arm11/Arm11Lib.inf | 1 - ArmPkg/Library/ArmLib/Arm11/Arm11LibPrePi.inf | 1 - ArmPkg/Library/ArmLib/Arm11/Arm11LibSec.inf | 1 - ArmPkg/Library/ArmLib/Arm9/Arm9ArmLib.inf | 3 --- ArmPkg/Library/ArmLib/Arm9/Arm9ArmLibPrePi.inf | 3 --- ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf | 3 --- ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf | 3 --- ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf | 3 --- ArmPkg/Library/ArmLib/Null/NullArmLib.inf | 3 --- 15 files changed, 12 insertions(+), 53 deletions(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 87dbd11b867f..b30de9152c13 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -82,8 +82,7 @@ gArmTokenSpaceGuid.PcdArmUncachedMemoryMask|0x0000000080000000|UINT64|0x00000002 # This PCD will free the unallocated buffers if their size reach this threshold. # We set the default value to 512MB. - gArmTokenSpaceGuid.PcdArmFreeUncachedMemorySizeThreshold|0x20000000|UINT64|0x00000043 - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold|1024|UINT32|0x00000003 + gArmTokenSpaceGuid.PcdArmFreeUncachedMemorySizeThreshold|0x20000000|UINT64|0x00000003 gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0xffff0000|UINT32|0x00000004 gArmTokenSpaceGuid.PcdCpuResetAddress|0x00000000|UINT32|0x00000005 diff --git a/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c b/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c index 8501e5c613c7..d8e53df6096e 100644 --- a/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c +++ b/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c @@ -20,27 +20,20 @@ VOID CacheRangeOperation ( IN VOID *Start, IN UINTN Length, - IN CACHE_OPERATION CacheOperation, IN LINE_OPERATION LineOperation ) { UINTN ArmCacheLineLength = ArmDataCacheLineLength(); UINTN ArmCacheLineAlignmentMask = ArmCacheLineLength - 1; - UINTN ArmCacheOperationThreshold = PcdGet32(PcdArmCacheOperationThreshold); - if ((CacheOperation != NULL) && (Length >= ArmCacheOperationThreshold)) { - ArmDrainWriteBuffer (); - CacheOperation (); - } else { - // Align address (rounding down) - UINTN AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask); - UINTN EndAddress = (UINTN)Start + Length; + // Align address (rounding down) + UINTN AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask); + UINTN EndAddress = (UINTN)Start + Length; - // Perform the line operation on an address in each cache line - while (AlignedAddress < EndAddress) { - LineOperation(AlignedAddress); - AlignedAddress += ArmCacheLineLength; - } + // Perform the line operation on an address in each cache line + while (AlignedAddress < EndAddress) { + LineOperation(AlignedAddress); + AlignedAddress += ArmCacheLineLength; } } @@ -70,7 +63,7 @@ InvalidateInstructionCacheRange ( IN UINTN Length ) { - CacheRangeOperation (Address, Length, ArmCleanDataCacheToPoU, ArmCleanDataCacheEntryByMVA); + CacheRangeOperation (Address, Length, ArmCleanDataCacheEntryByMVA); ArmInvalidateInstructionCache (); return Address; } @@ -91,7 +84,7 @@ WriteBackInvalidateDataCacheRange ( IN UINTN Length ) { - CacheRangeOperation(Address, Length, ArmCleanInvalidateDataCache, ArmCleanInvalidateDataCacheEntryByMVA); + CacheRangeOperation(Address, Length, ArmCleanInvalidateDataCacheEntryByMVA); return Address; } @@ -111,7 +104,7 @@ WriteBackDataCacheRange ( IN UINTN Length ) { - CacheRangeOperation(Address, Length, ArmCleanDataCache, ArmCleanDataCacheEntryByMVA); + CacheRangeOperation(Address, Length, ArmCleanDataCacheEntryByMVA); return Address; } @@ -122,6 +115,6 @@ InvalidateDataCacheRange ( IN UINTN Length ) { - CacheRangeOperation(Address, Length, NULL, ArmInvalidateDataCacheEntryByMVA); + CacheRangeOperation(Address, Length, ArmInvalidateDataCacheEntryByMVA); return Address; } diff --git a/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf b/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf index 5910db09d6ea..d5199729423c 100644 --- a/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf +++ b/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf @@ -31,6 +31,3 @@ [LibraryClasses] ArmLib BaseLib - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.inf b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.inf index e5247848b549..dd585dea91fb 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.inf +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.inf @@ -41,6 +41,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64LibPrePi.inf b/ArmPkg/Library/ArmLib/AArch64/AArch64LibPrePi.inf index 3a99e1b713cc..23fbe8673198 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64LibPrePi.inf +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64LibPrePi.inf @@ -43,6 +43,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf b/ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf index 57ac694cd733..302c09af49dd 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf @@ -38,6 +38,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/Arm11/Arm11Lib.inf b/ArmPkg/Library/ArmLib/Arm11/Arm11Lib.inf index 32d9299629a7..6ac74d985c78 100644 --- a/ArmPkg/Library/ArmLib/Arm11/Arm11Lib.inf +++ b/ArmPkg/Library/ArmLib/Arm11/Arm11Lib.inf @@ -47,5 +47,4 @@ gArmTokenSpaceGuid.PcdRelocateVectorTable [FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold gArmTokenSpaceGuid.PcdCpuVectorBaseAddress diff --git a/ArmPkg/Library/ArmLib/Arm11/Arm11LibPrePi.inf b/ArmPkg/Library/ArmLib/Arm11/Arm11LibPrePi.inf index 94dd03d82c5a..239493d3e60d 100644 --- a/ArmPkg/Library/ArmLib/Arm11/Arm11LibPrePi.inf +++ b/ArmPkg/Library/ArmLib/Arm11/Arm11LibPrePi.inf @@ -47,5 +47,4 @@ gArmTokenSpaceGuid.PcdRelocateVectorTable [FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold gArmTokenSpaceGuid.PcdCpuVectorBaseAddress diff --git a/ArmPkg/Library/ArmLib/Arm11/Arm11LibSec.inf b/ArmPkg/Library/ArmLib/Arm11/Arm11LibSec.inf index 69763ed4ff3a..ef3c8f8f72a4 100644 --- a/ArmPkg/Library/ArmLib/Arm11/Arm11LibSec.inf +++ b/ArmPkg/Library/ArmLib/Arm11/Arm11LibSec.inf @@ -43,5 +43,4 @@ gArmTokenSpaceGuid.PcdRelocateVectorTable [FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold gArmTokenSpaceGuid.PcdCpuVectorBaseAddress diff --git a/ArmPkg/Library/ArmLib/Arm9/Arm9ArmLib.inf b/ArmPkg/Library/ArmLib/Arm9/Arm9ArmLib.inf index 81661b2391d5..e8aa056fbfea 100644 --- a/ArmPkg/Library/ArmLib/Arm9/Arm9ArmLib.inf +++ b/ArmPkg/Library/ArmLib/Arm9/Arm9ArmLib.inf @@ -41,6 +41,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/Arm9/Arm9ArmLibPrePi.inf b/ArmPkg/Library/ArmLib/Arm9/Arm9ArmLibPrePi.inf index 0730487cfb9e..556e3dc5ab2a 100644 --- a/ArmPkg/Library/ArmLib/Arm9/Arm9ArmLibPrePi.inf +++ b/ArmPkg/Library/ArmLib/Arm9/Arm9ArmLibPrePi.inf @@ -41,6 +41,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf b/ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf index 55c0ec661a81..01bdfb699656 100644 --- a/ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf +++ b/ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf @@ -48,6 +48,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf b/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf index bc403d5613ca..ac081068db28 100644 --- a/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf +++ b/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf @@ -48,6 +48,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf b/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf index 4081d1a3e563..a958764f5648 100644 --- a/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf +++ b/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf @@ -42,6 +42,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold diff --git a/ArmPkg/Library/ArmLib/Null/NullArmLib.inf b/ArmPkg/Library/ArmLib/Null/NullArmLib.inf index 21c374f0b293..36860a7bf949 100644 --- a/ArmPkg/Library/ArmLib/Null/NullArmLib.inf +++ b/ArmPkg/Library/ArmLib/Null/NullArmLib.inf @@ -40,6 +40,3 @@ [Protocols] gEfiCpuArchProtocolGuid - -[FixedPcd] - gArmTokenSpaceGuid.PcdArmCacheOperationThreshold