From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.85.128.66; helo=mail-wm1-f66.google.com; envelope-from=philmd@redhat.com; receiver=edk2-devel@lists.01.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) (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 6A37721194891 for ; Wed, 5 Dec 2018 04:09:02 -0800 (PST) Received: by mail-wm1-f66.google.com with SMTP id z18so13025335wmc.4 for ; Wed, 05 Dec 2018 04:09:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=k67S0wTtAYSNSHimYY57ni8qMD0H1YjvWJV5asa14m0=; b=N3TTT/eWPkHsN2dwlksfdbqIrSAq8uHdopplhBXzZjz7vl4pcfWQXBJoROJ6pUl5EK OxFvtEl6r9yTT8nQ5s3jwbo2LzMULYvwk7En/TDE2w1FNKRqwwTwfg4eWkogYM2DIT/x TX8gcCqsz0UpD+AyuaW1B2AuPyrtPMFRBYGvjBYzirWL5z8IEYJ/v7Oob+u73ceGPsuJ gf81T0Qrr78hHvo6TdKENE31SdlFphmCFapgg32xzbuCbiU9Yog23DwLtyLk4p5NLL6y mHvWn1jnWXrw2fXttKr+Rtud+Rorf/591PqA0M5IID9cYwh9T6yb69XA7bK5KCdXJ4Z+ /TTg== X-Gm-Message-State: AA+aEWZLKbnoxXxVb7nNwmZ09O28NJC0pNH64KEzJdmtH8mbAC+yAURG 7dwYnNL6oQI0W5KX/WnaoVDUTQ== X-Google-Smtp-Source: AFSGD/X0YsdsbZBgn4K3snJrtMjoBusaj0cETdd3hbiTzQs8rE0Oi4uIhdTq6CeQUslTVbGdHP0FDg== X-Received: by 2002:a1c:b70b:: with SMTP id h11mr16214380wmf.72.1544011740893; Wed, 05 Dec 2018 04:09:00 -0800 (PST) Received: from [10.201.33.118] ([195.166.127.210]) by smtp.gmail.com with ESMTPSA id t187-v6sm11058023wmt.45.2018.12.05.04.08.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 04:09:00 -0800 (PST) To: Ard Biesheuvel , edk2-devel@lists.01.org Cc: lersek@redhat.com, Liming Gao References: <20181205082401.20224-1-ard.biesheuvel@linaro.org> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: <4cc65204-22fd-9b9f-96ce-5ef05c0028e2@redhat.com> Date: Wed, 5 Dec 2018 13:08:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20181205082401.20224-1-ard.biesheuvel@linaro.org> Subject: Re: [PATCH] BaseTools/CommonLib: drop the use of MAX_ADDRESS 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: , X-List-Received-Date: Wed, 05 Dec 2018 12:09:03 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 5/12/18 9:24, Ard Biesheuvel wrote: > The macro MAX_ADDRESS represents the largest virtual address that > is valid for a certain architecture. For the BaseTools, this quantity > is irrelevant, since the same tools can be used to build for different > targets. > > Since we only refer to it in a single place, which is an ASSERT() that > doesn't seem particularly useful (it ensures that memcpy() will not > be called with arguments that will make it read beyond the end of the > address space and wrap around), let's drop the ASSERT and all references > to MAX_ADDRESS. This looks to me best this way, thanks for cleaning this. > > Cc: Bob Feng > Cc: Liming Gao > Cc: Yonghong Zhu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daudé > --- > BaseTools/Source/C/Include/AArch64/ProcessorBind.h | 5 ----- > BaseTools/Source/C/Include/Arm/ProcessorBind.h | 5 ----- > BaseTools/Source/C/Include/Common/UefiBaseTypes.h | 1 - > BaseTools/Source/C/Include/Ia32/ProcessorBind.h | 5 ----- > BaseTools/Source/C/Include/X64/ProcessorBind.h | 5 ----- > BaseTools/Source/C/Common/CommonLib.c | 1 - > 6 files changed, 22 deletions(-) > > diff --git a/BaseTools/Source/C/Include/AArch64/ProcessorBind.h b/BaseTools/Source/C/Include/AArch64/ProcessorBind.h > index e7e9d83198a6..f956cab453f0 100644 > --- a/BaseTools/Source/C/Include/AArch64/ProcessorBind.h > +++ b/BaseTools/Source/C/Include/AArch64/ProcessorBind.h > @@ -90,11 +90,6 @@ typedef INT64 INTN; > /// > #define MAX_2_BITS 0xC000000000000000 > > -/// > -/// Maximum legal AARCH64 address > -/// > -#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF > - > /// > /// The stack alignment required for AARCH64 > /// > diff --git a/BaseTools/Source/C/Include/Arm/ProcessorBind.h b/BaseTools/Source/C/Include/Arm/ProcessorBind.h > index be4aac97664d..856d2bd9eff7 100644 > --- a/BaseTools/Source/C/Include/Arm/ProcessorBind.h > +++ b/BaseTools/Source/C/Include/Arm/ProcessorBind.h > @@ -88,11 +88,6 @@ typedef INT32 INTN; > /// > #define MAX_2_BITS 0xC0000000 > > -/// > -/// Maximum legal ARM address > -/// > -#define MAX_ADDRESS 0xFFFFFFFF > - > /// > /// The stack alignment required for ARM > /// > diff --git a/BaseTools/Source/C/Include/Common/UefiBaseTypes.h b/BaseTools/Source/C/Include/Common/UefiBaseTypes.h > index aa1aef3ce638..696ac15e4cd5 100644 > --- a/BaseTools/Source/C/Include/Common/UefiBaseTypes.h > +++ b/BaseTools/Source/C/Include/Common/UefiBaseTypes.h > @@ -170,6 +170,5 @@ typedef union { > > > #define EFI_MAX_BIT MAX_BIT > -#define EFI_MAX_ADDRESS MAX_ADDRESS > > #endif > diff --git a/BaseTools/Source/C/Include/Ia32/ProcessorBind.h b/BaseTools/Source/C/Include/Ia32/ProcessorBind.h > index 4719b53d37fa..96ac691df042 100644 > --- a/BaseTools/Source/C/Include/Ia32/ProcessorBind.h > +++ b/BaseTools/Source/C/Include/Ia32/ProcessorBind.h > @@ -131,11 +131,6 @@ typedef INT32 INTN; > #define MAX_BIT 0x80000000 > #define MAX_2_BITS 0xC0000000 > > -// > -// Maximum legal IA-32 address > -// > -#define MAX_ADDRESS 0xFFFFFFFF > - > // > // Modifier to ensure that all protocol member functions and EFI intrinsics > // use the correct C calling convention. All protocol member functions and > diff --git a/BaseTools/Source/C/Include/X64/ProcessorBind.h b/BaseTools/Source/C/Include/X64/ProcessorBind.h > index c625f8cef4a1..987738508333 100644 > --- a/BaseTools/Source/C/Include/X64/ProcessorBind.h > +++ b/BaseTools/Source/C/Include/X64/ProcessorBind.h > @@ -150,11 +150,6 @@ typedef INT64 INTN; > #define MAX_BIT 0x8000000000000000ULL > #define MAX_2_BITS 0xC000000000000000ULL > > -// > -// Maximum legal Itanium-based address > -// > -#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL > - > // > // Modifier to ensure that all protocol member functions and EFI intrinsics > // use the correct C calling convention. All protocol member functions and > diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c > index 42dfa821624d..5c40fdb5fd49 100644 > --- a/BaseTools/Source/C/Common/CommonLib.c > +++ b/BaseTools/Source/C/Common/CommonLib.c > @@ -1236,7 +1236,6 @@ InternalAllocateCopyPool ( > VOID *Memory; > > ASSERT (Buffer != NULL); > - ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1)); > > Memory = malloc (AllocationSize); > if (Memory != NULL) { >