linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 4/4] ARM: vfp: clear fpscr length and stride bits on entry to sig handler
Date: Mon, 30 Jan 2012 17:07:03 +0000	[thread overview]
Message-ID: <20120130170703.GE2248@linaro.org> (raw)
In-Reply-To: <1327922695-16121-5-git-send-email-will.deacon@arm.com>

On Mon, Jan 30, 2012 at 11:24:55AM +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. Although signal
> handlers run asynchronously with respect to the interrupted function,
> the handler itself expects to run as though it has been called like a
> normal function.
> 
> This patch updates the state mirroring the VFP hardware before entry to
> a signal handler so that it adheres to the PCS. Furthermore, we disable
> VFP to ensure that we trap on any floating point operation performed by
> the signal handler and synchronise the hardware appropriately. A check
> is inserted after the signal handler to avoid redundant flushing if VFP
> was not used.

Hmmm, that looks more like it.  I've not tried this out, but it looks
sensible.

Ignore my stale comments on your previous post.

Cheers
---Dave

> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm/kernel/signal.c |   17 ++++++++++++++++-
>  1 files changed, 16 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
> index 9e617bd..3de59a0 100644
> --- a/arch/arm/kernel/signal.c
> +++ b/arch/arm/kernel/signal.c
> @@ -207,6 +207,20 @@ static int preserve_vfp_context(struct vfp_sigframe __user *frame)
>  	__put_user_error(h->fpinst, &frame->ufp_exc.fpinst, err);
>  	__put_user_error(h->fpinst2, &frame->ufp_exc.fpinst2, err);
>  
> +	vfp_flush_hwstate(thread);
> +
> +	/*
> +	 * As per the PCS, clear the length and stride bits before entry
> +	 * to the signal handler.
> +	 */
> +	h->fpscr &= ~(FPSCR_LENGTH_MASK | FPSCR_STRIDE_MASK);
> +
> +	/*
> +	 * Disable VFP so that we can detect if it was used by the
> +	 * signal handler.
> +	 */
> +	h->fpexc &= ~FPEXC_EN;
> +
>  	return err ? -EFAULT : 0;
>  }
>  
> @@ -227,7 +241,8 @@ static int restore_vfp_context(struct vfp_sigframe __user *frame)
>  	if (magic != VFP_MAGIC || size != VFP_STORAGE_SIZE)
>  		return -EINVAL;
>  
> -	vfp_flush_hwstate(thread);
> +	if (h->fpexc & FPEXC_EN)
> +		vfp_flush_hwstate(thread);
>  
>  	/*
>  	 * Copy the floating point registers. There can be unused
> -- 
> 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

      reply	other threads:[~2012-01-30 17:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 11:24 [PATCH v2 0/4] Various VFP fixes Will Deacon
2012-01-30 11:24 ` [PATCH v2 1/4] ARM: vfp: flush thread hwstate before restoring context from sigframe Will Deacon
2012-01-30 11:24 ` [PATCH v2 2/4] ARM: vfp: fix ptrace regset modification race Will Deacon
2012-01-30 11:24 ` [PATCH v2 3/4] ARM: vfp: flush thread hwstate before copying ptrace registers Will Deacon
2012-01-30 11:24 ` [PATCH v2 4/4] ARM: vfp: clear fpscr length and stride bits on entry to sig handler Will Deacon
2012-01-30 17:07   ` 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=20120130170703.GE2248@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).