qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@xilinx.com>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Richard Henderson" <rth@twiddle.net>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	"Andreas Färber" <afaerber@suse.de>,
	"Alistair Francis" <alistair.francis@xilinx.com>
Subject: Re: [Qemu-devel] [PATCH RESEND v1 2/5] target-microblaze: Preserve the pvr registers during reset
Date: Thu, 28 May 2015 10:47:08 +1000	[thread overview]
Message-ID: <CAKmqyKOvL85cbCa4N3JTCZ7iy3pvGx=2p-JaRrTmT7SDaQJifg@mail.gmail.com> (raw)
In-Reply-To: <CAEgOgz4OSpeZm65STGGvLqfOzy4UnmdpUvhFX=v7h95iWqA_wQ@mail.gmail.com>

On Mon, May 25, 2015 at 1:53 PM, Peter Crosthwaite
<peter.crosthwaite@xilinx.com> wrote:
> On Mon, May 18, 2015 at 4:13 PM, Alistair Francis
> <alistair.francis@xilinx.com> wrote:
>> Move the Microblaze PVR registers to the end of the CPUMBState
>> and preserve them during reset. This is similar to what the
>> QEMU ARM model does with some of it's registers.
>>
>> This allows the Microblaze PVR registers to only be set once
>> at realise instead of constantly at reset.
>>
>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>> ---
>>
>> NOTE: The individial machine resets still write to the PVR
>> registers on each reset. This is no longer required as it only
>> needs to be done once. Instead of moving them now, they are
>> being left there and will be removed when they are all
>> converted to the standard CPU properties.
>>
>>  target-microblaze/cpu.c |   43 +++++++++++++++++++++++++------------------
>>  target-microblaze/cpu.h |   10 ++++++----
>>  2 files changed, 31 insertions(+), 22 deletions(-)
>>
>> diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c
>> index 67e3182..555bc4c 100644
>> --- a/target-microblaze/cpu.c
>> +++ b/target-microblaze/cpu.c
>> @@ -63,13 +63,37 @@ static void mb_cpu_reset(CPUState *s)
>>
>>      mcc->parent_reset(s);
>>
>> -    memset(env, 0, sizeof(CPUMBState));
>> +    memset(env, 0, offsetof(CPUMBState, pvr));
>>      env->res_addr = RES_ADDR_NONE;
>>      tlb_flush(s, 1);
>>
>>      /* Disable stack protector.  */
>>      env->shr = ~0;
>>
>> +#if defined(CONFIG_USER_ONLY)
>> +    /* start in user mode with interrupts enabled.  */
>> +    env->sregs[SR_MSR] = MSR_EE | MSR_IE | MSR_VM | MSR_UM;
>> +#else
>> +    env->sregs[SR_MSR] = 0;
>> +    mmu_init(&env->mmu);
>> +    env->mmu.c_mmu = 3;
>> +    env->mmu.c_mmu_tlb_access = 3;
>> +    env->mmu.c_mmu_zones = 16;
>> +#endif
>> +}
>> +
>> +static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
>> +{
>> +    CPUState *cs = CPU(dev);
>> +    MicroBlazeCPUClass *mcc = MICROBLAZE_CPU_GET_CLASS(dev);
>> +    MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
>> +    CPUMBState *env = &cpu->env;
>> +
>> +    cpu_reset(cs);
>
> So git did a poor job of showing the code motion of this patch as this
> is really context. But as follow up we should consider removing this
> as realize functions should not call resets.

Yeah, it really struggled with this patch for some reason.

I can still remove them from this patch. I'm touching it anyway

>
>> +    qemu_init_vcpu(cs);
>> +
>> +    memset(&env->pvr, 0, sizeof(env->pvr));
>> +
>
> Similar, 0 memsets in realize not needed but it is ultimately just
> context with the strange way git has done this patch.

Same with this.

>
> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

Thanks

Alistair

>
> Regards,
> Peter
>
>>      env->pvr.regs[0] = PVR0_PVR_FULL_MASK \
>>                         | PVR0_USE_BARREL_MASK \
>>                         | PVR0_USE_DIV_MASK \
>> @@ -99,25 +123,8 @@ static void mb_cpu_reset(CPUState *s)
>>      env->sregs[SR_PC] = cpu->base_vectors;
>>
>>  #if defined(CONFIG_USER_ONLY)
>> -    /* start in user mode with interrupts enabled.  */
>> -    env->sregs[SR_MSR] = MSR_EE | MSR_IE | MSR_VM | MSR_UM;
>>      env->pvr.regs[10] = 0x0c000000; /* Spartan 3a dsp.  */
>> -#else
>> -    env->sregs[SR_MSR] = 0;
>> -    mmu_init(&env->mmu);
>> -    env->mmu.c_mmu = 3;
>> -    env->mmu.c_mmu_tlb_access = 3;
>> -    env->mmu.c_mmu_zones = 16;
>>  #endif
>> -}
>> -
>> -static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
>> -{
>> -    CPUState *cs = CPU(dev);
>> -    MicroBlazeCPUClass *mcc = MICROBLAZE_CPU_GET_CLASS(dev);
>> -
>> -    cpu_reset(cs);
>> -    qemu_init_vcpu(cs);
>>
>>      mcc->parent_realize(dev, errp);
>>  }
>> diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h
>> index 4ea04ac..e4c1cde 100644
>> --- a/target-microblaze/cpu.h
>> +++ b/target-microblaze/cpu.h
>> @@ -260,16 +260,18 @@ struct CPUMBState {
>>  #define IFLAGS_TB_MASK  (D_FLAG | IMM_FLAG | DRTI_FLAG | DRTE_FLAG | DRTB_FLAG)
>>      uint32_t iflags;
>>
>> -    struct {
>> -        uint32_t regs[16];
>> -    } pvr;
>> -
>>  #if !defined(CONFIG_USER_ONLY)
>>      /* Unified MMU.  */
>>      struct microblaze_mmu mmu;
>>  #endif
>>
>>      CPU_COMMON
>> +
>> +    /* These fields are preserved on reset.  */
>> +
>> +    struct {
>> +        uint32_t regs[16];
>> +    } pvr;
>>  };
>>
>>  #include "cpu-qom.h"
>> --
>> 1.7.1
>>
>>
>

  reply	other threads:[~2015-05-28  0:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18  1:13 [Qemu-devel] [PATCH v1 0/5] Add Microblaze configuration options Alistair Francis
2015-05-18  1:13 ` [Qemu-devel] [PATCH v1 1/5] target-microblaze: Fix up indentation Alistair Francis
2015-05-25  3:44   ` [Qemu-devel] [PATCH RESEND " Peter Crosthwaite
2015-05-28  0:37     ` Alistair Francis
2015-05-18  1:13 ` [Qemu-devel] [PATCH v1 2/5] target-microblaze: Preserve the pvr registers during reset Alistair Francis
2015-05-25  3:53   ` [Qemu-devel] [PATCH RESEND " Peter Crosthwaite
2015-05-28  0:47     ` Alistair Francis [this message]
2015-05-18  1:13 ` [Qemu-devel] [PATCH v1 3/5] target-microblaze: Allow the stack protection to be disabled Alistair Francis
2015-05-25  4:07   ` [Qemu-devel] [PATCH RESEND " Peter Crosthwaite
2015-05-26  1:55     ` Alistair Francis
2015-05-26  1:59       ` Peter Crosthwaite
2015-05-18  1:13 ` [Qemu-devel] [PATCH v1 4/5] target-microblaze: Tidy up the base-vectors property Alistair Francis
2015-05-25  4:09   ` [Qemu-devel] [PATCH RESEND " Peter Crosthwaite
2015-05-18 23:14 ` [Qemu-devel] [PATCH RESEND v1 5/5] target-microblaze: Convert use-fpu to a CPU property Alistair Francis
2015-05-25  4:34   ` Peter Crosthwaite
2015-05-28  1:02     ` Alistair Francis
2015-05-18 23:16 ` [Qemu-devel] [PATCH RESEND v1 0/5] Add Microblaze configuration options Alistair Francis

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='CAKmqyKOvL85cbCa4N3JTCZ7iy3pvGx=2p-JaRrTmT7SDaQJifg@mail.gmail.com' \
    --to=alistair.francis@xilinx.com \
    --cc=afaerber@suse.de \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).