Received: by 10.192.165.148 with SMTP id m20csp406319imm; Fri, 20 Apr 2018 00:59:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Jm8+keRCmeMM6iHup3bUAV30t7mIK5bA8Mo0KYRHVBfXH/BYTxE9xEWFnZImjPfo1uuX0 X-Received: by 10.98.73.22 with SMTP id w22mr8747929pfa.96.1524211186920; Fri, 20 Apr 2018 00:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524211186; cv=none; d=google.com; s=arc-20160816; b=zU1JfoKFhD2bDsD48cUdUyOKIG5XO51+3CGbRN/ZpnLvYV5OI/INGpFaSnDUGZuQIJ dfNUKNbJG3DXZAeOjYrHzuvajzoBHxDO8n7Mw4w3XK9r/UTenUvZB4ZXQPjW6bPQm3iD PiURLq8DCMTC6Qy+hlLBtbmEpgm1L4XhSPzIrIUCQXq3taeuLnWbLyB17yicrWk+L7Ye YuBaBeqHgTpaUiaHbXc+IPJmUGWgDgM9Dy97/4Us3hASH5iCQXwbJbGo3QRegy/sFj57 VTKb0VOR9waISJu+sA93HQbyE5OuxJwFZsncM4umzex9yyvD1PnJ8N/yw78QlVdlGv6I GXWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=n5tKWOFzVIqweEaDe0Kwx8VJLgMRuBw1fIgTke/dUh8=; b=JT6P3OXCz/12n0NaU+DC6cVrkWGbcqs1GArZk5lX3DT+7q6YcmHdNpXysE6GnTsixV x380fTm3RILni57cIey5ciigHEmQVZR1HVxwo7rtw+CF5FtYz/2NoZGZYVUxCQWq/yJx 9ncSmfIfHsotnM+AG3oZXOLUCAUtdOrgN6Ppe+15OgZuGQVspQ9nC3xmV2R4PSdN88AY 3wCAEFtcDOZG3w9pI9/xwO19KMoZfNz6dD5jpMgLTjoD4g768hPzPc0v9BYyoFSz4AeZ kJrov6t72X1eMNQntui6UMOe2ZYVsvQXvdiAOgzzX+BayBHHVxSsTBy8+gAIcM+/3HlY Pjwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Px4Jii0O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o128si4402596pga.653.2018.04.20.00.59.32; Fri, 20 Apr 2018 00:59:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Px4Jii0O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754011AbeDTH6T (ORCPT + 99 others); Fri, 20 Apr 2018 03:58:19 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:50648 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753957AbeDTH6S (ORCPT ); Fri, 20 Apr 2018 03:58:18 -0400 Received: by mail-it0-f68.google.com with SMTP id p3-v6so1048264itc.0 for ; Fri, 20 Apr 2018 00:58:17 -0700 (PDT) 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=n5tKWOFzVIqweEaDe0Kwx8VJLgMRuBw1fIgTke/dUh8=; b=Px4Jii0OaB4liW8FCKC4F4TyRFhkjXMqe7GaRRvRSCqWYgvhv10/Du4ZCe/imqKz5P EK1VKXzyfj79nl02L+U1T/7ONcnIUJfDFf8ZuuNfo4xwO4amxnKHb1pvQ8QxwodFO/fj wtQkIzhiktjSc6DMG1/Ibt3AeNsAIG1YCyfHk= 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=n5tKWOFzVIqweEaDe0Kwx8VJLgMRuBw1fIgTke/dUh8=; b=FgOFRCoaW+zD+hle4ZS/SuX2LD71xyEqS1oa8fpPN1heNt7gI6MxcdjhgrEx5DMN1y 0W3HXC32pvPNhnAet+5mB1thOceium1gufNNdptBCGE8hrMKAVD8EsL6XsfQ0bPIuOMB 1DtLdm44YtcoPRtteSq3SZZuzwJ7GBoDtVMTkmDgfFkJyuvApjsQWxCik7ca6wbKuBwZ XLk6ELIITusMz50I0+T0XStYNJ3G//o2WXNBYTb44vnSkPsCOjwko/agPChaJcAoJD2F In+c7aOZknEOyAL8glZ4WCxSJs1f8V2mspJ+EJ7KLCLl7Aa9WblIpeg8NPvzoFUUH58k w3yQ== X-Gm-Message-State: ALQs6tA8wfVIeaWGfQ8T2z32UGlxZZI/XwcdtP6nn3AJHPRO7WDARagS RsO63b2z42BTiR4jxl9w4QAU4hqoYSo9SQUqrBFlAg== X-Received: by 2002:a24:67d7:: with SMTP id u206-v6mr1960131itc.138.1524211097303; Fri, 20 Apr 2018 00:58:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.187.67 with HTTP; Fri, 20 Apr 2018 00:58:15 -0700 (PDT) In-Reply-To: <20180419214204.19322-1-stefan@agner.ch> References: <20180419214204.19322-1-stefan@agner.ch> From: Ard Biesheuvel Date: Fri, 20 Apr 2018 09:58:15 +0200 Message-ID: Subject: Re: [PATCH] treewide: use PHYS_ADDR_MAX to avoid type casting ULLONG_MAX To: Stefan Agner Cc: Andrew Morton , Michal Hocko , Catalin Marinas , Linus Torvalds , Pavel Tatashin , Linux-MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19 April 2018 at 23:42, Stefan Agner wrote: > With PHYS_ADDR_MAX there is now a type safe variant for all > bits set. Make use of it. > > Patch created using a sematic patch as follows: > > // > @@ > typedef phys_addr_t; > @@ > -(phys_addr_t)ULLONG_MAX > +PHYS_ADDR_MAX > // > > Signed-off-by: Stefan Agner Acked-by: Ard Biesheuvel > --- > arch/arm64/mm/init.c | 6 +++--- > arch/mips/kernel/setup.c | 4 ++-- > arch/powerpc/mm/mem.c | 2 +- > arch/sparc/mm/init_64.c | 2 +- > arch/x86/mm/init_32.c | 2 +- > arch/x86/mm/init_64.c | 2 +- > drivers/firmware/efi/arm-init.c | 2 +- > drivers/remoteproc/qcom_q6v5_pil.c | 2 +- > drivers/soc/qcom/mdt_loader.c | 4 ++-- > 9 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 9f3c47acf8ff..f48b19496141 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -310,7 +310,7 @@ static void __init arm64_memory_present(void) > } > #endif > > -static phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX; > +static phys_addr_t memory_limit = PHYS_ADDR_MAX; > > /* > * Limit the memory size that was specified via FDT. > @@ -401,7 +401,7 @@ void __init arm64_memblock_init(void) > * high up in memory, add back the kernel region that must be accessible > * via the linear mapping. > */ > - if (memory_limit != (phys_addr_t)ULLONG_MAX) { > + if (memory_limit != PHYS_ADDR_MAX) { > memblock_mem_limit_remove_map(memory_limit); > memblock_add(__pa_symbol(_text), (u64)(_end - _text)); > } > @@ -664,7 +664,7 @@ __setup("keepinitrd", keepinitrd_setup); > */ > static int dump_mem_limit(struct notifier_block *self, unsigned long v, void *p) > { > - if (memory_limit != (phys_addr_t)ULLONG_MAX) { > + if (memory_limit != PHYS_ADDR_MAX) { > pr_emerg("Memory Limit: %llu MB\n", memory_limit >> 20); > } else { > pr_emerg("Memory Limit: none\n"); > diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c > index 563188ac6fa2..2c96c0c68116 100644 > --- a/arch/mips/kernel/setup.c > +++ b/arch/mips/kernel/setup.c > @@ -93,7 +93,7 @@ void __init add_memory_region(phys_addr_t start, phys_addr_t size, long type) > * If the region reaches the top of the physical address space, adjust > * the size slightly so that (start + size) doesn't overflow > */ > - if (start + size - 1 == (phys_addr_t)ULLONG_MAX) > + if (start + size - 1 == PHYS_ADDR_MAX) > --size; > > /* Sanity check */ > @@ -376,7 +376,7 @@ static void __init bootmem_init(void) > unsigned long reserved_end; > unsigned long mapstart = ~0UL; > unsigned long bootmap_size; > - phys_addr_t ramstart = (phys_addr_t)ULLONG_MAX; > + phys_addr_t ramstart = PHYS_ADDR_MAX; > bool bootmap_valid = false; > int i; > > diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c > index 737f8a4632cc..7607a509c695 100644 > --- a/arch/powerpc/mm/mem.c > +++ b/arch/powerpc/mm/mem.c > @@ -213,7 +213,7 @@ void __init mem_topology_setup(void) > /* Place all memblock_regions in the same node and merge contiguous > * memblock_regions > */ > - memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); > + memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); > } > > void __init initmem_init(void) > diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c > index 8aeb1aabe76e..f396048a0d68 100644 > --- a/arch/sparc/mm/init_64.c > +++ b/arch/sparc/mm/init_64.c > @@ -1620,7 +1620,7 @@ static void __init bootmem_init_nonnuma(void) > (top_of_ram - total_ram) >> 20); > > init_node_masks_nonnuma(); > - memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); > + memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); > allocate_node_data(0); > node_set_online(0); > } > diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c > index c893c6a3d707..979e0a02cbe1 100644 > --- a/arch/x86/mm/init_32.c > +++ b/arch/x86/mm/init_32.c > @@ -692,7 +692,7 @@ void __init initmem_init(void) > high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; > #endif > > - memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); > + memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); > sparse_memory_present_with_active_regions(0); > > #ifdef CONFIG_FLATMEM > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c > index 0a400606dea0..765a50fb6364 100644 > --- a/arch/x86/mm/init_64.c > +++ b/arch/x86/mm/init_64.c > @@ -742,7 +742,7 @@ kernel_physical_mapping_init(unsigned long paddr_start, > #ifndef CONFIG_NUMA > void __init initmem_init(void) > { > - memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0); > + memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0); > } > #endif > > diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c > index 80d1a885def5..b5214c143fee 100644 > --- a/drivers/firmware/efi/arm-init.c > +++ b/drivers/firmware/efi/arm-init.c > @@ -193,7 +193,7 @@ static __init void reserve_regions(void) > * uses its own memory map instead. > */ > memblock_dump_all(); > - memblock_remove(0, (phys_addr_t)ULLONG_MAX); > + memblock_remove(0, PHYS_ADDR_MAX); > > for_each_efi_memory_desc(md) { > paddr = md->phys_addr; > diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c > index 8e70a627e0bb..da8edf3f85b3 100644 > --- a/drivers/remoteproc/qcom_q6v5_pil.c > +++ b/drivers/remoteproc/qcom_q6v5_pil.c > @@ -615,7 +615,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc) > struct elf32_hdr *ehdr; > phys_addr_t mpss_reloc; > phys_addr_t boot_addr; > - phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX; > + phys_addr_t min_addr = PHYS_ADDR_MAX; > phys_addr_t max_addr = 0; > bool relocate = false; > char seg_name[10]; > diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c > index 17b314d9a148..dc09d7ac905f 100644 > --- a/drivers/soc/qcom/mdt_loader.c > +++ b/drivers/soc/qcom/mdt_loader.c > @@ -50,7 +50,7 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw) > const struct elf32_phdr *phdrs; > const struct elf32_phdr *phdr; > const struct elf32_hdr *ehdr; > - phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX; > + phys_addr_t min_addr = PHYS_ADDR_MAX; > phys_addr_t max_addr = 0; > int i; > > @@ -97,7 +97,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw, > const struct elf32_hdr *ehdr; > const struct firmware *seg_fw; > phys_addr_t mem_reloc; > - phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX; > + phys_addr_t min_addr = PHYS_ADDR_MAX; > phys_addr_t max_addr = 0; > size_t fw_name_len; > ssize_t offset; > -- > 2.17.0 >