On 28 February 2013 17:30, Anthony Green <gr...@moxielogic.com> wrote:
> On Thu, Feb 28, 2013 at 6:06 AM, Peter Maydell <peter.mayd...@linaro.org> 
> wrote:
>> On 27 February 2013 22:09, Anthony Green <gr...@moxielogic.com> wrote:
>>> +        case 0x31: /* div.l */
>>> +            {
>>> +                int a = (opcode >> 4) & 0xf;
>>> +                int b = opcode & 0xf;
>>> +                tcg_gen_div_i32(REG(a), REG(a), REG(b));
>>
>> Didn't Richard mention the problem of exceptions on division
>> in review of an earlier version of this patch?
>
> Current hardware doesn't trap on divide by zero, so I don't mind this
> failing now.  The exception processing mechanism will be implemented
> soon at which time I'll clean this up.

No, you must avoid generating TCG code which can do undefined
things, even if your CPU's divide instruction does not throw
an exception. In fact, especially if your CPU's divide insn
doesn't throw an exception. Otherwise QEMU could just blow up
when trying to execute buggy or malicious guest code.

-- PMM

Reply via email to