From patchwork Tue Apr 19 14:55:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 66104 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1897747qge; Tue, 19 Apr 2016 07:55:53 -0700 (PDT) X-Received: by 10.66.228.201 with SMTP id sk9mr4699720pac.5.1461077753366; Tue, 19 Apr 2016 07:55:53 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id tf6si14936369pac.233.2016.04.19.07.55.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Apr 2016 07:55:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9621E1A224E; Tue, 19 Apr 2016 07:55:49 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 08BF51A21B1 for ; Tue, 19 Apr 2016 07:55:48 -0700 (PDT) Received: by mail-wm0-x234.google.com with SMTP id n3so34396098wmn.0 for ; Tue, 19 Apr 2016 07:55:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vJBGCoKMMGtRUPffG9wQYqwU5xXsi7Ajq+jFK2RTTzM=; b=K2virbbka6SIWAwb72g00jXlhAwqPYmSnuKZFkildr4sOAI3dMTNSAhRnvSlo2aKVY gf14akV3VmnZlcxOVNvI5r21EOZ5ME8j3aigIclZL8H4v3NwBRVpMZa+CJOZxxVnPMTI lN6eg4wbErNr5FEVEqrCfQ9YaMVHu5NlLUAxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vJBGCoKMMGtRUPffG9wQYqwU5xXsi7Ajq+jFK2RTTzM=; b=IgBtx2a3KlrdUGRk/aVH821hTTqveZvZErGrVkBuxz8Enr8/RdTkECv7w2ARdx+OoW VewA8is+fG/H1S8x+21a1QYukaaw3FSoEmPsLOkTL6nm8NTSK95uyijXbrvXFaxfiBzc hnjzphTtNzwpEf1Wa2W8jm5HfoXPmuXkFVNrkCiObOzEFZhH5zLGw93VfaS7aoFTtJlF kFNFPBFxbbHgcPOfSRvHX9Quhy6oHWcYVNoQQfI7c8DkVNmEljPiSdyHXWe+hQWi3PNp w4IF3BbsM0ZLWD7QLQEmagTTXWJ8HbeQ/k00tfXWA2v3DfPwErDewO1PV2jX2qgxX2lV lzjw== X-Gm-Message-State: AOPr4FWVgsqGiztxNTUya2r9w5wrUWtZ6KW1hD48jVaBAozYSDB7YTwMN0mySMl8IgyUI3R1 X-Received: by 10.194.89.38 with SMTP id bl6mr3519482wjb.44.1461077746508; Tue, 19 Apr 2016 07:55:46 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id i5sm684778wjx.15.2016.04.19.07.55.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 07:55:45 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, ryan.harkin@linaro.org Date: Tue, 19 Apr 2016 16:55:34 +0200 Message-Id: <1461077734-4327-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461077734-4327-1-git-send-email-ard.biesheuvel@linaro.org> References: <1461077734-4327-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 5/5] ArmPkg/ArmDmaLib: do not remap arbitrary memory regions as uncached X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: heyi.guo@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In the DmaMap () operation, if the region to be mapped happens to be aligned to the Cache Writeback Granule (CWG) (whose value is typically 64 or 128 bytes and 2 KB maximum), we remap the memory as uncached. Since remapping memory occurs at page granularity, while the buffer and the CWG may be much smaller, there is no telling what other memory we affect by doing this, especially since the operation is not reverted in DmaUnmap(). So remove the remapping call. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c index 7e518ed3b83e..83f4d38a8a60 100644 --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c @@ -137,12 +137,6 @@ DmaMap ( // Flush the Data Cache (should not have any effect if the memory region is uncached) gCpu->FlushDataCache (gCpu, *DeviceAddress, *NumberOfBytes, EfiCpuFlushTypeWriteBackInvalidate); - - if ((Operation == MapOperationBusMasterRead) || (Operation == MapOperationBusMasterCommonBuffer)) { - // In case the buffer is used for instance to send command to a PCI controller, we must ensure the memory is uncached - Status = gDS->SetMemorySpaceAttributes (*DeviceAddress & ~(BASE_4KB - 1), ALIGN_VALUE (*NumberOfBytes, BASE_4KB), EFI_MEMORY_WC); - ASSERT_EFI_ERROR (Status); - } } Map->HostAddress = (UINTN)HostAddress;