linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: imre.deak@nokia.com (Imre Deak)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v2 2/2] ARM: VFP: preserve the HW context when calling signal handlers
Date: Sat, 6 Feb 2010 18:23:29 +0200	[thread overview]
Message-ID: <20100206162329.GD1109@localhost> (raw)
In-Reply-To: <20100206121203.GA17672@n2100.arm.linux.org.uk>

On Sat, Feb 06, 2010 at 01:12:03PM +0100, ext Russell King - ARM Linux wrote:
> On Sat, Feb 06, 2010 at 12:02:21PM +0200, Imre Deak wrote:
> > Right, don't know what made me think that this will work out. Perhaps
> > someone mentioning that the corresponding IOCTL is not in use yet. But that
> > was about half a year ago :)
> > 
> > I'll resend adding the new regs only to the signal frame, leaving the above
> > as is.
> 
> Second point on this.  Currently, the VFP context which we thought
> about saving onto the sigframe looks like this:
> 
> #if __LINUX_ARM_ARCH__ < 6
> /* For ARM pre-v6, we use fstmiax and fldmiax.  This adds one extra
>  * word after the registers, and a word of padding at the end for
>  * alignment.  */
> #define VFP_MAGIC               0x56465001
> #define VFP_STORAGE_SIZE        152
> #else
> #define VFP_MAGIC               0x56465002
> #define VFP_STORAGE_SIZE        144
> #endif
> 
> struct vfp_sigframe
> {
>         unsigned long           magic;
>         unsigned long           size;
>         union vfp_state         storage;
> };
> 
> This is horribly outdated.  We save:
> 
> - 16 or 32 64-bit registers depending on whether VFPv3
> - one 32-bit word of fpmx state if < ARMv6
> - one 32-bit word of fpexc
> - one 32-bit word of fpscr
> - one 32-bit word of fpinst
> - one 32-bit word of fpinst2
> - cpu if SMP
>
> This gives potentially the following options:
> 
> VFPv3	ARMv6	SMP
> n	n	n	16*8+5*4 = 148
> y	n	n	32*8+5*4 = 276
> n	y	n	16*8+4*4 = 144
> y	y	n	32*8+4*4 = 272
> n	n	y	16*8+6*4 = 152	*
> y	n	y	32*8+6*4 = 280	*
> n	y	y	16*8+5*4 = 148
> y	y	y	32*8+5*4 = 276

But the proposed patch didn't use union vfp_state, but a fixed size
struct for all 8 possibilities. Then the only drawback would be
undefined regs in certain cases, but the register positions would be
fixed. Also cpu is not part of the that struct.

> 
> The two marked with '*' are very unlikely to occur.
> 
> I think this technically comes under the heading of 'a disaster
> waiting to happen'.
> 
> We currently have no way to convey these possibilities to anything
> dealing with stack frames; certainly userspace applications which may
> decide to inspect the sigframe aren't going to deal with all these
> possibilities correctly - if we're lucky, they'll get one case right.
> 
> The stack frame should not care about whether we're running on SMP or
> not - and that rules out using vfp_hard_struct or vfp_state in the
> sigframe.  So we're into having a different structure.
> 
> Since sigframes are tagged, let's make use of that facility.  Let's
> save the 64-bit VFP registers - that way, the size of this structure
> defines how many registers there are.  num_regs = struct size / 8.
> 
> Save fpmx_state as a separate tagged entity if it's present.  (I doubt
> anyone has need to use this - it's just required to preserve VFP state.)
> 
> Then, save the remainder of the state information (fpexc, fpscr, fpinst,
> fpinst2 but _not_ cpu) as another separate tagged entity.
> 
> This means anyone who wants to inspect the VFP state has two or three
> tags to look for, but they're all well-defined, and are hopefully
> protected against the complexities of having to work out how to decode
> the current variable sized structure which we have at present.

Would this still give a benefit over the one fixed struct solution?

--Imre

  reply	other threads:[~2010-02-06 16:23 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1242744292-23776-1-git-send-email-imre.deak@nokia.com>
2010-02-04 21:37 ` [RFC PATCH v2 0/2] ARM: VFP: Save / restore VFP state on the signal handler path Imre Deak
2010-02-04 21:38   ` [RFC PATCH v2 1/2] ARM: VFP: add support to sync the VFP state of the current thread Imre Deak
2010-02-06 10:32     ` Russell King - ARM Linux
2010-02-06 11:20       ` Russell King - ARM Linux
2010-02-06 11:32         ` Russell King - ARM Linux
2010-02-06 11:41           ` Russell King - ARM Linux
2010-02-06 15:55         ` Imre Deak
2010-02-04 21:38   ` [RFC PATCH v2 2/2] ARM: VFP: preserve the HW context when calling signal handlers Imre Deak
2010-02-06  9:25     ` Russell King - ARM Linux
2010-02-06 10:02       ` Imre Deak
2010-02-06 12:12         ` Russell King - ARM Linux
2010-02-06 16:23           ` Imre Deak [this message]
2010-03-29 16:17   ` [RFC PATCH v3 0/3] ARM: VFP: Save / restore VFP state on the signal handler path imre.deak at nokia.com
2010-03-31 21:23     ` [RFC PATCH v4 " imre.deak at nokia.com
2010-04-02 14:36       ` [RFC PATCH v5 0/2] " imre.deak at nokia.com
2010-04-02 14:36         ` [RFC PATCH v5 1/2] ARM: VFP: fix the SMP versions of vfp_{sync, flush}_hwstate imre.deak at nokia.com
2010-04-12 18:39           ` [RFC PATCH v5 1/2] ARM: VFP: fix the SMP versions of vfp_{sync,flush}_hwstate Russell King - ARM Linux
2010-04-02 14:36         ` [RFC PATCH v5 2/2] ARM: VFP: preserve the HW context when calling signal handlers imre.deak at nokia.com
2010-04-12 18:41           ` Russell King - ARM Linux
2010-04-12 22:04         ` [RFC PATCH v5 0/2] ARM: VFP: Save / restore VFP state on the signal handler path Jamie Lokier
2010-04-13 11:42           ` Imre Deak
2010-04-13 11:59             ` Nicolas Pitre
2010-04-07 16:24       ` [RFC PATCH v4 0/3] " Dirk Behme
2010-04-07 16:39         ` Imre Deak
2010-04-07 17:31           ` Jason McMullan
2010-03-31 21:23     ` [RFC PATCH v4 1/3] ARM: VFP: fix the SMP versions of vfp_{sync, flush}_hwstate imre.deak at nokia.com
2010-03-31 21:23     ` [RFC PATCH v4 2/3] ARM: VFP: make user_vfp struct packed imre.deak at nokia.com
2010-03-31 21:23     ` [RFC PATCH v4 3/3] ARM: VFP: preserve the HW context when calling signal handlers imre.deak at nokia.com
2010-03-29 16:17   ` [RFC PATCH v3 1/3] ARM: VFP: add support to sync the VFP state of the current thread imre.deak at nokia.com
2010-03-29 16:17   ` [RFC PATCH v3 2/3] ARM: VFP: make user_vfp struct packed imre.deak at nokia.com
2010-03-29 16:17   ` [RFC PATCH v3 3/3] ARM: VFP: preserve the HW context when calling signal handlers imre.deak at nokia.com

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=20100206162329.GD1109@localhost \
    --to=imre.deak@nokia.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).