Use read_volatile for stack_check_guard.

Its whole point is that it will be aliased if the stack overflows, so it
doesn't make sense to use a reference. In fact the compiler might
optimise away the reads. Reading a pointer is still a bit dodgy, but
better.

Test: m vmbase_example_bin
Change-Id: I23e83d2b83d945d0fe66bcbd909cd5e04a609e12
diff --git a/vmbase/src/layout/mod.rs b/vmbase/src/layout/mod.rs
index 21c113a..00d7f9a 100644
--- a/vmbase/src/layout/mod.rs
+++ b/vmbase/src/layout/mod.rs
@@ -17,6 +17,7 @@
 pub mod crosvm;
 
 use crate::console::BASE_ADDRESS;
+use crate::linker::__stack_chk_guard;
 use core::ops::Range;
 use core::ptr::addr_of;
 
@@ -97,3 +98,11 @@
 pub fn binary_end() -> usize {
     linker_addr!(bin_end)
 }
+
+/// Value of __stack_chk_guard.
+pub fn stack_chk_guard() -> u64 {
+    // SAFETY: __stack_chk_guard shouldn't have any mutable aliases unless the stack overflows. If
+    // it does, then there could be undefined behaviour all over the program, but we want to at
+    // least have a chance at catching it.
+    unsafe { addr_of!(__stack_chk_guard).read_volatile() }
+}