Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/808362/?format=api
{ "id": 808362, "url": "http://patchwork.ozlabs.org/api/patches/808362/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/1504198860-12951-28-git-send-email-Dave.Martin@arm.com/", "project": { "id": 41, "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api", "name": "GNU C Library", "link_name": "glibc", "list_id": "libc-alpha.sourceware.org", "list_email": "libc-alpha@sourceware.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504198860-12951-28-git-send-email-Dave.Martin@arm.com>", "list_archive_url": null, "date": "2017-08-31T17:00:59", "name": "[RFC,v2,27/28] arm64: signal: Report signal frame size to userspace via auxv", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ac6ff571b10b25eb8ebdd62ed152ef995de32074", "submitter": { "id": 26612, "url": "http://patchwork.ozlabs.org/api/people/26612/?format=api", "name": "Dave Martin", "email": "Dave.Martin@arm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/1504198860-12951-28-git-send-email-Dave.Martin@arm.com/mbox/", "series": [ { "id": 882, "url": "http://patchwork.ozlabs.org/api/series/882/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=882", "date": "2017-08-31T17:00:32", "name": "ARM Scalable Vector Extension (SVE)", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/882/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/808362/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/808362/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<libc-alpha-return-83986-incoming=patchwork.ozlabs.org@sourceware.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "mailing list libc-alpha@sourceware.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-83986-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"oD9lNmGT\"; dkim-atps=neutral", "sourceware.org; auth=none" ], "Received": [ "from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjpln71FHz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 1 Sep 2017 03:10:13 +1000 (AEST)", "(qmail 123988 invoked by alias); 31 Aug 2017 17:09:29 -0000", "(qmail 123932 invoked by uid 89); 31 Aug 2017 17:09:29 -0000" ], "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id:in-reply-to\n\t:references; q=dns; s=default; b=h3zGbqCVW49/1duS1nQecAFzlZ0sTAD\n\tN+lYGfVo9EXmlVxzy5hBx+coj41A/NyEVnMcafH7GHCGGSQB+ohUl25KOkKouRT4\n\t2Z3wlLQjBFe8lZamEJKFHHx47/lJ1u9aaZCf07WaTbB4Fl04ta9NQWmrRmKdqTpD\n\tQP0p/RuM/m18=", "DKIM-Signature": "v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id:in-reply-to\n\t:references; s=default; bh=ZdZtqq6H0u+9piA6z2ZBnbV42Pc=; b=oD9lN\n\tmGTeAWAK0L+5xlVzjukikDFaJmorivoDZtwg2E9HpvMaZqnv6oMIZKu3Xs7iWfcr\n\tTN2udTMw6gpSZhX1+WD+Hl4D2knFUVKqRshjh7xsVm08wwMfaZMd9+fC6zuZI26/\n\tC8H+qmnMoK+e3MJpDXSH3BoZkJYy/P1jHds7MM=", "Mailing-List": "contact libc-alpha-help@sourceware.org; run by ezmlm", "Precedence": "bulk", "List-Id": "<libc-alpha.sourceware.org>", "List-Unsubscribe": "<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>", "List-Subscribe": "<mailto:libc-alpha-subscribe@sourceware.org>", "List-Archive": "<http://sourceware.org/ml/libc-alpha/>", "List-Post": "<mailto:libc-alpha@sourceware.org>", "List-Help": "<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>", "Sender": "libc-alpha-owner@sourceware.org", "X-Virus-Found": "No", "X-Spam-SWARE-Status": "No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=", "X-HELO": "foss.arm.com", "From": "Dave Martin <Dave.Martin@arm.com>", "To": "linux-arm-kernel@lists.infradead.org", "Cc": "Catalin Marinas <catalin.marinas@arm.com>, Will Deacon\n\t<will.deacon@arm.com>, \tArd Biesheuvel <ard.biesheuvel@linaro.org>,\n\t=?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= <alex.bennee@linaro.org>,\n\tSzabolcs Nagy <szabolcs.nagy@arm.com>, Richard Sandiford\n\t<richard.sandiford@arm.com>, \tkvmarm@lists.cs.columbia.edu,\n\tlibc-alpha@sourceware.org, \tlinux-arch@vger.kernel.org,\n\tMichael Ellerman <mpe@ellerman.id.au>", "Subject": "[RFC PATCH v2 27/28] arm64: signal: Report signal frame size to\n\tuserspace via auxv", "Date": "Thu, 31 Aug 2017 18:00:59 +0100", "Message-Id": "<1504198860-12951-28-git-send-email-Dave.Martin@arm.com>", "In-Reply-To": "<1504198860-12951-1-git-send-email-Dave.Martin@arm.com>", "References": "<1504198860-12951-1-git-send-email-Dave.Martin@arm.com>" }, "content": "Stateful CPU architecture extensions may require the signal frame\nto grow to a size that exceeds the arch's MINSIGSTKSZ #define.\nHowever, changing this #define is an ABI break.\n\nTo allow userspace the option of determining the signal frame size\nin a more forwards-compatible way, this patch adds a new auxv entry\ntagged with AT_MINSIGSTKSZ, which provides the maximum signal frame\nsize that the process can observe during its lifetime.\n\nIf AT_MINSIGSTKSZ is absent from the aux vector, the caller can\nassume that the MINSIGSTKSZ #define is sufficient. This allows for\na consistent interface with older kernels that do not provide\nAT_MINSIGSTKSZ.\n\nThe idea is that libc could expose this via sysconf() or some\nsimilar mechanism.\n\nThere is deliberately no AT_SIGSTKSZ. The kernel knows nothing\nabout userspace's own stack overheads and should not pretend to\nknow.\n\nFor arm64:\n\nThe primary motivation for this interface is the Scalable Vector\nExtension, which can require at least 4KB or so of extra space\nin the signal frame for the largest hardware implementations.\n\nTo determine the correct value, a \"Christmas tree\" mode (via the\nadd_all argument) is added to setup_sigframe_layout(), to simulate\naddition of all possible records to the signal frame at maximum\npossible size.\n\nIf this procedure goes wrong somehow, resulting in a stupidly large\nframe layout and hence failure of sigframe_alloc() to allocate a\nrecord to the frame, then this is indicative of a kernel bug: the\nkernel's internal SIGFRAME_MAXSZ is supposed to sanity-check\nagainst generting frames that we consider _impossibly_ large. In\nthis case, SIGSTKSZ is returned as a \"reasonable guess that is at\nleast bigger than MINSIGSTKSZ\" and we WARN().\n\nSigned-off-by: Dave Martin <Dave.Martin@arm.com>\n\n---\n\nChanges since v1\n----------------\n\nRelated to Ard Biesheuvel's comments:\n\n* Fix unbalanced ifelse bracing to conform to the kernel coding style.\n---\n arch/arm64/include/asm/elf.h | 5 +++++\n arch/arm64/include/asm/processor.h | 3 +++\n arch/arm64/include/uapi/asm/auxvec.h | 3 ++-\n arch/arm64/kernel/signal.c | 39 +++++++++++++++++++++++++++++++-----\n 4 files changed, 44 insertions(+), 6 deletions(-)", "diff": "diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h\nindex 33be513..8a2708a 100644\n--- a/arch/arm64/include/asm/elf.h\n+++ b/arch/arm64/include/asm/elf.h\n@@ -24,6 +24,10 @@\n #include <asm/ptrace.h>\n #include <asm/user.h>\n \n+#ifndef __ASSEMBLY__\n+#include <asm/processor.h> /* for get_minsigstksz(), used by ARCH_DLINFO */\n+#endif\n+\n /*\n * AArch64 static relocation types.\n */\n@@ -148,6 +152,7 @@ typedef struct user_fpsimd_state elf_fpregset_t;\n do {\t\t\t\t\t\t\t\t\t\\\n \tNEW_AUX_ENT(AT_SYSINFO_EHDR,\t\t\t\t\t\\\n \t\t (elf_addr_t)current->mm->context.vdso);\t\t\\\n+\tNEW_AUX_ENT(AT_MINSIGSTKSZ, get_minsigstksz());\t\t\t\\\n } while (0)\n \n #define ARCH_HAS_SETUP_ADDITIONAL_PAGES\ndiff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h\nindex df66452..18af4bd 100644\n--- a/arch/arm64/include/asm/processor.h\n+++ b/arch/arm64/include/asm/processor.h\n@@ -197,6 +197,9 @@ static inline void spin_lock_prefetch(const void *ptr)\n int cpu_enable_pan(void *__unused);\n int cpu_enable_cache_maint_trap(void *__unused);\n \n+/* User signal frame size discovery: */\n+int get_minsigstksz(void);\n+\n /* Userspace interface for PR_SVE_{SET,GET}_VL prctl()s: */\n #define SVE_SET_VL(arg)\tsve_set_current_vl(arg)\n #define SVE_GET_VL()\tsve_get_current_vl()\ndiff --git a/arch/arm64/include/uapi/asm/auxvec.h b/arch/arm64/include/uapi/asm/auxvec.h\nindex 4cf0c17..1d45b28 100644\n--- a/arch/arm64/include/uapi/asm/auxvec.h\n+++ b/arch/arm64/include/uapi/asm/auxvec.h\n@@ -18,7 +18,8 @@\n \n /* vDSO location */\n #define AT_SYSINFO_EHDR\t33\n+#define AT_MINSIGSTKSZ\t34\t/* stack needed for signal delivery */\n \n-#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */\n+#define AT_VECTOR_SIZE_ARCH 2 /* entries in ARCH_DLINFO */\n \n #endif\ndiff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c\nindex c3f94cf..7a3d6d2 100644\n--- a/arch/arm64/kernel/signal.c\n+++ b/arch/arm64/kernel/signal.c\n@@ -566,8 +566,15 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)\n \treturn 0;\n }\n \n-/* Determine the layout of optional records in the signal frame */\n-static int setup_sigframe_layout(struct rt_sigframe_user_layout *user)\n+/*\n+ * Determine the layout of optional records in the signal frame\n+ *\n+ * add_all: if true, lays out the biggest possible signal frame for\n+ *\tthis task; otherwise, generates a layout for the current state\n+ *\tof the task.\n+ */\n+static int setup_sigframe_layout(struct rt_sigframe_user_layout *user,\n+\t\t\t\t bool add_all)\n {\n \tint err;\n \n@@ -577,7 +584,7 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user)\n \t\treturn err;\n \n \t/* fault information, if valid */\n-\tif (current->thread.fault_code) {\n+\tif (add_all || current->thread.fault_code) {\n \t\terr = sigframe_alloc(user, &user->esr_offset,\n \t\t\t\t sizeof(struct esr_context));\n \t\tif (err)\n@@ -599,7 +606,6 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user)\n \treturn sigframe_alloc_end(user);\n }\n \n-\n static int setup_sigframe(struct rt_sigframe_user_layout *user,\n \t\t\t struct pt_regs *regs, sigset_t *set)\n {\n@@ -697,7 +703,7 @@ static int get_sigframe(struct rt_sigframe_user_layout *user,\n \tint err;\n \n \tinit_user_layout(user);\n-\terr = setup_sigframe_layout(user);\n+\terr = setup_sigframe_layout(user, false);\n \tif (err)\n \t\treturn err;\n \n@@ -931,3 +937,26 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,\n \t\tthread_flags = READ_ONCE(current_thread_info()->flags);\n \t} while (thread_flags & _TIF_WORK_MASK);\n }\n+\n+/*\n+ * Determine the stack space required for guaranteed signal devliery.\n+ * This function is used to populate AT_MINSIGSTKSZ at process startup.\n+ */\n+int get_minsigstksz(void)\n+{\n+\tstruct rt_sigframe_user_layout user;\n+\tint err;\n+\n+\tinit_user_layout(&user);\n+\terr = setup_sigframe_layout(&user, true);\n+\n+\tif (err) {\n+\t\tWARN_ON(1);\n+\n+\t\treturn SIGSTKSZ;\n+\t} else {\n+\t\treturn sigframe_size(&user) +\n+\t\t\tround_up(sizeof(struct frame_record), 16) +\n+\t\t\t16; /* max alignment padding */\n+\t}\n+}\n", "prefixes": [ "RFC", "v2", "27/28" ] }