diff mbox series

[v4,6/7] include: sbi: add emulate_load/store handler to platform ops

Message ID 1709692540-77803-7-git-send-email-ganboing@gmail.com
State Accepted
Headers show
Series Allow platform to handle load/store faults | expand

Commit Message

Bo Gan March 6, 2024, 2:35 a.m. UTC
This patch allows the platform to define load/store emulators. This
enables a platform to trap-and-emulate special devices or filter
access to existing physical devices.

Signed-off-by: Bo Gan <ganboing@gmail.com>
---
 include/sbi/sbi_platform.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Anup Patel March 11, 2024, 4:18 a.m. UTC | #1
On Wed, Mar 6, 2024 at 8:06 AM Bo Gan <ganboing@gmail.com> wrote:
>
> This patch allows the platform to define load/store emulators. This
> enables a platform to trap-and-emulate special devices or filter
> access to existing physical devices.
>
> Signed-off-by: Bo Gan <ganboing@gmail.com>

LGTM.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup

> ---
>  include/sbi/sbi_platform.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
> index 2fb33e1..f962aa4 100644
> --- a/include/sbi/sbi_platform.h
> +++ b/include/sbi/sbi_platform.h
> @@ -53,6 +53,7 @@ struct sbi_domain_memregion;
>  struct sbi_ecall_return;
>  struct sbi_trap_regs;
>  struct sbi_hart_features;
> +union sbi_ldst_data;
>
>  /** Possible feature flags of a platform */
>  enum sbi_platform_features {
> @@ -139,6 +140,13 @@ struct sbi_platform_operations {
>         int (*vendor_ext_provider)(long funcid,
>                                    struct sbi_trap_regs *regs,
>                                    struct sbi_ecall_return *out);
> +
> +       /** platform specific handler to fixup load fault */
> +       int (*emulate_load)(int rlen, unsigned long addr,
> +                           union sbi_ldst_data *out_val);
> +       /** platform specific handler to fixup store fault */
> +       int (*emulate_store)(int wlen, unsigned long addr,
> +                            union sbi_ldst_data in_val);
>  };
>
>  /** Platform default per-HART stack size for exception/interrupt handling */
> --
> 2.7.4
>
diff mbox series

Patch

diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index 2fb33e1..f962aa4 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -53,6 +53,7 @@  struct sbi_domain_memregion;
 struct sbi_ecall_return;
 struct sbi_trap_regs;
 struct sbi_hart_features;
+union sbi_ldst_data;
 
 /** Possible feature flags of a platform */
 enum sbi_platform_features {
@@ -139,6 +140,13 @@  struct sbi_platform_operations {
 	int (*vendor_ext_provider)(long funcid,
 				   struct sbi_trap_regs *regs,
 				   struct sbi_ecall_return *out);
+
+	/** platform specific handler to fixup load fault */
+	int (*emulate_load)(int rlen, unsigned long addr,
+			    union sbi_ldst_data *out_val);
+	/** platform specific handler to fixup store fault */
+	int (*emulate_store)(int wlen, unsigned long addr,
+			     union sbi_ldst_data in_val);
 };
 
 /** Platform default per-HART stack size for exception/interrupt handling */