From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web10.4890.1603138427767459445 for ; Mon, 19 Oct 2020 13:13:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eka+6Yjj; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603138427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4MMCz0kyqT5Aw1Yxl0oRO9Uul5vrNOP17r71teaeeMs=; b=eka+6YjjPRdEh/aIIx92SxXW3GQCsPegjhpgBrDrYhBxKGYrUZ1hoPecOSVPv0f7vWSJrJ LL9hha3jgOmQSRS/noV+TtCrlDluf41ZM/cN5YPBoI4aO6X/aShXAmMOY1HIzniTQ7hQA5 Poi21IAAEXFvLJdb+f+7M3go+E7k7xM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-qrW__2yjOLm8PjIbCjRGnA-1; Mon, 19 Oct 2020 16:13:45 -0400 X-MC-Unique: qrW__2yjOLm8PjIbCjRGnA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDADC1006C80; Mon, 19 Oct 2020 20:13:42 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-137.ams2.redhat.com [10.36.113.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07A1F5C1A3; Mon, 19 Oct 2020 20:13:40 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 3/3] MdeModulePkg/AcpiTableDxe: use pool allocation for RSDP if possible To: devel@edk2.groups.io, ard.biesheuvel@arm.com Cc: Dandan Bi , Liming Gao , Jian J Wang , Hao A Wu , Sami Mujawar , Leif Lindholm References: <20201016154923.21260-1-ard.biesheuvel@arm.com> <20201016154923.21260-4-ard.biesheuvel@arm.com> From: "Laszlo Ersek" Message-ID: Date: Mon, 19 Oct 2020 22:13:40 +0200 MIME-Version: 1.0 In-Reply-To: <20201016154923.21260-4-ard.biesheuvel@arm.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 10/16/20 17:49, Ard Biesheuvel wrote: > Use a pool allocation for the RSDP ACPI root pointer structure if no > memory limit is in effect that forces us to use page based allocation, > which may be wasteful if they get rounded up to 64 KB as is the case > on AArch64. > > Signed-off-by: Ard Biesheuvel > --- > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c | 30 ++++++++++++++------ > 1 file changed, 21 insertions(+), 9 deletions(-) > > diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > index 22f49a8489e7..fb939aa00f49 100644 > --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c > @@ -1737,19 +1737,26 @@ AcpiTableAcpiTableConstructor ( > RsdpTableSize += sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER); > } > > - PageAddress = 0xFFFFFFFF; > - Status = gBS->AllocatePages ( > - mAcpiTableAllocType, > - EfiACPIReclaimMemory, > - EFI_SIZE_TO_PAGES (RsdpTableSize), > - &PageAddress > - ); > + if (mAcpiTableAllocType != AllocateAnyPages) { > + PageAddress = 0xFFFFFFFF; > + Status = gBS->AllocatePages ( > + mAcpiTableAllocType, > + EfiACPIReclaimMemory, > + EFI_SIZE_TO_PAGES (RsdpTableSize), > + &PageAddress > + ); > + Pointer = (UINT8 *)(UINTN)PageAddress; (1) (same as earlier) please check for success before assigning the pointer > + } else { > + Status = gBS->AllocatePool ( > + EfiACPIReclaimMemory, > + RsdpTableSize, > + (VOID **)&Pointer); (2) (same as earlier) style: please break off the closing paren, or condense all the arguments. Looks OK other than these. Thanks Laszlo > + } > > if (EFI_ERROR (Status)) { > return EFI_OUT_OF_RESOURCES; > } > > - Pointer = (UINT8 *) (UINTN) PageAddress; > ZeroMem (Pointer, RsdpTableSize); > > AcpiTableInstance->Rsdp1 = (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) Pointer; > @@ -1797,7 +1804,12 @@ AcpiTableAcpiTableConstructor ( > } > > if (EFI_ERROR (Status)) { > - gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)AcpiTableInstance->Rsdp1, EFI_SIZE_TO_PAGES (RsdpTableSize)); > + if (mAcpiTableAllocType != AllocateAnyPages) { > + gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)AcpiTableInstance->Rsdp1, > + EFI_SIZE_TO_PAGES (RsdpTableSize)); > + } else { > + gBS->FreePool (AcpiTableInstance->Rsdp1); > + } > return EFI_OUT_OF_RESOURCES; > } > >