From patchwork Tue Aug 16 18:32:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Covington X-Patchwork-Id: 9284405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 326D560839 for ; Tue, 16 Aug 2016 18:36:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 248CA28643 for ; Tue, 16 Aug 2016 18:36:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 186BD287C8; Tue, 16 Aug 2016 18:36:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 84D73287C0 for ; Tue, 16 Aug 2016 18:36:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZjCP-0008FA-P9; Tue, 16 Aug 2016 18:34:53 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZjCK-0008BB-4F for linux-arm-kernel@lists.infradead.org; Tue, 16 Aug 2016 18:34:48 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 31D9261DA0; Tue, 16 Aug 2016 18:34:32 +0000 (UTC) Received: from illium.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cov@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7601961D8B; Tue, 16 Aug 2016 18:34:28 +0000 (UTC) From: Christopher Covington To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Suzuki K Poulose , James Hogan , Christopher Covington , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm64: Expose TASK_SIZE to userspace via auxv Date: Tue, 16 Aug 2016 14:32:29 -0400 Message-Id: <20160816183231.21179-1-cov@codeaurora.org> X-Mailer: git-send-email 2.9.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160816_113448_224351_ABDA8C40 X-CRM114-Status: GOOD ( 11.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jon Masters , Jeremy Linton MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some userspace applications need to know the maximum virtual address they can use (TASK_SIZE). There are several possible values for TASK_SIZE with the arm64 kernel, and such applications are either making bad hard-coded assumptions, or are guessing and checking using system calls like munmap(), which may have other reasons for returning an error than TASK_SIZE being exceeded. To make correct functioning easy for userspace applications that need to know the maximum virtual address they can use, communicate TASK_SIZE via the ELF auxiliary vector, just like PAGE_SIZE is currently communicated. Signed-off-by: Christopher Covington --- Tested with the following commands: LD_SHOW_AUXV=1 sleep 1 # GNU dynamic ld-linux*.so hexdump -v -e '4/4 "%08x " "\n"' /proc/self/auxv | \ sed -r 's/0*([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)/\1 0x\4\3/ s/^0 / NULL: / s/^3 / PHDR: / s/^4 / PHENT: / s/^5 / PHNUM: / s/^6 / PAGESZ: / s/^7 / BASE: / s/^8 / FLAGS: / s/^9 / ENTRY: / s/^b / UID: / s/^c / EUID: / s/^d / GID: / s/^e / EGID: / s/^f /PLATFORM: / s/^10 / HWCAP: / s/^11 / CLKTCK: / s/^17 / SECURE: / s/^19 / RANDOM: / s/^1f / EXECFN: / s/^21 / VDSO: / s/^22 / TASKSZ: /' # compatible with static busybox --- arch/arm64/include/asm/elf.h | 1 + arch/arm64/include/uapi/asm/auxvec.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index a55384f..3811795 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -145,6 +145,7 @@ typedef struct user_fpsimd_state elf_fpregset_t; do { \ NEW_AUX_ENT(AT_SYSINFO_EHDR, \ (elf_addr_t)current->mm->context.vdso); \ + NEW_AUX_ENT(AT_TASKSZ, TASK_SIZE); \ } while (0) #define ARCH_HAS_SETUP_ADDITIONAL_PAGES diff --git a/arch/arm64/include/uapi/asm/auxvec.h b/arch/arm64/include/uapi/asm/auxvec.h index 4cf0c17..595bfda 100644 --- a/arch/arm64/include/uapi/asm/auxvec.h +++ b/arch/arm64/include/uapi/asm/auxvec.h @@ -18,7 +18,8 @@ /* vDSO location */ #define AT_SYSINFO_EHDR 33 +#define AT_TASKSZ 34 -#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */ +#define AT_VECTOR_SIZE_ARCH 2 /* entries in ARCH_DLINFO */ #endif