From patchwork Wed Dec 19 20:56:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154301 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5381587ljp; Wed, 19 Dec 2018 12:57:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/VTMeYkpWM9oFJoh4IKRpH88UfQiJEHnivoHWOeooKiP47YeeEF/VkyhRaT7doMSqZxXM4t X-Received: by 2002:a63:235f:: with SMTP id u31mr20569178pgm.122.1545253021092; Wed, 19 Dec 2018 12:57:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545253021; cv=none; d=google.com; s=arc-20160816; b=QpG5jh2i2AWlkPGjxL5uv6wvTQAcviZ3O9pOyAj+H98HhhXBblwi/SrHoNPlUwPq4l kD6L0zabwPS6IOTMnAMFs6ar+pimAfYNqfoOTbqpIqbPC0Bb4gjqR8qzxMPf4dSTq+NP e5jX85L2XCPsBkJCEz1MKrJ+cGLF7MeF/pqRusiYp0e6FwPZ2iB5PaJZXzvIbPDhoE51 bi/zVvIR2yFHDuJbHG0QWtuYwGAq5pyujVhOD/WWSN1DNDBFzVMMR39DEeZOXNI7ST97 7Hw90QDBDxUr00zdnCeIjYKV0Ai9PT4iK3DYzHYAKoUFsxGUW0m+Pq/WmDppOvuGhDB+ rArQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=V+H4luQWa4qx+F0zMMi4bhXjNvj6iy5mYuh1+oi4VS4=; b=QZe5WWpq55Wz81b5I7/gM7yJHIiS3DQ4RebU0vLP0uKug0Sn7T+ROHoM9uSxigJYdB +oVBak1A1OjjQbqWRNv27g1SicczJkXmhoWDjcHG9RGgME+fUFV78L+AS9Z9UPO+JfmN tyj6gk42PCdhQ/cMCj6d1QAHTywneYOnH4IvemvatpQmvaRLSihkD0JXOMPpNm4Hk4GV p2h/ZnFtk6QMAAku+i+nRCMUMZO6QDc3edViB1JS2BdhbwC22baPfF7iWLGwn/qqzMc+ KRslGse2mq5BqeS7t78soyusQFxGGGLCYTtl5EEURMQu/r4V1T+vnIbHqDU11V2j1nCs Lwjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=W0d6SWtD; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id g1si16555437pgu.149.2018.12.19.12.57.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Dec 2018 12:57:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=W0d6SWtD; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 CF6C4211A2D92; Wed, 19 Dec 2018 12:56:58 -0800 (PST) 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: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 3CA8D211A2D88 for ; Wed, 19 Dec 2018 12:56:56 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id p6so7576440wmc.1 for ; Wed, 19 Dec 2018 12:56:56 -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=aCUdqos/08USlHIiVgndGXk235pO7GX3DEnUuk7DuCw=; b=W0d6SWtD5wxXkOMbw/ae8b/Y5AzaUoIDWJzAn1rOebzbqMTb4CcdwnZei0SwkavRae niGjEXsbcMs1Sivmow1qHbMLsgBKeWFMMvgEgBrxu0Thnme2px2sHm2NrIjVIBjsbV10 7Zp9Yewa4IHUuSr7HwEB8z8d09dK61sCJ/caI= 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=aCUdqos/08USlHIiVgndGXk235pO7GX3DEnUuk7DuCw=; b=DPd4K7WCGLYX40PZ7p3eE7DryLNg53aX9C3RK34j70841zkAxfM1R2Z3Tb7CcdkXTv SyZTRwK0A8Tcqp7lXR2sd7CTl3mtJn9RD+00RDssu8PDYHbpvyWTX2KcX+RBVuxZDSa8 NVvKXAKdj+s86jAujInQcxbAdddDfkU97ZvvrkY2jOK2tEKJYzz/aFGFbcNsYh+uFX5q Cy6ST54p4G/yFo0N0HTY+GwjHns4g3IHJ2EGooEO3iwRdphAl5sx+6KCrWTBTMVYCPVk bqkk7lBsmrsTDclca4HqBAyvOd1IbAIyKjv259cewDQg+CUens3WymEY3e+dNVBLd8/m UkGQ== X-Gm-Message-State: AA+aEWZqSNIishOOuVtw+4dPRGvtitgbkTNK/lPeDKgUR4Ku2AZqmbDt jS3UPgXvp1wIaCevRJlCXe7mqxNeyrLsMw== X-Received: by 2002:a1c:6442:: with SMTP id y63mr8261244wmb.143.1545253014255; Wed, 19 Dec 2018 12:56:54 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:e5c9:6e00:25cb:e32e]) by smtp.gmail.com with ESMTPSA id j202sm16267294wmf.15.2018.12.19.12.56.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Dec 2018 12:56:53 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Wed, 19 Dec 2018 21:56:37 +0100 Message-Id: <20181219205640.4704-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181219205640.4704-1-ard.biesheuvel@linaro.org> References: <20181219205640.4704-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Subject: [edk2] [PATCH v2 3/6] MdeModulePkg/Dxe/Page: take MAX_ALLOC_ADDRESS into account 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: Andrew Jones , Hao Wu , Liming Gao , Michael D Kinney , Laszlo Ersek Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Take MAX_ALLOC_ADDRESS into account in the implementation of the page allocation routines, so that they will only return memory that is addressable by the CPU at boot time, even if more memory is available in the GCD memory map. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/Mem/Page.c | 52 ++++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) -- 2.19.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Jian J Wang diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/Page.c index 961c5b833546..5ad8e1171ef7 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -52,26 +52,26 @@ LIST_ENTRY mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemor BOOLEAN mMemoryTypeInformationInitialized = FALSE; EFI_MEMORY_TYPE_STATISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1] = { - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiReservedMemoryType - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiLoaderCode - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiLoaderData - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiBootServicesCode - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiBootServicesData - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiRuntimeServicesCode - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiRuntimeServicesData - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiConventionalMemory - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiUnusableMemory - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiACPIReclaimMemory - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiACPIMemoryNVS - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiMemoryMappedIO - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiMemoryMappedIOPortSpace - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiPalCode - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiPersistentMemory - { 0, MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiMaxMemoryType + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiReservedMemoryType + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiLoaderCode + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiLoaderData + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiBootServicesCode + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiBootServicesData + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiRuntimeServicesCode + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiRuntimeServicesData + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiConventionalMemory + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiUnusableMemory + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiACPIReclaimMemory + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiACPIMemoryNVS + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiMemoryMappedIO + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiMemoryMappedIOPortSpace + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiPalCode + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiPersistentMemory + { 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiMaxMemoryType }; -EFI_PHYSICAL_ADDRESS mDefaultMaximumAddress = MAX_ADDRESS; -EFI_PHYSICAL_ADDRESS mDefaultBaseAddress = MAX_ADDRESS; +EFI_PHYSICAL_ADDRESS mDefaultMaximumAddress = MAX_ALLOC_ADDRESS; +EFI_PHYSICAL_ADDRESS mDefaultBaseAddress = MAX_ALLOC_ADDRESS; EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = { { EfiReservedMemoryType, 0 }, @@ -419,7 +419,7 @@ PromoteMemoryResource ( Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE); if (Entry->GcdMemoryType == EfiGcdMemoryTypeReserved && - Entry->EndAddress < MAX_ADDRESS && + Entry->EndAddress < MAX_ALLOC_ADDRESS && (Entry->Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) == (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)) { // @@ -640,7 +640,7 @@ CoreAddMemoryDescriptor ( gMemoryTypeInformation[FreeIndex].NumberOfPages ); mMemoryTypeStatistics[Type].BaseAddress = 0; - mMemoryTypeStatistics[Type].MaximumAddress = MAX_ADDRESS; + mMemoryTypeStatistics[Type].MaximumAddress = MAX_ALLOC_ADDRESS; } } return; @@ -697,7 +697,7 @@ CoreAddMemoryDescriptor ( } } mMemoryTypeStatistics[Type].CurrentNumberOfPages = 0; - if (mMemoryTypeStatistics[Type].MaximumAddress == MAX_ADDRESS) { + if (mMemoryTypeStatistics[Type].MaximumAddress == MAX_ALLOC_ADDRESS) { mMemoryTypeStatistics[Type].MaximumAddress = mDefaultMaximumAddress; } } @@ -1318,15 +1318,15 @@ CoreInternalAllocatePages ( // // The max address is the max natively addressable address for the processor // - MaxAddress = MAX_ADDRESS; + MaxAddress = MAX_ALLOC_ADDRESS; // // Check for Type AllocateAddress, // if NumberOfPages is 0 or - // if (NumberOfPages << EFI_PAGE_SHIFT) is above MAX_ADDRESS or + // if (NumberOfPages << EFI_PAGE_SHIFT) is above MAX_ALLOC_ADDRESS or // if (Start + NumberOfBytes) rolls over 0 or - // if Start is above MAX_ADDRESS or - // if End is above MAX_ADDRESS, + // if Start is above MAX_ALLOC_ADDRESS or + // if End is above MAX_ALLOC_ADDRESS, // return EFI_NOT_FOUND. // if (Type == AllocateAddress) { @@ -1968,7 +1968,7 @@ CoreAllocatePoolPages ( // // Find the pages to convert // - Start = FindFreePages (MAX_ADDRESS, NumberOfPages, PoolType, Alignment, + Start = FindFreePages (MAX_ALLOC_ADDRESS, NumberOfPages, PoolType, Alignment, NeedGuard); //