* [PATCH v2, resend] arm: properly range check immediate operands of VSHL and VQSHL
@ 2015-01-08 11:55 Jan Beulich
2015-01-09 19:18 ` Nicholas Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2015-01-08 11:55 UTC (permalink / raw)
To: binutils; +Cc: Richard Earnshaw, Nick Clifton
[-- Attachment #1: Type: text/plain, Size: 4016 bytes --]
These two, other than VQSHLU, didn't have their immediates properly range
checked so far.
(Re-sending unchanged from the original v2 due to never having got an
answer to https://sourceware.org/ml/binutils/2013-04/msg00121.html.)
gas/
2015-01-08 Jan Beulich <jbeulich@suse.com>
* gas/config/tc-arm.c (do_neon_shl_imm): Check immediate range.
(do_neon_qshl_imm): Likewise.
gas/testsuite/
2015-01-08 Jan Beulich <jbeulich@suse.com>
* gas/arm/neon-addressing-bad.s: Add test for invalid VSHL,
VQSHL, and VQSHLU immediates.
* gas/arm/neon-addressing-bad.l: Update accordingly.
--- 2015-01-08/gas/config/tc-arm.c 2015-01-07 09:38:02.000000000 +0100
+++ 2015-01-08/gas/config/tc-arm.c 2015-01-08 12:45:59.000000000 +0100
@@ -14102,8 +14102,12 @@ do_neon_shl_imm (void)
{
enum neon_shape rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
struct neon_type_el et = neon_check_type (2, rs, N_EQK, N_KEY | N_I_ALL);
+ int imm = inst.operands[2].imm;
+
+ constraint (imm < 0 || (unsigned)imm >= et.size,
+ _("immediate out of range for shift"));
NEON_ENCODE (IMMED, inst);
- neon_imm_shift (FALSE, 0, neon_quad (rs), et, inst.operands[2].imm);
+ neon_imm_shift (FALSE, 0, neon_quad (rs), et, imm);
}
else
{
@@ -14134,10 +14138,12 @@ do_neon_qshl_imm (void)
{
enum neon_shape rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
struct neon_type_el et = neon_check_type (2, rs, N_EQK, N_SU_ALL | N_KEY);
+ int imm = inst.operands[2].imm;
+ constraint (imm < 0 || (unsigned)imm >= et.size,
+ _("immediate out of range for shift"));
NEON_ENCODE (IMMED, inst);
- neon_imm_shift (TRUE, et.type == NT_unsigned, neon_quad (rs), et,
- inst.operands[2].imm);
+ neon_imm_shift (TRUE, et.type == NT_unsigned, neon_quad (rs), et, imm);
}
else
{
--- 2015-01-08/gas/testsuite/gas/arm/neon-addressing-bad.l 2013-10-04 10:37:17.000000000 +0200
+++ 2015-01-08/gas/testsuite/gas/arm/neon-addressing-bad.l 2015-01-08 12:45:59.000000000 +0100
@@ -25,3 +25,15 @@
[^:]*:29: Error: r15 not allowed here -- `vst1.8 {Q1},R0'
[^:]*:30: Error: r15 not allowed here -- `vst1.8 {D0},\[PC\]'
[^:]*:31: Error: r15 not allowed here -- `vst1.8 {D0},\[PC,#0\]'
+[^:]*:34: Error: immediate out of range for shift -- `vshl.i8 d0,d0,#8'
+[^:]*:36: Error: immediate out of range for shift -- `vshl.i16 d0,d0,#16'
+[^:]*:38: Error: immediate out of range for shift -- `vshl.i32 d0,d0,#32'
+[^:]*:40: Error: .* -- `vshl.i64 d0,d0,#64'
+[^:]*:43: Error: immediate out of range for shift -- `vqshl.s8 d0,d0,#8'
+[^:]*:45: Error: immediate out of range for shift -- `vqshl.s16 d0,d0,#16'
+[^:]*:47: Error: immediate out of range for shift -- `vqshl.s32 d0,d0,#32'
+[^:]*:49: Error: .* -- `vqshl.s64 d0,d0,#64'
+[^:]*:52: Error: immediate out of range for shift -- `vqshlu.s8 d0,d0,#8'
+[^:]*:54: Error: immediate out of range for shift -- `vqshlu.s16 d0,d0,#16'
+[^:]*:56: Error: immediate out of range for shift -- `vqshlu.s32 d0,d0,#32'
+[^:]*:58: Error: .* -- `vqshlu.s64 d0,d0,#64'
--- 2015-01-08/gas/testsuite/gas/arm/neon-addressing-bad.s 2013-10-04 10:37:17.000000000 +0200
+++ 2015-01-08/gas/testsuite/gas/arm/neon-addressing-bad.s 2015-01-08 12:45:59.000000000 +0100
@@ -29,3 +29,30 @@ VST1.8 {D0}, R0
VST1.8 {Q1}, R0
VST1.8 {D0}, [PC]
VST1.8 {D0}, [PC, #0]
+
+VSHL.I8 d0, d0, #7
+VSHL.I8 d0, d0, #8
+VSHL.I16 d0, d0, #15
+VSHL.I16 d0, d0, #16
+VSHL.I32 d0, d0, #31
+VSHL.I32 d0, d0, #32
+VSHL.I64 d0, d0, #63
+VSHL.I64 d0, d0, #64
+
+VQSHL.S8 d0, d0, #7
+VQSHL.S8 d0, d0, #8
+VQSHL.S16 d0, d0, #15
+VQSHL.S16 d0, d0, #16
+VQSHL.S32 d0, d0, #31
+VQSHL.S32 d0, d0, #32
+VQSHL.S64 d0, d0, #63
+VQSHL.S64 d0, d0, #64
+
+VQSHLU.S8 d0, d0, #7
+VQSHLU.S8 d0, d0, #8
+VQSHLU.S16 d0, d0, #15
+VQSHLU.S16 d0, d0, #16
+VQSHLU.S32 d0, d0, #31
+VQSHLU.S32 d0, d0, #32
+VQSHLU.S64 d0, d0, #63
+VQSHLU.S64 d0, d0, #64
[-- Attachment #2: binutils-master-arm-vshift-immediate.patch --]
[-- Type: text/plain, Size: 4076 bytes --]
arm: properly range check immediate operands of VSHL and VQSHL
These two, other than VQSHLU, didn't have their immediates properly range
checked so far.
(Re-sending unchanged from the original v2 due to never having got an
answer to https://sourceware.org/ml/binutils/2013-04/msg00121.html.)
gas/
2015-01-08 Jan Beulich <jbeulich@suse.com>
* gas/config/tc-arm.c (do_neon_shl_imm): Check immediate range.
(do_neon_qshl_imm): Likewise.
gas/testsuite/
2015-01-08 Jan Beulich <jbeulich@suse.com>
* gas/arm/neon-addressing-bad.s: Add test for invalid VSHL,
VQSHL, and VQSHLU immediates.
* gas/arm/neon-addressing-bad.l: Update accordingly.
--- 2015-01-08/gas/config/tc-arm.c 2015-01-07 09:38:02.000000000 +0100
+++ 2015-01-08/gas/config/tc-arm.c 2015-01-08 12:45:59.000000000 +0100
@@ -14102,8 +14102,12 @@ do_neon_shl_imm (void)
{
enum neon_shape rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
struct neon_type_el et = neon_check_type (2, rs, N_EQK, N_KEY | N_I_ALL);
+ int imm = inst.operands[2].imm;
+
+ constraint (imm < 0 || (unsigned)imm >= et.size,
+ _("immediate out of range for shift"));
NEON_ENCODE (IMMED, inst);
- neon_imm_shift (FALSE, 0, neon_quad (rs), et, inst.operands[2].imm);
+ neon_imm_shift (FALSE, 0, neon_quad (rs), et, imm);
}
else
{
@@ -14134,10 +14138,12 @@ do_neon_qshl_imm (void)
{
enum neon_shape rs = neon_select_shape (NS_DDI, NS_QQI, NS_NULL);
struct neon_type_el et = neon_check_type (2, rs, N_EQK, N_SU_ALL | N_KEY);
+ int imm = inst.operands[2].imm;
+ constraint (imm < 0 || (unsigned)imm >= et.size,
+ _("immediate out of range for shift"));
NEON_ENCODE (IMMED, inst);
- neon_imm_shift (TRUE, et.type == NT_unsigned, neon_quad (rs), et,
- inst.operands[2].imm);
+ neon_imm_shift (TRUE, et.type == NT_unsigned, neon_quad (rs), et, imm);
}
else
{
--- 2015-01-08/gas/testsuite/gas/arm/neon-addressing-bad.l 2013-10-04 10:37:17.000000000 +0200
+++ 2015-01-08/gas/testsuite/gas/arm/neon-addressing-bad.l 2015-01-08 12:45:59.000000000 +0100
@@ -25,3 +25,15 @@
[^:]*:29: Error: r15 not allowed here -- `vst1.8 {Q1},R0'
[^:]*:30: Error: r15 not allowed here -- `vst1.8 {D0},\[PC\]'
[^:]*:31: Error: r15 not allowed here -- `vst1.8 {D0},\[PC,#0\]'
+[^:]*:34: Error: immediate out of range for shift -- `vshl.i8 d0,d0,#8'
+[^:]*:36: Error: immediate out of range for shift -- `vshl.i16 d0,d0,#16'
+[^:]*:38: Error: immediate out of range for shift -- `vshl.i32 d0,d0,#32'
+[^:]*:40: Error: .* -- `vshl.i64 d0,d0,#64'
+[^:]*:43: Error: immediate out of range for shift -- `vqshl.s8 d0,d0,#8'
+[^:]*:45: Error: immediate out of range for shift -- `vqshl.s16 d0,d0,#16'
+[^:]*:47: Error: immediate out of range for shift -- `vqshl.s32 d0,d0,#32'
+[^:]*:49: Error: .* -- `vqshl.s64 d0,d0,#64'
+[^:]*:52: Error: immediate out of range for shift -- `vqshlu.s8 d0,d0,#8'
+[^:]*:54: Error: immediate out of range for shift -- `vqshlu.s16 d0,d0,#16'
+[^:]*:56: Error: immediate out of range for shift -- `vqshlu.s32 d0,d0,#32'
+[^:]*:58: Error: .* -- `vqshlu.s64 d0,d0,#64'
--- 2015-01-08/gas/testsuite/gas/arm/neon-addressing-bad.s 2013-10-04 10:37:17.000000000 +0200
+++ 2015-01-08/gas/testsuite/gas/arm/neon-addressing-bad.s 2015-01-08 12:45:59.000000000 +0100
@@ -29,3 +29,30 @@ VST1.8 {D0}, R0
VST1.8 {Q1}, R0
VST1.8 {D0}, [PC]
VST1.8 {D0}, [PC, #0]
+
+VSHL.I8 d0, d0, #7
+VSHL.I8 d0, d0, #8
+VSHL.I16 d0, d0, #15
+VSHL.I16 d0, d0, #16
+VSHL.I32 d0, d0, #31
+VSHL.I32 d0, d0, #32
+VSHL.I64 d0, d0, #63
+VSHL.I64 d0, d0, #64
+
+VQSHL.S8 d0, d0, #7
+VQSHL.S8 d0, d0, #8
+VQSHL.S16 d0, d0, #15
+VQSHL.S16 d0, d0, #16
+VQSHL.S32 d0, d0, #31
+VQSHL.S32 d0, d0, #32
+VQSHL.S64 d0, d0, #63
+VQSHL.S64 d0, d0, #64
+
+VQSHLU.S8 d0, d0, #7
+VQSHLU.S8 d0, d0, #8
+VQSHLU.S16 d0, d0, #15
+VQSHLU.S16 d0, d0, #16
+VQSHLU.S32 d0, d0, #31
+VQSHLU.S32 d0, d0, #32
+VQSHLU.S64 d0, d0, #63
+VQSHLU.S64 d0, d0, #64
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2, resend] arm: properly range check immediate operands of VSHL and VQSHL
2015-01-08 11:55 [PATCH v2, resend] arm: properly range check immediate operands of VSHL and VQSHL Jan Beulich
@ 2015-01-09 19:18 ` Nicholas Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nicholas Clifton @ 2015-01-09 19:18 UTC (permalink / raw)
To: Jan Beulich, binutils; +Cc: Richard Earnshaw
Hi Jan,
> gas/
> 2015-01-08 Jan Beulich <jbeulich@suse.com>
>
> * gas/config/tc-arm.c (do_neon_shl_imm): Check immediate range.
> (do_neon_qshl_imm): Likewise.
>
> gas/testsuite/
> 2015-01-08 Jan Beulich <jbeulich@suse.com>
>
> * gas/arm/neon-addressing-bad.s: Add test for invalid VSHL,
> VQSHL, and VQSHLU immediates.
> * gas/arm/neon-addressing-bad.l: Update accordingly.
Approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-09 19:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-08 11:55 [PATCH v2, resend] arm: properly range check immediate operands of VSHL and VQSHL Jan Beulich
2015-01-09 19:18 ` Nicholas Clifton
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 read-only IMAP folder(s) and NNTP newsgroup(s).