diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-09-02 20:25:58 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-09-02 20:25:58 +0200 |
| commit | 5d5ef75337cd4db7224d5e0cdb6da2dc96ab8224 (patch) | |
| tree | 6b6f013c09789da472917ff5e00f6bf0d2f7899b /src/tools/bridge.c | |
| parent | c3ef6380a7baa6457974fe2eca1652dff6808cca (diff) | |
| download | box64-5d5ef75337cd4db7224d5e0cdb6da2dc96ab8224.tar.gz box64-5d5ef75337cd4db7224d5e0cdb6da2dc96ab8224.zip | |
Add some support vor VSyscall
Diffstat (limited to 'src/tools/bridge.c')
| -rwxr-xr-x | src/tools/bridge.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tools/bridge.c b/src/tools/bridge.c index 3fdaa2ac..5f6bb5af 100755 --- a/src/tools/bridge.c +++ b/src/tools/bridge.c @@ -203,6 +203,50 @@ void* GetNativeFncOrFnc(uintptr_t fnc) return (void*)b->f; } +// using the brdige mecanism for the VSyscall +uintptr_t AddVSyscall(bridge_t* bridge, int num) +{ + brick_t *b = NULL; + int sz = -1; + #ifdef DYNAREC + int prot = 0; + do { + #endif + pthread_mutex_lock(&my_context->mutex_bridge); + b = bridge->last; + if(b->sz == NBRICK) { + b->next = NewBrick(); + b = b->next; + bridge->last = b; + } + sz = b->sz; + #ifdef DYNAREC + pthread_mutex_unlock(&my_context->mutex_bridge); + if(box64_dynarec) { + prot=(getProtection((uintptr_t)b->b)&PROT_DYNAREC)?1:0; + if(prot) + unprotectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t)); + else // only add DB if there is no protection + addDBFromAddressRange((uintptr_t)&b->b[b->sz].CC, sizeof(onebridge_t)); + } + } while(sz!=b->sz); // this while loop if someone took the slot when the bridge mutex was unlocked doing memory protection managment + pthread_mutex_lock(&my_context->mutex_bridge); + #endif + b->sz++; + b->b[sz].B8 = 0xB8; + b->b[sz].num = num; + b->b[sz]._0F = 0x0F; + b->b[sz]._05 = 0x05; + b->b[sz]._C3 = 0xC3; + pthread_mutex_unlock(&my_context->mutex_bridge); + #ifdef DYNAREC + if(box64_dynarec) + protectDB((uintptr_t)b->b, NBRICK*sizeof(onebridge_t)); + #endif + + return (uintptr_t)&b->b[sz].CC; +} + #ifdef HAVE_TRACE KHASH_MAP_INIT_INT64(bridgename, const char*) static kh_bridgename_t *bridgename; |