From patchwork Mon Jan 28 16:23:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 156788 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3618107jaa; Mon, 28 Jan 2019 08:25:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Z+hBCEgX1T5292w4SZaot7COIXOcX+86lw1Q8Qz8IOU41+5xUMxp1FCd/xlqpG1NTbDC/ X-Received: by 2002:a17:902:925:: with SMTP id 34mr21594554plm.14.1548692757279; Mon, 28 Jan 2019 08:25:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548692757; cv=none; d=google.com; s=arc-20160816; b=sFNg79dh7jbsZ34/vNxhjoE7P7qP5v1XXofAaAgkZ5BxH43cUzHmPk5glemhL/UJ1U XNjHNWTxE2eCkmqGVV8hmMbcDv8pfHsNwz8777IQDQ+QQRMKhA2YLF8jNV91E4+Zx2+C xrebgJVoJRtsnDXCGMUuIoH9DvBTm4ivyTehDmTHaUMWubAiuZcST5eXiqTXNm1UHOgN UInOHN28UDAwlqIZE/H3fHMN07jqLYSbtGELLaeuJHmxhJFJ8DrwPIvWNdrrmwenaKcY 5xFzcjkmxHPYuR/FJM9f8LOYpEe6fXLNETstk7WpGZYlFpZEy472K6HEMbFsoP0vU7tO UvUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:delivered-to; bh=9GthpFccQOLXGQcou5epHnOkovm4dTzJbdUrAlZ+gDE=; b=tnUxvhJTJlde2cMyWXqJhMbXdXJLfAKLRVDwXBBIY3L5ta+mj8/003ObdrRs3HeGXd aEHpsEt9zvL5UmfD7VrMs7xtpiE0thXBaEftpmQ/PHO1DfpSswDeGOJV6BGGShntMLaS +F6boRSKdauJdIZvjg7BWKMBlvWN1g02His+8FTOMFn7hePEFqix0wiVOdrwoySrKe44 14CEckmpBqBrjq3Z7rq55l9oI+1D2ypu2G+0i0tD3UZcqts0zd2ebM8Q8djKpGZhqleJ duWj+xikTRdad1wb8wHVg62UyNCJzaCRk0Sse3WWIPuHtK+NNiy+WD/jng/i+MDIPiQY qpXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hu3ug85q; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id b19si35143978pfm.100.2019.01.28.08.25.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 08:25:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hu3ug85q; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A119821C8EFB5; Mon, 28 Jan 2019 08:25:55 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::443; helo=mail-wr1-x443.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (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 650582063E305 for ; Mon, 28 Jan 2019 08:23:38 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id s12so18726080wrt.4 for ; Mon, 28 Jan 2019 08:23:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AaqNeRtSn9NN/W1OyRYOIyCClAnlLqpifjFNNW14924=; b=hu3ug85qukqKxnyhANY5yUUxaxTbTXPZWo4ISWSYWWvIJ4rbfgh5HOFtul+K1mUztI i/ZXhlV7pCFoo7UHMSvZlbsP+qoIRXq3HyU1eJ3fcbJTVF+Q3dbmXgfveCr1V6NuDdkw 2HJfEsixVc3CnDS4ugQlWfRVEn7uBVfmhxy7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AaqNeRtSn9NN/W1OyRYOIyCClAnlLqpifjFNNW14924=; b=NUulgFWICFPX55FlwfIKNo9vgjuqZvelmIbOuGQdrPajv1KwVVNCc3Le9PB4iVGDVJ JDUYIfLHYFTDew9j70EkxyZLFz0Qsmq+uQWkytKTRhvU59xEU5ZRAeXy5cN0mgKdDIUY 2bLiDfB1/KKZf87sHe76a1NgpAAKUzyNyyQ+LAQsqtV/bljQzeoPwW1or2nx2DpO34jR cwA7GN5+L+T2lbf7MDbr71JxbK74RABoGYruGtYY0vHTYSlBJ9Zwn+eMyW+ig3SmMhhw edb9spPYODjL9+Em5szQrpgGIrPKKcoBnqDfhZNgn8JVChgoi9a+l8i9Tk6+zO3lVlAx 5Kbw== X-Gm-Message-State: AJcUukdz6nOMomBzX1sxAM20n1e7Q90UCqKGtYsN5T3VIfyB1lDwp701 i5EEU+BoLUCZ72pfPonJMxJvmJrMXAw= X-Received: by 2002:adf:e64d:: with SMTP id b13mr22980342wrn.276.1548692616204; Mon, 28 Jan 2019 08:23:36 -0800 (PST) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id q14sm88088935wrw.39.2019.01.28.08.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 08:23:35 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 28 Jan 2019 17:23:32 +0100 Message-Id: <20190128162332.10894-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [edk2] [PATCH] ArmPkg/ArmMmuLib ARM: trim high memory regions instead of rejecting them X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" ArmSetMemoryAttributes() still chokes in some cases, i.e., when the length of the region exceeds 4 GB, the subtraction overflows, which results in the region being misidentified as being 32-bit addressable. Let's update the logic to trim the length to what we can address with 32 bits. This fixes the issue, and also deals with the issue where an entire region is disregarded if part of it exceeds beyond what we can map with 32 bits. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.1 _______________________________________________ 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/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c index bffab83d4fd0..baa085c3849a 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -744,10 +744,11 @@ ArmSetMemoryAttributes ( UINT64 ChunkLength; BOOLEAN FlushTlbs; - if (BaseAddress > (UINT64)MAX_ADDRESS - Length + 1) { + if (BaseAddress > (UINT64)MAX_ADDRESS) { return EFI_UNSUPPORTED; } + Length = MIN (Length, (UINT64)MAX_ADDRESS - BaseAddress + 1); if (Length == 0) { return EFI_SUCCESS; }