Skip to contentSkip to conversation

sparc64 with 32-bit user-space context switching question

DISCUSSION Mikael Pettersson 2 participants 4 messages Dec 18, 2007 – Dec 19, 2007

lore
Share & tools
lore
#0 lore raw

I'd like to use the BR (branch on integer register) instruction in 32-bit user-space code on sparc64. The problem is that BR interprets the entire 64-bit contents of the register, which depending on how the value was produced may or may not do the right thing in 32-bit code.

My main question is: what does the kernel do to the high 32 bits of the 64-bit integer registers during context switches? Does it
a) preserve all 64 bits,
b) clear the high halves (truncate to 32 bits), or
c) insert unpredictable junk?

I can handle a) and b), but c) means that I cannot ever safely use BR in 32-bit userspace.

Also, does anyone know what Solaris does to the high 32 bits during context switches?

/Mikael

#1 lore raw

From: Mikael Pettersson <[email protected]>
Date: Tue, 18 Dec 2007 13:06:55 +0100

Quoted 3 lines

My main question is: what does the kernel do to the high 32 bits of the 64-bit integer registers during context switches?

Only %oX and %gX registers have the full 64-bit preserved across context switches for 32-bit processes.

The %lX and %iX registers cannot have their full 64-bits preserved because the amount of save space is fixed by the register window save area layout on the stack, which only saves 32-bit values for each register.

#2 lore raw
In reply to Mikael Pettersson

From: Mikael Pettersson <[email protected]>
Date: Tue, 18 Dec 2007 13:06:55 +0100

Quoted 2 lines

Also, does anyone know what Solaris does to the
high 32 bits during context switches?

Solaris handles things identically to Linux.

These rules are even encoded into places like the
GCC backend for sparc, when generating v9 code
for 32-bit.

#3 lore raw
In reply to Mikael Pettersson
Quoted 15 lines · David Miller

From: Mikael Pettersson <[email protected]>
Date: Tue, 18 Dec 2007 13:06:55 +0100

Quoted 3 lines

My main question is: what does the kernel do to the high 32 bits of the 64-bit integer registers during context switches?

Only %oX and %gX registers have the full 64-bit preserved across context switches for 32-bit processes.

The %lX and %iX registers cannot have their full 64-bits preserved because the amount of save space is fixed by the register window save area layout on the stack, which only saves 32-bit values for each register.

Quoted 8 lines
Quoted 2 lines

Also, does anyone know what Solaris does to the
high 32 bits during context switches?

Solaris handles things identically to Linux.

These rules are even encoded into places like the
GCC backend for sparc, when generating v9 code
for 32-bit.

Thanks, this helps.

/Mikael