Skip to contentSkip to conversation

xen/nospec: Remove unreachable code

PATCH In review Andrew Cooper 3 participants 3 messages Apr 10, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/nospec: Remove unreachable code

When CONFIG_SPECULATIVE_HARDEN_LOCK is active, this reads:

  static always_inline bool lock_evaluate_nospec(bool condition)
  {
      return arch_lock_evaluate_nospec(condition);
      return condition;
  }

Insert an #else to take out the second return.

Fixes 7ef0084418e1 ("x86/spinlock: introduce support for blocking speculation into critical regions")

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Federico Serafini <[email protected]>
CC: Nicola Vetrini <[email protected]>

---
 xen/include/xen/nospec.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/include/xen/nospec.h +2 -1
index 9fb15aa26aa9..828dbd4e0ad8 100644
@@ -82,8 +82,9 @@ static always_inline bool lock_evaluate_nospec(bool condition)
 {
 #ifdef CONFIG_SPECULATIVE_HARDEN_LOCK
     return arch_lock_evaluate_nospec(condition);
-#endif
+#else
     return condition;
+#endif
 }
 
 #endif /* XEN_NOSPEC_H */

base-commit: 0e7ea8ca5fc9bce9248414f6aaf2dc861abd45d9

Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Andrew Cooper

When CONFIG_SPECULATIVE_HARDEN_LOCK is active, this reads:

static always_inline bool lock_evaluate_nospec(bool condition)

 {
     return arch_lock_evaluate_nospec(condition);
     return condition;
Quoted 7 lines

}

Insert an #else to take out the second return.

Fixes 7ef0084418e1 ("x86/spinlock: introduce support for blocking speculation into critical regions")

---

Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 8 lines · Andrew Cooper

When CONFIG_SPECULATIVE_HARDEN_LOCK is active, this reads:

  static always_inline bool lock_evaluate_nospec(bool condition)
  {
      return arch_lock_evaluate_nospec(condition);
      return condition;
  }
Quoted 4 lines

Insert an #else to take out the second return.

Fixes 7ef0084418e1 ("x86/spinlock: introduce support for blocking speculation into critical regions")