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::344; helo=mail-wm1-x344.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (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 E4D3E2119621B for ; Fri, 30 Nov 2018 03:39:14 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id z18so5471653wmc.4 for ; Fri, 30 Nov 2018 03:39:14 -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=17xDrwZiEKNW6DJrV3MGKaPjxPcJCTxCZiNbMSoelcY=; b=gPZKOk/M7tLhOH714863WkLrEQ0bXPU2+9LomU29kGHx9GZLqdyBNWMwB7vF8cswDk obIJrAVjO3Pv9Ae4pfI/em7VX3r9QJVBcfWSjdh0xeTppC+hQ6OtmAKjiYAxP1xE3OSI HuLcsw+XBpvLUDwg2+h5WxMIxyJg44VZfTmW8= 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=17xDrwZiEKNW6DJrV3MGKaPjxPcJCTxCZiNbMSoelcY=; b=p1m/+c5ZZu9JCCO7BfwU7ZaaId6tW+0hC45d6VO6xRULWk64wFF7E60+x5RGssH2Ez o+SLTyHwY4mKddy9itAVhXsyawDsOQKMbCzKmiFPRftxEYXOWx+o07+Mc0X9U9QvKEQi DPFlOctlb3b+XaAxTANOLwWFyKj97l9yl5FPMp4Wc5KCyPRhhx/ny7CbUcRKsn1N2Op4 bWdpd5QxdZhr0hrCTtmpOQO5THYWjKnWj9w2YDFurq7xXe6R1rObMmUDTAwMrlEFW4B6 y7B2HB0oNq3rWLAvcxc+6vh/idSvxQkGbaEPJh/fvOo3Xrdh6zzIKVe65srkP7b0Ju7D /7Gw== X-Gm-Message-State: AA+aEWa4ovJ6amz/KdXLa1giffK3ekcP/S8e5OAMnWKnOxOzXX1mlCwZ GyEmQgXEUI/PxUmIuUUmjffmcw== X-Google-Smtp-Source: AFSGD/Wtsra9N+uJZpTGGkt1SQn0/hraHOee81e35R3JZBmsQDawSWekBqdfryZWdxeDqDqOsNu5TQ== X-Received: by 2002:a1c:81c6:: with SMTP id c189mr4971837wmd.86.1543577953457; Fri, 30 Nov 2018 03:39:13 -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 4sm4980454wra.73.2018.11.30.03.39.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 03:39:12 -0800 (PST) Date: Fri, 30 Nov 2018 11:39:11 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, Laszlo Ersek , Eric Auger , Andrew Jones , Philippe Mathieu-Daude Message-ID: <20181130113911.kr52mp6inpxvgocr@bivouac.eciton.net> References: <20181130112829.12173-1-ard.biesheuvel@linaro.org> <20181130112829.12173-3-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20181130112829.12173-3-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH v2 2/4] ArmPkg/ArmMmuLib ARM: handle unmapped sections when updating permissions 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: Fri, 30 Nov 2018 11:39:15 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Nov 30, 2018 at 12:28:27PM +0100, Ard Biesheuvel wrote: > The ARM ArmMmuLib code currently does not take into account that > setting permissions on a region should take into account that a > region may not be mapped yet to begin with. > > So when updating a section descriptor whose old value is zero, > pass in the address explicitly. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm > --- > ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c > index ec51e072ab43..889b22867dc7 100644 > --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c > +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c > @@ -695,8 +695,12 @@ UpdateSectionEntries ( > } else { > // still a section entry > > - // mask off appropriate fields > - Descriptor = CurrentDescriptor & ~EntryMask; > + if (CurrentDescriptor != 0) { > + // mask off appropriate fields > + Descriptor = CurrentDescriptor & ~EntryMask; > + } else { > + Descriptor = ((UINTN)FirstLevelIdx + i) << TT_DESCRIPTOR_SECTION_BASE_SHIFT; > + } > > // mask in new attributes and/or permissions > Descriptor |= EntryValue; > -- > 2.19.1 >