mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-30 14:35:17 -04:00
kern: print backtrace on panic
This commit is contained in:
parent
cb6af379d8
commit
8cfffc69d5
7 changed files with 106 additions and 14 deletions
|
@ -59,6 +59,51 @@ namespace ams::kern::arm64::cpu {
|
|||
EnsureInstructionConsistency();
|
||||
}
|
||||
|
||||
/* Helper for address access. */
|
||||
ALWAYS_INLINE bool GetPhysicalAddressWritable(KPhysicalAddress *out, KVirtualAddress addr, bool privileged = false) {
|
||||
const uintptr_t va = GetInteger(addr);
|
||||
|
||||
if (privileged) {
|
||||
__asm__ __volatile__("at s1e1w, %[va]" :: [va]"r"(va) : "memory");
|
||||
} else {
|
||||
__asm__ __volatile__("at s1e0w, %[va]" :: [va]"r"(va) : "memory");
|
||||
}
|
||||
InstructionMemoryBarrier();
|
||||
|
||||
u64 par = GetParEl1();
|
||||
|
||||
if (par & 0x1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (out) {
|
||||
*out = KPhysicalAddress((par & 0xFFFFFFFFF000ull) | (va & 0xFFFull));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool GetPhysicalAddressReadable(KPhysicalAddress *out, KVirtualAddress addr, bool privileged = false) {
|
||||
const uintptr_t va = GetInteger(addr);
|
||||
|
||||
if (privileged) {
|
||||
__asm__ __volatile__("at s1e1r, %[va]" :: [va]"r"(va) : "memory");
|
||||
} else {
|
||||
__asm__ __volatile__("at s1e0r, %[va]" :: [va]"r"(va) : "memory");
|
||||
}
|
||||
InstructionMemoryBarrier();
|
||||
|
||||
u64 par = GetParEl1();
|
||||
|
||||
if (par & 0x1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (out) {
|
||||
*out = KPhysicalAddress((par & 0xFFFFFFFFF000ull) | (va & 0xFFFull));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Synchronization helpers. */
|
||||
NOINLINE void SynchronizeAllCores();
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ namespace ams::kern::arm64::cpu {
|
|||
|
||||
MESOSPHERE_CPU_DEFINE_SYSREG_ACCESSORS(VbarEl1, vbar_el1)
|
||||
|
||||
MESOSPHERE_CPU_DEFINE_SYSREG_ACCESSORS(ParEl1, par_el1)
|
||||
|
||||
MESOSPHERE_CPU_DEFINE_SYSREG_ACCESSORS(SctlrEl1, sctlr_el1)
|
||||
|
||||
MESOSPHERE_CPU_DEFINE_SYSREG_ACCESSORS(CpuActlrEl1, s3_1_c15_c2_0)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace ams::kern {
|
|||
public:
|
||||
static NOINLINE void Initialize();
|
||||
|
||||
static NOINLINE void Printf(const char *format, ...);
|
||||
static NOINLINE void Printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
||||
static NOINLINE void VPrintf(const char *format, ::std::va_list vl);
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace ams::kern {
|
||||
|
||||
NORETURN void Panic(const char *file, int line, const char *format, ...);
|
||||
NORETURN void Panic(const char *file, int line, const char *format, ...) __attribute__((format(printf, 3, 4)));
|
||||
NORETURN void Panic();
|
||||
|
||||
}
|
||||
|
@ -31,11 +31,12 @@ namespace ams::kern {
|
|||
#endif
|
||||
|
||||
#ifdef MESOSPHERE_ENABLE_ASSERTIONS
|
||||
#define MESOSPHERE_ASSERT_IMPL(expr, ...) \
|
||||
({ \
|
||||
if (AMS_UNLIKELY(!(expr))) { \
|
||||
MESOSPHERE_PANIC(__VA_ARGS__); \
|
||||
} \
|
||||
#define MESOSPHERE_ASSERT_IMPL(expr, ...) \
|
||||
({ \
|
||||
const bool __tmp_meso_assert_val = (expr); \
|
||||
if (AMS_UNLIKELY(!__tmp_meso_assert_val)) { \
|
||||
MESOSPHERE_PANIC(__VA_ARGS__); \
|
||||
} \
|
||||
})
|
||||
#else
|
||||
#define MESOSPHERE_ASSERT_IMPL(expr, ...) do { static_cast<void>(expr); } while (0)
|
||||
|
@ -56,14 +57,16 @@ namespace ams::kern {
|
|||
|
||||
#define MESOSPHERE_ABORT_UNLESS(expr) \
|
||||
({ \
|
||||
if (AMS_UNLIKELY(!(expr))) { \
|
||||
const bool _tmp_meso_assert_val = (expr); \
|
||||
if (AMS_UNLIKELY(!_tmp_meso_assert_val)) { \
|
||||
MESOSPHERE_PANIC("Abort(): %s", #expr); \
|
||||
} \
|
||||
})
|
||||
|
||||
#define MESOSPHERE_INIT_ABORT_UNLESS(expr) \
|
||||
({ \
|
||||
if (AMS_UNLIKELY(!(expr))) { \
|
||||
const bool __tmp_meso_assert_val = (expr); \
|
||||
if (AMS_UNLIKELY(!__tmp_meso_assert_val)) { \
|
||||
MESOSPHERE_INIT_ABORT(); \
|
||||
} \
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue