All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: peter.crosthwaite@xilinx.com, qemu-devel@nongnu.org,
	afaerber@suse.de, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v2 3/5] target-microblaze: Allow the stack protection to be disabled/enabled
Date: Thu, 28 May 2015 16:17:33 +1000	[thread overview]
Message-ID: <20150528061733.GQ30952@toto> (raw)
In-Reply-To: <84e456db1be3f771dea4020092662a9e80c4cf54.1432790821.git.alistair.francis@xilinx.com>

On Thu, May 28, 2015 at 03:37:42PM +1000, Alistair Francis wrote:
> Microblaze stack protection is configurable and isn't always enabled.
> This patch allows the stack protection to be disabled/enabled from the
> CPU properties.
> 
> The stack protection is disabled by default as by default the Microblaze
> machines enable the MMU and stack protection can't be enabled if the
> MMU is.
> 
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>

Hi Alistair,


> ---
> V2:
>  - Change the variable name to stackprot
>  - Include protection for the second time stack protection
>    is enabled
>  - Disable stack protection by default
> 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 |    4 ++--
>  4 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/target-microblaze/cpu-qom.h b/target-microblaze/cpu-qom.h
> index e3e0701..e08adb9 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 stackprot;
> +    } cfg;
> +
>      CPUMBState env;
>  } MicroBlazeCPU;
>  
> diff --git a/target-microblaze/cpu.c b/target-microblaze/cpu.c
> index 95be540..ead2fcd 100644
> --- a/target-microblaze/cpu.c
> +++ b/target-microblaze/cpu.c
> @@ -114,6 +114,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.stackprot ? PVR0_SPROT_MASK : 0);

Could you please skip the parentheses.

> +
>      env->pvr.regs[10] = 0x0c000000; /* Default to spartan 3a dsp family.  */
>      env->pvr.regs[11] = PVR11_USE_MMU | (16 << 17);
>  
> @@ -156,6 +159,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.stackprot,
> +                     false),

I think the change to default false should be done in a separate patch
as it changes the function behaviour of the default CPU.




>      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..bd10b40 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.stackprot) {
>          stackprot = 1;
>      }
>  
> @@ -875,7 +875,7 @@ static inline TCGv *compute_ldst_addr(DisasContext *dc, TCGv *t)
>              return &cpu_R[dc->ra];
>          }
>  
> -        if (dc->rb == 1) {
> +        if (dc->rb == 1 && dc->cpu->cfg.stackprot) {
>              stackprot = 1;
>          }
>  
> -- 
> 1.7.1
> 

  reply	other threads:[~2015-05-28  6:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28  5:35 [Qemu-devel] [PATCH v2 0/5] Add Microblaze configuration options Alistair Francis
2015-05-28  5:36 ` [Qemu-devel] [PATCH v2 1/5] target-microblaze: Fix up indentation Alistair Francis
2015-05-28  6:33   ` Edgar E. Iglesias
2015-05-28  5:37 ` [Qemu-devel] [PATCH v2 2/5] target-microblaze: Preserve the pvr registers during reset Alistair Francis
2015-05-28  6:42   ` Edgar E. Iglesias
2015-05-28  5:37 ` [Qemu-devel] [PATCH v2 3/5] target-microblaze: Allow the stack protection to be disabled/enabled Alistair Francis
2015-05-28  6:17   ` Edgar E. Iglesias [this message]
2015-05-29  5:35     ` Alistair Francis
2015-05-29  5:39       ` Alistair Francis
2015-05-29  5:42         ` Edgar E. Iglesias
2015-05-29  5:51           ` Alistair Francis
2015-05-28  5:38 ` [Qemu-devel] [PATCH v2 4/5] target-microblaze: Tidy up the base-vectors property Alistair Francis
2015-05-28  5:38 ` [Qemu-devel] [PATCH v2 5/5] target-microblaze: Convert use-fpu to a CPU property Alistair Francis
2015-05-28  6:25   ` Edgar E. Iglesias
2015-05-29  5:50     ` 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=20150528061733.GQ30952@toto \
    --to=edgar.iglesias@xilinx.com \
    --cc=afaerber@suse.de \
    --cc=alistair.francis@xilinx.com \
    --cc=peter.crosthwaite@xilinx.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.