On 6 January 2017 at 03:27, David Gibson <[email protected]> wrote:
> On Thu, Jan 05, 2017 at 04:56:07PM +0530, Nikunj A Dadhania wrote:
>> xxinsertw: VSX Vector Insert Word
>
> I think this still has problems with out of bounds values.
>
>>
>> Signed-off-by: Nikunj A Dadhania <[email protected]>
>> ---
>> target-ppc/helper.h | 1 +
>> target-ppc/int_helper.c | 25 +++++++++++++++++++++++++
>> target-ppc/translate/vsx-impl.inc.c | 5 +++--
>> target-ppc/translate/vsx-ops.inc.c | 1 +
>> 4 files changed, 30 insertions(+), 2 deletions(-)
>>
>> +
>> +#if defined(HOST_WORDS_BIGENDIAN)
>> + ins_index = index;
>> + for (i = 0; i < es && ins_index < 16; i++, ins_index++) {
>> + xt.u8[ins_index] = xb.u8[8 - es + i];
>
> Unlike extract, you don't mod the ins_index here. Which IIUC, means
> for UIMM > 12 you will overwrite data beyond xt, which sounds like a
> very bad thing.
"ins_index < 16" in for loop will take.
>
>> + }
>> +#else
>> + ins_index = 15 - index;
>> + for (i = es - 1; i >= 0 && ins_index >= 0; i--, ins_index--) {
Here "ins_index >= 0" in for loop will take.
>> + xt.u8[ins_index] = xb.u8[8 + i];
>> + }
>> +#endif
>> +
>> + putVSR(xtn, &xt, env);
>> +}
>> +
Regards
Nikunj