From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::343; helo=mail-wm1-x343.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (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 8CD5E21A00AE6 for ; Mon, 28 Jan 2019 10:11:56 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id r24so11061606wmh.0 for ; Mon, 28 Jan 2019 10:11:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/z4YaVki4A++yYFFB+9GhfyQkGgzh5JuhRT1mocwXS4=; b=IavMTQz1UOsy905jf4JQYwxdOJliV5CYVAiMUFbkNSHUToIFT6V6/TylESxiD2Vlwn JIlsYFvP96w0oOcGkoVvSU3Q40H+K7LLJ7SXiDTCELnbD2zj1TOMpnyW2+JO2TboNvJR Dt+3OWpvnHm58qZhhtbLdD1HvlYD1vnIVd7sA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/z4YaVki4A++yYFFB+9GhfyQkGgzh5JuhRT1mocwXS4=; b=f0rCvqn1WTIPnzulUwsYypLr6aqNxgt08L2/58R0NhtHKckOjo3U7Is6YQWNQxBARa JnHYptbQZ52cCu+z7qLj2ExLCtPlxm4tzExsTY2NtfijOkj1uR31hbbfZ1TsUUuH5PaT DVMNxdoBQVboQlUj+zq2AL9ES7aC2npPDsNesdalMY+9H8pFvFDlIbyQUL9Qbr7bgYA2 u+Ucl5NYTG9q3ijaXrr0BUD425QFNMpgkx31jDILlzw+8gBLyANHncpzgqaHRuCW6vrf n+GYXkCd0I5X3YTVlvEvvGjmItEtlytTGMVKBAn7v1e4BoYJaafX2NEbF6K7CKfTmesy /3Ng== X-Gm-Message-State: AHQUAuY+6RZa9F4Ipq1+s1pIvKq8A3kk92Nn+/NSbRSkW2hNP3U9CtiP ITYzcKKg5rXrnTVSqB27Mcr3mQ== X-Google-Smtp-Source: AHgI3IaIwib4sjs3USAh3UCYyNcjN1bFPbblpYXS0hi4QYcb89ydLpXYQ8hNBohxdbc3wC8ZukTQCg== X-Received: by 2002:a1c:650a:: with SMTP id z10mr5940455wmb.148.1548699114240; Mon, 28 Jan 2019 10:11:54 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id i186sm209199wmd.19.2019.01.28.10.11.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 10:11:53 -0800 (PST) Date: Mon, 28 Jan 2019 18:11:52 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org Message-ID: <20190128181152.n6orfozwmiozny4w@bivouac.eciton.net> References: <20190128162332.10894-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20190128162332.10894-1-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [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: , X-List-Received-Date: Mon, 28 Jan 2019 18:11:56 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jan 28, 2019 at 05:23:32PM +0100, Ard Biesheuvel wrote: > 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 Reviewed-by: Leif Lindholm > --- > ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > 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; > } > -- > 2.20.1 >