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=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-Google-Smtp-Source: AFSGD/WqyWMyYSuI4xvHSqRyICc1tH2QB9p9RIJxdGgPd1+MAQEQugNfxHRkJwnWHyWKlocyYmHkcQ== 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 Cc: Ard Biesheuvel , Leif Lindholm , Laszlo Ersek , Eric Auger , Andrew Jones , Philippe Mathieu-Daude 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: [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:28:37 -0000 Content-Transfer-Encoding: 8bit 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(-) 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