qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v1 2/3] target-microblaze: Allow the stack protect


From: Alistair Francis
Subject: Re: [Qemu-devel] [RFC v1 2/3] target-microblaze: Allow the stack protection to be disabled
Date: Fri, 15 May 2015 16:51:17 +1000

On Fri, May 15, 2015 at 3:26 PM, Peter Crosthwaite
<address@hidden> wrote:
> On Wed, May 13, 2015 at 11:08 PM, Alistair Francis
> <address@hidden> wrote:
>> Microblaze stack protection is configurable and isn't always enabled.
>> This patch allows the stack protection to be disabled from the CPU
>> properties.
>>
>> Signed-off-by: Alistair Francis <address@hidden>
>> ---
>>
>>  target-microblaze/cpu-qom.h   |    5 +++++
>>  target-microblaze/cpu.c       |    2 ++
>>  target-microblaze/op_helper.c |    4 +++-
>>  3 files changed, 10 insertions(+), 1 deletions(-)
>>
>> diff --git a/target-microblaze/cpu-qom.h b/target-microblaze/cpu-qom.h
>> index e3e0701..7bc5b81 100644
>> --- a/target-microblaze/cpu-qom.h
>> +++ b/target-microblaze/cpu-qom.h
>> @@ -59,6 +59,11 @@ typedef struct MicroBlazeCPU {
>>      uint32_t base_vectors;
>>      /*< public >*/
>>
>> +    /* Microblaze Configuration Settings */
>> +    struct {
>> +        bool stackproc;
>> +    } cfg;
>> +
>>      CPUMBState env;
>>  } MicroBlazeCPU;
>>
>> diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c
>> index 67e3182..c08da19 100644
>> --- a/target-microblaze/cpu.c
>> +++ b/target-microblaze/cpu.c
>> @@ -152,6 +152,8 @@ static const VMStateDescription vmstate_mb_cpu = {
>>
>>  static Property mb_properties[] = {
>>      DEFINE_PROP_UINT32("xlnx.base-vectors", MicroBlazeCPU, base_vectors, 0),
>> +    DEFINE_PROP_BOOL("xlnx.use-stack-protection", MicroBlazeCPU, 
>> cfg.stackproc,
>> +                     true),
>
> This should deposit (at realize time) into pvr[0].SPROT bit.

Thanks Peter. I will add that.

Thanks,

Alistair

>
> Regards,
> Peter
>
>>      DEFINE_PROP_END_OF_LIST(),
>>  };
>>
>> diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c
>> index d2b3624..24df538 100644
>> --- a/target-microblaze/op_helper.c
>> +++ b/target-microblaze/op_helper.c
>> @@ -467,7 +467,9 @@ void helper_memalign(CPUMBState *env, uint32_t addr, 
>> uint32_t dr, uint32_t wr,
>>
>>  void helper_stackprot(CPUMBState *env, uint32_t addr)
>>  {
>> -    if (addr < env->slr || addr > env->shr) {
>> +    MicroBlazeCPU *cpu = mb_env_get_cpu(env);
>> +
>> +    if (cpu->cfg.stackproc && (addr < env->slr || addr > env->shr)) {
>>          qemu_log("Stack protector violation at %x %x %x\n",
>>                   addr, env->slr, env->shr);
>>          env->sregs[SR_EAR] = addr;
>> --
>> 1.7.1
>>
>>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]