Skip to content
Permalink
Browse files
Unreviewed, reverting r287908.
https://bugs.webkit.org/show_bug.cgi?id=235156

Broke M1 Monterey JSC

Reverted changeset:

"Update hashThreadState() to exclude __opaque_flags."
https://bugs.webkit.org/show_bug.cgi?id=235081
https://commits.webkit.org/r287908


Canonical link: https://commits.webkit.org/245979@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287950 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
webkit-commit-queue committed Jan 12, 2022
1 parent b04f96f commit 28c5a2ce7f44e40b4ccb8466370884151b9f1acb
Showing with 125 additions and 8 deletions.
  1. +13 −0 Source/JavaScriptCore/ChangeLog
  2. +75 −1 Source/JavaScriptCore/runtime/MachineContext.h
  3. +13 −0 Source/WTF/ChangeLog
  4. +22 −1 Source/WTF/wtf/PlatformRegisters.h
  5. +2 −6 Source/WTF/wtf/threads/Signals.cpp
@@ -1,3 +1,16 @@
2022-01-12 Commit Queue <commit-queue@webkit.org>

Unreviewed, reverting r287908.
https://bugs.webkit.org/show_bug.cgi?id=235156

Broke M1 Monterey JSC

Reverted changeset:

"Update hashThreadState() to exclude __opaque_flags."
https://bugs.webkit.org/show_bug.cgi?id=235081
https://commits.webkit.org/r287908

2022-01-11 Zan Dobersek <zdobersek@igalia.com>

[RISCV64] riscv64 backend should lower offlineasm instructions
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>.
* Copyright (C) 2018-2022 Apple Inc. All rights reserved.
* Copyright (C) 2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -39,8 +39,11 @@ namespace MachineContext {
template<typename T = void*> T stackPointer(const PlatformRegisters&);

#if OS(WINDOWS) || HAVE(MACHINE_CONTEXT)
template<typename T = void*> void setStackPointer(PlatformRegisters&, T);
template<typename T = void*> T framePointer(const PlatformRegisters&);
template<typename T = void*> void setFramePointer(PlatformRegisters&, T);
inline MacroAssemblerCodePtr<PlatformRegistersLRPtrTag> linkRegister(const PlatformRegisters&);
inline void setLinkRegister(PlatformRegisters&, MacroAssemblerCodePtr<CFunctionPtrTag>);
inline std::optional<MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>> instructionPointer(const PlatformRegisters&);
inline void setInstructionPointer(PlatformRegisters&, MacroAssemblerCodePtr<CFunctionPtrTag>);

@@ -64,8 +67,11 @@ static inline void*& framePointerImpl(mcontext_t&);
#endif // !USE(PLATFORM_REGISTERS_WITH_PROFILE)

template<typename T = void*> T stackPointer(const mcontext_t&);
template<typename T = void*> void setStackPointer(mcontext_t&, T);
template<typename T = void*> T framePointer(const mcontext_t&);
template<typename T = void*> void setFramePointer(mcontext_t&, T);
inline MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> instructionPointer(const mcontext_t&);
inline void setInstructionPointer(mcontext_t&, MacroAssemblerCodePtr<CFunctionPtrTag>);

template<size_t N> void*& argumentPointer(mcontext_t&);
template<size_t N> void* argumentPointer(const mcontext_t&);
@@ -144,6 +150,19 @@ inline T stackPointer(const PlatformRegisters& regs)
#endif
}

template<typename T>
inline void setStackPointer(PlatformRegisters& regs, T value)
{
#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
assertIsNotTagged(bitwise_cast<void*>(value));
WTF_WRITE_PLATFORM_REGISTERS_SP_WITH_PROFILE(regs, bitwise_cast<void*>(value));
#elif USE(DARWIN_REGISTER_MACROS)
__darwin_arm_thread_state64_set_sp(regs, value);
#else
stackPointerImpl(regs) = bitwise_cast<void*>(value);
#endif
}

#else // not OS(WINDOWS) || HAVE(MACHINE_CONTEXT)

template<typename T>
@@ -210,6 +229,19 @@ inline T stackPointer(const mcontext_t& machineContext)
return bitwise_cast<T>(stackPointerImpl(const_cast<mcontext_t&>(machineContext)));
#endif
}

template<typename T>
inline void setStackPointer(mcontext_t& machineContext, T value)
{
#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
assertIsNotTagged(bitwise_cast<void*>(value));
WTF_WRITE_MACHINE_CONTEXT_SP_WITH_PROFILE(machineContext, bitwise_cast<void*>(value));
#elif USE(DARWIN_REGISTER_MACROS)
return setStackPointer(machineContext->__ss, value);
#else
stackPointerImpl(machineContext) = bitwise_cast<void*>(value);
#endif
}
#endif // HAVE(MACHINE_CONTEXT)


@@ -279,6 +311,17 @@ inline T framePointer(const PlatformRegisters& regs)
return bitwise_cast<T>(framePointerImpl(const_cast<PlatformRegisters&>(regs)));
#endif
}

template<typename T>
inline void setFramePointer(PlatformRegisters& regs, T value)
{
#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
assertIsNotTagged(bitwise_cast<void*>(value));
WTF_WRITE_PLATFORM_REGISTERS_FP_WITH_PROFILE(regs, bitwise_cast<void*>(value));
#else
framePointerImpl(regs) = bitwise_cast<void*>(value);
#endif
}
#endif // OS(WINDOWS) || HAVE(MACHINE_CONTEXT)


@@ -341,6 +384,17 @@ inline T framePointer(const mcontext_t& machineContext)
return bitwise_cast<T>(framePointerImpl(const_cast<mcontext_t&>(machineContext)));
#endif
}

template<typename T>
inline void setFramePointer(mcontext_t& machineContext, T value)
{
#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
assertIsNotTagged(bitwise_cast<void*>(value));
WTF_WRITE_MACHINE_CONTEXT_FP_WITH_PROFILE(machineContext, bitwise_cast<void*>(value));
#else
framePointerImpl(machineContext) = bitwise_cast<void*>(value);
#endif
}
#endif // HAVE(MACHINE_CONTEXT)


@@ -487,6 +541,17 @@ inline MacroAssemblerCodePtr<PlatformRegistersPCPtrTag> instructionPointer(const
return MacroAssemblerCodePtr<PlatformRegistersPCPtrTag>(value);
#endif
}

inline void setInstructionPointer(mcontext_t& machineContext, MacroAssemblerCodePtr<CFunctionPtrTag> value)
{
#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
WTF_WRITE_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext, value.executableAddress());
#elif USE(DARWIN_REGISTER_MACROS)
setInstructionPointer(machineContext->__ss, value);
#else
instructionPointerImpl(machineContext) = value.executableAddress();
#endif
}
#endif // HAVE(MACHINE_CONTEXT)


@@ -503,6 +568,15 @@ inline MacroAssemblerCodePtr<PlatformRegistersLRPtrTag> linkRegister(const Platf
#endif
return MacroAssemblerCodePtr<PlatformRegistersLRPtrTag>(value);
}

inline void setLinkRegister(PlatformRegisters& regs, MacroAssemblerCodePtr<CFunctionPtrTag> value)
{
#if USE(PLATFORM_REGISTERS_WITH_PROFILE)
WTF_WRITE_PLATFORM_REGISTERS_PC_WITH_PROFILE(regs, value.executableAddress());
#else
__darwin_arm_thread_state64_set_lr_fptr(regs, value.executableAddress());
#endif
}
#endif // OS(DARWIN) && __DARWIN_UNIX03 && CPU(ARM64)

#if HAVE(MACHINE_CONTEXT)
@@ -1,3 +1,16 @@
2022-01-12 Commit Queue <commit-queue@webkit.org>

Unreviewed, reverting r287908.
https://bugs.webkit.org/show_bug.cgi?id=235156

Broke M1 Monterey JSC

Reverted changeset:

"Update hashThreadState() to exclude __opaque_flags."
https://bugs.webkit.org/show_bug.cgi?id=235081
https://commits.webkit.org/r287908

2022-01-10 Yusuke Suzuki <ysuzuki@apple.com>

[JSC] Enable libpas jit-heap when libpas is enabled
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
* Copyright (C) 2019-2022 Apple Inc. All rights reserved.
* Copyright (C) 2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -119,12 +119,21 @@ using WTF::threadStatePCInternal;
#define WTF_READ_PLATFORM_REGISTERS_SP_WITH_PROFILE(regs) \
reinterpret_cast<void*>(arm_thread_state64_get_sp(const_cast<PlatformRegisters&>(regs)))

#define WTF_WRITE_PLATFORM_REGISTERS_SP_WITH_PROFILE(regs, newPointer) \
arm_thread_state64_set_sp(regs, reinterpret_cast<uintptr_t>(newPointer))

#define WTF_READ_PLATFORM_REGISTERS_FP_WITH_PROFILE(regs) \
reinterpret_cast<void*>(arm_thread_state64_get_fp(const_cast<PlatformRegisters&>(regs)))

#define WTF_WRITE_PLATFORM_REGISTERS_FP_WITH_PROFILE(regs, newPointer) \
arm_thread_state64_set_fp(regs, reinterpret_cast<uintptr_t>(newPointer))

#define WTF_READ_PLATFORM_REGISTERS_LR_WITH_PROFILE(regs) \
threadStateLRInternal(const_cast<PlatformRegisters&>(regs))

#define WTF_WRITE_PLATFORM_REGISTERS_LR_WITH_PROFILE(regs, newPointer) \
arm_thread_state64_set_lr_fptr(regs, newPointer)

#define WTF_READ_PLATFORM_REGISTERS_PC_WITH_PROFILE(regs) \
threadStatePCInternal(const_cast<PlatformRegisters&>(regs))

@@ -134,12 +143,24 @@ using WTF::threadStatePCInternal;
#define WTF_READ_MACHINE_CONTEXT_SP_WITH_PROFILE(machineContext) \
WTF_READ_PLATFORM_REGISTERS_SP_WITH_PROFILE(machineContext->__ss)

#define WTF_WRITE_MACHINE_CONTEXT_SP_WITH_PROFILE(machineContext, newPointer) \
WTF_WRITE_PLATFORM_REGISTERS_SP_WITH_PROFILE(machineContext->__ss, newPointer)

#define WTF_READ_MACHINE_CONTEXT_FP_WITH_PROFILE(machineContext) \
WTF_READ_PLATFORM_REGISTERS_FP_WITH_PROFILE(machineContext->__ss)

#define WTF_WRITE_MACHINE_CONTEXT_FP_WITH_PROFILE(machineContext, newPointer) \
WTF_WRITE_PLATFORM_REGISTERS_FP_WITH_PROFILE(machineContext->__ss, newPointer)

#define WTF_WRITE_MACHINE_CONTEXT_LR_WITH_PROFILE(machineContext, newPointer) \
WTF_WRITE_PLATFORM_REGISTERS_LR_WITH_PROFILE(machineContext->__ss, newPointer)

#define WTF_READ_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext) \
WTF_READ_PLATFORM_REGISTERS_PC_WITH_PROFILE(machineContext->__ss)

#define WTF_WRITE_MACHINE_CONTEXT_PC_WITH_PROFILE(machineContext, newPointer) \
WTF_WRITE_PLATFORM_REGISTERS_PC_WITH_PROFILE(machineContext->__ss, newPointer)

#endif // USE(PLATFORM_REGISTERS_WITH_PROFILE)

using WTF::PlatformRegisters;
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2022 Apple Inc. All rights reserved.
* Copyright (C) 2017-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -172,14 +172,10 @@ inline ptrauth_generic_signature_t hashThreadState(const thread_state_t source)

const uintptr_t* srcPtr = reinterpret_cast<const uintptr_t*>(source);

// Exclude the __opaque_flags field which is reserved for OS use.
// __opaque_flags is at the end of the payload.
for (size_t i = 0; i < threadStateSizeInPointers - 1; ++i) {
for (size_t i = 0; i < threadStateSizeInPointers; ++i) {
if (i != threadStatePCPointerIndex)
hash = ptrauth_sign_generic_data(srcPtr[i], hash);
}
const uint32_t* cpsrPtr = reinterpret_cast<const uint32_t*>(&srcPtr[threadStateSizeInPointers - 1]);
hash = ptrauth_sign_generic_data(static_cast<uint64_t>(*cpsrPtr), hash);

return hash;
}

0 comments on commit 28c5a2c

Please sign in to comment.