[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/4] xen/riscv: add csr_read_safe() helper





On 4/2/26 8:30 AM, Jan Beulich wrote:
On 31.03.2026 21:04, Oleksii Kurochko wrote:
@@ -78,6 +80,38 @@
                             : "memory" );                        \
  })
+static always_inline bool csr_read_safe(unsigned long csr,
+                                        unsigned long *val)
+{
+#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
+    asm_inline goto (
+        "1: csrr %[val], %[csr]\n"
+        ASM_EXTABLE(1b, %l[fault])
+        : [val] "=&r" (*val)

Why the & when there's only a single insn?

Agree, the & isn't needed here.


+        : [csr] "i" (csr)
+        :
+        : fault );
+
+    return true;
+
+ fault:
+    return false;
+#else
+    bool allowed = false;
+
+    asm_inline volatile (
+        "1: csrr %[val], %[csr]\n"
+        "   li %[allowed], 1\n"
+        "2:\n"
+        ASM_EXTABLE(1b, 2b)
+        : [val] "=&r" (*val), [allowed] "+r" (allowed)
+        : [csr] "i" (csr)
+        : );

Why the excess colon?

Missed to proper cleanup. It could be also dropped.


With these adjusted (again happy to do so while committing, so long
as you agree):

I would be happy with that.

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Thanks!

~ Oleksii



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.