asm: make use regular asserts that will just work on baremetal

Previously had wonky line pointer in asm_main. New interface simpler and more portable.

Add tests for ASSERT_EQ_ and family in arm and aarch64, previously on x86_64.

ASSERT_EQ_ and family in ARM can now either take =123, =addr or var, before this
the = was added on macros so var was not possible.

Define the main function directly in assembly, the C driver was useless.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-23 00:00:00 +00:00
parent 72200dee4e
commit c8c4f89854
90 changed files with 1003 additions and 978 deletions

View File

@@ -1,8 +1,8 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#armv8-aarch64-x31-register */
#include "common.h"
#include <lkmc.h>
LKMC_ENTRY
LKMC_PROLOGUE
/* ERROR: can never use the name x31. */
#if 0
mov x31, 31
@@ -11,12 +11,12 @@ LKMC_ENTRY
/* mov (register) is an alias for ORR, which accepts xzr. */
mov x19, 1
mov x19, xzr
LKMC_ASSERT_EQ(x19, 0)
LKMC_ASSERT_EQ(x19, =0)
/* Same encoding as the mov version. */
mov x19, 1
orr x19, xzr, xzr
LKMC_ASSERT_EQ(x19, 0)
LKMC_ASSERT_EQ(x19, =0)
/* So, orr, which is not an alias, can only take xzr, not sp. */
#if 0
@@ -26,7 +26,7 @@ LKMC_ENTRY
/* Zero register discards result if written to. */
mov x19, 1
orr xzr, x19, x19
LKMC_ASSERT_EQ(xzr, 0)
LKMC_ASSERT_EQ(xzr, =0)
/* MOV (to/from SP) is an alias for ADD (immediate). */
mov x19, sp
@@ -36,7 +36,7 @@ LKMC_ENTRY
/* Exact same encoding as above. */
add x20, sp, 0
mov sp, x19
LKMC_ASSERT_EQ(x20, 1)
LKMC_ASSERT_EQ(x20, =1)
/* So, ADD (immediate), which is not an alias, can only take sp, not xzr. */
#if 0
@@ -48,4 +48,4 @@ LKMC_ENTRY
* does not say anything about SP, and so does accept xzr just fine.
*/
add xzr, xzr, xzr
LKMC_EXIT
LKMC_EPILOGUE