Convert LKMC_DUMP_SYSTEM_REGS to a function lkmc_dump_system_regs

Add ID_AA64ISAR1_EL1.JSCVT.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-06-05 02:00:01 +00:00
parent 9bff1e9a1a
commit 2ccce0cf1f
3 changed files with 42 additions and 36 deletions

View File

@@ -6,6 +6,6 @@
#include <lkmc/aarch64_dump_regs.h> #include <lkmc/aarch64_dump_regs.h>
int main(void) { int main(void) {
LKMC_DUMP_SYSTEM_REGS; lkmc_dump_system_regs();
return 0; return 0;
} }

View File

@@ -13,7 +13,7 @@
static int myinit(void) static int myinit(void)
{ {
#if !defined(LKMC_DO_NOTHING) #if !defined(LKMC_DO_NOTHING)
LKMC_DUMP_SYSTEM_REGS; lkmc_dump_system_regs();
#endif #endif
return 0; return 0;
} }

View File

@@ -16,40 +16,46 @@
#endif #endif
/* Dump registers that are only visible from privileged levels of the system. */ /* Dump registers that are only visible from privileged levels of the system. */
#define LKMC_DUMP_SYSTEM_REGS \ void lkmc_dump_system_regs() {
uint32_t sctlr_el1; \ uint32_t sctlr_el1;
__asm__ ("mrs %0, sctlr_el1" : "=r" (sctlr_el1) : :); \ __asm__ ("mrs %0, sctlr_el1" : "=r" (sctlr_el1) : :);
LKMC_DUMP_SYSTEM_REGS_PRINTF("SCTLR_EL1 0x%" PRIX32 "\n", sctlr_el1); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("SCTLR_EL1 0x%" PRIX32 "\n", sctlr_el1);
LKMC_DUMP_SYSTEM_REGS_PRINTF("SCTLR_EL1.nTWE 0x%" PRIX32 "\n", (sctlr_el1 >> 18) & 1); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("SCTLR_EL1.nTWE 0x%" PRIX32 "\n", (sctlr_el1 >> 18) & 1);
LKMC_DUMP_SYSTEM_REGS_PRINTF("SCTLR_EL1.A 0x%" PRIX32 "\n", (sctlr_el1 >> 1) & 1); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("SCTLR_EL1.A 0x%" PRIX32 "\n", (sctlr_el1 >> 1) & 1);
/* https://cirosantilli.com/linux-kernel-module-cheat#arm-paging */ \ /* https://cirosantilli.com/linux-kernel-module-cheat#arm-paging */
LKMC_DUMP_SYSTEM_REGS_PRINTF("SCTLR_EL1.M 0x%" PRIX32 "\n", (sctlr_el1 >> 0) & 1); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("SCTLR_EL1.M 0x%" PRIX32 "\n", (sctlr_el1 >> 0) & 1);
\
uint64_t id_aa64pfr0_el1; \ uint64_t id_aa64isar1_el1;
__asm__ ("mrs %0, id_aa64pfr0_el1" : "=r" (id_aa64pfr0_el1) : :); \ __asm__ ("mrs %0, id_aa64isar1_el1" : "=r" (id_aa64isar1_el1) : :);
LKMC_DUMP_SYSTEM_REGS_PRINTF("ID_AA64PFR0_EL1 0x%" PRIX64 "\n", id_aa64pfr0_el1); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("ID_AA64ISAR1_EL1 0x%" PRIX64 "\n", id_aa64isar1_el1);
LKMC_DUMP_SYSTEM_REGS_PRINTF("ID_AA64PFR0_EL1.SVE 0x%" PRIX64 "\n", (id_aa64pfr0_el1 >> 32) & 0xF); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("ID_AA64ISAR1_EL1.JSCVT 0x%" PRIX64 "\n", (id_aa64isar1_el1 >> 12) & 0xF);
\
uint64_t CurrentEL; \ uint64_t id_aa64pfr0_el1;
__asm__ ("mrs %0, CurrentEL;" : "=r" (CurrentEL) : :); \ __asm__ ("mrs %0, id_aa64pfr0_el1" : "=r" (id_aa64pfr0_el1) : :);
LKMC_DUMP_SYSTEM_REGS_PRINTF("CurrentEL 0x%" PRIX64 "\n", CurrentEL); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("ID_AA64PFR0_EL1 0x%" PRIX64 "\n", id_aa64pfr0_el1);
/* https://cirosantilli.com/linux-kernel-module-cheat#arm-exception-levels */ \ LKMC_DUMP_SYSTEM_REGS_PRINTF("ID_AA64PFR0_EL1.SVE 0x%" PRIX64 "\n", (id_aa64pfr0_el1 >> 32) & 0xF);
LKMC_DUMP_SYSTEM_REGS_PRINTF("CurrentEL.EL 0x%" PRIX64 "\n", CurrentEL >> 2); \
\ uint64_t CurrentEL;
/* https://cirosantilli.com/linux-kernel-module-cheat#arm-paging */ \ __asm__ ("mrs %0, CurrentEL;" : "=r" (CurrentEL) : :);
{ \ LKMC_DUMP_SYSTEM_REGS_PRINTF("CurrentEL 0x%" PRIX64 "\n", CurrentEL);
uint64_t tcr_el1; \ /* https://cirosantilli.com/linux-kernel-module-cheat#arm-exception-levels */
__asm__ ("mrs %0, tcr_el1;" : "=r" (tcr_el1) : :); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("CurrentEL.EL 0x%" PRIX64 "\n", CurrentEL >> 2);
LKMC_DUMP_SYSTEM_REGS_PRINTF("TCR_EL1 0x%" PRIX64 "\n", tcr_el1); \
LKMC_DUMP_SYSTEM_REGS_PRINTF("TCR_EL1.A1 0x%" PRIX64 "\n", (tcr_el1 >> 22) & 1); \ /* https://cirosantilli.com/linux-kernel-module-cheat#arm-paging */
\ {
uint64_t ttbr0_el1; \ uint64_t tcr_el1;
__asm__ ("mrs %0, ttbr0_el1;" : "=r" (ttbr0_el1) : :); \ __asm__ ("mrs %0, tcr_el1;" : "=r" (tcr_el1) : :);
LKMC_DUMP_SYSTEM_REGS_PRINTF("TTBR0_EL1 0x%" PRIX64 "\n", ttbr0_el1); \ LKMC_DUMP_SYSTEM_REGS_PRINTF("TCR_EL1 0x%" PRIX64 "\n", tcr_el1);
\ LKMC_DUMP_SYSTEM_REGS_PRINTF("TCR_EL1.A1 0x%" PRIX64 "\n", (tcr_el1 >> 22) & 1);
uint64_t ttbr1_el1; \
__asm__ ("mrs %0, ttbr1_el1;" : "=r" (ttbr1_el1) : :); \ uint64_t ttbr0_el1;
LKMC_DUMP_SYSTEM_REGS_PRINTF("TTBR1_EL1 0x%" PRIX64 "\n", ttbr1_el1); \ __asm__ ("mrs %0, ttbr0_el1;" : "=r" (ttbr0_el1) : :);
LKMC_DUMP_SYSTEM_REGS_PRINTF("TTBR0_EL1 0x%" PRIX64 "\n", ttbr0_el1);
uint64_t ttbr1_el1;
__asm__ ("mrs %0, ttbr1_el1;" : "=r" (ttbr1_el1) : :);
LKMC_DUMP_SYSTEM_REGS_PRINTF("TTBR1_EL1 0x%" PRIX64 "\n", ttbr1_el1);
} }
}
#endif #endif