Revert team and thread changes for COMPAT_MODE (hrev52010 & hrev52011).

This reverts commit c558f9c8fe.
This reverts commit 44f24718b1.
This reverts commit a69cb33030.
This reverts commit 951182620e.

There have been multiple reports that these changes break mounting NTFS partitions
(on all systems, see #14204), and shutting down (on certain systems, see #12405.)
Until they can be fixed, they are being backed out.
This commit is contained in:
Augustin Cavalier
2018-06-14 22:25:06 -04:00
parent 211cb77acf
commit 513403d420
17 changed files with 57 additions and 549 deletions
+3 -8
View File
@@ -579,6 +579,9 @@ void x86_write_msr(uint32 registerNumber, uint64 value);
void x86_context_switch(struct arch_thread* oldState,
struct arch_thread* newState);
void x86_fnsave(void* fpuState);
void x86_frstor(const void* fpuState);
void x86_fxsave(void* fpuState);
void x86_fxrstor(const void* fpuState);
@@ -589,14 +592,6 @@ void x86_fxsave_swap(void* oldFpuState, const void* newFpuState);
#endif
#if !defined(__x86_64__) || defined(_COMPAT_MODE)
void x86_fnsave(void* fpuState);
void x86_frstor(const void* fpuState);
#endif // !defined(__x86_64__) || defined(_COMPAT_MODE)
static inline void
arch_cpu_idle(void)
{
-28
View File
@@ -163,34 +163,6 @@ static_assert(sizeof(compat_thread_info) == 76,
"size of compat_thread_info mismatch");
inline status_t
copy_ref_var_to_user(thread_info &info, thread_info* userInfo)
{
if (!IS_USER_ADDRESS(userInfo))
return B_BAD_ADDRESS;
Thread* thread = thread_get_current_thread();
bool compatMode = (thread->flags & THREAD_FLAGS_COMPAT_MODE) != 0;
if (compatMode) {
compat_thread_info compatInfo;
compatInfo.thread = info.thread;
compatInfo.team = info.team;
strlcpy(compatInfo.name, info.name, sizeof(compatInfo.name));
compatInfo.state = info.state;
compatInfo.priority = info.priority;
compatInfo.sem = info.sem;
compatInfo.user_time = info.user_time;
compatInfo.kernel_time = info.kernel_time;
compatInfo.stack_base = (uint32)(addr_t)info.stack_base;
compatInfo.stack_end = (uint32)(addr_t)info.stack_end;
if (user_memcpy(userInfo, &compatInfo, sizeof(compatInfo)) < B_OK)
return B_BAD_ADDRESS;
} else if (user_memcpy(userInfo, &info, sizeof(info)) < B_OK) {
return B_BAD_ADDRESS;
}
return B_OK;
}
inline status_t
copy_ref_var_to_user(void* &addr, void** userAddr)
{
@@ -1,60 +0,0 @@
/*
* Copyright 2018, Haiku Inc. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_COMPAT_RESOURCE_H
#define _KERNEL_COMPAT_RESOURCE_H
#include <sys/resource.h>
typedef uint32 compat_rlim_t;
struct compat_rlimit {
compat_rlim_t rlim_cur; /* current soft limit */
compat_rlim_t rlim_max; /* hard limit */
};
inline status_t
copy_ref_var_to_user(struct rlimit &rl, struct rlimit* urlp)
{
if (!IS_USER_ADDRESS(urlp))
return B_BAD_ADDRESS;
Thread* thread = thread_get_current_thread();
bool compatMode = (thread->flags & THREAD_FLAGS_COMPAT_MODE) != 0;
if (compatMode) {
struct compat_rlimit compat_rl;
compat_rl.rlim_cur = rl.rlim_cur;
compat_rl.rlim_max = rl.rlim_max;
if (user_memcpy(urlp, &compat_rl, sizeof(compat_rl)) < B_OK)
return B_BAD_ADDRESS;
} else if (user_memcpy(urlp, &rl, sizeof(rl)) < B_OK) {
return B_BAD_ADDRESS;
}
return B_OK;
}
inline status_t
copy_ref_var_from_user(struct rlimit* urlp, struct rlimit &rl)
{
if (!IS_USER_ADDRESS(urlp))
return B_BAD_ADDRESS;
Thread* thread = thread_get_current_thread();
bool compatMode = (thread->flags & THREAD_FLAGS_COMPAT_MODE) != 0;
if (compatMode) {
struct compat_rlimit compat_rl;
if (user_memcpy(&compat_rl, urlp, sizeof(compat_rl)) < B_OK)
return B_BAD_ADDRESS;
rl.rlim_cur = compat_rl.rlim_cur;
rl.rlim_max = compat_rl.rlim_max;
} else if (user_memcpy(&rl, urlp, sizeof(rl)) < B_OK) {
return B_BAD_ADDRESS;
}
return B_OK;
}
#endif // _KERNEL_COMPAT_RESOURCE_H
@@ -1,61 +0,0 @@
/*
* Copyright 2018, Haiku Inc. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_COMPAT_THREAD_DEFS_H
#define _KERNEL_COMPAT_THREAD_DEFS_H
#include <thread_defs.h>
#define compat_ptr_t uint32
struct compat_thread_creation_attributes {
compat_ptr_t entry;
compat_ptr_t name;
int32 priority;
compat_ptr_t args1;
compat_ptr_t args2;
compat_ptr_t stack_address;
uint32_t stack_size;
uint32_t guard_size;
compat_ptr_t pthread;
uint32 flags;
} _PACKED;
static_assert(sizeof(struct compat_thread_creation_attributes) == 40,
"size of compat_thread_creation_attributes mismatch");
inline status_t
copy_ref_var_from_user(BKernel::ThreadCreationAttributes* userAttrs,
BKernel::ThreadCreationAttributes &attrs)
{
if (!IS_USER_ADDRESS(userAttrs))
return B_BAD_ADDRESS;
Thread* thread = thread_get_current_thread();
bool compatMode = (thread->flags & THREAD_FLAGS_COMPAT_MODE) != 0;
if (compatMode) {
struct compat_thread_creation_attributes compatAttrs;
if (user_memcpy(&compatAttrs, userAttrs, sizeof(compatAttrs)) < B_OK)
return B_BAD_ADDRESS;
attrs.entry = (int32 (*)(void*, void*))(addr_t)compatAttrs.entry;
attrs.name = (const char*)(addr_t)compatAttrs.name;
attrs.priority = compatAttrs.priority;
attrs.args1 = (void*)(addr_t)compatAttrs.args1;
attrs.args2 = (void*)(addr_t)compatAttrs.args2;
attrs.stack_address = (void*)(addr_t)compatAttrs.stack_address;
attrs.stack_size = compatAttrs.stack_size;
attrs.guard_size = compatAttrs.guard_size;
attrs.pthread = (pthread_t)(addr_t)compatAttrs.pthread;
attrs.flags = compatAttrs.flags;
} else if (user_memcpy(&attrs, userAttrs, sizeof(attrs)) < B_OK) {
return B_BAD_ADDRESS;
}
return B_OK;
}
#endif // _KERNEL_COMPAT_THREAD_DEFS_H
-5
View File
@@ -82,11 +82,6 @@ extern "C" {
extern status_t elf_resolve_symbol(struct elf_image_info* image,
elf_sym* symbol, struct elf_image_info* sharedImage,
elf_addr* _symbolAddress);
#ifdef _COMPAT_MODE
extern status_t elf32_resolve_symbol(struct elf_image_info* image,
elf_sym* symbol, struct elf_image_info* sharedImage,
elf_addr* _symbolAddress);
#endif
#ifdef __cplusplus
}
@@ -35,10 +35,6 @@ public:
addr_t Base() const { return fBase; }
addr_t EndAddress() const { return fEndAddress; }
size_t Size() const { return fEndAddress - fBase + 1; }
void SetSize(size_t size) {
fEndAddress = fBase + (size - 1);
fFreeSpace = size; }
size_t FreeSpace() const { return fFreeSpace; }
bool IsBeingDeleted() const { return fDeleting; }
-4
View File
@@ -37,10 +37,6 @@ enum {
#define THREAD_CREATION_FLAG_DEFER_SIGNALS 0x01
// create the thread with signals deferred, i.e. with
// user_thread::defer_signals set to 1
#ifdef _COMPAT_MODE
# define THREAD_CREATION_FLAG_COMPAT_MODE 0x02
// create the thread with a compatibility mode
#endif
struct thread_creation_attributes {