mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
synced 2025-10-08 15:25:43 +10:00
powerpc/sstep: Fix array out of bound warning
Compiling kernel with -Warray-bounds throws below warning:
In function 'emulate_vsx_store':
warning: array subscript is above array bounds [-Warray-bounds]
buf.d[2] = byterev_8(reg->d[1]);
~~~~~^~~
buf.d[3] = byterev_8(reg->d[0]);
~~~~~^~~
Fix it by using temporary array variable 'union vsx_reg buf32[]' in
that code block. Also, with element_size = 32, 'union vsx_reg *reg'
is an array of size 2. So, use 'reg' as an array instead of pointer
in the same code block.
Fixes: af99da7433
("powerpc/sstep: Support VSX vector paired storage access instructions")
Suggested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210129071745.111466-1-ravi.bangoria@linux.ibm.com
This commit is contained in:
parent
4025c784c5
commit
344717a14c
@ -818,13 +818,15 @@ void emulate_vsx_store(struct instruction_op *op, const union vsx_reg *reg,
|
|||||||
break;
|
break;
|
||||||
if (rev) {
|
if (rev) {
|
||||||
/* reverse 32 bytes */
|
/* reverse 32 bytes */
|
||||||
buf.d[0] = byterev_8(reg->d[3]);
|
union vsx_reg buf32[2];
|
||||||
buf.d[1] = byterev_8(reg->d[2]);
|
buf32[0].d[0] = byterev_8(reg[1].d[1]);
|
||||||
buf.d[2] = byterev_8(reg->d[1]);
|
buf32[0].d[1] = byterev_8(reg[1].d[0]);
|
||||||
buf.d[3] = byterev_8(reg->d[0]);
|
buf32[1].d[0] = byterev_8(reg[0].d[1]);
|
||||||
reg = &buf;
|
buf32[1].d[1] = byterev_8(reg[0].d[0]);
|
||||||
|
memcpy(mem, buf32, size);
|
||||||
|
} else {
|
||||||
|
memcpy(mem, reg, size);
|
||||||
}
|
}
|
||||||
memcpy(mem, reg, size);
|
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
/* stxv, stxvx, stxvl, stxvll */
|
/* stxv, stxvx, stxvl, stxvll */
|
||||||
|
Loading…
Reference in New Issue
Block a user