diff mbox series

[v2,09/39] xen/riscv: introduce asm/guest_atomics.h

Message ID 48ecbc771d3870eee86dd11a19f0dd9029e93c01.1700761381.git.oleksii.kurochko@gmail.com (mailing list archive)
State Superseded
Headers show
Series Enable build of full Xen for RISC-V | expand

Commit Message

Oleksii Kurochko Nov. 24, 2023, 10:30 a.m. UTC
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
Changes in V2:
 - Nothing changed. Only rebase.
---
 xen/arch/riscv/include/asm/guest_atomics.h | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 xen/arch/riscv/include/asm/guest_atomics.h

Comments

Jan Beulich Dec. 7, 2023, 2:20 p.m. UTC | #1
On 24.11.2023 11:30, Oleksii Kurochko wrote:
> --- /dev/null
> +++ b/xen/arch/riscv/include/asm/guest_atomics.h
> @@ -0,0 +1,48 @@
> +#ifndef __ASM_RISCV_GUEST_ATOMICS_H
> +#define __ASM_RISCV_GUEST_ATOMICS_H
> +
> +/*
> + * TODO: implement guest atomics
> + */

Along with this, wouldn't it be better to have e.g. ASSERT_UNREACHABLE()
in the unimplemented functions?

Jan

> +#define guest_testop(name)                                                  \
> +static inline int guest_##name(struct domain *d, int nr, volatile void *p)  \
> +{                                                                           \
> +    (void) d;                                                               \
> +    (void) nr;                                                              \
> +    (void) p;                                                               \
> +                                                                            \
> +    return 0;                                                               \
> +}
> +
> +#define guest_bitop(name)                                                   \
> +static inline void guest_##name(struct domain *d, int nr, volatile void *p) \
> +{                                                                           \
> +    (void) d;                                                               \
> +    (void) nr;                                                              \
> +    (void) p;                                                               \
> +}
> +
> +guest_bitop(set_bit)
> +guest_bitop(clear_bit)
> +guest_bitop(change_bit)
> +
> +#undef guest_bitop
> +
> +guest_testop(test_and_set_bit)
> +guest_testop(test_and_clear_bit)
> +guest_testop(test_and_change_bit)
> +
> +#undef guest_testop
> +
> +#define guest_test_bit(d, nr, p) ((void)(d), test_bit(nr, p))
> +
> +#endif /* __ASM_RISCV_GUEST_ATOMICS_H */
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
Oleksii Kurochko Dec. 8, 2023, 9:22 a.m. UTC | #2
On Thu, 2023-12-07 at 15:20 +0100, Jan Beulich wrote:
> On 24.11.2023 11:30, Oleksii Kurochko wrote:
> > --- /dev/null
> > +++ b/xen/arch/riscv/include/asm/guest_atomics.h
> > @@ -0,0 +1,48 @@
> > +#ifndef __ASM_RISCV_GUEST_ATOMICS_H
> > +#define __ASM_RISCV_GUEST_ATOMICS_H
> > +
> > +/*
> > + * TODO: implement guest atomics
> > + */
> 
> Along with this, wouldn't it be better to have e.g.
> ASSERT_UNREACHABLE()
> in the unimplemented functions?
Thanks for recommendation. It would be better to add
ASSERT_UNREACHABLE.

~ Oleksii
> 
> > +#define
> > guest_testop(name)                                                 
> > \
> > +static inline int guest_##name(struct domain *d, int nr, volatile
> > void *p)  \
> > +{                                                                 
> >           \
> > +    (void)
> > d;                                                               \
> > +    (void)
> > nr;                                                              \
> > +    (void)
> > p;                                                               \
> > +                                                                  
> >           \
> > +    return
> > 0;                                                               \
> > +}
> > +
> > +#define
> > guest_bitop(name)                                                  
> > \
> > +static inline void guest_##name(struct domain *d, int nr, volatile
> > void *p) \
> > +{                                                                 
> >           \
> > +    (void)
> > d;                                                               \
> > +    (void)
> > nr;                                                              \
> > +    (void)
> > p;                                                               \
> > +}
> > +
> > +guest_bitop(set_bit)
> > +guest_bitop(clear_bit)
> > +guest_bitop(change_bit)
> > +
> > +#undef guest_bitop
> > +
> > +guest_testop(test_and_set_bit)
> > +guest_testop(test_and_clear_bit)
> > +guest_testop(test_and_change_bit)
> > +
> > +#undef guest_testop
> > +
> > +#define guest_test_bit(d, nr, p) ((void)(d), test_bit(nr, p))
> > +
> > +#endif /* __ASM_RISCV_GUEST_ATOMICS_H */
> > +/*
> > + * Local variables:
> > + * mode: C
> > + * c-file-style: "BSD"
> > + * c-basic-offset: 4
> > + * indent-tabs-mode: nil
> > + * End:
> > + */
>
diff mbox series

Patch

diff --git a/xen/arch/riscv/include/asm/guest_atomics.h b/xen/arch/riscv/include/asm/guest_atomics.h
new file mode 100644
index 0000000000..9f14f76e92
--- /dev/null
+++ b/xen/arch/riscv/include/asm/guest_atomics.h
@@ -0,0 +1,48 @@ 
+#ifndef __ASM_RISCV_GUEST_ATOMICS_H
+#define __ASM_RISCV_GUEST_ATOMICS_H
+
+/*
+ * TODO: implement guest atomics
+ */
+
+#define guest_testop(name)                                                  \
+static inline int guest_##name(struct domain *d, int nr, volatile void *p)  \
+{                                                                           \
+    (void) d;                                                               \
+    (void) nr;                                                              \
+    (void) p;                                                               \
+                                                                            \
+    return 0;                                                               \
+}
+
+#define guest_bitop(name)                                                   \
+static inline void guest_##name(struct domain *d, int nr, volatile void *p) \
+{                                                                           \
+    (void) d;                                                               \
+    (void) nr;                                                              \
+    (void) p;                                                               \
+}
+
+guest_bitop(set_bit)
+guest_bitop(clear_bit)
+guest_bitop(change_bit)
+
+#undef guest_bitop
+
+guest_testop(test_and_set_bit)
+guest_testop(test_and_clear_bit)
+guest_testop(test_and_change_bit)
+
+#undef guest_testop
+
+#define guest_test_bit(d, nr, p) ((void)(d), test_bit(nr, p))
+
+#endif /* __ASM_RISCV_GUEST_ATOMICS_H */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */