From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] ARM: vfp: clear fpscr length and stride bits on return from sig handler
Date: Mon, 30 Jan 2012 16:49:05 +0000 [thread overview]
Message-ID: <20120130164905.GB2248@linaro.org> (raw)
In-Reply-To: <1327681443-16627-5-git-send-email-will.deacon@arm.com>
On Fri, Jan 27, 2012 at 04:24:03PM +0000, Will Deacon wrote:
> The ARM PCS mandates that the length and stride bits of the fpscr are
> cleared on entry to and return from a public interface.
That means we need to reset that state on _entry_ to the signal handler,
since the interrupted thread is interrupted at an arbitrarily location
which need not be a public interface, whereas the signal handler entry
point definitely is a public interface.
On exit from the signal handler, surely we must restore the interrupted
thread's state for these bits, not reset them to zero? The interrupted
thread could be in the middle of something which makes assumptions about
what these bits are set to.
This is rather analogous to the handling of the CPSR.E bit.
Cheers
---Dave
>
> This patch ensures that the VFP context restored from a signal frame
> is made to adhere to this specification.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
> arch/arm/kernel/signal.c | 10 ++++++++--
> 1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
> index 9e617bd..274b8fc 100644
> --- a/arch/arm/kernel/signal.c
> +++ b/arch/arm/kernel/signal.c
> @@ -216,7 +216,7 @@ static int restore_vfp_context(struct vfp_sigframe __user *frame)
> struct vfp_hard_struct *h = &thread->vfpstate.hard;
> unsigned long magic;
> unsigned long size;
> - unsigned long fpexc;
> + unsigned long fpexc, fpscr;
> int err = 0;
>
> __get_user_error(magic, &frame->magic, err);
> @@ -238,7 +238,13 @@ static int restore_vfp_context(struct vfp_sigframe __user *frame)
> /*
> * Copy the status and control register.
> */
> - __get_user_error(h->fpscr, &frame->ufp.fpscr, err);
> + __get_user_error(fpscr, &frame->ufp.fpscr, err);
> +
> + /*
> + * As per the PCS, clear the length and stride bits.
> + */
> + fpscr &= ~(FPSCR_LENGTH_MASK | FPSCR_STRIDE_MASK);
> + h->fpscr = fpscr;
>
> /*
> * Sanitise and restore the exception registers.
> --
> 1.7.4.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2012-01-30 16:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-27 16:23 [PATCH 0/4] Various VFP fixes Will Deacon
2012-01-27 16:24 ` [PATCH 1/4] ARM: vfp: flush thread hwstate before restoring context from sigframe Will Deacon
2012-01-27 16:24 ` [PATCH 2/4] ARM: vfp: fix ptrace regset modification race Will Deacon
2012-01-27 16:24 ` [PATCH 3/4] ARM: vfp: flush thread hwstate before copying ptrace registers Will Deacon
2012-01-27 16:24 ` [PATCH 4/4] ARM: vfp: clear fpscr length and stride bits on return from sig handler Will Deacon
2012-01-27 17:46 ` Will Deacon
2012-01-30 16:49 ` Dave Martin [this message]
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=20120130164905.GB2248@linaro.org \
--to=dave.martin@linaro.org \
--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).