From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-x233.google.com (mail-wr0-x233.google.com [IPv6:2a00:1450:400c:c0c::233]) (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 6DEBC82226 for ; Wed, 22 Feb 2017 10:25:09 -0800 (PST) Received: by mail-wr0-x233.google.com with SMTP id 89so7939926wrr.3 for ; Wed, 22 Feb 2017 10:25:09 -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; bh=86tRaLXNh4jG5PH7v9lHRWgZoFiaBQ8bDbsNCKKwkys=; b=aWVNDte1Ees/jXQKZ67CLdQVAotFgvqb+aBIwXdfU1JLdSsbpmRrtZ8TA5hotjvcjX 2m1LqFJqvXv1ko8Q8/eyVov6jCe0we7K9fkum//zCqoHH94jUx+bBDHaI70BFayqDn54 YpbBz4acviZbixKF1I/j9rxnUKQkTbRApt4zQ= 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=86tRaLXNh4jG5PH7v9lHRWgZoFiaBQ8bDbsNCKKwkys=; b=nJLGJIH6GmBQjiYr+EfH8f2wnBq1mlfwdwvQOvf5ZRPnCP9rlttiutNQkc1z1q1wyk 9wMb3S5cvrXqdZw0iGofe69HWRJBrfNX/t474tVYFNgPAvG+/aaArD/hnIgiQzDzNqKj d6wNFuiL/K2GllOKg4Q/yP2w6PypccsQihKlqD/PsQAm+e1HX60P7pfDGUYMVNQ1pQlI KnLIap3jZd3cghndCXXPMLiTxdB3vmzFfWv88TGbCDfQjg/lM3fm3ctCS8jtEMtbUb1L dgi6soPFXJuSQaUqzblYj+eb1t8QyYwA0HtcZcAsZ2F+G8fHuZMyyLOBikyDNeCqBzRw 6PDw== X-Gm-Message-State: AMke39kFVKj2lKZ3pOP/gxMaYOA6NWSy88tvD32GT+uxxNBtkCueRKORq39fOJh8S2xh3eyR X-Received: by 10.223.139.137 with SMTP id o9mr28192125wra.88.1487787908027; Wed, 22 Feb 2017 10:25:08 -0800 (PST) Received: from localhost.localdomain ([196.80.204.181]) by smtp.gmail.com with ESMTPSA id e73sm3504667wmi.32.2017.02.22.10.25.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Feb 2017 10:25:07 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, afish@apple.com, leif.lindholm@linaro.org, michael.d.kinney@intel.com, liming.gao@intel.com, jiewen.yao@intel.com Cc: lersek@redhat.com, feng.tian@intel.com, star.zeng@intel.com, Ard Biesheuvel Date: Wed, 22 Feb 2017 18:24:55 +0000 Message-Id: <1487787898-5222-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487787898-5222-1-git-send-email-ard.biesheuvel@linaro.org> References: <1487787898-5222-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [RFC PATCH 1/4] MdeModulePkg/DxeCore: allow BootServicesData->BootServicesCode conversion X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Feb 2017 18:25:09 -0000 Unlike all other PE/COFF images loaded after it, the DXE core is loaded into BootServicesData memory rather than BootServicesCode memory, due to the fact that the PEI phase memory allocation routines only distinguish between boot-time and runtime. So in preparation of adding support for restricted permissions, allow the direct conversion of BootServicesData to BootServicesCode. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/Mem/Page.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index bda4f6397e91..b0939c596991 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -773,7 +773,8 @@ CoreConvertPagesEx ( // // Debug code - verify conversion is allowed // - if (!(NewType == EfiConventionalMemory ? 1 : 0) ^ (Entry->Type == EfiConventionalMemory ? 1 : 0)) { + if (!(NewType == EfiConventionalMemory ? 1 : 0) ^ (Entry->Type == EfiConventionalMemory ? 1 : 0) && + !(NewType == EfiBootServicesCode && Entry->Type == EfiBootServicesData)) { DEBUG ((DEBUG_ERROR | DEBUG_PAGE, "ConvertPages: Incompatible memory types\n")); return EFI_NOT_FOUND; } -- 2.7.4