Skip to content

cmd/asm: riscv64 assembler does not check the shift amount input #57755

@wdvxdr1123

Description

@wdvxdr1123

What did you do?

TEXT ·SLLI128(SB),NOSPLIT,$0-0
	MOV	rs+0(FP), A1
	SLLI	$128, A1, A2
	MOV	A2, rd+8(FP)
	RET

compile this assembly code with GOARCH=riscv64.

What did you expect to see?

got a error shift amount out of range 0 to 63

What did you see instead?

assemble successfully but got a illegal instruction fault in run time.

SIGILL: illegal instruction
PC=0x6494c m=0 sigcode=1
instruction bytes: 0x13 0x96 0x5 0x8 0x23 0x38 0xc1 0x0 0x67 0x80 0x0 0x0 0x0 0x0 0x0 0x0

goroutine 1 [running]:
main.SLLI128(0x1)
	riscv1/asm.s:9 +0x4 fp=0x3f84032768 sp=0x3f84032768 pc=0x6494c
main.main()
	riscv1/main.go:52 +0x28 fp=0x3f84032780 sp=0x3f84032768 pc=0x64928
runtime.main()
	runtime/proc.go:250 +0x218 fp=0x3f840327d8 sp=0x3f84032780 pc=0x3dcd8
runtime.goexit()
	runtime/asm_riscv64.s:512 +0x4 fp=0x3f840327d8 sp=0x3f840327d8 pc=0x61e7c

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions