Skip to content

Commit fea966f

Browse files
Stuart Menefypmundt
authored andcommitted
sh: Remove implicit sign extension from assembler immediates
The SH instruction set has several instructions which accept an 8 bit immediate operand. For logical instructions this operand is zero extended, for arithmetic instructions the operand is sign extended. After adding an option to the assembler to check this, it was found that several pieces of assembly code were assuming this behaviour, and in one case getting it wrong. So this patch explicitly sign extends any immediate operands, which makes it obvious what is happening, and fixes the one case which got it wrong. Signed-off-by: Stuart Menefy <stuart.menefy@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent d724a9c commit fea966f

5 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎arch/sh/boot/compressed/head_32.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ startup:
2222
bt clear_bss
2323
sub r0, r2
2424
mov.l bss_start_addr, r0
25-
mov #0xe0, r1
25+
mov #0xffffffe0, r1
2626
and r1, r0 ! align cache line
2727
mov.l text_start_addr, r3
2828
mov r0, r1

‎arch/sh/include/asm/entry-macros.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.endm
88

99
.macro sti
10-
mov #0xf0, r11
10+
mov #0xfffffff0, r11
1111
extu.b r11, r11
1212
not r11, r11
1313
stc sr, r10

‎arch/sh/kernel/cpu/sh3/entry.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ restore_all:
257257
!
258258
! Calculate new SR value
259259
mov k3, k2 ! original SR value
260-
mov #0xf0, k1
260+
mov #0xfffffff0, k1
261261
extu.b k1, k1
262262
not k1, k1
263263
and k1, k2 ! Mask original SR value

‎arch/sh/kernel/entry-common.S‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ need_resched:
9898

9999
mov #OFF_SR, r0
100100
mov.l @(r0,r15), r0 ! get status register
101-
and #0xf0, r0 ! interrupts off (exception path)?
102-
cmp/eq #0xf0, r0
101+
shlr r0
102+
and #(0xf0>>1), r0 ! interrupts off (exception path)?
103+
cmp/eq #(0xf0>>1), r0
103104
bt noresched
104105
mov.l 3f, r0
105106
jsr @r0 ! call preempt_schedule_irq

‎arch/sh/lib/clear_page.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ENTRY(clear_page)
5757
ENTRY(__clear_user)
5858
!
5959
mov #0, r0
60-
mov #0xe0, r1 ! 0xffffffe0
60+
mov #0xffffffe0, r1
6161
!
6262
! r4..(r4+31)&~32 -------- not aligned [ Area 0 ]
6363
! (r4+31)&~32..(r4+r5)&~32 -------- aligned [ Area 1 ]

0 commit comments

Comments
 (0)