From patchwork Fri Nov 30 11:28:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 152520 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3539526ljp; Fri, 30 Nov 2018 03:28:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/UhfIYqv1LnVIZbdhiUsFfNMEn6zq7rokjbRWONYLEf3T44l3EE5ANFes8GhwAFIY/DCWng X-Received: by 2002:a63:1766:: with SMTP id 38mr4392819pgx.299.1543577321597; Fri, 30 Nov 2018 03:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543577321; cv=none; d=google.com; s=arc-20160816; b=nxR8E03klhIPZFwHuJ3fc4xWs7Uoitaus7bcrsGuNjZziIFMuF/X00i3EIyP5oklNW iWG0AcLaV3Fw4PrsFEc3BMLe6TwBX3t4Kgf6yP0YwbFpgQ8n4JX4losw0MBeSgWpEACZ 68kpl8OFYv7HJWrXwe7y+PH9EHN7C75ls/NugHTnqPMwG2Srm+001fh+xEiqfuBfFdql UFUA7kcSHuzAFRmrS8MD2IrpGWfWbQPnetVvOi5jfQR+vWxIHsX5r9Z9QAFGhwVspSfQ qIGqSQZdEExzFVaQmTHMntYv8dIkQne7+MkX5BSgLd/NNrhB/ALuZRqg312xohd/eJie OtLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=XdNWZVBpLgPEQhLyKJ+tvZ/AwW+r0xKITNwt6/xP0G8=; b=wmQP5GF+c916g0EgJhu1umpTq9KtdSCWIIbWbfHO0g3otcwK7vA/Qi5+e7LmL/e+e/ K47U9qyai9Ao11Za0J1mpeVQhwZJuSNKD/fj0wDM/VVqUVvZeYCcWS5dlHcBXoRLf+SN O+jv1ZArsyfznf7H9JHPM7Mx1B6r/yV8Q/uW4LU5EMcwPgyhZHTrDekU5Hh0ip/n0cP8 5UPgAFHytqeJiWQxndLEJwgrJFqFSQ4DT5nZd3jDq4e7pXsqykqRowdYQ/sU4lqOmvfM 0gAaG15K4LjCtFtb4OgOU2fumzvzo+93/DTb2rcOPA3wPvB/lhnskzlFBTkNwHqqJFhC nZaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=DrvwL9yY; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id q18si4833781pls.30.2018.11.30.03.28.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 03:28:41 -0800 (PST) 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 header.s=google header.b=DrvwL9yY; 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 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 EFCF021197B01; Fri, 30 Nov 2018 03:28:38 -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::343; helo=mail-wm1-x343.google.com; envelope-from=ard.biesheuvel@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 24C7721CAD998 for ; Fri, 30 Nov 2018 03:28:37 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id k198so5366434wmd.3 for ; Fri, 30 Nov 2018 03:28:37 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=i7vr5ZjMFgX+1eTECSn7kjNQU6jaQGfmNlsOKqY/sVQ=; b=DrvwL9yY/x6GcoOszy6zZsPEzP4t3i8Y46m5P1gsa8tgUHkDR6kEIry2IINfZUg5Cq 7kHCLchg6h9Z8iGxsD3l5v6tL23I9wPv1fVjqYNz48wxHUX4d8yhFPEqJcXDoz3lAKa4 ih2dS0itx8WybnMkoWNE53JYJ0VRPOjiqxaOE= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=i7vr5ZjMFgX+1eTECSn7kjNQU6jaQGfmNlsOKqY/sVQ=; b=fB99qcP7qU/EDDDnsU4CpI6+8+jyf1LwHD5eaDIFv5T/07B1qxOgzHeSzAjg5BP9jx p1YIFgpmO+tDsxfQTcSSWAKifXUUsRVPEhWsa4cnMyUCDbBS8fhuAzQ18m7lSQxqV9ym SU3npxPlHp0edqG0Y1pA3SjvgmK1JhB3aFaTB9K/+MTdFimSs6uODRpsx9cpUkx1Yp/h hNXJqD5ilwgCc82palfSkqR9RizKaEf3ZcS70Pyh8aSr8heiuQW/icjn6DVjho00bslz 9vy2xcsn45Mf2PLfsd7hcDmR+hFzVM7BUZrAlGi8TYOoBEvKF/lBsdSiC9ic9WUeMgaq TCkA== X-Gm-Message-State: AA+aEWY4Lme526XcG6oU+f3NFdXUggUh+hSJV4up8Zob54IX9d5qbIGw qs8skvXGWyycV2HHalPgeqEnHk6U6Nc= X-Received: by 2002:a1c:93ca:: with SMTP id v193mr5434899wmd.82.1543577315387; Fri, 30 Nov 2018 03:28:35 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:f070:d240:312e:9f99]) by smtp.gmail.com with ESMTPSA id h16sm4340570wrs.60.2018.11.30.03.28.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 03:28:34 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 30 Nov 2018 12:28:27 +0100 Message-Id: <20181130112829.12173-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130112829.12173-1-ard.biesheuvel@linaro.org> References: <20181130112829.12173-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [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: , Cc: Andrew Jones , Laszlo Ersek Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.19.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 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;