-
Notifications
You must be signed in to change notification settings - Fork 96
Isolated inlined C code into source and header files #1699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
de19e61
6b8e4db
b5a7e77
fce8c5d
e50e65a
d4ea914
233fc54
d68bd31
785db8c
6286f53
8350229
2cc4318
df3a309
aba77f0
b13f590
0fe4e0d
f40f79c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rename this to memtag.h? |
|
z5146542 marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /****************************************************************************/ | ||
| /* the diy toolsuite */ | ||
| /* */ | ||
| /* Jade Alglave, University College London, UK. */ | ||
| /* Luc Maranget, INRIA Paris, France. */ | ||
| /* */ | ||
| /* Copyright 2025-present Institut National de Recherche en Informatique et */ | ||
| /* en Automatique and the authors. All rights reserved. */ | ||
| /* */ | ||
| /* This software is governed by the CeCILL-B license under French law and */ | ||
| /* abiding by the rules of distribution of free software. You can use, */ | ||
| /* modify and/ or redistribute the software under the terms of the CeCILL-B */ | ||
| /* license as circulated by CEA, CNRS and INRIA at the following URL */ | ||
| /* "http://www.cecill.info". We also give a copy in LICENSE.txt. */ | ||
| /****************************************************************************/ | ||
| #ifndef ASMHANDLER_H | ||
| #define ASMHANDLER_H 1 | ||
| void exceptions_init_test(void *p); | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /****************************************************************************/ | ||
| /* the diy toolsuite */ | ||
| /* */ | ||
| /* Jade Alglave, University College London, UK. */ | ||
| /* Luc Maranget, INRIA Paris-Rocquencourt, France. */ | ||
| /* */ | ||
| /* Copyright 2015-present Institut National de Recherche en Informatique et */ | ||
| /* en Automatique and the authors. All rights reserved. */ | ||
| /* */ | ||
| /* This software is governed by the CeCILL-B license under French law and */ | ||
| /* abiding by the rules of distribution of free software. You can use, */ | ||
| /* modify and/ or redistribute the software under the terms of the CeCILL-B */ | ||
| /* license as circulated by CEA, CNRS and INRIA at the following URL */ | ||
| /* "http://www.cecill.info". We also give a copy in LICENSE.txt. */ | ||
| /****************************************************************************/ | ||
| /**********************/ | ||
| /* User level barrier */ | ||
| /**********************/ | ||
| #ifndef BARRIER_H | ||
| #define BARRIER_H 1 | ||
|
|
||
| typedef struct { | ||
| volatile int c,sense; | ||
| int n ; | ||
| } sense_t; | ||
|
|
||
| void barrier_init (sense_t *p,int n); | ||
|
|
||
| void barrier_wait(sense_t *p); | ||
| #endif |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this now a file that is both a standalone header and we might also inline?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is a standalone header yes. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,22 @@ | ||
| /****************************************************************************/ | ||
| /* the diy toolsuite */ | ||
| /* */ | ||
| /* Jade Alglave, University College London, UK. */ | ||
| /* Luc Maranget, INRIA Paris, France. */ | ||
| /* Rémy Citérin, ARM Ltd, Cambridge, UK */ | ||
| /* */ | ||
| /* Copyright 2026-present Institut National de Recherche en Informatique et */ | ||
| /* en Automatique and the authors. All rights reserved. */ | ||
| /* */ | ||
| /* This software is governed by the CeCILL-B license under French law and */ | ||
| /* abiding by the rules of distribution of free software. You can use, */ | ||
| /* modify and/ or redistribute the software under the terms of the CeCILL-B */ | ||
| /* license as circulated by CEA, CNRS and INRIA at the following URL */ | ||
| /* "http://www.cecill.info". We also give a copy in LICENSE.txt. */ | ||
| /****************************************************************************/ | ||
| #ifndef INSTRUCTION_H | ||
| #define INSTRUCTION_H | ||
| #include <stdint.h> | ||
|
|
||
| typedef uint32_t ins_t; /* Type of instructions */ | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,20 +16,40 @@ | |
| /* Authors: */ | ||
| /* Nikos Nikoleris, Arm Limited. */ | ||
| /****************************************************************************/ | ||
| #include <kvm-self.h> | ||
| #include <_find_ins.h> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is going to be a real header file should we remove the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to preserve the file names as much as possible for now, but if you think that these files should be renamed I will do so. |
||
| #include <../kvm-headers.h> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not great can we please move kvm-headers into the libdir? |
||
|
|
||
| static void litmus_icache_sync(uintptr_t vaddr, uintptr_t vaddr_end) | ||
| static ins_t getret(void) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this remain static? |
||
| ins_t *x1; | ||
| ins_t r; | ||
| asm __volatile__ ( | ||
| "adr %[x1],0f\n\t" | ||
| "ldr %w[x2],[%[x1]]\n\t" | ||
| "b 1f\n" | ||
| "0:\n\t" | ||
| "ret\n" | ||
| "1:\n" | ||
| :[x1] "=&r" (x1),[x2] "=&r" (r) | ||
| : | ||
| : "cc","memory" | ||
| ); | ||
| return r; | ||
| } | ||
|
|
||
| void litmus_icache_sync(uintptr_t vaddr, uintptr_t vaddr_end) | ||
| { | ||
| while (vaddr < vaddr_end) { | ||
| selfbar((void *)vaddr); | ||
| vaddr += cache_line_size; | ||
| } | ||
| } | ||
|
|
||
| static size_t code_size(ins_t *p,int skip) { | ||
| size_t code_size(ins_t *p,int skip) { | ||
| return (find_ins(getret(), p, skip) + 1) * sizeof(ins_t); | ||
| } | ||
|
|
||
| static void litmus_pte_unset_el0(uintptr_t vaddr, uintptr_t vaddr_end) | ||
| void litmus_pte_unset_el0(uintptr_t vaddr, uintptr_t vaddr_end) | ||
| { | ||
| while (vaddr < vaddr_end) { | ||
| pteval_t *pte = litmus_tr_pte((void *)vaddr); | ||
|
|
@@ -43,7 +63,7 @@ static void litmus_pte_unset_el0(uintptr_t vaddr, uintptr_t vaddr_end) | |
| ); | ||
| } | ||
|
|
||
| static void code_init(void *code, void *src, size_t sz) | ||
| void code_init(void *code, void *src, size_t sz) | ||
| { | ||
| memcpy(code, src, sz); | ||
| litmus_icache_sync((uintptr_t)code, (uintptr_t)code + sz); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /****************************************************************************/ | ||
| /* the diy toolsuite */ | ||
| /* */ | ||
| /* Jade Alglave, University College London, UK. */ | ||
| /* Luc Maranget, INRIA Paris-Rocquencourt, France. */ | ||
| /* */ | ||
| /* Copyright 2026-present Institut National de Recherche en Informatique et */ | ||
| /* en Automatique and the authors. All rights reserved. */ | ||
| /* */ | ||
| /* This software is governed by the CeCILL-B license under French law and */ | ||
| /* abiding by the rules of distribution of free software. You can use, */ | ||
| /* modify and/ or redistribute the software under the terms of the CeCILL-B */ | ||
| /* license as circulated by CEA, CNRS and INRIA at the following URL */ | ||
| /* "http://www.cecill.info". We also give a copy in LICENSE.txt. */ | ||
| /****************************************************************************/ | ||
| #ifndef KVM_SELF_H | ||
| #define KVM_SELF_H 1 | ||
|
|
||
| #include <stdint.h> | ||
| #include <stddef.h> | ||
| #include <instruction.h> | ||
| #include <self.h> | ||
|
|
||
| void litmus_icache_sync(uintptr_t vaddr, uintptr_t vaddr_end); | ||
|
|
||
| size_t code_size(ins_t *p,int skip); | ||
|
|
||
| void litmus_pte_unset_el0(uintptr_t vaddr, uintptr_t vaddr_end); | ||
|
|
||
| void code_init(void *code, void *src, size_t sz); | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to memtag.c?