From patchwork Thu Feb 12 05:24:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44583 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3EC0421527 for ; Thu, 12 Feb 2015 05:26:19 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id y19sf4910520wgg.1 for ; Wed, 11 Feb 2015 21:26:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=v27vG7PY2CegkMA1lcLOu+ShH/4EXKlShKEtpg7iG+U=; b=NV4ywiFmfIbNNt7e9uFB+RLT9r3zwIjquL6RU5MgR+QVlVrtjnvwr5GVCWI3go+8at 09yZv0yBTLLoHI2XLa/etRT9KSG3XRAxpTANhW9iTt7qK1iwLQSdq+kal8MZ+NozQtHo vU35ldQ9hSR0172M77BHhc1zwRPuXMw5Ywcnk6WFPxZnEmKqmkuKMOht+a7MkCvUgZPh JsCMklbNDAeYU9GqWRvjx8OGr+qGVDxL8J4N5wOGWEv5RS4QGG0eCiVjvXrWk8cyE71e oNqjOF+knteZJI9yIG47koGdGEbTekh4gSJDLlO+z7kuVTByXSOmUFG2fJt0ZoyPM55k Q33g== X-Gm-Message-State: ALoCoQn91+eLSl5t3XJZIYJDqllEnIGc5wirD1J5Tp8rhDJ+ryiortbixuHl9pbCzEuERX0j+atr X-Received: by 10.112.119.141 with SMTP id ku13mr260926lbb.7.1423718778479; Wed, 11 Feb 2015 21:26:18 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.239.165 with SMTP id vt5ls158351lac.0.gmail; Wed, 11 Feb 2015 21:26:18 -0800 (PST) X-Received: by 10.112.211.168 with SMTP id nd8mr1764043lbc.18.1423718778224; Wed, 11 Feb 2015 21:26:18 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id jd8si2133394lbc.99.2015.02.11.21.26.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Feb 2015 21:26:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id z11so7411239lbi.8 for ; Wed, 11 Feb 2015 21:26:18 -0800 (PST) X-Received: by 10.152.45.100 with SMTP id l4mr1655893lam.112.1423718778107; Wed, 11 Feb 2015 21:26:18 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp228556lbj; Wed, 11 Feb 2015 21:26:17 -0800 (PST) X-Received: by 10.66.136.17 with SMTP id pw17mr3529874pab.33.1423718776415; Wed, 11 Feb 2015 21:26:16 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id fi4si3532945pbc.179.2015.02.11.21.26.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Feb 2015 21:26:16 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YLmGk-0006GU-6P; Thu, 12 Feb 2015 05:24:54 +0000 Received: from mail-pa0-f49.google.com ([209.85.220.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YLmGg-0006Ak-HN for linux-arm-kernel@lists.infradead.org; Thu, 12 Feb 2015 05:24:51 +0000 Received: by mail-pa0-f49.google.com with SMTP id fb1so8922451pad.8 for ; Wed, 11 Feb 2015 21:24:29 -0800 (PST) X-Received: by 10.66.132.6 with SMTP id oq6mr3544842pab.29.1423718669179; Wed, 11 Feb 2015 21:24:29 -0800 (PST) Received: from ards-macbook-pro.local ([210.177.145.249]) by mx.google.com with ESMTPSA id i5sm2441397pat.42.2015.02.11.21.24.26 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Feb 2015 21:24:28 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, matt.fleming@intel.com, leif.lindholm@linaro.org, roy.franz@linaro.org, mark.rutland@arm.com, mingo@redhat.com Subject: [PATCH] efi: get_memory_map: add sufficient slack for memory descriptors Date: Thu, 12 Feb 2015 13:24:19 +0800 Message-Id: <1423718659-795-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150211_212450_609882_15F4CE94 X-CRM114-Status: GOOD ( 10.94 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.220.49 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 As it turns out, when allocating room for the UEFI memory map using UEFI's AllocatePool (), it may result in two new memory map entries being created, for instance, when using Tianocore's preallocated region feature. For example, the following region 0x00005ead5000-0x00005ebfffff [Conventional Memory| | | | | |WB|WT|WC|UC] may be split like this 0x00005ead5000-0x00005eae2fff [Conventional Memory| | | | | |WB|WT|WC|UC] 0x00005eae3000-0x00005eae4fff [Loader Data | | | | | |WB|WT|WC|UC] 0x00005eae5000-0x00005ebfffff [Conventional Memory| | | | | |WB|WT|WC|UC] if the preallocated Loader Data region was chosen to be right in the middle of the original free space. After patch d1a8d66b9177 ("efi/libstub: Call get_memory_map() to obtain map and desc sizes"), this is not being dealt with correctly anymore, as the existing logic to allocate room for a single additional entry has become insufficient. So instead, add room for two additional entries instead. Fixes: d1a8d66b9177 ("efi/libstub: Call get_memory_map() to obtain map and desc sizes") Signed-off-by: Ard Biesheuvel Reviewed-by: Roy Franz Acked-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/efi-stub-helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index af5d63c7cc53..ca0b07ed3b14 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -84,10 +84,10 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, return EFI_LOAD_ERROR; /* - * Add an additional efi_memory_desc_t because we're doing an - * allocation which may be in a new descriptor region. + * Add room for two additional efi_memory_desc_t entries because we're + * doing an allocation which may be in a new descriptor region. */ - *map_size += *desc_size; + *map_size += *desc_size * 2; status = efi_call_early(allocate_pool, EFI_LOADER_DATA, *map_size, (void **)&m); if (status != EFI_SUCCESS)