Alpha: unbreak osf_setsysinfo(SSI_NVPAIRS, [SSIN_UACPROC, UAC_SIGBUS])
PATCH 1/1 Alpha: unbreak osf_setsysinfo(SSI_NVPAIRS, [SSIN_UACPROC, UAC_SIGBUS])
From: Sergei Trofimovich <[email protected]>
Update 'UAC_SHIFT' to match 'ALPHA_UAC_SHIFT'.
I don't know why kernel maintains 2 copies of the same constant. One (UAC_SHIFT) is used to shift bits in syscall definition, and another is in trap handler (ALPHA_UAC_SHIFT).
Was broken by
Quoted 10 lines
commit
745dd2405e281d96c0a449103bdf6a895048f28cAuthor: Michael Cree <[email protected]> Date: Mon Nov 30 22:44:40 2009 -0500Alpha: Rearrange thread info flags fixing two regressions
Both regressions fixed by (1) rearranging
TIF_NOTIFY_RESUMEflag to be in lower 8 bits of the thread info flags, and (2) making sure thatALPHA_UAC_SHIFTmatches the rearrangement of the thread info flags.
Quoted 5 lines
Signed-off-by Michael Cree <[email protected]>Cc Richard Henderson <[email protected]>Cc Ivan Kokshaysky <[email protected]>Cc David Howells <[email protected]>,Signed-off-by Matt Turner <[email protected]>
--- arch/alpha/include/asm/sysinfo.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/alpha/include/asm/sysinfo.h +1 -1
@@ -32,7 +32,7 @@/* This is the shift that is applied to the UAC bits as stored in the per-thread flags. See thread_info.h. */ -#define UAC_SHIFT 6 +#define UAC_SHIFT 10#endif
Signature · 1 line
1.7.3.4
Quoted 11 lines · On 12/08/11 03:25, [email protected] wrote:
From: Sergei Trofimovich <[email protected]>
Update '
UAC_SHIFT' to match 'ALPHA_UAC_SHIFT'.I don't know why kernel maintains 2 copies of the same constant. One (
UAC_SHIFT) is used to shift bits in syscall definition, and another is in trap handler (ALPHA_UAC_SHIFT).Was broken by
Quoted 2 lines
commit
745dd2405e281d96c0a449103bdf6a895048f28c
Author: Michael Cree <[email protected]>
Bollocks.
The shift for the UAC flags was well and truly broken before that commit as the TIF_UAC_NOPRINT, etc., flags did not match the definition of either the UAC_ALPHA_SHIFT or the UAC_SHIFT flag. I fixed UAC_ALPHA_SHIFT to match the actual UAC flag definitions.
What I didn't realise was that UAC_SHIFT was also defined and used elsewhere in the Alpha architecture code (so UAC_SHIFT _remained_ broken).
arch/alpha/include/asm/sysinfo.h line 35
Quoted 10 lines
arch/alpha/include/asm/sysinfo.h +1
-1@@ -32,7 +32,7 @@/* This is the shift that is applied to the UAC bits as stored in the per-thread flags. See thread_info.h. */ -#define UAC_SHIFT 6 +#define UAC_SHIFT 10
But you haven't really fixed it. If indeed UAC_SHIFT is exactly the same as UAC_ALPHA_SHIFT then two definitions remain and that leaves the possibility of someone changing one thereby screwing up the other.
Surely it would be better to unify UAC_ALPHA_SHIFT and UAC_SHIFT and use one macro in all relevant places.
I am happy for you to reference my commit but I would prefer the commit message saying something more along the line that it left part of the fix undone which you are now completing.
With the above changes I will be happy to give my acknowledgement.
Thanks
Michael.
Quoted 5 lines
Quoted 3 lines
Was broken by
Quoted 2 lines
commit
745dd2405e281d96c0a449103bdf6a895048f28c
Author: Michael Cree <[email protected]>Bollocks.
Ugh, my apologies! Didn't intend to insult you. I failed to read your changelog (and patch) properly. Now I see The a583f1b54249b was the first in flag skew.
I'll build alpha toolchain / qemu root and will try to cook nicer patch with compile-time safety checks.
Sorry.
Signature · 1 line
Sergei
Quoted 2 lines
I'll build alpha toolchain / qemu root and will try to cook nicer patch with compile-time safety checks.
Sent reworked patch: http://marc.info/?l=linux-alpha&m=131318270531656&w=2
Yelling at the header I've found minor nit:
...
#define SET_UNALIGN_CTL(task,value) ({ \
task_thread_info(task)->flags = ((task_thread_info(task)->flags & \
~ALPHA_UAC_MASK)
| (((value) << ALPHA_UAC_SHIFT) & (1<<TIF_UAC_NOPRINT))\
| (((value) << (ALPHA_UAC_SHIFT + 1)) & (1<<TIF_UAC_SIGBUS)) \
| (((value) << (ALPHA_UAC_SHIFT - 1)) & (1<<TIF_UAC_NOFIX)));\
0; })#define GET_UNALIGN_CTL(task,value) ({ \
put_user((task_thread_info(task)->flags & (1 << TIF_UAC_NOPRINT))\
>> ALPHA_UAC_SHIFT \
| (task_thread_info(task)->flags & (1 << TIF_UAC_SIGBUS))\
>> (ALPHA_UAC_SHIFT + 1) \
| (task_thread_info(task)->flags & (1 << TIF_UAC_NOFIX))\
>> (ALPHA_UAC_SHIFT - 1), \
(int __user *)(value)); \
})The macros SET_UNALIGN_CTL/GET_UNALIGN_CTL are used only in kernel/sys.c:prctl syscall.
Quoted 1 line
| (((value) <<
ALPHA_UAC_SHIFT) & (1<<TIF_UAC_NOPRINT))
prctl.h: # define PR_UNALIGN_NOPRINT 1
Quoted 1 line
| (((value) << (
ALPHA_UAC_SHIFT+ 1)) & (1<<TIF_UAC_SIGBUS))
prctl.h: # define PR_UNALIGN_SIGBUS 2
Quoted 1 line
| (((value) << (
ALPHA_UAC_SHIFT- 1)) & (1<<TIF_UAC_NOFIX)));
prctl.h: no '4' value
Do you think it's worth adding to userspace interface
or should one just remove it from handled by prctl flags [ABI change]?
Thanks!
include/linux/prctl.h +1 -0
@@ -15,6 +15,7 @@#define PR_SET_UNALIGN 6# define PR_UNALIGN_NOPRINT 1/* silently fix up unaligned user accesses */ # define PR_UNALIGN_SIGBUS 2/* generate SIGBUS on unaligned user access */ +# define PR_UNALIGN_NOFIX 4/* skip offending instruction and do nothing */ /* Get/set whether or not to drop capabilities on setuid() away from * uid 0 (as per security/commoncap.c) */
Signature · 1 line
Sergei
Quoted 32 lines · Sergei Trofimovich
Quoted 2 lines
I'll build alpha toolchain / qemu root and will try to cook nicer patch with compile-time safety checks.
Sent reworked patch: http://marc.info/?l=linux-alpha&m=131318270531656&w=2
Yelling at the header I've found minor nit:
...#define SET_UNALIGN_CTL(task,value) ({ \ task_thread_info(task)->flags = ((task_thread_info(task)->flags & \ ~ALPHA_UAC_MASK) | (((value) << ALPHA_UAC_SHIFT) & (1<<TIF_UAC_NOPRINT))\ | (((value) << (ALPHA_UAC_SHIFT + 1)) & (1<<TIF_UAC_SIGBUS)) \ | (((value) << (ALPHA_UAC_SHIFT - 1)) & (1<<TIF_UAC_NOFIX)));\ 0; })#define GET_UNALIGN_CTL(task,value) ({ \ put_user((task_thread_info(task)->flags & (1 << TIF_UAC_NOPRINT))\ >> ALPHA_UAC_SHIFT \ | (task_thread_info(task)->flags & (1 << TIF_UAC_SIGBUS))\ >> (ALPHA_UAC_SHIFT + 1) \ | (task_thread_info(task)->flags & (1 << TIF_UAC_NOFIX))\ >> (ALPHA_UAC_SHIFT - 1), \ (int __user *)(value)); \ })The macros SET_UNALIGN_CTL/GET_UNALIGN_CTL are used only in kernel/sys.c:prctl syscall.
Quoted 1 line
| (((value) <<
ALPHA_UAC_SHIFT) & (1<<TIF_UAC_NOPRINT))
prctl.h: # definePR_UNALIGN_NOPRINT1Quoted 1 line
| (((value) << (
ALPHA_UAC_SHIFT+ 1)) & (1<<TIF_UAC_SIGBUS))
Quoted 8 lines
prctl.h: # definePR_UNALIGN_SIGBUS2Quoted 1 line
| (((value) << (
ALPHA_UAC_SHIFT- 1)) & (1<<TIF_UAC_NOFIX)));
prctl.h: no '4' valueDo you think it's worth adding to userspace interface
or should one just remove it from handled by prctl flags [ABI change]?
My understanding is that user-space ABI changes/removals are unacceptable. It has been there for some time thus must remain.
But I do note that the NOFIX option is not documented in the prctl syscall man page or in the prctl application man page, so only someone acquainted with the kernel code would know it exists.
My feeling is that it should stay the way it is. I'm not aware of a use for the NOFIX option, and I have no idea why it was originally implemented -- its implementation predates git history.
But others more familiar with early development of Alpha arch code may disagree with me.
Cheers
Michael.