From patchwork Mon Jul 16 15:25:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 142028 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2555716ljj; Mon, 16 Jul 2018 08:25:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfW/X9y2oKf2zGy727PxxmGFLwweiWf7iaXLf7Bf7+HsdVsghn7hSE/PUkYFMkd85/amvct X-Received: by 2002:a17:902:8:: with SMTP id 8-v6mr17372998pla.287.1531754734551; Mon, 16 Jul 2018 08:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531754734; cv=none; d=google.com; s=arc-20160816; b=jitPzsai7sUPX/hi0MX9QGYts7YLh31LAhHtc1MdNClf12zMWzlwKANMaeYmSNk1TR ituTa9YYA1d1ItA8Pp68AEpAXkBZD6wHmxyb2VHOtQVO/sToFvcZUFnr5GW5QSb90XDS 5h5N+Pti3yrSWNK2TzYTdnXK9TNmrJK5W552+smqOH77O/jMLX21IYkeBCR2Z7cjBUbG 8NAQssz/l9JaT7dBjfssVHD6w/mkVMCYXBwtlHCqX3OTlMJ173253lhRievoABHoR2rH fKWO3AgpQw+atjI9GMymrbtB1bbT4lyTdk7FrWd4AQuRhnBUjx5Sp3U09aDa9yWmJv8c ibSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=2/I7RdC6Nf9qPuGWcq6K7amXCofBvQRwqH5aHzoLk7g=; b=pzKmRXsgwfP8YaugbCYLD6WmSqRb9UHzYFzs1ScxuXenKbbSaUwPgwOczznfZ6k7m4 FWSPDHSjd5o54GYNZNOFVl/RgvoEI8wGJoMgmtEYdxekF35jPXU8F52imIIsBIkkIFmV 9yDtja/Udo15xMyKPG80Pvnnkn/8wXEYbf+b3cMpAEkD1H6QO0gDTdbcgfSYo9cI1kgQ Ws+kaCpsGgYG2qS18DaGLWAG8xpekA1fvVPurVXjdxkO5oGX0WhDapFo4MVL6/2lg/xj kHdINE1+k1F2i6SL7SED7XglrBJD39voooDjqaFWVPbfjJn90ILcOsL0qMpDFz46aj7R FynA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jqJR4zqF; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t66-v6si11789011pgt.181.2018.07.16.08.25.34; Mon, 16 Jul 2018 08:25:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jqJR4zqF; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727595AbeGPPx2 (ORCPT + 3 others); Mon, 16 Jul 2018 11:53:28 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:35955 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727387AbeGPPx2 (ORCPT ); Mon, 16 Jul 2018 11:53:28 -0400 Received: by mail-pl0-f68.google.com with SMTP id e11-v6so2446831plb.3 for ; Mon, 16 Jul 2018 08:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=QHkyj7iK2G+KiS/f1gnyHXpriJIl/r8BzQ/sJBCI4D8=; b=jqJR4zqFuPBZTTfWg2OmtMzx5sh1MnB/PfFH/9S7kv96uOPejrDN/WgGHkifAzf63v M33eLorfRd7XWao1KFJtoCmN8Dpy+HDJAYGjdJTtAwjz4I2wmZ+326DwreOMuULCin4u ZBq3k428wsUDpYEEl+kSliNy6oHzAqevreLms= 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; bh=QHkyj7iK2G+KiS/f1gnyHXpriJIl/r8BzQ/sJBCI4D8=; b=futT/vivXksO5C+lC3chSj9huB8MT5Ag2uhwo5jpe4LlKJaShhwsHUIUuAajKkhXt8 KOYJUV5nz/l/WLRxOn+UG0zpmajptsiQg7tkMmJG0M8cX2sJQCsfSkoXtWX9BbQ9oC76 SBJXexvq/ebkYHbUlS2sMnHyZlVkqSHMtMvWm49iPFfMYJYFNcK23rG4sVbq2ADWmYhW HhrqyJs34AjRkxy3K0vN1V9ZYgIYGscyDK4PmXsdkUtSy5g6FDJt5q5z4C71krCuK1Fi eV/x0Jl4Ipssw/V99tpYmoDg/j20WIoziyKQof35jFa+M0vSIWMfreMU8vcQ21vHDsW5 PdNQ== X-Gm-Message-State: AOUpUlFenR8OqeFHIxJZ0bs9vPz+WxWqFoHtYW7hGNQiAhGDar1o0I9V A9A1ZViyUaNJZVR5rL1zuswzH/Y+ExQ= X-Received: by 2002:a17:902:4424:: with SMTP id k33-v6mr17034336pld.242.1531754733068; Mon, 16 Jul 2018 08:25:33 -0700 (PDT) Received: from localhost.localdomain (175-98-98-130.static.tfn.net.tw. [175.98.98.130]) by smtp.gmail.com with ESMTPSA id u8-v6sm53156229pfl.105.2018.07.16.08.25.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 08:25:32 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: mingo@kernel.org, Ard Biesheuvel , Peter Jones Subject: [PATCH] efi/esrt: only call efi_mem_reserve() for boot services memory Date: Mon, 16 Jul 2018 23:25:07 +0800 Message-Id: <20180716152507.24730-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Commit 7e1550b8f208 ("efi: Drop type and attribute checks in efi_mem_desc_lookup()") refactored the implementation of efi_mem_desc_lookup() so that the type check is moved to the callers, one of which is the x86 version of efi_arch_mem_reserve(), where we added a modified check that only takes EFI_BOOT_SERVICES_DATA regions into account. This is reasonable, since it is the only memory type that requires this, but doing so uncovered some unexpected behavior in the ESRT code, which permits the ESRT table to reside in other types of memory than what the UEFI spec mandates (i.e., EFI_BOOT_SERVICES_DATA), and unconditionally calls efi_mem_reserve() on the region in question. This may result in errors such as esrt: Reserving ESRT space from 0x000000009c810318 to 0x000000009c810350. efi: Failed to lookup EFI memory descriptor for 0x000000009c810318 when the ESRT table is not in EFI_BOOT_SERVICES_DATA memory, but we try to reserve it nonetheless. So make the call to efi_mem_reserve() conditional on the memory type. Cc: Peter Jones Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/esrt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c index 375a77c1c6e5..5d06bd247d07 100644 --- a/drivers/firmware/efi/esrt.c +++ b/drivers/firmware/efi/esrt.c @@ -329,7 +329,8 @@ void __init efi_esrt_init(void) end = esrt_data + size; pr_info("Reserving ESRT space from %pa to %pa.\n", &esrt_data, &end); - efi_mem_reserve(esrt_data, esrt_data_size); + if (md.type == EFI_BOOT_SERVICES_DATA) + efi_mem_reserve(esrt_data, esrt_data_size); pr_debug("esrt-init: loaded.\n"); }