diff mbox series

[v5,03/23] xen/riscv: introduce nospec.h

Message ID 16370492de5344ae8e1aab688261600491868f4e.1708962629.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 Feb. 26, 2024, 5:38 p.m. UTC
From the unpriviliged doc:
  No standard hints are presently defined.
  We anticipate standard hints to eventually include memory-system spatial
  and temporal locality hints, branch prediction hints, thread-scheduling
  hints, security tags, and instrumentation flags for simulation/emulation.

Also, there are no speculation execution barriers.

Therefore, functions evaluate_nospec() and block_speculation() should
remain empty until a specific platform has an extension to deal with
speculation execution.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 Changes in V5:
   - new patch
---
 xen/arch/riscv/include/asm/nospec.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 xen/arch/riscv/include/asm/nospec.h

Comments

Jan Beulich Feb. 27, 2024, 7:38 a.m. UTC | #1
On 26.02.2024 18:38, Oleksii Kurochko wrote:
> From the unpriviliged doc:
>   No standard hints are presently defined.
>   We anticipate standard hints to eventually include memory-system spatial
>   and temporal locality hints, branch prediction hints, thread-scheduling
>   hints, security tags, and instrumentation flags for simulation/emulation.
> 
> Also, there are no speculation execution barriers.
> 
> Therefore, functions evaluate_nospec() and block_speculation() should
> remain empty until a specific platform has an extension to deal with
> speculation execution.

What about array_index_mask_nospec(), though? No custom implementation,
meaning the generic one will be used there? If that's the intention,
then ...

> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

Jan
Oleksii Kurochko Feb. 28, 2024, 9:59 a.m. UTC | #2
On Tue, 2024-02-27 at 08:38 +0100, Jan Beulich wrote:
> On 26.02.2024 18:38, Oleksii Kurochko wrote:
> > From the unpriviliged doc:
> >   No standard hints are presently defined.
> >   We anticipate standard hints to eventually include memory-system
> > spatial
> >   and temporal locality hints, branch prediction hints, thread-
> > scheduling
> >   hints, security tags, and instrumentation flags for
> > simulation/emulation.
> > 
> > Also, there are no speculation execution barriers.
> > 
> > Therefore, functions evaluate_nospec() and block_speculation()
> > should
> > remain empty until a specific platform has an extension to deal
> > with
> > speculation execution.
> 
> What about array_index_mask_nospec(), though? No custom
> implementation,
> meaning the generic one will be used there? If that's the intention,
> then ...
Yes, the generic one will be used.

~ Oleksii
> 
> > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> 
> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
> Jan
>
Julien Grall Feb. 29, 2024, 1:49 p.m. UTC | #3
Hi Oleksii,

On 26/02/2024 17:38, Oleksii Kurochko wrote:
>  From the unpriviliged doc:
>    No standard hints are presently defined.
>    We anticipate standard hints to eventually include memory-system spatial
>    and temporal locality hints, branch prediction hints, thread-scheduling
>    hints, security tags, and instrumentation flags for simulation/emulation.
> 
> Also, there are no speculation execution barriers.
> 
> Therefore, functions evaluate_nospec() and block_speculation() should
> remain empty until a specific platform has an extension to deal with
> speculation execution.
> 
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> ---
>   Changes in V5:
>     - new patch
> ---
>   xen/arch/riscv/include/asm/nospec.h | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
>   create mode 100644 xen/arch/riscv/include/asm/nospec.h
> 
> diff --git a/xen/arch/riscv/include/asm/nospec.h b/xen/arch/riscv/include/asm/nospec.h
> new file mode 100644
> index 0000000000..4fb404a0a2
> --- /dev/null
> +++ b/xen/arch/riscv/include/asm/nospec.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0 */

New file should use the SPDX tag GPL-2.0-only. I guess this could be 
fixed on commit?

Cheers,
Jan Beulich Feb. 29, 2024, 2:01 p.m. UTC | #4
On 29.02.2024 14:49, Julien Grall wrote:
> On 26/02/2024 17:38, Oleksii Kurochko wrote:
>> --- /dev/null
>> +++ b/xen/arch/riscv/include/asm/nospec.h
>> @@ -0,0 +1,25 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
> 
> New file should use the SPDX tag GPL-2.0-only. I guess this could be 
> fixed on commit?

I wouldn't mind doing so.

Jan
Oleksii Kurochko Feb. 29, 2024, 4:09 p.m. UTC | #5
On Thu, 2024-02-29 at 15:01 +0100, Jan Beulich wrote:
> On 29.02.2024 14:49, Julien Grall wrote:
> > On 26/02/2024 17:38, Oleksii Kurochko wrote:
> > > --- /dev/null
> > > +++ b/xen/arch/riscv/include/asm/nospec.h
> > > @@ -0,0 +1,25 @@
> > > +/* SPDX-License-Identifier: GPL-2.0 */
> > 
> > New file should use the SPDX tag GPL-2.0-only. I guess this could
> > be 
> > fixed on commit?
> 
> I wouldn't mind doing so.
I would happy with that. Thanks.

~ Oleksii
Jan Beulich Feb. 29, 2024, 4:27 p.m. UTC | #6
On 26.02.2024 18:38, Oleksii Kurochko wrote:
> --- /dev/null
> +++ b/xen/arch/riscv/include/asm/nospec.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Copyright (C) 2024 Vates */
> +
> +#ifndef _ASM_GENERIC_NOSPEC_H
> +#define _ASM_GENERIC_NOSPEC_H

Btw, at the very last second I noticed the GENERIC in here, which I
took the liberty to replace. But please be more careful when moving
files around in the tree.

Jan
diff mbox series

Patch

diff --git a/xen/arch/riscv/include/asm/nospec.h b/xen/arch/riscv/include/asm/nospec.h
new file mode 100644
index 0000000000..4fb404a0a2
--- /dev/null
+++ b/xen/arch/riscv/include/asm/nospec.h
@@ -0,0 +1,25 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2024 Vates */
+
+#ifndef _ASM_GENERIC_NOSPEC_H
+#define _ASM_GENERIC_NOSPEC_H
+
+static inline bool evaluate_nospec(bool condition)
+{
+    return condition;
+}
+
+static inline void block_speculation(void)
+{
+}
+
+#endif /* _ASM_GENERIC_NOSPEC_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */