From patchwork Mon Mar 18 16:35:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10858025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C307139A for ; Mon, 18 Mar 2019 16:36:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64DF228F9A for ; Mon, 18 Mar 2019 16:36:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54BDB2903C; Mon, 18 Mar 2019 16:36:08 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6690F28F9A for ; Mon, 18 Mar 2019 16:36:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 373B46B0006; Mon, 18 Mar 2019 12:36:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 321A16B0007; Mon, 18 Mar 2019 12:36:02 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E8576B0008; Mon, 18 Mar 2019 12:36:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by kanga.kvack.org (Postfix) with ESMTP id BEC936B0006 for ; Mon, 18 Mar 2019 12:36:01 -0400 (EDT) Received: by mail-wm1-f70.google.com with SMTP id t190so3441228wmt.8 for ; Mon, 18 Mar 2019 09:36:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=W7fYsGKRBlmTW3CD7cbX3LbedsaSpni9GuqLbWnL0zM=; b=kp/V4dr/OiD58aROKoDzSuW/0rAxB/5Ra8V1hl6PFJerVf6xm0xylOql1jf6Wie0cL 1YWBpXpdWyrECu9VdC1asD+nNOyk9oafgUzR3GCcJVO5KD9Crp6D+ZqZaTlRxcxGlQyw NLJf5Q1XkDo9gkAoa6rdpvWA9ODFRyuKiQrCPlzIG0LNf3HnIV6IlTzybkFqjeRO7fmM oGpH6zxrRHnk0jq6/eaFaRi3ENdCYSS81lRaUChWA6d3GpntAF7VUtQKtxpLXF8LKugW LTFXnq6RKIU6dj1uAAJE61oh44/rdmD5s5efSDwZx3plQhRP6uYxlwDeOcdC9g8t2stx /WLQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com X-Gm-Message-State: APjAAAUqCpS97ZrvQULEg42klt6bgUYu22Bg2UGjvQi4Ju9nM31mQiFj xb2VCRrqLCS4YpKNH35siH/1iXynfqCzsvCv/w1AuHRG6fc08LYJ2KpN9fxkPjkiDm9AI6CK4tk S9f0M52vM4YMGr/Bh6hP6q2lXJAM/YWDO3zyB3M8QnqbNu+gk8h2bDbbcLJ5GfYPu9Q== X-Received: by 2002:a5d:4710:: with SMTP id y16mr4492405wrq.176.1552926961207; Mon, 18 Mar 2019 09:36:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwD/iPhfC1aLLwNsKyX96aiVPG5ixxS5wd8RskceyZNJMHXxvGjjNsXgBTSDISgiKS+4gb0 X-Received: by 2002:a5d:4710:: with SMTP id y16mr4492357wrq.176.1552926960367; Mon, 18 Mar 2019 09:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552926960; cv=none; d=google.com; s=arc-20160816; b=YpOWwV/qXH1shSYZJiBAwlU5BMU59E0ojpRqHXfGxG+UYaZzEIXto+1OeNzCdaVtWA BwJaJ6ckSzy92fkspCiTVGEITGg30wZ7ZcuFR3hPySU5c1lEHmD8GMuSIuVt42KBL4DG aQyfP+8csdNvqAfSVe8OP0n0Lva6t+s7b+CFRpluRXqs94spzS0INLAhMZSUh1cWLFPV t1zaYrINE62c+zPW1JTDVR8zn3H+2h4GWL4ax2cr9GlrV2K1TLPdGtRPw/bffUr3ZyBW BIpnYVEOgicj8/CpuhvFsa4f7Es6G9l+ua3Iis96iNcd90/wasmdj+rrDnJhWetQu1kA 33+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=W7fYsGKRBlmTW3CD7cbX3LbedsaSpni9GuqLbWnL0zM=; b=lAvTPw45Jh2FKG55CgAxbeNwEhMD85MFTcfDMBQjB7JDSevk/XDVkEwKPEBFXAVWSS yTaGi/zlrj3VM6P6Pko2gX2ClZcetnSanOugagEUqZcQYV8pWJOgOP2f7yM102dMzAj4 Sw79FD2/f171tC05EFElRM6NehABAR4GpCdlXKxJeM4y6SZn1xPjGJgApLMt4VAtqDEg 3AcjPt54+ev8n9lt0IK77HXN9oh1WF3PK54+V2u/H8TXJuZkI3mDZymGBABQ0et1szX8 QQvB+4cLjgYsz/Mx35eTXEvgtr4VlqQxqM0IE6zZicY2VUpFMDInzwiaP7hPm6vscSHP Nghg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id v184si6390929wma.96.2019.03.18.09.35.59 for ; Mon, 18 Mar 2019 09:36:00 -0700 (PDT) Received-SPF: pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 20D71165C; Mon, 18 Mar 2019 09:35:59 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ED7E23F614; Mon, 18 Mar 2019 09:35:52 -0700 (PDT) From: Vincenzo Frascino To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Arnaldo Carvalho de Melo , Branislav Rankov , Catalin Marinas , Chintan Pandya , Daniel Borkmann , Dave Martin , "David S. Miller" , Dmitry Vyukov , Eric Dumazet , Evgeniy Stepanov , Graeme Barnes , Greg Kroah-Hartman , Ingo Molnar , Jacob Bramley , Kate Stewart , Kees Cook , Kevin Brodsky , "Kirill A . Shutemov" , Kostya Serebryany , Lee Smith , Luc Van Oostenryck , Mark Rutland , Peter Zijlstra , Ramana Radhakrishnan , Robin Murphy , Ruben Ayrapetyan , Shuah Khan , Steven Rostedt , Szabolcs Nagy , Will Deacon Subject: [PATCH v2 1/4] elf: Make AT_FLAGS arch configurable Date: Mon, 18 Mar 2019 16:35:30 +0000 Message-Id: <20190318163533.26838-2-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318163533.26838-1-vincenzo.frascino@arm.com> References: <20190318163533.26838-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Currently, the AT_FLAGS in the elf auxiliary vector are set to 0 by default by the kernel. Some architectures might need to expose to the userspace a non-zero value to advertise some platform specific ABI functionalities. Make AT_FLAGS configurable by the architectures that require it. Cc: Catalin Marinas Cc: Will Deacon CC: Andrey Konovalov CC: Alexander Viro Signed-off-by: Vincenzo Frascino --- fs/binfmt_elf.c | 6 +++++- fs/binfmt_elf_fdpic.c | 6 +++++- fs/compat_binfmt_elf.c | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 7d09d125f148..f699a9ef5112 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -84,6 +84,10 @@ static int elf_core_dump(struct coredump_params *cprm); #define ELF_CORE_EFLAGS 0 #endif +#ifndef ELF_AT_FLAGS +#define ELF_AT_FLAGS 0 +#endif + #define ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(ELF_MIN_ALIGN-1)) #define ELF_PAGEOFFSET(_v) ((_v) & (ELF_MIN_ALIGN-1)) #define ELF_PAGEALIGN(_v) (((_v) + ELF_MIN_ALIGN - 1) & ~(ELF_MIN_ALIGN - 1)) @@ -249,7 +253,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec, NEW_AUX_ENT(AT_PHENT, sizeof(struct elf_phdr)); NEW_AUX_ENT(AT_PHNUM, exec->e_phnum); NEW_AUX_ENT(AT_BASE, interp_load_addr); - NEW_AUX_ENT(AT_FLAGS, 0); + NEW_AUX_ENT(AT_FLAGS, ELF_AT_FLAGS); NEW_AUX_ENT(AT_ENTRY, exec->e_entry); NEW_AUX_ENT(AT_UID, from_kuid_munged(cred->user_ns, cred->uid)); NEW_AUX_ENT(AT_EUID, from_kuid_munged(cred->user_ns, cred->euid)); diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index b53bb3729ac1..cf1e680a6b88 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -82,6 +82,10 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *, static int elf_fdpic_core_dump(struct coredump_params *cprm); #endif +#ifndef ELF_AT_FLAGS +#define ELF_AT_FLAGS 0 +#endif + static struct linux_binfmt elf_fdpic_format = { .module = THIS_MODULE, .load_binary = load_elf_fdpic_binary, @@ -651,7 +655,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm, NEW_AUX_ENT(AT_PHENT, sizeof(struct elf_phdr)); NEW_AUX_ENT(AT_PHNUM, exec_params->hdr.e_phnum); NEW_AUX_ENT(AT_BASE, interp_params->elfhdr_addr); - NEW_AUX_ENT(AT_FLAGS, 0); + NEW_AUX_ENT(AT_FLAGS, ELF_AT_FLAGS); NEW_AUX_ENT(AT_ENTRY, exec_params->entry_addr); NEW_AUX_ENT(AT_UID, (elf_addr_t) from_kuid_munged(cred->user_ns, cred->uid)); NEW_AUX_ENT(AT_EUID, (elf_addr_t) from_kuid_munged(cred->user_ns, cred->euid)); diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c index 15f6e96b3bd9..a21cf99701ae 100644 --- a/fs/compat_binfmt_elf.c +++ b/fs/compat_binfmt_elf.c @@ -79,6 +79,11 @@ #define ELF_HWCAP2 COMPAT_ELF_HWCAP2 #endif +#ifdef COMPAT_ELF_AT_FLAGS +#undef ELF_AT_FLAGS +#define ELF_AT_FLAGS COMPAT_ELF_AT_FLAGS +#endif + #ifdef COMPAT_ARCH_DLINFO #undef ARCH_DLINFO #define ARCH_DLINFO COMPAT_ARCH_DLINFO From patchwork Mon Mar 18 16:35:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10858027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C945139A for ; Mon, 18 Mar 2019 16:36:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5B9D28F9A for ; Mon, 18 Mar 2019 16:36:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D893F2903C; Mon, 18 Mar 2019 16:36:10 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C86828F9A for ; Mon, 18 Mar 2019 16:36:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFF916B0007; Mon, 18 Mar 2019 12:36:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BAC966B0008; Mon, 18 Mar 2019 12:36:08 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9B036B000A; Mon, 18 Mar 2019 12:36:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 541E56B0007 for ; Mon, 18 Mar 2019 12:36:08 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id l20so4532634wrf.23 for ; Mon, 18 Mar 2019 09:36:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OisYVOBbP2Vpq4E/v0HrS0vXKqDoNwWJhpOlxjcmyYc=; b=r7617mWwPlaKRPXCI1JlQ0IW8+on3LvpaY5EBveJs8IAhrl4jGUa6+naSpvD9o8NaG wUzbib14e1MktU8CYKyW0uq6BQUxAri9+CSNSnPir6M9yeH00HklKXVj304eCpEtIZFa lZg3QmpVxY9gUR+FOfJ7QV9/IqI+kJe6HqQUvN+7X8ph5zvMGRSEwOAXeV6tMhMLe107 AXj3/g4iDLbGdH/C7ouufRVT3Ma3V/3PTl7MSdcvSHHZQh7vLK4mNMInUANQ3HX8Qdzx MFokr/oNdXMS2rSUg5LJO1cpyn/cWszO/M9Z6LfCCxcwqnW+g/HmeijNJR0GZrg8AmMK zujw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com X-Gm-Message-State: APjAAAVBy1zpnlxsAWwS5VuejIKuOIkTRT1Yo3G9oq8UeJfA+NGzKNXt DTns+1gVhUjL6aeCazmrxt1/7nZ7vipmbRKI9CfEWi5lptHcu6RrxZTNJAy95LR5zGErzIw3ciV P0Saj08HwoAz6jTzm9F5s185D9zGi4MkuSRYMIT1MuxWZjk7wviNFwEh7uNofUEZLUw== X-Received: by 2002:a5d:458d:: with SMTP id p13mr3563358wrq.224.1552926967763; Mon, 18 Mar 2019 09:36:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlYMKY060xx5Y309sszHS0wVtFWDpuOBM7myvCetgClR1/Re5mk4fVx4IDW3nCnX9XqAPY X-Received: by 2002:a5d:458d:: with SMTP id p13mr3563282wrq.224.1552926966656; Mon, 18 Mar 2019 09:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552926966; cv=none; d=google.com; s=arc-20160816; b=VXCKbHknfBHjNo6XwTCvNzHPOx1k0b2iLmqSt06gTZ152lcnNkZ9KyZqW7hnRsY6cW v0s8cmPIloM0rBN2nvmD9tAAG3Ja6mor0R5xIc0Bx0FlFuZk1cyJpwffXX05/y/aYrUl Q+gWD+eYOWiQF84Js6WpiMl2Zn7upC6TN6TerdGEOWYP447M/k9qSesqC3Rl8YQAj2oJ 1INrIn0qVAjbZSPD4MhSi0RcNNY7R2TWNhoPUAbkiQKHwMoN8qUVU1wvLC9vjpZLCb0m UaKG9v6/ANc03FhzjvKZIS/WZ+ka1hg+Hr36+yY8hIWjpWx8EJFdrP0M70yqNR9ALvAl mGbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=OisYVOBbP2Vpq4E/v0HrS0vXKqDoNwWJhpOlxjcmyYc=; b=B6NFvqnwYQxHsFYQDd5rO1SCIBRWwq7MZ6mREegy/ah4+PqOcEIFV1dg+z1nJtirQ3 KFUSc1B/nqocZuALdlOmDj2V3449gJXWlNTOZsLuB2e9p6kh1PmWVw5CvH4qw6ZdYNn5 m7fIjrwOLR+1XGKKVOyJLXDdELPWnbFtuIkbf1WFTocPA37BaD/F0hDLjLKxjpWbzjZw VO7GPcECsdHUT7+9jquZVPXQ1EE+4i6yU1G6dS7GNqekXXGvdqaRC4hS3A5El952AHQx 2U/bz01TcHwxsORcxRysOYyv8K43MAKRXfkcBhVprH/vqVHi4QTorDXZAqvDTchvDcQc /KXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id r6si891432wmf.99.2019.03.18.09.36.06 for ; Mon, 18 Mar 2019 09:36:06 -0700 (PDT) Received-SPF: pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87E5A1682; Mon, 18 Mar 2019 09:36:05 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 63E6A3F614; Mon, 18 Mar 2019 09:35:59 -0700 (PDT) From: Vincenzo Frascino To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Arnaldo Carvalho de Melo , Branislav Rankov , Catalin Marinas , Chintan Pandya , Daniel Borkmann , Dave Martin , "David S. Miller" , Dmitry Vyukov , Eric Dumazet , Evgeniy Stepanov , Graeme Barnes , Greg Kroah-Hartman , Ingo Molnar , Jacob Bramley , Kate Stewart , Kees Cook , Kevin Brodsky , "Kirill A . Shutemov" , Kostya Serebryany , Lee Smith , Luc Van Oostenryck , Mark Rutland , Peter Zijlstra , Ramana Radhakrishnan , Robin Murphy , Ruben Ayrapetyan , Shuah Khan , Steven Rostedt , Szabolcs Nagy , Will Deacon Subject: [PATCH v2 2/4] arm64: Define Documentation/arm64/elf_at_flags.txt Date: Mon, 18 Mar 2019 16:35:31 +0000 Message-Id: <20190318163533.26838-3-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318163533.26838-1-vincenzo.frascino@arm.com> References: <20190318163533.26838-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP On arm64 the TCR_EL1.TBI0 bit has been always enabled hence the userspace (EL0) is allowed to set a non-zero value in the top byte but the resulting pointers are not allowed at the user-kernel syscall ABI boundary. With the relaxed ABI proposed through this document, it is now possible to pass tagged pointers to the syscalls, when these pointers are in memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap() or brk(). This change in the ABI requires a mechanism to inform the userspace that such an option is available. Specify and document the way in which AT_FLAGS can be used to advertise this feature to the userspace. Cc: Catalin Marinas Cc: Will Deacon CC: Andrey Konovalov Signed-off-by: Vincenzo Frascino Squash with "arm64: Define Documentation/arm64/elf_at_flags.txt" --- Documentation/arm64/elf_at_flags.txt | 133 +++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Documentation/arm64/elf_at_flags.txt diff --git a/Documentation/arm64/elf_at_flags.txt b/Documentation/arm64/elf_at_flags.txt new file mode 100644 index 000000000000..9b3494207c14 --- /dev/null +++ b/Documentation/arm64/elf_at_flags.txt @@ -0,0 +1,133 @@ +ARM64 ELF AT_FLAGS +================== + +This document describes the usage and semantics of AT_FLAGS on arm64. + +1. Introduction +--------------- + +AT_FLAGS is part of the Auxiliary Vector, contains the flags and it +is set to zero by the kernel on arm64 unless one or more of the +features detailed in paragraph 2 are present. + +The auxiliary vector can be accessed by the userspace using the +getauxval() API provided by the C library. +getauxval() returns an unsigned long and when a flag is present in +the AT_FLAGS, the corresponding bit in the returned value is set to 1. + +The AT_FLAGS with a "defined semantics" on arm64 are exposed to the +userspace via user API (uapi/asm/atflags.h). +The AT_FLAGS bits with "undefined semantics" are set to zero by default. +This means that the AT_FLAGS bits to which this document does not assign +an explicit meaning are to be intended reserved for future use. +The kernel will populate all such bits with zero until meanings are +assigned to them. If and when meanings are assigned, it is guaranteed +that they will not impact the functional operation of existing userspace +software. Userspace software should ignore any AT_FLAGS bit whose meaning +is not defined when the software is written. + +The userspace software can test for features by acquiring the AT_FLAGS +entry of the auxiliary vector, and testing whether a relevant flag +is set. + +Example of a userspace test function: + +bool feature_x_is_present(void) +{ + unsigned long at_flags = getauxval(AT_FLAGS); + if (at_flags & FEATURE_X) + return true; + + return false; +} + +Where the software relies on a feature advertised by AT_FLAGS, it +must check that the feature is present before attempting to +use it. + +2. Features exposed via AT_FLAGS +-------------------------------- + +bit[0]: ARM64_AT_FLAGS_SYSCALL_TBI + + On arm64 the TCR_EL1.TBI0 bit has been always enabled on the arm64 + kernel, hence the userspace (EL0) is allowed to set a non-zero value + in the top byte but the resulting pointers are not allowed at the + user-kernel syscall ABI boundary. + When bit[0] is set to 1 the kernel is advertising to the userspace + that a relaxed ABI is supported hence this type of pointers are now + allowed to be passed to the syscalls, when these pointers are in + memory ranges privately owned by a process and obtained by the + process in accordance with the definition of "valid tagged pointer" + in paragraph 3. + In these cases the tag is preserved as the pointer goes through the + kernel. Only when the kernel needs to check if a pointer is coming + from userspace an untag operation is required. + +3. ARM64_AT_FLAGS_SYSCALL_TBI +----------------------------- + +From the kernel syscall interface prospective, we define, for the purposes +of this document, a "valid tagged pointer" as a pointer that either it has +a zero value set in the top byte or it has a non-zero value, it is in memory +ranges privately owned by a userspace process and it is obtained in one of +the following ways: + - mmap() done by the process itself, where either: + * flags = MAP_PRIVATE | MAP_ANONYMOUS + * flags = MAP_PRIVATE and the file descriptor refers to a regular + file or "/dev/zero" + - a mapping below sbrk(0) done by the process itself + - any memory mapped by the kernel in the process's address space during + creation and following the restrictions presented above (i.e. data, bss, + stack). + +When the ARM64_AT_FLAGS_SYSCALL_TBI flag is set by the kernel, the following +behaviours are guaranteed by the ABI: + + - Every current or newly introduced syscall can accept any valid tagged + pointers. + + - If a non valid tagged pointer is passed to a syscall then the behaviour + is undefined. + + - Every valid tagged pointer is expected to work as an untagged one. + + - The kernel preserves any valid tagged pointers and returns them to the + userspace unchanged in all the cases except the ones documented in the + "Preserving tags" paragraph of tagged-pointers.txt. + +A definition of the meaning of tagged pointers on arm64 can be found in: +Documentation/arm64/tagged-pointers.txt. + +Example of correct usage (pseudo-code) for a userspace application: + +bool arm64_syscall_tbi_is_present(void) +{ + unsigned long at_flags = getauxval(AT_FLAGS); + if (at_flags & ARM64_AT_FLAGS_SYSCALL_TBI) + return true; + + return false; +} + +void main(void) +{ + char *addr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS, -1, 0); + + int fd = open("test.txt", O_WRONLY); + + /* Check if the relaxed ABI is supported */ + if (arm64_syscall_tbi_is_present()) { + /* Add a tag to the pointer */ + addr = tag_pointer(addr); + } + + strcpy("Hello World\n", addr); + + /* Write to a file */ + write(fd, addr, sizeof(addr)); + + close(fd); +} + From patchwork Mon Mar 18 16:35:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10858033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9B38139A for ; Mon, 18 Mar 2019 16:36:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 979A928F9A for ; Mon, 18 Mar 2019 16:36:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A68E2903C; Mon, 18 Mar 2019 16:36:16 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1157628F9A for ; Mon, 18 Mar 2019 16:36:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 238186B0008; Mon, 18 Mar 2019 12:36:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1C2176B000A; Mon, 18 Mar 2019 12:36:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08AC36B000C; Mon, 18 Mar 2019 12:36:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id A5FA96B0008 for ; Mon, 18 Mar 2019 12:36:14 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id 65so6194397wri.15 for ; Mon, 18 Mar 2019 09:36:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XEELYYF6lc/hWetNLA+zrjJi6XxuwPk+tQQR+ZM7sY8=; b=ln7vCazJD4bHessIuvM+3Rf07uAFyc0K3LQ7AUS8CEQO5iKiud4ktNmYX11NVb7dE0 VpYlupPIKBl8objr7QTwpIYcYzjAuDTy3PQxmLJTTtP5iwNsX7a20VYmCJlJgGEgjY0g ZFwt7oxyz8i6J9/Q5C5Y5a/Ag+kE5Rzy4kaL+3jUTY0IFhPFr4CO9OIBG10KhSnzjhNa DkuxGvTzwAcRjUyPJFO0ERaxzTUacHCFuqyApMTP2zpc128NcpzfELDt202X8wgxOXCH 26qXYkL5Nmx6RqRKsZYt+2gepXNXXhj6VuV61AFqMpWCQTE+YZEN0Un+SG9+aoOP1YO7 nTwA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com X-Gm-Message-State: APjAAAUNm0EAaQkkiSG9iW11tZUev0d8gSAEZehGkal2PgOe1RnotNS/ mIVp2q2RPgFZyqxEOPoGOOXBRYHwR5UtjjHx5KxhVR0S19K5lV6/7R1WbAy8RNYKr56EWoRd51o 4zcMP+vE8uENEc2qbSoFCLyHarxn5WSyHXD+ZdnaQxswU47N3DN5mt+DdBD9HQimYKA== X-Received: by 2002:a5d:4f91:: with SMTP id d17mr13853865wru.67.1552926974070; Mon, 18 Mar 2019 09:36:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxf/R8ATqf44IIM8cDif04FKiCVdx5LerBWWDAI5YwVEBcJRqzHKZWudp4DJRJJi2HZ4SuN X-Received: by 2002:a5d:4f91:: with SMTP id d17mr13853811wru.67.1552926973210; Mon, 18 Mar 2019 09:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552926973; cv=none; d=google.com; s=arc-20160816; b=EMajpXr17DSWbklqRifHQZ9UFPtGhNvx9E9hYE0dvDLJab/WNhw9IQyExWKyfuTfb1 Rf2GyGrr1vfgSpfvXCFr5iDQ/0Ow1BVamwhUGivf9OI0JsShuMqaYGkp68zr9TTr8dse tuBjKE18SiDYhoFLvcC0bMjLmoEGWj1WX0qjos/k8CwZ3NpmqmjsgkILRcNJsLdjH3W2 RwdOo+m016+S7cyjZHi6RS4SvPP9XILfWFhlq7jixomz99n1s3YbrHh7hVDthAsP2qbd 7xHSNIcZuZgz7TtLPOV7fh6L07ecSIPp1HQiVyDHFLeqdG2EUgMs0yuF50WUWOdA3KgW rjlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=XEELYYF6lc/hWetNLA+zrjJi6XxuwPk+tQQR+ZM7sY8=; b=B2M2Iyr5vy+d8KFRlrWhQLBTophMcz9qruzwTy5FATDPr5ndegcEQyGIf/ztkDRIKF huB5J0ux0/dpCZZU3Mvjky32PeKxKkeEM24DpEMJJ1MX6VLDzNM4patKrQNtaILIAOAI X8FH5HDUpGc98/fbbfg5SeNR4JgSpthYgNGkJR+OOqWKnDU3ASDnVeuqf4HXngoMKweC irKiBRQjolzIyo/ZLqL39RcCwHbzhPIRj5qQY3U96u8NTQWemVMhjLqMr0mMwbS49MZ4 u/9rJ0BJ4TUkzJgtL3fEoYloCqV1HQraWp0sJWi8td3RYAy0B6WGaV/ne0Nti41epIay LT5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id v62si6517277wma.181.2019.03.18.09.36.12 for ; Mon, 18 Mar 2019 09:36:13 -0700 (PDT) Received-SPF: pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EEC7B174E; Mon, 18 Mar 2019 09:36:11 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C9F083F614; Mon, 18 Mar 2019 09:36:05 -0700 (PDT) From: Vincenzo Frascino To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Arnaldo Carvalho de Melo , Branislav Rankov , Catalin Marinas , Chintan Pandya , Daniel Borkmann , Dave Martin , "David S. Miller" , Dmitry Vyukov , Eric Dumazet , Evgeniy Stepanov , Graeme Barnes , Greg Kroah-Hartman , Ingo Molnar , Jacob Bramley , Kate Stewart , Kees Cook , Kevin Brodsky , "Kirill A . Shutemov" , Kostya Serebryany , Lee Smith , Luc Van Oostenryck , Mark Rutland , Peter Zijlstra , Ramana Radhakrishnan , Robin Murphy , Ruben Ayrapetyan , Shuah Khan , Steven Rostedt , Szabolcs Nagy , Will Deacon Subject: [PATCH v2 3/4] arm64: Relax Documentation/arm64/tagged-pointers.txt Date: Mon, 18 Mar 2019 16:35:32 +0000 Message-Id: <20190318163533.26838-4-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318163533.26838-1-vincenzo.frascino@arm.com> References: <20190318163533.26838-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP On arm64 the TCR_EL1.TBI0 bit has been always enabled hence the userspace (EL0) is allowed to set a non-zero value in the top byte but the resulting pointers are not allowed at the user-kernel syscall ABI boundary. With the relaxed ABI proposed in this set, it is now possible to pass tagged pointers to the syscalls, when these pointers are in memory ranges obtained by an anonymous (MAP_ANONYMOUS) mmap() or sbrk(). Relax the requirements described in tagged-pointers.txt to be compliant with the behaviours guaranteed by the ABI deriving from the introduction of the ARM64_AT_FLAGS_SYSCALL_TBI flag. Cc: Catalin Marinas Cc: Will Deacon CC: Andrey Konovalov Signed-off-by: Vincenzo Frascino --- Documentation/arm64/tagged-pointers.txt | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Documentation/arm64/tagged-pointers.txt b/Documentation/arm64/tagged-pointers.txt index a25a99e82bb1..df27188b9433 100644 --- a/Documentation/arm64/tagged-pointers.txt +++ b/Documentation/arm64/tagged-pointers.txt @@ -18,7 +18,8 @@ Passing tagged addresses to the kernel -------------------------------------- All interpretation of userspace memory addresses by the kernel assumes -an address tag of 0x00. +an address tag of 0x00, unless the ARM64_AT_FLAGS_SYSCALL_TBI flag is +set by the kernel. This includes, but is not limited to, addresses found in: @@ -31,18 +32,23 @@ This includes, but is not limited to, addresses found in: - the frame pointer (x29) and frame records, e.g. when interpreting them to generate a backtrace or call graph. -Using non-zero address tags in any of these locations may result in an -error code being returned, a (fatal) signal being raised, or other modes -of failure. +Using non-zero address tags in any of these locations when the +ARM64_AT_FLAGS_SYSCALL_TBI flag is not set by the kernel, may result in +an error code being returned, a (fatal) signal being raised, or other +modes of failure. -For these reasons, passing non-zero address tags to the kernel via -system calls is forbidden, and using a non-zero address tag for sp is -strongly discouraged. +For these reasons, when the flag is not set, passing non-zero address +tags to the kernel via system calls is forbidden, and using a non-zero +address tag for sp is strongly discouraged. Programs maintaining a frame pointer and frame records that use non-zero address tags may suffer impaired or inaccurate debug and profiling visibility. +A definition of the meaning of ARM64_AT_FLAGS_SYSCALL_TBI and of the +guarantees that the ABI provides when the flag is set by the kernel can +be found in: Documentation/arm64/elf_at_flags.txt. + Preserving tags --------------- @@ -57,6 +63,9 @@ be preserved. The architecture prevents the use of a tagged PC, so the upper byte will be set to a sign-extension of bit 55 on exception return. +This behaviours are preserved even when the ARM64_AT_FLAGS_SYSCALL_TBI flag +is set by the kernel. + Other considerations -------------------- From patchwork Mon Mar 18 16:35:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 10858037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62CD11669 for ; Mon, 18 Mar 2019 16:36:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4776228F9A for ; Mon, 18 Mar 2019 16:36:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AB3B2903C; Mon, 18 Mar 2019 16:36:24 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B429528F9A for ; Mon, 18 Mar 2019 16:36:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B88A06B000A; Mon, 18 Mar 2019 12:36:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B37E06B000C; Mon, 18 Mar 2019 12:36:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A02646B000D; Mon, 18 Mar 2019 12:36:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by kanga.kvack.org (Postfix) with ESMTP id 499DE6B000A for ; Mon, 18 Mar 2019 12:36:22 -0400 (EDT) Received: by mail-wr1-f69.google.com with SMTP id p3so7874395wrs.7 for ; Mon, 18 Mar 2019 09:36:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ezRVeTwRbKjwyCBcJ/VbvBoL5xr9mdv2L018wxn1S2c=; b=Uj3cuOAGDUDfZEqe3WHzlzAQjnNapAFYUnnzKzDx6sj3zGnYzqHom9EcgqFfq1afrq W2k6TfrSe9RVazg4fyh+VHf4X7+Uz7e91t7hTi6J7fsPphmYS85OWWfDoIREdg8vHtP2 5AB19SjIT5l8fcFp2/9A6GwUHLFg9qBIHEYtByCDIBJRC2f2UlQ7ySrX/ArXMRorBE0E +7xJmDipo/z4UbIjSxq/xHFgINZ/GuC6rnxuYlqwIUqWFM0cGdSv8lqpvBhu/VkqD/2G pkdPuxl1n2ujtLVfQren+3zyULhuumGEGBwyxcmggQKwusE04b0AQRvofJZVKxD3vsKZ D6ag== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com X-Gm-Message-State: APjAAAXBwha9xOpE7FkXjqyjUDZyujHgrQo9kuj6MF9C1FXGBeJaudrh yz7IbnOszMiyEzJ0Isf9FMAC4zuV1xODZgrgxaoug5R7tVsEpkdhyt9vPw975TR4U8uqrvlNMvr 83YerWylqi6emLxp2Gimki9UwzzN4lEPJZ1fH65NFFUB+NQCVwZYmlNRlzvG33NfkQA== X-Received: by 2002:a1c:7f0f:: with SMTP id a15mr8946449wmd.99.1552926981706; Mon, 18 Mar 2019 09:36:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyta15SG+iExsV3qfI8mwzoCxcAxyCMW+6QNuBnvUcBhuiG5uXzt+kAyxXIZQqbIXXsXIrE X-Received: by 2002:a1c:7f0f:: with SMTP id a15mr8946313wmd.99.1552926979501; Mon, 18 Mar 2019 09:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552926979; cv=none; d=google.com; s=arc-20160816; b=hH+VAYfWTDJl6KFZinfpVrtFl4O+bzApGXI0oOz82Rd7HAViBK9wlHn+49jwwsNiBN hp/WsXbPpHem9NQGwNg+urQM4cVfb/rh2YP3UmuBV996saJkI/N+fcpoXNhcgnNIDA3v AEFwXDT50sDHUj5oY77KGsKHyIGb6J23EA/R1RO7P/m8SE1WfNgcMZLZgigSN/g6cbc3 bFP9vPWI+pgLpOqgww6ZIHjuf6jx8FN+exxxoIbDXN89t/ToJhiusVZ1f3VTLrmPJML3 XWyJ0VcLDQE2Kn+cQQ+WG48L0B0z3Yn4mLqD1HQxdVjGY0NXQFqwDxJthT6jXiH0cN2T 6NXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ezRVeTwRbKjwyCBcJ/VbvBoL5xr9mdv2L018wxn1S2c=; b=OmiDno/Ez3eOJ/qb0ACwUhuL7jum3UPO2kY9sPteHEBAA//uEJYnMcQQM3CnboRyg0 nyPZsPQcJtavSzILOh3ueJJzOdtzN3aBkEQtfSc0fMwKJHPTQvkriWKHXtK8akpcQP6p wJXo1Dd1lt2I5JYmAl3Uel6rzFmNOTk+DDmZKMcXyjGbMdUaJVgDID/4Z5FChxaRL5mA 4xFRUr6MJrIQ/+k4NFo1Baw2K4TbcVuQBJPQeJz09RM2fH50+9cuLCqqcHAzGqqvkK6+ C55txyJ+VnoacAt/zhm5Qzdz3ls8hJy9Bbw+KZz2lft/HOIUGbT5caVRTFg6HGoJ8Z8h ELYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id i10si7140479wrp.248.2019.03.18.09.36.19 for ; Mon, 18 Mar 2019 09:36:19 -0700 (PDT) Received-SPF: pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincenzo.frascino@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 623681A25; Mon, 18 Mar 2019 09:36:18 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3D9E83F614; Mon, 18 Mar 2019 09:36:12 -0700 (PDT) From: Vincenzo Frascino To: linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Arnaldo Carvalho de Melo , Branislav Rankov , Catalin Marinas , Chintan Pandya , Daniel Borkmann , Dave Martin , "David S. Miller" , Dmitry Vyukov , Eric Dumazet , Evgeniy Stepanov , Graeme Barnes , Greg Kroah-Hartman , Ingo Molnar , Jacob Bramley , Kate Stewart , Kees Cook , Kevin Brodsky , "Kirill A . Shutemov" , Kostya Serebryany , Lee Smith , Luc Van Oostenryck , Mark Rutland , Peter Zijlstra , Ramana Radhakrishnan , Robin Murphy , Ruben Ayrapetyan , Shuah Khan , Steven Rostedt , Szabolcs Nagy , Will Deacon Subject: [PATCH v2 4/4] arm64: elf: Advertise relaxed ABI Date: Mon, 18 Mar 2019 16:35:33 +0000 Message-Id: <20190318163533.26838-5-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318163533.26838-1-vincenzo.frascino@arm.com> References: <20190318163533.26838-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP On arm64 the TCR_EL1.TBI0 bit has been always enabled hence the userspace (EL0) is allowed to set a non-zero value in the top byte but the resulting pointers are not allowed at the user-kernel syscall ABI boundary. Set ARM64_AT_FLAGS_SYSCALL_TBI (bit[0]) in the AT_FLAGS to advertise the relaxation of the ABI to the userspace. Cc: Catalin Marinas Cc: Will Deacon CC: Andrey Konovalov Signed-off-by: Vincenzo Frascino --- arch/arm64/include/asm/atflags.h | 7 +++++++ arch/arm64/include/asm/elf.h | 5 +++++ arch/arm64/include/uapi/asm/atflags.h | 8 ++++++++ 3 files changed, 20 insertions(+) create mode 100644 arch/arm64/include/asm/atflags.h create mode 100644 arch/arm64/include/uapi/asm/atflags.h diff --git a/arch/arm64/include/asm/atflags.h b/arch/arm64/include/asm/atflags.h new file mode 100644 index 000000000000..b20093d61bf2 --- /dev/null +++ b/arch/arm64/include/asm/atflags.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_ATFLAGS_H +#define __ASM_ATFLAGS_H + +#include + +#endif diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h index 6adc1a90e7e6..73d5184a4dd9 100644 --- a/arch/arm64/include/asm/elf.h +++ b/arch/arm64/include/asm/elf.h @@ -16,6 +16,7 @@ #ifndef __ASM_ELF_H #define __ASM_ELF_H +#include #include /* @@ -167,6 +168,10 @@ do { \ NEW_AUX_ENT(AT_IGNORE, 0); \ } while (0) +/* Platform specific AT_FLAGS */ +#define ELF_AT_FLAGS ARM64_AT_FLAGS_SYSCALL_TBI +#define COMPAT_ELF_AT_FLAGS 0 + #define ARCH_HAS_SETUP_ADDITIONAL_PAGES struct linux_binprm; extern int arch_setup_additional_pages(struct linux_binprm *bprm, diff --git a/arch/arm64/include/uapi/asm/atflags.h b/arch/arm64/include/uapi/asm/atflags.h new file mode 100644 index 000000000000..1cf25692ffd6 --- /dev/null +++ b/arch/arm64/include/uapi/asm/atflags.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __UAPI_ASM_ATFLAGS_H +#define __UAPI_ASM_ATFLAGS_H + +/* Platform specific AT_FLAGS */ +#define ARM64_AT_FLAGS_SYSCALL_TBI (1 << 0) + +#endif