From: Blue Swirl <blauwirbel@gmail.com>
To: Jia Liu <proljc@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v9 11/15] target-or32: Add system instructions
Date: Sun, 15 Jul 2012 07:54:45 +0000 [thread overview]
Message-ID: <CAAu8pHv++qaMTkOchaCGYhdrQCB_hephptegDOPZUm5jNHqa6Q@mail.gmail.com> (raw)
In-Reply-To: <CAJBMM-v2V6sMD3gq2a9yb187M_iOCf=yzz0mWHALDdpnntbh3Q@mail.gmail.com>
On Sun, Jul 15, 2012 at 12:39 AM, Jia Liu <proljc@gmail.com> wrote:
> Hi Blue
>
> On Sat, Jul 14, 2012 at 10:42 PM, Blue Swirl <blauwirbel@gmail.com> wrote:
>> On Sat, Jul 14, 2012 at 2:08 PM, Jia Liu <proljc@gmail.com> wrote:
>>> Hi Max
>>>
>>> On Sat, Jul 14, 2012 at 9:49 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>>>>>> I don't think so, please check for example target-ppc/translate.c:4192
>>>>>> on how supervisor only mfsr is handled there.
>>>>>>
>>>>>
>>>>> Thank you for comment, Blue.
>>>>>
>>>>> is this code OK?
>>>>
>>>> Shouldn't there also be an exception in softmmu mode
>>>> if the CPU is not in supervisor mode?
>>>>
>>>
>>> Sorry, I...
>>> May you give me more comment? I'm not sure about this.
>>
>> If a user tries to execute a supervisor instruction (only allowed for
>> kernel level code, not applications), the instruction won't be
>> executed but an exception will be raised.
>>
>> This is the PPC mfsr instruction part of target-ppc/translate.c:
>> /* mfsr */
>> static void gen_mfsr(DisasContext *ctx)
>> {
>> #if defined(CONFIG_USER_ONLY)
>> gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
>> #else
>> TCGv t0;
>> if (unlikely(!ctx->mem_idx)) {
>>
>> Here the MMU mode is checked for user mode. I'd use more explicit
>> check ctx->mmu_idx == MMU_USER_IDX.
>>
>> gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
>> return;
>> }
>> t0 = tcg_const_tl(SR(ctx->opcode));
>> gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0);
>> tcg_temp_free(t0);
>> #endif
>> }
>>
>
> Thank you very much for this nice example.
> Is this code OK?
> case 0x2d: /* l.mfspr */
> LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
> {
> #if defined(CONFIG_USER_ONLY)
> gen_illegal_exception(dc);
> #else
> TCGv_i32 ti = tcg_const_i32(I16);
> if (dc->mem_idx == MMU_USER_IDX) {
> gen_illegal_exception(dc);
> return;
> }
> gen_helper_mfspr(cpu_R[rd], cpu_env, cpu_R[rd], cpu_R[ra], ti);
> tcg_temp_free_i32(ti);
> #endif
> }
> break;
>
> case 0x30: /* l.mtspr */
> LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11);
> {
> #if defined(CONFIG_USER_ONLY)
> gen_illegal_exception(dc);
Maybe return?
> #else
> TCGv_i32 im = tcg_const_i32(tmp);
> if (dc->mem_idx == MMU_USER_IDX) {
> gen_illegal_exception(dc);
> return;
> }
> gen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);
> tcg_temp_free_i32(im);
> #endif
> }
> break;
Otherwise looks OK. Perhaps there are other supervisor mode only
instructions which need this kind of checks?
>
>
>>>
>>>>>
>>>>> case 0x2d: /* l.mfspr */
>>>>> LOG_DIS("l.mfspr r%d, r%d, %d\n", rd, ra, I16);
>>>>> {
>>>>> #if defined(CONFIG_USER_ONLY)
>>>>> gen_illegal_exception(dc);
>>>>> #else
>>>>> TCGv_i32 ti = tcg_const_i32(I16);
>>>>> gen_helper_mfspr(cpu_R[rd], cpu_env, cpu_R[rd], cpu_R[ra], ti);
>>>>> tcg_temp_free_i32(ti);
>>>>> #endif
>>>>> }
>>>>> break;
>>>>>
>>>>> case 0x30: /* l.mtspr */
>>>>> LOG_DIS("l.mtspr %d, r%d, r%d, %d\n", I5, ra, rb, I11);
>>>>> {
>>>>> #if defined(CONFIG_USER_ONLY)
>>>>> gen_illegal_exception(dc);
>>>>> #else
>>>>> TCGv_i32 im = tcg_const_i32(tmp);
>>>>> gen_helper_mtspr(cpu_env, cpu_R[ra], cpu_R[rb], im);
>>>>> tcg_temp_free_i32(im);
>>>>> #endif
>>>>> }
>>>>> break;
>>>>>
>>>>
>>>> --
>>>> Thanks.
>>>> -- Max
>>>
>>> Regards,
>>> Jia.
>
> Regards,
> Jia
next prev parent reply other threads:[~2012-07-15 7:55 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-13 4:34 [Qemu-devel] [PATCH v9 00/15] QEMU OpenRISC support Jia Liu
2012-07-13 4:34 ` [Qemu-devel] [PATCH v9 01/15] target-or32: Add target stubs and QOM cpu Jia Liu
2012-07-13 4:34 ` [Qemu-devel] [PATCH v9 02/15] target-or32: Add MMU support Jia Liu
2012-07-13 4:34 ` [Qemu-devel] [PATCH v9 03/15] target-or32: Add interrupt support Jia Liu
2012-07-13 4:34 ` [Qemu-devel] [PATCH v9 04/15] target-or32: Add exception support Jia Liu
2012-07-13 4:34 ` [Qemu-devel] [PATCH v9 05/15] target-or32: Add int instruction helpers Jia Liu
2012-07-13 9:18 ` Max Filippov
2012-07-14 11:44 ` Jia Liu
2012-07-13 4:34 ` [Qemu-devel] [PATCH v9 06/15] target-or32: Add float " Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 07/15] target-or32: Add instruction translation Jia Liu
2012-07-13 8:09 ` Peter Maydell
2012-07-13 8:26 ` Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 08/15] target-or32: Add PIC support Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 09/15] target-or32: Add timer support Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 10/15] target-or32: Add a IIS dummy board Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 11/15] target-or32: Add system instructions Jia Liu
2012-07-13 9:27 ` Max Filippov
2012-07-14 11:12 ` Jia Liu
2012-07-14 13:19 ` Blue Swirl
2012-07-14 13:39 ` Jia Liu
2012-07-14 13:49 ` Max Filippov
2012-07-14 14:08 ` Jia Liu
2012-07-14 14:42 ` Blue Swirl
2012-07-15 0:39 ` Jia Liu
2012-07-15 7:54 ` Blue Swirl [this message]
2012-07-15 13:31 ` Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 12/15] target-or32: Add gdb stub support Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 13/15] target-or32: Add linux syscall, signal and termbits Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 14/15] target-or32: Add linux user support Jia Liu
2012-07-13 4:35 ` [Qemu-devel] [PATCH v9 15/15] target-or32: Add testcases Jia Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAu8pHv++qaMTkOchaCGYhdrQCB_hephptegDOPZUm5jNHqa6Q@mail.gmail.com \
--to=blauwirbel@gmail.com \
--cc=jcmvbkbc@gmail.com \
--cc=proljc@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).