From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wj0-x241.google.com (mail-wj0-x241.google.com [IPv6:2a00:1450:400c:c01::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 D213C81A33 for ; Wed, 14 Dec 2016 09:57:16 -0800 (PST) Received: by mail-wj0-x241.google.com with SMTP id j10so6106325wjb.3 for ; Wed, 14 Dec 2016 09:57:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nyGHi1hK5c8c+/2L6Z27Dw1hxEBy68AyIy8ttB/6lO0=; b=slg3EftITXf+118H5j6MrkB98U7qUtX5HIFVv0zARWgphYDDmzsM4Luh2u2Q9SDiCC nz5rLXHdjt9Bx7pj0CbRkaz6BhzoT+hy4WDJ0zbjRKNxPnEyb9Bv/8TI891kY5cw1aB8 6cSwaaR3tC9FGNz6q60xYs+h78sEiPAE+YQm0kBY6ghpm/dj7A/FbACuj5qDuOnsRwIC 5b+PjrdCyB2SQikyIyLrFQiRAycPnMPFae6ve0fOCBqBBpi5CqdWELkl2+P+vragSqvM rYSFYpbIL3quYyyRWoZ0UwqWHaeA6MaETd65kUE0uIOJqrWhseFLOCeXaAH3WJmGOV+D cP/A== 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=nyGHi1hK5c8c+/2L6Z27Dw1hxEBy68AyIy8ttB/6lO0=; b=HrdhYrSGvfeCb+ViYfW6V+aKsRw5XeRZeir4kb+aT2jIToCe7G98fVPoP5GTYdOOeR PjWuLhuT7TUcLPgbzSejdocTJsld8UlrTSraZo32NnBcBmBI7GUIpRko5qQ6QiY2h8Q7 Q0UNYF0QfDASE6iz12pqx4Fz8tdocyd2FWRBtZrbFAslEsztx5xBnspQHnQ4gDBZN00b B6xrFxOx7gLP+khgTnVDpZo70f0+tGLN/rJmEBVpqKSvZUe6mHq8cPStgprsnhkUZnH8 Dvwy8YqJBfJWyzsiC7hg9Z1vdLoXhNitengzJgg+iFqxOoe7vzKYpZ6jkrPsx4UkoCHx g+ew== X-Gm-Message-State: AKaTC03W4/f4aSjrWQ2qO14bVTzymdB2GtAZggtgRGCXkLEtH7fPcd4AdlO89jjL4q4Di10JqoQUZwsf3aCogg== X-Received: by 10.194.58.237 with SMTP id u13mr42923281wjq.10.1481738234590; Wed, 14 Dec 2016 09:57:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.183.2 with HTTP; Wed, 14 Dec 2016 09:57:14 -0800 (PST) In-Reply-To: References: From: Michael Zimmermann Date: Wed, 14 Dec 2016 18:57:14 +0100 Message-ID: To: Ard Biesheuvel Cc: "edk2-devel@lists.01.org" Subject: Re: correct way to reserve memory from PrePi? 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, 14 Dec 2016 17:57:17 -0000 Content-Type: text/plain; charset=UTF-8 I've enabled GCD debugging and apparently it doesn't accept the allocation: GCD:AllocateMemorySpace(Base=0000000090000000,Length=0000000010000000) GcdAllocateType = AtAddress GcdMemoryType = SystemMem Alignment = 0000000000000001 ImageHandle = FDE28F90 DeviceHandle = 0 CoreAllocateSpaceCheckEntry:982 handle=FDE28F90 CoreAllocateSpace:1130 Status = Not Found GCDMemType Range Capabilities Attributes ========== ================================= ================ ================ NonExist 0000000000000000-000000007FFFFFFF 0000000000000000 0000000000000000 SystemMem 0000000080000000-00000000FDFFFFFF 800000000000000E 0000000000000000* NonExist 00000000FE000000-00000000FE3FFFFF 0000000000000000 0000000000000000 SystemMem 00000000FE400000-00000000FFFE5FFF 800000000000000E 0000000000000000 SystemMem 00000000FFFE6000-00000000FFFEEFFF 800000000000000E 0000000000000000* SystemMem 00000000FFFEF000-00000000FFFFFFFF 800000000000000E 0000000000000000 It fails in this line: https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Gcd/Gcd.c#L982 In this example I've used(start,size) 0x80000000,0x80000000 for the resource descriptors. If I use 0x80000000,0x40000000 and 0xc0000000,0x40000000 everything works just fine. Thanks Michael On Wed, Dec 14, 2016 at 4:13 PM, Michael Zimmermann wrote: > As far as I know the proper way is to create resource descriptors > using BuildResourceDescriptorHob and then allocate reserved areas > using BuildMemoryAllocationHob. This way I don't have any overlapping > descriptors - I just allocated some memory very early. > > I ran many tests and it looks like all calls to > BuildMemoryAllocationHob get ignored if my dram hobs look like this: > 0x00000000 - 0x40000000 > > If I split this range into two Hob's like this everything seems to > work just fine: > 0x00000000 - 0x20000000 > 0x20000000 - 0x20000000 > > I took a look at other platforms like Juno and they add big dram Hob's > (2GB and 6GB) too so why is this a problem? > > Thanks > Michael > > On Wed, Dec 14, 2016 at 11:21 AM, Ard Biesheuvel > wrote: >> On 14 December 2016 at 10:02, Michael Zimmermann >> wrote: >>> I tried both BuildResourceDescriptorHob and BuildMemoryAllocationHob >>> but apparently they don't have any effect. >>> When I look at the output of the shell's memmap command there aren't >>> any reserved/unavailable pages. >>> >>> Furthermore, when using AllocatePages with one of the physical >>> addresses which I've reserved it succeeds which means that it's not >>> just a problem of how the memmap command works. >>> >>> Am I doing something wrong or is this a bug? >>> >> >> I think you need to ensure that they don't overlap existing resource >> descriptors: if you declare a region as reserved, you should not >> declare it as memory first