-
Notifications
You must be signed in to change notification settings - Fork 0
add libhc #16
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
Open
caden-kline
wants to merge
1
commit into
main_4.10
Choose a base branch
from
libhc
base: main_4.10
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add libhc #16
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "include/linux/libhc"] | ||
path = include/linux/libhc | ||
url = https://github.com/panda-re/libhc.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,5 @@ | ||
#ifndef HYPERCALL_H | ||
#define HYPERCALL_H | ||
#include "linux/types.h" | ||
|
||
static inline void igloo_hypercall(unsigned long num, unsigned long arg1) { | ||
#if defined(CONFIG_MIPS) | ||
register unsigned long reg0 asm("v0") = num; | ||
register unsigned long reg1 asm("a0") = arg1; | ||
|
||
asm volatile( | ||
"movz $0, $0, $0" | ||
: "+r"(reg0) | ||
: "r"(reg1) // num in register v0 | ||
: "memory" | ||
); | ||
|
||
|
||
#elif defined(CONFIG_ARM64) | ||
register unsigned long reg0 asm("x8") = num; | ||
register unsigned long reg1 asm("x0") = arg1; | ||
asm volatile( | ||
"msr S0_0_c5_c0_0, xzr \n" | ||
: "+r"(reg1) | ||
: "r"(reg0) | ||
: "memory" | ||
); | ||
#elif defined(CONFIG_ARM) | ||
register unsigned long reg0 asm("r7") = num; | ||
register unsigned long reg1 asm("r0") = arg1; | ||
|
||
asm volatile( | ||
"mcr p7, 0, r0, c0, c0, 0" | ||
: "+r"(reg1) | ||
: "r"(reg0) | ||
: "memory" | ||
); | ||
#elif defined(CONFIG_X86_64) | ||
register unsigned long reg0 asm("rax") = num; | ||
register unsigned long reg1 asm("rdi") = arg1; | ||
|
||
asm volatile( | ||
"cpuid" | ||
: "+r"(reg0) // hypercall num + return value in rax | ||
: "r"(reg1) // arguments | ||
: "memory", "ebx", "ecx", "edx" // No clobber | ||
); | ||
#else | ||
#error "No igloo_hypercall support for architecture" | ||
#endif | ||
} | ||
|
||
static inline unsigned long igloo_hypercall2(unsigned long num, unsigned long arg1, unsigned long arg2) { | ||
#if defined(CONFIG_ARM64) | ||
register unsigned long reg0 asm("x8") = num; | ||
register unsigned long reg1 asm("x0") = arg1; | ||
register unsigned long reg2 asm("x1") = arg2; | ||
asm volatile( | ||
"msr S0_0_c5_c0_0, xzr \n" | ||
: "+r"(reg1) // Input and output | ||
: "r"(reg0), "r"(reg2) | ||
: "memory" | ||
); | ||
return reg1; | ||
#elif defined(CONFIG_ARM) | ||
register unsigned long reg0 asm("r7") = num; | ||
register unsigned long reg1 asm("r0") = arg1; | ||
register unsigned long reg2 asm("r1") = arg2; | ||
|
||
asm volatile( | ||
"mcr p7, 0, r0, c0, c0, 0" | ||
: "+r"(reg1) // Input and output | ||
: "r"(reg0), "r"(reg2) | ||
: "memory" | ||
); | ||
|
||
return reg1; | ||
|
||
#elif defined(CONFIG_MIPS) | ||
register unsigned long reg0 asm("v0") = num; | ||
register unsigned long reg1 asm("a0") = arg1; | ||
register unsigned long reg2 asm("a1") = arg2; | ||
|
||
asm volatile( | ||
"movz $0, $0, $0" | ||
: "+r"(reg0) // Input and output in R0 | ||
: "r"(reg1) , "r" (reg2)// arg2 in register A1 | ||
: "memory" | ||
); | ||
return reg0; | ||
#elif defined(CONFIG_X86_64) | ||
register unsigned long reg0 asm("rax") = num; | ||
register unsigned long reg1 asm("rdi") = arg1; | ||
register unsigned long reg2 asm("rsi") = arg2; | ||
|
||
asm volatile( | ||
"cpuid" | ||
: "+r"(reg0) // hypercall num + return value in rax | ||
: "r"(reg1), "r"(reg2) // arguments | ||
: "memory", "ebx", "ecx", "edx" | ||
); | ||
|
||
return reg0; | ||
#else | ||
#error "No igloo_hypercall2 support for architecture" | ||
#endif | ||
} | ||
|
||
#endif | ||
#include "libhc/hypercall.h" | ||
#endif | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why does this file still exist? Shouldn't you just make all the places that include hypercall.h include libhc/hypercall.h?
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.
The header guard and linux/types.h requirement is unique to the kernel. Though I'm now double checking that the linux types.h is true. If it's not then I'll just add the the header guard to libhc
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.
types is no longer required for reasons I don't know.