From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::144; helo=mail-it1-x144.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x144.google.com (mail-it1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 BA6BB21A00AE6 for ; Mon, 28 Jan 2019 11:03:14 -0800 (PST) Received: by mail-it1-x144.google.com with SMTP id m8so11700215itk.0 for ; Mon, 28 Jan 2019 11:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=otZNLScCJI8HBMW/GecIEO/VaV+5/ghVz06EgrQfbAg=; b=A1SCGL8hrbtiNGjHYYap/NLPMG3g91unK0kV+OqnQvLM2Scx0KLRIwS6G4mKVON03I ms03KAryNF8uDp52mXwJ1rgr4WGTMCXYim8zH0cca6551GIPRamrC0YCUsbqHb4lPsE8 wgkXTfN2mcomqoFS3CX3hPc3AJ11qNri7VFx8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=otZNLScCJI8HBMW/GecIEO/VaV+5/ghVz06EgrQfbAg=; b=SRQ24k2/ekDfzG5w+ME+M1wIWdBeB5UsC8H5xFLyPqs+A3XpS+McXB0rL9RlzQCRYo I0FS48Zd1iRQ+Pz0FV/5L55pZ3wSvxNm2oV2XXGYUQNjQQR2f0QiItovxAcB/+UDFXC1 WkwiSTphvF7bdZWdmANmy+QYDw5l3IdZeCnjyhkAiwsp5978RFhuT6ZTj/ggLXmg62wm Bten+M66R1/Zfrpac9R8DM2Imcb8lWBQuPCtLQSqJjvQxLsLJtNSevYLJ052I3GjYGsT 0z2UQXWdDlWoO/gGwziKGmbMrJ/7hV18cO7KZpAu70KVrOwlM00tyuvjB6UOi9WTGdER ENZg== X-Gm-Message-State: AJcUukcYn7+ooYJ3D+54NcZdTO46mQIXrySpEWZveSDiRNVxtqQDneuH iFNyfu+O+NJ5Fj0Hh7pQFMVAPTILQ7XKaSfghtJHhA== X-Google-Smtp-Source: ALg8bN4nt/DoF4na/dgWqGQNpElZyu/NrLj9pGNOXYdUncyIJ/2/4H9nMam6foA26sJYTABsRjAfTwhEGdzYxKJKgcM= X-Received: by 2002:a05:660c:4b:: with SMTP id p11mr11393229itk.71.1548702193517; Mon, 28 Jan 2019 11:03:13 -0800 (PST) MIME-Version: 1.0 References: <20190128162332.10894-1-ard.biesheuvel@linaro.org> <20190128181152.n6orfozwmiozny4w@bivouac.eciton.net> In-Reply-To: <20190128181152.n6orfozwmiozny4w@bivouac.eciton.net> From: Ard Biesheuvel Date: Mon, 28 Jan 2019 20:03:01 +0100 Message-ID: To: Leif Lindholm Cc: "edk2-devel@lists.01.org" 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 19:03:15 -0000 Content-Type: text/plain; charset="UTF-8" On Mon, 28 Jan 2019 at 19:11, Leif Lindholm wrote: > > 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 > Thanks Pushed as 9a00a7164a39..66509f90fc66 > > --- > > 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 > >