From: hchauhan@ventanamicro.com <hchauhan@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH 1/9] include: sbi: Fine grain the permissions for M and SU modes
Date: Mon, 9 Jan 2023 10:13:20 +0530 [thread overview]
Message-ID: <002201d923e4$e7be14d0$b73a3e70$@ventanamicro.com> (raw)
In-Reply-To: <CAAhSdy31psyvSi6auXN+9=UnbD+-b53jd3KG9ACFO9ZxSoMw7w@mail.gmail.com>
-----Original Message-----
From: Anup Patel <anup@brainfault.org>
Sent: 06 January 2023 23:06
To: Himanshu Chauhan <hchauhan@ventanamicro.com>
Cc: opensbi at lists.infradead.org
Subject: Re: [PATCH 1/9] include: sbi: Fine grain the permissions for M and SU modes
On Tue, Dec 20, 2022 at 4:16 PM Himanshu Chauhan <hchauhan@ventanamicro.com> wrote:
>
> Split the permissions for M-mode and SU-mode. This would help if
> different sections of OpenSBI need to be given different permissions
> and if M-mode has different permisssions than the SU-mode over a
> region.
>
> Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
> ---
> include/sbi/sbi_domain.h | 40
> +++++++++++++++++++++++++++++++++++-----
> 1 file changed, 35 insertions(+), 5 deletions(-)
>
> diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index
> 5553d21..955ffa3 100644
> --- a/include/sbi/sbi_domain.h
> +++ b/include/sbi/sbi_domain.h
> @@ -36,11 +36,41 @@ struct sbi_domain_memregion {
> */
> unsigned long base;
> /** Flags representing memory region attributes */
> -#define SBI_DOMAIN_MEMREGION_READABLE (1UL << 0)
> -#define SBI_DOMAIN_MEMREGION_WRITEABLE (1UL << 1)
> -#define SBI_DOMAIN_MEMREGION_EXECUTABLE (1UL << 2)
> -#define SBI_DOMAIN_MEMREGION_MMODE (1UL << 3)
> -#define SBI_DOMAIN_MEMREGION_ACCESS_MASK (0xfUL)
> +#define SBI_DOMAIN_MEMREGION_M_READABLE (1UL << 0)
> +#define SBI_DOMAIN_MEMREGION_M_WRITABLE (1UL << 1)
> +#define SBI_DOMAIN_MEMREGION_M_EXECUTABLE (1UL << 2)
> +#define SBI_DOMAIN_MEMREGION_SU_READABLE (1UL << 3)
> +#define SBI_DOMAIN_MEMREGION_SU_WRITABLE (1UL << 4)
> +#define SBI_DOMAIN_MEMREGION_SU_EXECUTABLE (1UL << 5)
> +
> + /** Bit to control if permissions are enforced on all modes */
> +#define SBI_DOMAIN_MEMREGION_ENF_PERMISSIONS (1UL << 6)
> +
> +#define SBI_DOMAIN_MEMREGION_M_RWX (SBI_DOMAIN_MEMREGION_M_READABLE | \
> + SBI_DOMAIN_MEMREGION_M_WRITABLE | \
> +
> +SBI_DOMAIN_MEMREGION_M_EXECUTABLE)
> +
> + /* Unrestricted M-mode accesses but enfoced on SU-mode */
> +#define SBI_DOMAIN_MEMREGION_READABLE (SBI_DOMAIN_MEMREGION_SU_READABLE | \
> + SBI_DOMAIN_MEMREGION_M_RWX)
> +#define SBI_DOMAIN_MEMREGION_WRITEABLE (SBI_DOMAIN_MEMREGION_SU_WRITABLE | \
> + SBI_DOMAIN_MEMREGION_M_RWX)
> +#define SBI_DOMAIN_MEMREGION_EXECUTABLE (SBI_DOMAIN_MEMREGION_SU_EXECUTABLE | \
> +
> +SBI_DOMAIN_MEMREGION_M_RWX)
> +
> + /* Enforced accesses across all modes */
> +#define SBI_DOMAIN_MEMREGION_ENF_READABLE (SBI_DOMAIN_MEMREGION_SU_READABLE | \
> + SBI_DOMAIN_MEMREGION_M_READABLE)
> +#define SBI_DOMAIN_MEMREGION_ENF_WRITABLE (SBI_DOMAIN_MEMREGION_SU_WRITABLE | \
> + SBI_DOMAIN_MEMREGION_M_WRITABLE)
> +#define SBI_DOMAIN_MEMREGION_ENF_EXECUTABLE (SBI_DOMAIN_MEMREGION_SU_EXECUTABLE | \
> +
> +SBI_DOMAIN_MEMREGION_M_EXECUTABLE)
Small nit: Please try to keep each line within 80 characters
It becomes difficult to build upon existing macros having large names and keep the column restrictions. Only way to honour the column restriction is to shorten the new and exiting names. I believe it would be too much change. Moreover, 80 column limit comes from very old terminal types. So it may be relaxed to a more sane value like 100 or so. Just my thoughts.
I can make the changes if you think restricting them to 80 column makes more sense. But that would take change to existing macro names.
Regards
Himanshu
> +
> +#define SBI_DOMAIN_MEMREGION_ACCESS_MASK (0x3fUL)
> +#define SBI_DOMAIN_MEMREGION_M_ACCESS_MASK (0x7UL)
> +#define SBI_DOMAIN_MEMREGION_SU_ACCESS_MASK (0x38UL)
> +
> +#define SBI_DOMAIN_MEMREGION_SU_ACCESS_SHIFT (3)
>
> #define SBI_DOMAIN_MEMREGION_MMIO (1UL << 31)
> unsigned long flags;
> --
> 2.39.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
Otherwise, it looks good to me.
Reviewed-by: Anup Patel <anup@brainfault.org>
Regards,
Anup
next prev parent reply other threads:[~2023-01-09 4:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 10:46 [PATCH 0/9] Split region permissions into M-mode and SU-mode Himanshu Chauhan
2022-12-20 10:46 ` [PATCH 1/9] include: sbi: Fine grain the permissions for M and SU modes Himanshu Chauhan
2023-01-06 17:35 ` Anup Patel
2023-01-09 4:43 ` hchauhan [this message]
2023-01-09 5:19 ` Anup Patel
2022-12-20 10:46 ` [PATCH 2/9] lib: sbi: Use finer permission semantics for address validation Himanshu Chauhan
2023-01-06 17:38 ` Anup Patel
2022-12-20 10:46 ` [PATCH 3/9] lib: sbi: Add permissions for the firmware start till end Himanshu Chauhan
2023-01-06 17:44 ` Anup Patel
2022-12-20 10:46 ` [PATCH 4/9] lib: sbi: Use finer permission sematics to decide on PMP bits Himanshu Chauhan
2023-01-06 17:45 ` Anup Patel
2022-12-20 10:46 ` [PATCH 5/9] lib: sbi: Modify the boot time region flag prints Himanshu Chauhan
2023-01-06 17:47 ` Anup Patel
2022-12-20 10:46 ` [PATCH 6/9] lib: utils: Use SU-{R/W/X} flags for region permissions during parsing Himanshu Chauhan
2023-01-06 17:49 ` Anup Patel
2022-12-20 10:46 ` [PATCH 7/9] lib: utils: Disallow non-root domains from adding M-mode regions Himanshu Chauhan
2023-01-06 17:51 ` Anup Patel
2022-12-20 10:46 ` [PATCH 8/9] lib: utils: Add M-mode {R/W} flags to the MMIO regions Himanshu Chauhan
2023-01-06 17:52 ` Anup Patel
2022-12-20 10:46 ` [PATCH 9/9] docs: Update domain's region permissions and requirements Himanshu Chauhan
2023-01-06 17:54 ` Anup Patel
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='002201d923e4$e7be14d0$b73a3e70$@ventanamicro.com' \
--to=hchauhan@ventanamicro.com \
--cc=opensbi@lists.infradead.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