catalinux / srh (public) (License: GPLv3) (since 2016-02-04) (hash sha1)
srh = Stop Row Hammer
Try to stop the row hammer attacks. It is a work in progress.
List of commits:
Subject Hash Author Date (UTC)
First version fe8b5ebc6a823d2045bce201a9638283db2c6ead Catalin(ux) M. BOIE 2015-03-12 17:58:12
Commit fe8b5ebc6a823d2045bce201a9638283db2c6ead - First version
Author: Catalin(ux) M. BOIE
Author date (UTC): 2015-03-12 17:58
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2015-03-12 17:58
Parent(s):
Signing key:
Tree: e736a473a7bf17feec637f4db451d4632dc2bd30
File Lines added Lines deleted
.gitignore 2 0
Makefile 0 0
README 2 0
srhd.c 71 0
File .gitignore added (mode: 100644) (index 0000000..331ac97)
1 srhd
2 *.log
File Makefile added (mode: 100644) (index 0000000..e69de29)
File README added (mode: 100644) (index 0000000..5ffbfa8)
1 Stop row hammer (srh)
2
File srhd.c added (mode: 100644) (index 0000000..fb84fdd)
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <errno.h>
6 #include <string.h>
7 #include <sys/ioctl.h>
8 #include <linux/perf_event.h>
9 #include <asm/unistd.h>
10
11 static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
12 int cpu, int group_fd, unsigned long flags)
13 {
14 return syscall(__NR_perf_event_open, hw_event, pid, cpu, group_fd, flags);
15 }
16
17 static void test_function(void)
18 {
19 int i, j;
20
21 for (i = 0; i < 1000; i++) {
22 asm volatile("clflush (%0);" : : "r" (&j) : "memory");
23 }
24 }
25
26 int main(void)
27 {
28 struct perf_event_attr attr;
29 long long count;
30 int fd;
31 ssize_t n;
32 unsigned char buf[4096];
33
34 memset(&attr, 0, sizeof(struct perf_event_attr));
35 attr.type = PERF_TYPE_HARDWARE;
36 attr.size = sizeof(struct perf_event_attr);
37 attr.config = PERF_COUNT_HW_INSTRUCTIONS; /* CHECK: PERF_TYPE_HW_CACHE */
38 attr.sample_freq = 990;
39 attr.freq = 1;
40 attr.enable_on_exec = 1;
41 attr.disabled = 1;
42 attr.exclude_kernel = 1;
43 attr.exclude_hv = 1;
44 attr.wakeup_events = 16;
45
46 fd = perf_event_open(&attr, 0, -1, -1, PERF_FLAG_FD_CLOEXEC);
47 if (fd == -1) {
48 fprintf(stderr, "Cannot call perf_event_open, config %llx\n",
49 attr.config);
50 return EXIT_FAILURE;
51 }
52
53 ioctl(fd, PERF_EVENT_IOC_RESET, 0);
54 ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
55 test_function();
56 ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
57
58 n = read(fd, buf, sizeof(buf));
59 fprintf(stderr, "n = %zd\n", n);
60 if (n <= 0) {
61 fprintf(stderr, "Cannot read: %s!\n", strerror(errno));
62 return EXIT_FAILURE;
63 }
64
65 memcpy(&count, buf, sizeof(long long));
66 printf("Instructions: %lld\n", count);
67
68 close(fd);
69
70 return 0;
71 }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/srh

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/srh

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/srh

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main