From: Dave.Martin@arm.com (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 3/5] arm64: signal: factor out signal frame record allocation
Date: Fri, 9 Sep 2016 15:15:44 +0100 [thread overview]
Message-ID: <1473430576-20792-4-git-send-email-Dave.Martin@arm.com> (raw)
In-Reply-To: <1473430576-20792-1-git-send-email-Dave.Martin@arm.com>
Factor out the allocator for signal frame optional records into a
separate function, to ensure consistency and facilitate later
expansion of the signal frame.
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
---
arch/arm64/kernel/signal.c | 43 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 36 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 3bce940..963d2ba 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -75,6 +75,22 @@ static size_t sigframe_size(struct rt_sigframe_user_layout const *user)
return round_up(max(user->size, sizeof(struct rt_sigframe)), 16);
}
+/*
+ * Allocate space for an optional record of <size> bytes in the user
+ * signal frame. The offset from the signal frame base address to the
+ * allocated block is assigned to *offset.
+ */
+static int sigframe_alloc(struct rt_sigframe_user_layout *user,
+ unsigned long *offset, size_t size)
+{
+ size_t padded_size = round_up(size, 16);
+
+ *offset = user->size;
+ user->size += padded_size;
+
+ return 0;
+}
+
static void __user *apply_user_offset(
struct rt_sigframe_user_layout const *user, unsigned long offset)
{
@@ -283,19 +299,32 @@ badframe:
/* Determine the layout of optional records in the signal frame */
static int setup_sigframe_layout(struct rt_sigframe_user_layout *user)
{
- user->fpsimd_offset = user->size;
- user->size += round_up(sizeof(struct fpsimd_context), 16);
+ int err;
+
+ err = sigframe_alloc(user, &user->fpsimd_offset,
+ sizeof(struct fpsimd_context));
+ if (err)
+ return err;
/* fault information, if valid */
if (current->thread.fault_code) {
- user->esr_offset = user->size;
- user->size += round_up(sizeof(struct esr_context), 16);
+ err = sigframe_alloc(user, &user->esr_offset,
+ sizeof(struct esr_context));
+ if (err)
+ return err;
}
- /* set the "end" magic */
- user->end_offset = user->size;
+ /*
+ * Allocate space for the terminator record.
+ * HACK: here we undo the reservation of space for the end record.
+ * This bodge should be replaced with a cleaner approach later on.
+ */
+ user->limit = offsetof(struct rt_sigframe, uc.uc_mcontext.__reserved) +
+ sizeof(user->sigframe->uc.uc_mcontext.__reserved);
- return 0;
+ err = sigframe_alloc(user, &user->end_offset,
+ sizeof(struct _aarch64_ctx));
+ return err;
}
--
2.1.4
next prev parent reply other threads:[~2016-09-09 14:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-09 14:15 [RFC PATCH 0/5] arm64: Signal context expansion Dave Martin
2016-09-09 14:15 ` [RFC PATCH 1/5] arm64: signal: Refactor sigcontext parsing in rt_sigreturn Dave Martin
2016-09-09 14:15 ` [RFC PATCH 2/5] arm64: signal: factor frame layout and population into separate passes Dave Martin
2016-09-09 14:15 ` Dave Martin [this message]
2016-09-09 14:15 ` [RFC PATCH 4/5] arm64: signal: Allocate extra sigcontext space as needed Dave Martin
2016-09-09 14:15 ` [RFC PATCH 5/5] arm64: signal: Parse extra_context during sigreturn Dave Martin
2016-09-09 14:39 ` [RFC PATCH 0/5] arm64: Signal context expansion Florian Weimer
2016-09-09 15:21 ` Dave Martin
2016-09-09 17:01 ` Florian Weimer
2016-09-12 11:17 ` Dave Martin
2016-09-12 12:49 ` Florian Weimer
2016-09-12 15:21 ` Dave Martin
2016-09-12 15:01 ` Szabolcs Nagy
2016-09-12 15:30 ` Dave Martin
2016-09-12 16:44 ` Szabolcs Nagy
2016-09-12 17:24 ` Dave Martin
2016-09-13 9:28 ` Florian Weimer
2016-09-13 15:52 ` Dave Martin
2016-09-13 16:02 ` Florian Weimer
2016-09-15 16:45 ` Dave Martin
2016-09-16 12:10 ` Florian Weimer
2016-09-16 17:39 ` Dave Martin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473430576-20792-4-git-send-email-Dave.Martin@arm.com \
--to=dave.martin@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).