From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=leif.lindholm@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 47C6522402DE1 for ; Wed, 28 Feb 2018 07:49:56 -0800 (PST) Received: by mail-wm0-x242.google.com with SMTP id t6so5995057wmt.5 for ; Wed, 28 Feb 2018 07:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qTuAzO7Rip5onMU70LGjtSm3NoYEzboooHpwA0YTPqQ=; b=FPRPHB+CY6MajAM5sr4yE0rNHYQCB2Tlpkfu5+r3gFlmuzdipjeS9AMc7CRUGTJbcY 8B6kWBsBgGoAdaMpjydSaS2jAYRBPwAVjOXmSxlnjxIT/0dNirMMhvGE4FXIgDsITVAU qpdQEVHHckGss91B/MEMsaoAVFt7RKum5qBQM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qTuAzO7Rip5onMU70LGjtSm3NoYEzboooHpwA0YTPqQ=; b=ZvIKv1CgjZjSUFbA8aDKe/8DBx0wvetDFgcQn8OrgntCA2VRYjrzGr0scI+XUAe0G9 UsjkwLmIw14G0i45M/R5D8MwHttsLb6nMolTDFf/dfJZ2a8MrE77f5vj7i75CtAvJdFe CCv+P3RiREO9Mmu/dvMS+lFKmAOQKUbSrOLAnYW2jdX1ETQ0xdS29vtHXtZ1WdvB206k 0dcMz1yDJVU10cBypjqm/uS1z1hPXrHQUFMPaNeqmQCmtHER0+s8vqGt1FY9x0Cytoeb 8uUh6N1nczO2a42lLhHLQBwrb0S3xMxOcNi8w1DmXWYVcSIKpPIYC0ALsqkuKecttb/c Pzhw== X-Gm-Message-State: APf1xPBvYAg68tkQdsItkpSpZM7QMYPcGFZ7G7jTFb+YBFuhD2DmaV2H vttPilY7wxi3z730VICOQ516FA== X-Google-Smtp-Source: AH8x226iSUnT9xUuyeQv1oB79PVXtRibSsGJ5Qsg3x2RH+D5fCmNheuKIEy81yFY9gSzTk4EPAwXnA== X-Received: by 10.28.3.65 with SMTP id 62mr14225617wmd.116.1519833361801; Wed, 28 Feb 2018 07:56:01 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id a14sm1784089wra.27.2018.02.28.07.56.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Feb 2018 07:56:00 -0800 (PST) Date: Wed, 28 Feb 2018 15:55:59 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org Message-ID: <20180228155559.gbnaduc55omygecp@bivouac.eciton.net> References: <20180228154441.10554-1-ard.biesheuvel@linaro.org> <20180228154441.10554-2-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <20180228154441.10554-2-ard.biesheuvel@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH 2/2] ArmPlatformPkg/MemoryInitPeiLib: reserve rather than remove FV memory X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2018 15:49:56 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Feb 28, 2018 at 03:44:41PM +0000, Ard Biesheuvel wrote: > Instead of completely removing the memory occupied by the primary PrePi > FV from the memory map, thereby making it inaccessible to the OS, mark > it as boot services data. This will ensure that the memory is left > untouched by the firmware, but will release it to the OS when it calls > ExitBootServices(). > > Note that for reasons that are not entirely clear, this only works as > desired if the memory allocation HOB and the resource descriptor HOB > that describe the region are identical in offset and size, and so we > still need to iterate over the descriptors and split them up. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel Thanks for the rework - for the series: Reviewed-by: Leif Lindholm > --- > ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c | 21 ++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c > index 2feb11f21d5d..01fd028dbd55 100644 > --- a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c > +++ b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c > @@ -129,7 +129,8 @@ MemoryPeim ( > FdTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFdBaseAddress) + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFdSize); > > // EDK2 does not have the concept of boot firmware copied into DRAM. To avoid the DXE > - // core to overwrite this area we must mark the region with the attribute non-present > + // core to overwrite this area we must create a memory allocation HOB for the region, > + // but this only works if we split off the underlying resource descriptor as well. > if ((PcdGet64 (PcdFdBaseAddress) >= PcdGet64 (PcdSystemMemoryBase)) && (FdTop <= SystemMemoryTop)) { > Found = FALSE; > > @@ -145,12 +146,10 @@ MemoryPeim ( > ResourceTop = NextHob.ResourceDescriptor->PhysicalStart + ResourceLength; > > if (PcdGet64 (PcdFdBaseAddress) == NextHob.ResourceDescriptor->PhysicalStart) { > - if (SystemMemoryTop == FdTop) { > - NextHob.ResourceDescriptor->ResourceAttribute = ResourceAttributes & ~EFI_RESOURCE_ATTRIBUTE_PRESENT; > - } else { > - // Create the System Memory HOB for the firmware with the non-present attribute > + if (SystemMemoryTop != FdTop) { > + // Create the System Memory HOB for the firmware > BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, > - ResourceAttributes & ~EFI_RESOURCE_ATTRIBUTE_PRESENT, > + ResourceAttributes, > PcdGet64 (PcdFdBaseAddress), > PcdGet32 (PcdFdSize)); > > @@ -159,9 +158,9 @@ MemoryPeim ( > NextHob.ResourceDescriptor->ResourceLength -= PcdGet32(PcdFdSize); > } > } else { > - // Create the System Memory HOB for the firmware with the non-present attribute > + // Create the System Memory HOB for the firmware > BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, > - ResourceAttributes & ~EFI_RESOURCE_ATTRIBUTE_PRESENT, > + ResourceAttributes, > PcdGet64 (PcdFdBaseAddress), > PcdGet32 (PcdFdSize)); > > @@ -177,6 +176,12 @@ MemoryPeim ( > ResourceTop - FdTop); > } > } > + > + // Mark the memory covering the Firmware Device as boot services data > + BuildMemoryAllocationHob (PcdGet64 (PcdFdBaseAddress), > + PcdGet32 (PcdFdSize), > + EfiBootServicesData); > + > Found = TRUE; > break; > } > -- > 2.11.0 >