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 3/5] target-microblaze: Allow the stack protection to be disabled
Date: Tue, 26 May 2015 11:55:40 +1000 [thread overview]
Message-ID: <CAKmqyKPhuRGD8PFsR9eUx3tOS+26-xsE4NvoVbaBMzXKF-LUvQ@mail.gmail.com> (raw)
In-Reply-To: <CAEgOgz7CWihc96+hzcHyXF1aqHNA4Oj5--E2Jj_tf_C=qt-4YA@mail.gmail.com>
On Mon, May 25, 2015 at 2:07 PM, Peter Crosthwaite
<peter.crosthwaite@xilinx.com> wrote:
> On Mon, May 18, 2015 at 4:13 PM, Alistair Francis
> <alistair.francis@xilinx.com> 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 <alistair.francis@xilinx.com>
>> ---
>> Changes since RFC:
>> - Move the cfg.stackproc check into translate.c
>> - Set the PVR register
>>
>> target-microblaze/cpu-qom.h | 5 +++++
>> target-microblaze/cpu.c | 5 +++++
>> target-microblaze/cpu.h | 1 +
>> target-microblaze/translate.c | 2 +-
>> 4 files changed, 12 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;
>
> stackprot? Although should we just verbatim match to the TRMs name for
> these variables (dropping the redundant leading C_)? That would make
> this "use_stack_protection" and match to QOM property name exactly.
I think "use_stack_protection" is too long, it makes it harder to stay under
the 80 characters for each line.
I'll change it to 'stackprot' though.
>
>> + } cfg;
>> +
>> CPUMBState env;
>> } MicroBlazeCPU;
>>
>> diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c
>> index 555bc4c..4deb256 100644
>> --- a/target-microblaze/cpu.c
>> +++ b/target-microblaze/cpu.c
>> @@ -117,6 +117,9 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
>> | PVR2_USE_FPU2_MASK \
>> | PVR2_FPU_EXC_MASK \
>> | 0;
>> +
>> + env->pvr.regs[0] |= (cpu->cfg.stackproc ? PVR0_SPROT_MASK : 0);
>> +
>
> Parentheses not needed.
True, but then they get re-added in the next patch as more
configuration variables get added.
I can remove them from this one.
>
>> env->pvr.regs[10] = 0x0c000000; /* Default to spartan 3a dsp family. */
>> env->pvr.regs[11] = PVR11_USE_MMU | (16 << 17);
>>
>> @@ -159,6 +162,8 @@ static const VMStateDescription vmstate_mb_cpu = {
>>
>> static Property mb_properties[] = {
>> DEFINE_PROP_UINT32("xlnx.base-vectors", MicroBlazeCPU, base_vectors, 0),
>> + DEFINE_PROP_BOOL("use-stack-protection", MicroBlazeCPU, cfg.stackproc,
>> + true),
>> DEFINE_PROP_END_OF_LIST(),
>> };
>>
>> diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h
>> index e4c1cde..481f463 100644
>> --- a/target-microblaze/cpu.h
>> +++ b/target-microblaze/cpu.h
>> @@ -128,6 +128,7 @@ typedef struct CPUMBState CPUMBState;
>> #define PVR0_FAULT 0x00100000
>> #define PVR0_VERSION_MASK 0x0000FF00
>> #define PVR0_USER1_MASK 0x000000FF
>> +#define PVR0_SPROT_MASK 0x00000001
>>
>> /* User 2 PVR mask */
>> #define PVR1_USER2_MASK 0xFFFFFFFF
>> diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
>> index 4068946..19faf40 100644
>> --- a/target-microblaze/translate.c
>> +++ b/target-microblaze/translate.c
>> @@ -862,7 +862,7 @@ static inline TCGv *compute_ldst_addr(DisasContext *dc, TCGv *t)
>> int stackprot = 0;
>>
>> /* All load/stores use ra. */
>> - if (dc->ra == 1) {
>> + if (dc->ra == 1 && dc->cpu->cfg.stackproc) {
>
> There is a similar logic below for dc->rb:
>
> if (dc->rb == 1) {
> stackprot = 1;
> }
>
> Should it have the same guard?
Yes, it should. I just missed that one.
Thanks,
Alistair
>
> Regards,
> Peter
>
>> stackprot = 1;
>> }
>>
>> --
>> 1.7.1
>>
>>
>
next prev parent reply other threads:[~2015-05-26 1:56 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
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 [this message]
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=CAKmqyKPhuRGD8PFsR9eUx3tOS+26-xsE4NvoVbaBMzXKF-LUvQ@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).