Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-21fa
project05b
Commits
d0f51525
Commit
d0f51525
authored
4 years ago
by
Caleb C. Sander
Browse files
Options
Download
Email Patches
Plain Diff
Remove util.c
parent
752826ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+1
-4
Makefile
include/util.h
+18
-2
include/util.h
src/exploit.c
+0
-1
src/exploit.c
with
19 additions
and
7 deletions
+19
-7
Makefile
View file @
d0f51525
...
...
@@ -3,10 +3,7 @@ CFLAGS = -Iinclude -Wall -Wextra -O3 -g
all
:
bin/cache_timing bin/index_guesser bin/recover_local_secret bin/recover_protected_local_secret bin/exploit
bin/%.o
:
lib/%.c
$(CC)
$(CFLAGS)
-c
$^
-o
$@
bin/%
:
src/%.c bin/util.o include/%.h
bin/%
:
src/%.c include/%.h
$(CC)
$(CFLAGS)
$(
filter-out
%.h,
$^
)
-o
$@
clean
:
...
...
This diff is collapsed.
Click to expand it.
include/util.h
View file @
d0f51525
...
...
@@ -2,6 +2,7 @@
#define _UTIL_H
#include <inttypes.h>
#include <x86intrin.h>
#define PAGE_SIZE 4096
...
...
@@ -19,13 +20,28 @@ inline void force_read(const void *address) {
* Evicts any cache line currently storing the given address.
* This ensures that the byte at the address is no longer in the cache.
*/
void
flush_cache_line
(
const
void
*
address
);
void
flush_cache_line
(
const
void
*
address
)
{
_mm_clflush
(
address
);
_mm_mfence
();
for
(
volatile
int
i
=
0
;
i
<
10000
;
i
++
)
{
}
}
/**
* Counts the number of processor clocks elapsed when reading a byte at the given address.
* Note that the number of clocks can be quite large
* if the process happens to be interrupted in this function.
*/
uint64_t
time_read
(
const
void
*
address
);
uint64_t
time_read
(
const
void
*
address
)
{
uint64_t
start
=
__rdtsc
();
_mm_lfence
();
force_read
(
address
);
_mm_mfence
();
_mm_lfence
();
uint64_t
result
=
__rdtsc
()
-
start
;
_mm_mfence
();
_mm_lfence
();
return
result
;
}
#endif
/* _UTIL_H */
This diff is collapsed.
Click to expand it.
src/exploit.c
View file @
d0f51525
...
...
@@ -15,5 +15,4 @@
*/
int
main
()
{
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help