[kernel][x86] Convert halt_interlock from legacy int -> ktl::atomic

|halt_interlock| is a per-CPU flag used in the HLT-version of the x86
idle loop; it is used in the adaptive spin before HLT, so that remote
wakeups can avoid an IPI while a target CPU is spinning.

Specifically:
. When a CPU is idle, it executes the idle thread; the thread executes
  the HLT instruction in a loop until there is something else to do.
. HLT may have a long entry / exit latency
. Before we HLT, we spin a bit, checking for work; while we're spinning
  remote cores can wake us with a pure store. After we enter halt, we need
  to use an IPI to wake a sleeping core.

1. A core that's about to sleep sets a per-cpu variable,
   'halt_interlock', to 1.
2. It then spins a bit, checking that halt_interlock is still == 1
3. It then uses CMPXCHG to switch halt_interlock -> 2.
4. Then it halts

A wakeup does:
1. CMPXCHG switches halt_interlock from 1->0
2. If it fails, we use an IPI to do a heavyweight wake

Convert the flag from a volatile int to a ktl::atomic<>.

Bug: 47117 Use only ktl::atomic in the kernel

Change-Id: I63a6b57e5d906e7d22e8b19919c4d176b8d372c2
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/441925
Commit-Queue: Venkatesh Srinivas <venkateshs@google.com>
Reviewed-by: Nick Maniscalco <maniscalco@google.com>
Testability-Review: Nick Maniscalco <maniscalco@google.com>
2 files changed
tree: e041962b80416addc899df106b2b7c3eba6a7c09
  1. boards/
  2. build/
  3. bundles/
  4. docs/
  5. examples/
  6. garnet/
  7. products/
  8. scripts/
  9. sdk/
  10. src/
  11. third_party/
  12. tools/
  13. zircon/
  14. .clang-format
  15. .clang-tidy
  16. .gitattributes
  17. .gitignore
  18. .gn
  19. .style.yapf
  20. AUTHORS
  21. BUILD.gn
  22. CODE_OF_CONDUCT.md
  23. CONTRIBUTING.md
  24. LICENSE
  25. OWNERS
  26. PATENTS
  27. README.md
  28. rustfmt.toml
README.md

Fuchsia

Pink + Purple == Fuchsia (a new operating system)

What is Fuchsia?

Fuchsia is a modular, capability-based operating system. Fuchsia runs on modern 64-bit Intel and ARM processors.

Fuchsia is an open source project with a code of conduct that we expect everyone who interacts with the project to respect.

Read more about Fuchsia's principles.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See fuchsia.dev.