Skip to contentSkip to conversation

lib: sbi: check A2 register in ecall_dbcn_handler.

PATCH New Gianluca Guida 3 participants 4 messages Jun 22, 2023 – Jun 29, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: sbi: check A2 register in ecall_dbcn_handler.

Do not ignore register A2 (high bits of physical address) in the dbcn handler (RV64).

---

The spec doesn't seem to imply that in RV64 only one paramenter will be used.

Thanks,
G.

 lib/sbi/sbi_ecall_dbcn.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/sbi/sbi_ecall_dbcn.c +5 -2
index e0b892c..ecec027 100644
@@ -34,11 +34,14 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
 		 * Based on above, we simply fail if the upper 32bits of
 		 * the physical address (i.e. a2 register) is non-zero on
 		 * RV32.
+                 *
+                 * Analogously, we fail if the upper 64bit of the
+                 * physical address (i.e. a2 register) is non-zero on
+                 * RV64.
 		 */
-#if __riscv_xlen == 32
 		if (regs->a2)
 			return SBI_ERR_FAILED;
-#endif
+
 		if (!sbi_domain_check_addr_range(sbi_domain_thishart_ptr(),
 					regs->a1, regs->a0, smode,
 					SBI_DOMAIN_READ|SBI_DOMAIN_WRITE))
Signature · 1 line
2.34.1
Applied
#1 lore raw

PATCH 1/1 lib: sbi: check A2 register in ecall_dbcn_handler.

Quoted 5 lines · On Thu, Jun 22, 2023 at 11:10?PM Gianluca Guida <[email protected]> wrote:

Do not ignore register A2 (high bits of physical address) in the dbcn handler (RV64).

Looks good to me.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 41 lines

---

The spec doesn't seem to imply that in RV64 only one paramenter will be used.

Thanks,
G.

 lib/sbi/sbi_ecall_dbcn.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/sbi/sbi_ecall_dbcn.c +5 -3
index e0b892c..ecec027 100644
@@ -34,11 +34,14 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
                 * Based on above, we simply fail if the upper 32bits of
                 * the physical address (i.e. a2 register) is non-zero on
                 * RV32.
+                 *
+                 * Analogously, we fail if the upper 64bit of the
+                 * physical address (i.e. a2 register) is non-zero on
+                 * RV64.
                 */
-#if __riscv_xlen == 32
                if (regs->a2)
                        return SBI_ERR_FAILED;
-#endif
+
                if (!sbi_domain_check_addr_range(sbi_domain_thishart_ptr(),
                                        regs->a1, regs->a0, smode,
                                        SBI_DOMAIN_READ|SBI_DOMAIN_WRITE))
--

2.34.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#2 lore raw

PATCH 1/1 lib: sbi: check A2 register in ecall_dbcn_handler.

In reply to Gianluca Guida
Quoted 21 lines · Gianluca Guida

Do not ignore register A2 (high bits of physical address) in the dbcn handler (RV64).

---

The spec doesn't seem to imply that in RV64 only one paramenter will be used.

Thanks,
G.

 lib/sbi/sbi_ecall_dbcn.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/sbi/sbi_ecall_dbcn.c +0 -0
index e0b892c..ecec027 100644

lib/sbi/sbi_ecall_dbcn.c static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid, · line 40

Quoted 7 lines
lib/sbi/sbi_ecall_dbcn.c +4 -0
@@ -34,11 +34,14 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
 		 * Based on above, we simply fail if the upper 32bits of
 		 * the physical address (i.e. a2 register) is non-zero on
 		 * RV32.
+                 *
+                 * Analogously, we fail if the upper 64bit of the
+                 * physical address (i.e. a2 register) is non-zero on
+                 * RV64.

I see I'm too late, since Anup already applied, but the above lines have leading spaces instead of tabs.

Thanks,
drew

Quoted 17 lines
lib/sbi/sbi_ecall_dbcn.c +1 -2
 		 */
-#if __riscv_xlen == 32
 		if (regs->a2)
 			return SBI_ERR_FAILED;
-#endif
+
 		if (!sbi_domain_check_addr_range(sbi_domain_thishart_ptr(),
 					regs->a1, regs->a0, smode,
 					SBI_DOMAIN_READ|SBI_DOMAIN_WRITE))
Signature · 7 lines
2.34.1


-- 
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
#3 lore raw

PATCH 1/1 lib: sbi: check A2 register in ecall_dbcn_handler.

On Sat, Jun 24, 2023 at 12:08?PM Andrew Jones <[email protected]> wrote:
[...]

Quoted 19 lines
Quoted 8 lines
 lib/sbi/sbi_ecall_dbcn.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/sbi/sbi_ecall_dbcn.c +0 -0
index e0b892c..ecec027 100644

lib/sbi/sbi_ecall_dbcn.c static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid, · line 40

Quoted 7 lines
lib/sbi/sbi_ecall_dbcn.c +4 -0
@@ -34,11 +34,14 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
               * Based on above, we simply fail if the upper 32bits of
               * the physical address (i.e. a2 register) is non-zero on
               * RV32.
+                 *
+                 * Analogously, we fail if the upper 64bit of the
+                 * physical address (i.e. a2 register) is non-zero on
+                 * RV64.

I see I'm too late, since Anup already applied, but the above lines have leading spaces instead of tabs.

I'll send a follow-up patch.

Thank you,
G.