From patchwork Tue Apr 19 14:55:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 66102 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1897718qge; Tue, 19 Apr 2016 07:55:48 -0700 (PDT) X-Received: by 10.98.100.213 with SMTP id y204mr4641432pfb.123.1461077748424; Tue, 19 Apr 2016 07:55:48 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id y6si10538968pas.218.2016.04.19.07.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Apr 2016 07:55:48 -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 026EA1A227C; Tue, 19 Apr 2016 07:55:46 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) (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 ACA241A227C for ; Tue, 19 Apr 2016 07:55:44 -0700 (PDT) Received: by mail-wm0-x236.google.com with SMTP id v188so165722436wme.1 for ; Tue, 19 Apr 2016 07:55:44 -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=3ndG04Fyq+58eNGcRvQInHoSzOWbTazHZQd5obQmJjA=; b=Uga70MPJ29Hksz5VAyPgwMvv+5JjlfzdoyJfcypvmaSi/LzPYbh75Mn7Nse+iPVWRJ efctcJWVQT8RO4DeiJqfVzbeTn9qbtC8/5hPFbsl6QVDOzQi8GTJ9wns7BxSgXTMoKaO CGwfL5s3uYdUD0UJ+QAIkDaUvUAcPYV1qy1SQ= 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=3ndG04Fyq+58eNGcRvQInHoSzOWbTazHZQd5obQmJjA=; b=nAVsuM/32LZeWOWJIf4HNOLtJnkZPzsbAF/oYxrlN26lPN7maomzZ6SOI1SrKm/G8+ CNjmenUK8zCflm1OGxT+7Dqfob4KPBHWIbHjje8xrg/ELxJlbZ3fOAShAI532gBkWvYB R+S+RP2xVWwX+1Cm0XYKAZ9B+CDLVZMwGjFKBMEk2Drm41ZVO9Q285aUKfMxgN+y+0DY lfY0l8H8BTaOxGzXl5STTCwli8i5jXFDfAbrKmrHrm0Wd9Qw797lSIlG4gfEadWblu2A r3maC2EEPgBPJhPITWzQNk8YDuLB5N9tVR7b7c7Rr3ArzG0I1GXgARBnWcRJtwv0Azwo u10w== X-Gm-Message-State: AOPr4FUgrijr819w7i9FNKjJrMH/ISq2HTTyr2+eJF0XdW1PdpEcjaIjjbJsTVs0g2ob/Dqj X-Received: by 10.194.92.107 with SMTP id cl11mr4117011wjb.21.1461077743231; Tue, 19 Apr 2016 07:55:43 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id i5sm684778wjx.15.2016.04.19.07.55.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 07:55:42 -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:32 +0200 Message-Id: <1461077734-4327-3-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 3/5] ArmPkg/ArmDmaLib: interpret GCD attributes as a bit field 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" Comparing a GCD attribute field directly against EFI_MEMORY_UC and EFI_MEMORY_WT is incorrect, since it may have other bits set as well which are not related to the cacheability of the region. So instead, test explicitly against the flags EFI_MEMORY_WB and EFI_MEMORY_WT, which must be set if the region may be mapped with cacheable attributes. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 4 +--- 1 file changed, 1 insertion(+), 3 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 834afdba10ef..7f6598318a91 100644 --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c @@ -101,9 +101,7 @@ DmaMap ( } // If the mapped buffer is not an uncached buffer - if ( (GcdDescriptor.Attributes != EFI_MEMORY_WC) && - (GcdDescriptor.Attributes != EFI_MEMORY_UC) ) - { + if ((GcdDescriptor.Attributes & (EFI_MEMORY_WB | EFI_MEMORY_WT)) != 0) { // // If the buffer does not fill entire cache lines we must double buffer into // uncached memory. Device (PCI) address becomes uncached page.