From patchwork Wed Sep 12 13:21:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 146566 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4825719ljw; Wed, 12 Sep 2018 06:22:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaW/wsuW7jxLcAq8CBLNHvOF3D4EcLCnEzvjUL6j34/ac5vCEBQLOG+vx+kXOSxcgVqq8x2 X-Received: by 2002:a62:50c3:: with SMTP id g64-v6mr2324004pfj.244.1536758575114; Wed, 12 Sep 2018 06:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536758575; cv=none; d=google.com; s=arc-20160816; b=zWBqddSPCkqXEoO1KXIRLghZYQSoOORxvdSrBD2TRxH83jnb5sQ0CB2Ii3nrVM6sMq WwhPVITEtqUNl8g3C/mJXdmp7E4grfyiKDWTjJTqPltg/ay8F4HtLFfL936N0yBwQAiq 063o4vvrd8ohZoe/vZXBItxMAylrzedMVBfbg3LdCqFNW8IX6usdR3rxAjY8xa0sn/XU 9xEOUTbbxY+6OQ+hoCpfvs+PnyTiIwE67n6BpBWuqI3VzJ5enOt1el1BM/fQTND2nS44 nAYkaXUe2KltjPUvbKlgZXcecfFHAWIfm2XmT4cfJuZi0c0Rk1Ulr9jkv7Mom0/Azpvd 4BnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=M6sTNkHs+AdCyWYHhTUM+ynCzqiTeJhxU5YRyy6IE4A=; b=G0KBK+qz45SozGbWip1DYGxMQ1CwHXmHuNcJucSZGCW/MRpn/okDmkz6KXqspqC1V8 gJROTHQ/F3AK94OIMzx9ChzDZBhX1fidB5PdGvW2jNsiXyABxnKUhpNZTtYjj1KtTmtm BhHXixJVDvsYo6h8luZkMnMMkGI6ogOgFuh8m9fdWUexjhwgP5/KKTrgGNU5UHP9K1zo ehAYZl5bDSlrxpEQqXkqRRqaK5Z0FnxfESi/zYqaVFORW6cjgYKv2XvNjDKfU+os2GI0 dNFsxIrM9OfD3N7qaKJ0HYFaFR0pUBf6OWyc8aMcYMs+af8t51QVQAGI/B6evEZYTToi +2Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JxYuvLcu; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id e27-v6si1191122pgn.253.2018.09.12.06.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 06:22:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=JxYuvLcu; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 9A9C821A00AE6; Wed, 12 Sep 2018 06:22:48 -0700 (PDT) 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:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (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 A08C22112B1C4 for ; Wed, 12 Sep 2018 06:22:46 -0700 (PDT) Received: by mail-wm0-x242.google.com with SMTP id t25-v6so2387473wmi.3 for ; Wed, 12 Sep 2018 06:22:46 -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:in-reply-to:references; bh=S3nLKLfL07G6P4WtOTyogrPlvnV+9rWMIzQYOQ2BRu4=; b=JxYuvLcuQymVAv9A0xhgbyf/C75AD5XAczzjMvD/fFVA2ZWOjGx0TLRa+FmEMcUFsA DSIMzTshd84AC26Tf70mFZSrG+XIQyvO3NtO3yaPI0CsYXDNBBrKNZWjbZis6c7BSaT5 FTpnTfN6vSFnZbpaXyn+8MOvdPYwVcurvXH9c= 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; bh=S3nLKLfL07G6P4WtOTyogrPlvnV+9rWMIzQYOQ2BRu4=; b=Xvprt5xudknmaF4e6/2UaLUs1l2KItuuk+VvUpsMv7PZI41WViwxijny1l4Bc7lWyE Z+HqXjI9UO5l1zCFMTFOZYCIK/Gfpx+ElgVuBiYWOg3ji91jZf/p2l1pkt8StxpotGbp 7IAg7HRvFBv0IW0ajra18RqEVNnVcDbt3DMYCREfgR50EMe3E+jod6Wlrz7hoAOTx/8f 7XLDC6UhnKp0EnSMJcQLPUVn+xBX65TzIZZ4JocEZhKROFm0hEs9I3wViHlvlw5OhYwW Hkd66scZQ4CQLeERSZzLBMwoa1b+Rk/T5guVdprrtBWHZwSpbznLRQo1RMN9KlEoNh83 tT/Q== X-Gm-Message-State: APzg51BNWZLCJtElw6LUETNSwczyDurSb5gnRuU66BQfw9EeX/nWCk+/ X+0N6Pfk71DfGNbOYR31juLJr5WQYWZTtg== X-Received: by 2002:a1c:148f:: with SMTP id 137-v6mr1589695wmu.61.1536758564972; Wed, 12 Sep 2018 06:22:44 -0700 (PDT) Received: from mba13.kuq.prv ([2001:a62:605:90f4:1f3:d690:1764:36ca]) by smtp.gmail.com with ESMTPSA id e133-v6sm1985129wma.33.2018.09.12.06.22.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 06:22:44 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 12 Sep 2018 15:21:51 +0200 Message-Id: <20180912132151.4258-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180912132151.4258-1-ard.biesheuvel@linaro.org> References: <20180912132151.4258-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 4/4] MdeModulePkg/UefiBootManagerLib: allow foreign Driver#### images 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: Ruiyu Ni , Zimmer Vincent , Eric Dong , Andrew Fish , agraf@suse.de, Brian Richardson , Michael D Kinney , Laszlo Ersek , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Allow PE/COFF images that must execute under emulation for Driver#### options, by relaxing the machine type check to include support for machine types that is provided by the emulator. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c | 26 +++++++++++++++++++- MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h | 1 + MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c index 7bf96646c690..67e3dfd7e9e1 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c @@ -1185,6 +1185,29 @@ EfiBootManagerFreeLoadOptions ( return EFI_SUCCESS; } +STATIC +BOOLEAN +BmIsImageTypeSupported ( + IN UINT16 MachineType, + IN UINT16 SubSystem + ) +{ + EFI_STATUS Status; + EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL *Emu; + + if (EFI_IMAGE_MACHINE_TYPE_SUPPORTED (MachineType)) { + return TRUE; + } + + Status = gBS->LocateProtocol (&gEdkiiPeCoffImageEmulatorProtocolGuid, + NULL, (VOID **)&Emu); + if (EFI_ERROR (Status)) { + return FALSE; + } + + return Emu->IsImageSupported (Emu, MachineType, SubSystem); +} + /** Return whether the PE header of the load option is valid or not. @@ -1235,7 +1258,8 @@ BmIsLoadOptionPeHeaderValid ( OptionalHeader = (EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHeader->Pe32.OptionalHeader; if ((OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC || OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) && - EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeHeader->Pe32.FileHeader.Machine) + BmIsImageTypeSupported (PeHeader->Pe32.FileHeader.Machine, + OptionalHeader->Subsystem) ) { // // Check the Subsystem: diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h index 978fbff966f6..5f64ef304b87 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h @@ -47,6 +47,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf index 72c5ca1cd59e..09e2134acf8e 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf +++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf @@ -104,6 +104,7 @@ gEfiDevicePathProtocolGuid ## SOMETIMES_CONSUMES gEfiBootLogoProtocolGuid ## SOMETIMES_CONSUMES gEfiSimpleTextInputExProtocolGuid ## SOMETIMES_CONSUMES + gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES gEfiGraphicsOutputProtocolGuid ## SOMETIMES_CONSUMES gEfiUsbIoProtocolGuid ## SOMETIMES_CONSUMES