Commit 9be87323 authored by Caleb C. Sander's avatar Caleb C. Sander
Browse files

Add clang-format

parent 2f64e330
No related merge requests found
Showing with 40 additions and 11 deletions
+40 -11
---
# We'll use defaults from the Google style, but with 4 columns indentation.
BasedOnStyle: Google
# Never allow single-line functions
AllowShortFunctionsOnASingleLine: None
# Allow lines up to 90 characters
ColumnLimit: 90
# Indent each block by 4 spaces
IndentWidth: 4
TabWidth: 4
# Require 1 space before a comment on the same line
SpacesBeforeTrailingComments: 1
# Put a space after a cast, e.g. `(void) arg;`
SpaceAfterCStyleCast: true
---
#!/bin/bash
if loc="$(type -p "clang-format")" && [[ -x $loc ]]; then
for name in $(git diff --cached --name-only --diff-filter=ACM); do
if echo $name | grep -Eq "\.[ch]$"; then
echo "Formatting ${name}..."
clang-format -i $name
fi
done
else
echo "You do not have clang-format installed; so, we were unable to unify the formatting in your files."
fi
...@@ -9,7 +9,8 @@ void force_read(const void *address) { ...@@ -9,7 +9,8 @@ void force_read(const void *address) {
void flush_cache_line(const void *address) { void flush_cache_line(const void *address) {
_mm_clflush(address); _mm_clflush(address);
_mm_mfence(); _mm_mfence();
for (volatile int i = 0; i < 10000; i++) {} for (volatile int i = 0; i < 10000; i++) {
}
} }
uint64_t time_read(const void *address) { uint64_t time_read(const void *address) {
......
...@@ -19,7 +19,7 @@ static inline void *get_kernel_data_address(void) { ...@@ -19,7 +19,7 @@ static inline void *get_kernel_data_address(void) {
return (void *) address; return (void *) address;
} }
/* TODO: Copy your code from the previous stage and edit do_access().
// TODO: Copy your code from the previous stage and make the necessary edits to do_access() * Note that this code WILL NOT WORK on compute-cpu2.
// Note that this code WILL NOT WORK on compute-cpu2. You must push it to gitlab to get it to run * You must push it to GitLab to run it on one of the meltdown machines.
// on one of the meltdown machines. */
...@@ -30,7 +30,8 @@ static inline void do_access(page_t *pages, size_t secret_index) { ...@@ -30,7 +30,8 @@ static inline void do_access(page_t *pages, size_t secret_index) {
int main() { int main() {
page_t *pages = init_pages(); page_t *pages = init_pages();
// TODO: Copy me from the previous stage and edit me so I loop over SECRET_LENGTH characters. /* TODO: Copy me from the previous stage and edit me
* to loop over SECRET_LENGTH characters. */
printf("\n"); printf("\n");
free(pages); free(pages);
......
...@@ -33,13 +33,13 @@ static inline void do_access(page_t *pages, size_t secret_index) { ...@@ -33,13 +33,13 @@ static inline void do_access(page_t *pages, size_t secret_index) {
// Don't forget to call cache_secret() to ensure the secret is in memory. // Don't forget to call cache_secret() to ensure the secret is in memory.
} }
// TODO: Implement a SIGSEGV handler // TODO: Implement a SIGSEGV handler
int main() { int main() {
// TODO: Install your SIGSEGV handler // TODO: Install your SIGSEGV handler
// TODO: For the remainder of the function, copy from the previous stage and edit the following:
// 1. Add asm volatile("label:") to the location you want the SIGSEGV handler to return to. /* TODO: Copy the code from the previous stage and edit the following:
// 2. For each letter, it might take more than one attempt to get a valid guess. Throw all the logic in an inner loop. * 1. Add `asm volatile("label:")` where you want the SIGSEGV handler to return to.
* 2. For each letter, it might take more than one attempt to get a cache hit.
* Throw all the logic in an inner loop. */
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment