From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::241; helo=mail-it0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x241.google.com (mail-it0-x241.google.com [IPv6:2607:f8b0:4001:c0b::241]) (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 4AA1622402DF4 for ; Wed, 28 Feb 2018 08:06:46 -0800 (PST) Received: by mail-it0-x241.google.com with SMTP id u66so1718646ith.1 for ; Wed, 28 Feb 2018 08:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5MAxNI+YJEVtKHgKfEcBHwjUfYJagZcza1sEUNY81bs=; b=edVrKm6oqzfyz8M6iP3ylC/mKA0J63Co6QHCiG2iB6JD4DppdlTC7vNmpROluEHHDX xfRZkag9lbJtjLmJaXr8bVzQc7mVOaUoP00XXBtgEvDA7SOfFzbvYom3rTO7eKURW1bv 23Vl9So9rx0IYsXtp8VWumB1vvh/7w7btDxkQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5MAxNI+YJEVtKHgKfEcBHwjUfYJagZcza1sEUNY81bs=; b=KPjcOswN0UQkrWfXg2xycZpynBXsnjYVzf/TN54jwLxWIn8GYwsIdqMJkZhfqrPOVI 4L/6CIeEL6i4Kg6afQVsbj5uac84DPYxXb3ZeGycl9UEQS7bR7LG+yiWe5AQ8+FAEl2k LuHSpnWnBo3Iqnj8/skojVKBPKNieJ25nBbrGkq9dUFoler2yUn/qqQoIqp70hXsDLHf lXbzOKJmj0Au7ZwPrp3u73fCHDN/PPOOlvhThHK+7+/r0beU37qp4Tq/S9NRLd0fC9IH pBxmQLuj+anoXJUHWofKffPao9vAvynKF6njxX2O62PMiLRnpdZjG8d7uv1vRsekRCTz /TQA== X-Gm-Message-State: APf1xPBTJoiImR9oNHwMv6eGwjF60jM5Ygt14TuZl8A/i3rCePoHa7GB oaW+wgcxU9BnkC/FdPTUR8VvNgfb/+n4lj1+A8wN/LkpPQU= X-Google-Smtp-Source: AG47ELuEkRta5RZW6VWZYSGzckcc1sa2RrNAVsUJrK6KqHvyWPfaCM3m3ehYUQOt4Uw2es7MYDjjl/lnwd9U02rMeIg= X-Received: by 10.36.90.5 with SMTP id v5mr21706850ita.138.1519834373889; Wed, 28 Feb 2018 08:12:53 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.138.209 with HTTP; Wed, 28 Feb 2018 08:12:53 -0800 (PST) In-Reply-To: <20180228155559.gbnaduc55omygecp@bivouac.eciton.net> References: <20180228154441.10554-1-ard.biesheuvel@linaro.org> <20180228154441.10554-2-ard.biesheuvel@linaro.org> <20180228155559.gbnaduc55omygecp@bivouac.eciton.net> From: Ard Biesheuvel Date: Wed, 28 Feb 2018 16:12:53 +0000 Message-ID: To: Leif Lindholm Cc: "edk2-devel@lists.01.org" 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 16:06:47 -0000 Content-Type: text/plain; charset="UTF-8" On 28 February 2018 at 15:55, Leif Lindholm wrote: > 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 > Thanks Pushed as f3b314331ce1..44d2e8d7cab3 >> --- >> 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 >>