From b5f5f6a5bcde6832ba707d92d28aa698b1dafc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Sun, 12 May 2019 00:00:08 +0000 Subject: [PATCH] userland: attempt to fix all assembly example links to README --- README.adoc | 39 +++++++++++++------ userland/arch/aarch64/add.S | 2 +- userland/arch/aarch64/add_vector.S | 2 +- userland/arch/aarch64/adr.S | 2 +- userland/arch/aarch64/adrp.S | 2 +- userland/arch/aarch64/beq.S | 2 +- userland/arch/aarch64/bfi.S | 2 +- userland/arch/aarch64/c/earlyclobber.c | 2 +- userland/arch/aarch64/c/inc.c | 2 +- userland/arch/aarch64/c/inc_float.c | 2 +- userland/arch/aarch64/c/reg_var.c | 2 +- userland/arch/aarch64/c/reg_var_float.c | 2 +- userland/arch/aarch64/cbz.S | 2 +- userland/arch/aarch64/cset.S | 2 +- userland/arch/aarch64/fadd_vector.S | 2 +- userland/arch/aarch64/gas_data_sizes.S | 2 +- userland/arch/aarch64/hello_driver.S | 7 ---- userland/arch/aarch64/movk.S | 2 +- userland/arch/aarch64/movn.S | 2 +- userland/arch/aarch64/ret.S | 2 +- userland/arch/aarch64/simd_interleave.S | 2 +- userland/arch/aarch64/str.S | 2 +- userland/arch/aarch64/ubfm.S | 2 +- userland/arch/aarch64/ubfx.S | 2 +- userland/arch/aarch64/x31.S | 2 +- userland/arch/arm/add.S | 2 +- userland/arch/arm/address_modes.S | 2 +- userland/arch/arm/adr.S | 2 +- userland/arch/arm/and.S | 2 +- userland/arch/arm/b.S | 2 +- userland/arch/arm/beq.S | 2 +- userland/arch/arm/bfi.S | 2 +- userland/arch/arm/bic.S | 2 +- userland/arch/arm/bl.S | 2 +- userland/arch/arm/c/add.c | 2 +- .../arch/arm/c/freestanding/linux/hello.c | 5 ++- userland/arch/arm/c/inc.c | 2 +- userland/arch/arm/c/inc_float.c | 2 +- userland/arch/arm/c/inc_memory.c | 2 +- userland/arch/arm/c/inc_memory_global.c | 2 +- userland/arch/arm/c/reg_var.c | 2 +- userland/arch/arm/clz.S | 2 +- userland/arch/arm/cond.S | 2 +- userland/arch/arm/gas_data_sizes.S | 2 + userland/arch/arm/hello_driver.S | 23 ----------- userland/arch/arm/immediates.S | 2 +- userland/arch/arm/inc_array.S | 2 +- userland/arch/arm/ldmia.S | 2 +- userland/arch/arm/ldr_pseudo.S | 2 +- userland/arch/arm/ldrb.S | 2 +- userland/arch/arm/ldrh.S | 2 +- userland/arch/arm/mov.S | 2 +- userland/arch/arm/movw.S | 2 +- userland/arch/arm/mul.S | 5 ++- userland/arch/arm/nop.S | 2 +- userland/arch/arm/push.S | 2 +- userland/arch/arm/rbit.S | 5 ++- userland/arch/arm/rev.S | 5 ++- userland/arch/arm/s_suffix.S | 2 +- userland/arch/arm/shift.S | 2 +- userland/arch/arm/sub.S | 5 ++- userland/arch/arm/thumb.S | 6 ++- userland/arch/arm/tst.S | 5 ++- userland/arch/arm/vadd.S | 2 +- userland/arch/arm/vcvt.S | 2 +- userland/arch/arm/vcvta.S | 2 +- userland/arch/arm/vcvtr.S | 2 +- userland/arch/x86_64/c/add.c | 2 +- userland/arch/x86_64/c/inc.c | 2 +- userland/arch/x86_64/c/scratch.c | 2 +- userland/arch/x86_64/c/scratch_hardcode.c | 2 +- userland/arch/x86_64/gas_data_sizes.S | 2 +- userland/arch/x86_64/paddq.S | 2 +- 73 files changed, 119 insertions(+), 112 deletions(-) delete mode 100644 userland/arch/aarch64/hello_driver.S delete mode 100644 userland/arch/arm/hello_driver.S diff --git a/README.adoc b/README.adoc index 13fecaf..2e537cf 100644 --- a/README.adoc +++ b/README.adoc @@ -9,7 +9,7 @@ :toclevels: 6 :toc-title: -The perfect emulation setup to study and develop the <> v5.0, kernel modules, <> and x86_64, ARMv7 and ARMv8 <> and <> assembly. <> and <> just work. Powered by <> and <>. Highly automated. Thoroughly documented. Automated <>. "Tested" in an Ubuntu 18.04 host. +The perfect emulation setup to study and develop the <> v5.0, kernel modules, <>, <> and x86_64, ARMv7 and ARMv8 <> and <> assembly. <> and <> just work. Powered by <> and <>. Highly automated. Thoroughly documented. Automated <>. "Tested" in an Ubuntu 18.04 host. TL;DR: <> @@ -373,7 +373,7 @@ Have you ever felt that a single `inc` instruction was not enough? Really? Me to So let's hack the <>, which is part of link:https://en.wikipedia.org/wiki/GNU_Binutils[GNU Binutils], to add a new shiny version of `inc` called... `myinc`! -GCC uses GNU GAS as its backend, so we will test out new mnemonic with an inline assembly test program: link:userland/arch/x86_64/binutils_hack.c[], which is just a copy of link:userland/arch/x86_64/asm_hello.c[] but with `myinc` instead of `inc`. +GCC uses GNU GAS as its backend, so we will test out new mnemonic with an <> test program: link:userland/arch/x86_64/binutils_hack.c[], which is just a copy of link:userland/arch/x86_64/asm_hello.c[] but with `myinc` instead of `inc`. The inline assembly is disabled with an `#ifdef`, so first modify the source to enable that. @@ -955,7 +955,7 @@ Notable userland content included / moving into this repository includes: * <> * <> * <> -* https://github.com/cirosantilli/algorithm-cheat will be good to move here for performance analysis +* https://github.com/cirosantilli/algorithm-cheat TODO will be good to move here for performance analysis <> ==== Userland setup getting started @@ -11685,7 +11685,7 @@ corresponding register field is interpreted as returning zero when read or disca When instructions do not interpret this operand encoding as the zero register, use of the name XZR is an error ____ -=== Assembly SIMD +=== SIMD assembly Much like ADD for non-SIMD, start learning SIMD instructions by looking at the integer and floating point SIMD ADD instructions of each ISA: @@ -11980,7 +11980,7 @@ Some of the differences include: When reading disassembly, many instructions have either a `.n` or `.w` suffix. -`.n` means narrow, and stands for the Thumb encoding of an instructions, while `.w` means wide and stands for the ARM encoding. +`.n` means narrow, and stands for the <> of an instructions, while `.w` means wide and stands for the ARM encoding. Bibliography: https://stackoverflow.com/questions/27147043/n-suffix-to-branch-instruction @@ -12145,7 +12145,7 @@ Understanding the basics of instruction encodings is fundamental to help you to aarch32 has two "instruction sets", which to look just like encodings. -Some control bit determines which one we are currently on, and userland can switch between them with the <>. +Some control bit must determine which one we are currently on, and userland can switch between them with the <> TODO: details. The encodings are: @@ -12154,6 +12154,8 @@ The encodings are: + T stands for "Thumb", which is the original name for the technology. The word "Thumb" does not appear on <> however. It does appear on <> though. + +Example: link:userland/arch/arm/thumb.S[] ++ See also: <> F2.1.3 "Instruction encodings". Within each instruction set, there can be multiple encodings for a given function, and they are noted simply as: @@ -12188,7 +12190,10 @@ TODO: what to do if we want to jump longer than that? Branch if equal based on the status registers. -Example: link:userland/arch/arm/beq.S[]. +Examples: + +* link:userland/arch/arm/beq.S[]. +* link:userland/arch/aarch64/beq.S[]. The family of instructions includes: @@ -12217,13 +12222,13 @@ The current ARM / Thumb mode is encoded in the least significant bit of lr. Since `bl` encodes the current ARM / Thumb in the register, `bx` keeps the mode unchanged by default. -===== ARM ret instruction +===== ARMv8 aarch64 ret instruction Example: link:userland/arch/aarch64/ret.S[] -In ARMv8 aarch64: +ARMv8 AArch64 only: -* there is no `bx` since no Thumb to worry about, so it is called just `br` +* there is no `bx` in AArch64 since no Thumb to worry about, so it is called just `br` * the `ret` instruction was added in addition to `br`, with the following differences: ** provides a hint that this is a function call return ** has a default argument `x30` if none is given. This is where `bl` puts the return value. @@ -12388,8 +12393,6 @@ AArch64 loses those instructions, likely because it was not possible anymore to Arithmetic: -* link:userland/arch/arm/add.S[]. We use this simple instruction to explain syntax common to most data processing instructions, so have a good look at that file. -** link:userland/arch/aarch64/add.S[] * link:userland/arch/arm/mul.S[]: multiply * link:userland/arch/arm/sub.S[]: subtract * link:userland/arch/arm/rbit.S[]: reverse bit order @@ -12589,6 +12592,18 @@ Bibliography: https://stackoverflow.com/questions/1875491/nop-for-iphone-binarie === ARM SIMD +==== ARM fadd vs vadd + +It is very confusing, but `fadds` and `faddd` in Aarch32 are <> for `vadd.f32` and `vadd.f64`. + +The same goes for most ARMv7 mnemonics: `f*` is old, and `v*` is the newer better syntax. + +But then, in ARMv8, they decided to use `fadd` as the main floating point add name, and get rid of `vadd`! + +Also keep in mind that fused multiply add is `fmadd`. + +Examples at: <> + ==== ARM SIMD instructions ===== ARM vcvt instruction diff --git a/userland/arch/aarch64/add.S b/userland/arch/aarch64/add.S index 37cc473..120c746 100644 --- a/userland/arch/aarch64/add.S +++ b/userland/arch/aarch64/add.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#data-processing-instructions */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#userland-assembly */ #include "common.h" diff --git a/userland/arch/aarch64/add_vector.S b/userland/arch/aarch64/add_vector.S index 25c8662..b449b73 100644 --- a/userland/arch/aarch64/add_vector.S +++ b/userland/arch/aarch64/add_vector.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#assembly-simd +/* https://github.com/cirosantilli/linux-kernel-module-cheat#simd-assembly * * Add a bunch of integers in one go. */ diff --git a/userland/arch/aarch64/adr.S b/userland/arch/aarch64/adr.S index 09302ff..51478f5 100644 --- a/userland/arch/aarch64/adr.S +++ b/userland/arch/aarch64/adr.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#adr */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-adr-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/adrp.S b/userland/arch/aarch64/adrp.S index 1e4fda7..530d749 100644 --- a/userland/arch/aarch64/adrp.S +++ b/userland/arch/aarch64/adrp.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#adr */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-adr-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/beq.S b/userland/arch/aarch64/beq.S index b1ed351..997c8ec 100644 --- a/userland/arch/aarch64/beq.S +++ b/userland/arch/aarch64/beq.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#cbz */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-beq-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/bfi.S b/userland/arch/aarch64/bfi.S index b8513ab..b3b6596 100644 --- a/userland/arch/aarch64/bfi.S +++ b/userland/arch/aarch64/bfi.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#bfi */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-bfi-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/c/earlyclobber.c b/userland/arch/aarch64/c/earlyclobber.c index 03e4197..4e9b6f2 100644 --- a/userland/arch/aarch64/c/earlyclobber.c +++ b/userland/arch/aarch64/c/earlyclobber.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly-early-clobbers */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly-early-clobbers */ #include #include diff --git a/userland/arch/aarch64/c/inc.c b/userland/arch/aarch64/c/inc.c index d1b7822..80b259c 100644 --- a/userland/arch/aarch64/c/inc.c +++ b/userland/arch/aarch64/c/inc.c @@ -1,6 +1,6 @@ /* Increment a variable in inline assembly. * - * https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly + * https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly */ #include diff --git a/userland/arch/aarch64/c/inc_float.c b/userland/arch/aarch64/c/inc_float.c index ecd5c75..bada60d 100644 --- a/userland/arch/aarch64/c/inc_float.c +++ b/userland/arch/aarch64/c/inc_float.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly-floating-point-arm */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly-floating-point-arm */ #include diff --git a/userland/arch/aarch64/c/reg_var.c b/userland/arch/aarch64/c/reg_var.c index c00a289..52ed40d 100644 --- a/userland/arch/aarch64/c/reg_var.c +++ b/userland/arch/aarch64/c/reg_var.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly-register-variables */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly-register-variables */ #include #include diff --git a/userland/arch/aarch64/c/reg_var_float.c b/userland/arch/aarch64/c/reg_var_float.c index db4c49f..8c1c88e 100644 --- a/userland/arch/aarch64/c/reg_var_float.c +++ b/userland/arch/aarch64/c/reg_var_float.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly-register-variables */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly-register-variables */ #include #include diff --git a/userland/arch/aarch64/cbz.S b/userland/arch/aarch64/cbz.S index 7561cf7..31982ab 100644 --- a/userland/arch/aarch64/cbz.S +++ b/userland/arch/aarch64/cbz.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#cbz */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-cbz-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/cset.S b/userland/arch/aarch64/cset.S index a446df9..66a8fb1 100644 --- a/userland/arch/aarch64/cset.S +++ b/userland/arch/aarch64/cset.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#cset */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-cset-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/fadd_vector.S b/userland/arch/aarch64/fadd_vector.S index 0c507bd..ebaa595 100644 --- a/userland/arch/aarch64/fadd_vector.S +++ b/userland/arch/aarch64/fadd_vector.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#assembly-simd +/* https://github.com/cirosantilli/linux-kernel-module-cheat#simd-assembly * * Add a bunch of floating point numbers in one go. */ diff --git a/userland/arch/aarch64/gas_data_sizes.S b/userland/arch/aarch64/gas_data_sizes.S index b24af13..3243e59 100644 --- a/userland/arch/aarch64/gas_data_sizes.S +++ b/userland/arch/aarch64/gas_data_sizes.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#gas-data-sizes */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gnu-gas-assembler data sizes */ #include "common.h" diff --git a/userland/arch/aarch64/hello_driver.S b/userland/arch/aarch64/hello_driver.S deleted file mode 100644 index 86b73ef..0000000 --- a/userland/arch/aarch64/hello_driver.S +++ /dev/null @@ -1,7 +0,0 @@ -/* MInimal sanity check of the C driver. */ -.text -.global asm_main -asm_main: -asm_main_after_prologue: - mov w0, 0 - ret diff --git a/userland/arch/aarch64/movk.S b/userland/arch/aarch64/movk.S index 5947df3..4563c95 100644 --- a/userland/arch/aarch64/movk.S +++ b/userland/arch/aarch64/movk.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#movk */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#armv8-aarch64-movk-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/movn.S b/userland/arch/aarch64/movn.S index 27db454..253e9ca 100644 --- a/userland/arch/aarch64/movn.S +++ b/userland/arch/aarch64/movn.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#movn */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#armv8-aarch64-movn-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/ret.S b/userland/arch/aarch64/ret.S index a356e4d..6570ea1 100644 --- a/userland/arch/aarch64/ret.S +++ b/userland/arch/aarch64/ret.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#bl */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#armv8-aarch64-ret-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/simd_interleave.S b/userland/arch/aarch64/simd_interleave.S index 12ba4cf..38bcc8b 100644 --- a/userland/arch/aarch64/simd_interleave.S +++ b/userland/arch/aarch64/simd_interleave.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#simd-interleaving */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-simd-interleaving */ #include "common.h" diff --git a/userland/arch/aarch64/str.S b/userland/arch/aarch64/str.S index 568f781..e65799d 100644 --- a/userland/arch/aarch64/str.S +++ b/userland/arch/aarch64/str.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#armv8-str */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#armv8-aarch64-str-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/ubfm.S b/userland/arch/aarch64/ubfm.S index c1943bc..7924917 100644 --- a/userland/arch/aarch64/ubfm.S +++ b/userland/arch/aarch64/ubfm.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#ubfm */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-ubfm-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/ubfx.S b/userland/arch/aarch64/ubfx.S index 8dd1f3c..3223235 100644 --- a/userland/arch/aarch64/ubfx.S +++ b/userland/arch/aarch64/ubfx.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#ubfx */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-ubfx-instruction */ #include "common.h" diff --git a/userland/arch/aarch64/x31.S b/userland/arch/aarch64/x31.S index d16e1a1..00b9432 100644 --- a/userland/arch/aarch64/x31.S +++ b/userland/arch/aarch64/x31.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#x31 */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#armv8-aarch64-x31-register */ #include "common.h" diff --git a/userland/arch/arm/add.S b/userland/arch/arm/add.S index 5e3cd42..5bec4f9 100644 --- a/userland/arch/arm/add.S +++ b/userland/arch/arm/add.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#data-processing-instructions */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-data-processing-instructions */ #include "common.h" diff --git a/userland/arch/arm/address_modes.S b/userland/arch/arm/address_modes.S index 55925e6..66e2ad1 100644 --- a/userland/arch/arm/address_modes.S +++ b/userland/arch/arm/address_modes.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#addressing-modes */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-addressing-modes */ #include "common.h" diff --git a/userland/arch/arm/adr.S b/userland/arch/arm/adr.S index 0d1ee47..13e1638 100644 --- a/userland/arch/arm/adr.S +++ b/userland/arch/arm/adr.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#adr */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-adr-instruction */ #include "common.h" diff --git a/userland/arch/arm/and.S b/userland/arch/arm/and.S index 8d4caca..0e39161 100644 --- a/userland/arch/arm/and.S +++ b/userland/arch/arm/and.S @@ -1,4 +1,4 @@ -/* Bitwise AND. */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-bitwise-instructions */ #include "common.h" diff --git a/userland/arch/arm/b.S b/userland/arch/arm/b.S index df5c707..bf7ab03 100644 --- a/userland/arch/arm/b.S +++ b/userland/arch/arm/b.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#b */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-b-instruction */ #include "common.h" ENTRY diff --git a/userland/arch/arm/beq.S b/userland/arch/arm/beq.S index 51b9d6d..3c9564f 100644 --- a/userland/arch/arm/beq.S +++ b/userland/arch/arm/beq.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#beq */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-beq-instruction */ #include "common.h" diff --git a/userland/arch/arm/bfi.S b/userland/arch/arm/bfi.S index e7976e3..0f15c16 100644 --- a/userland/arch/arm/bfi.S +++ b/userland/arch/arm/bfi.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#bfi */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-bfi-instruction */ #include "common.h" diff --git a/userland/arch/arm/bic.S b/userland/arch/arm/bic.S index 8f2bce0..a1aff45 100644 --- a/userland/arch/arm/bic.S +++ b/userland/arch/arm/bic.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#bic */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-bic-instruction */ #include "common.h" diff --git a/userland/arch/arm/bl.S b/userland/arch/arm/bl.S index 2b21b8b..4dbbdef 100644 --- a/userland/arch/arm/bl.S +++ b/userland/arch/arm/bl.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#bl */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-bl-instruction */ #include "common.h" diff --git a/userland/arch/arm/c/add.c b/userland/arch/arm/c/add.c index 882c005..d46acf3 100644 --- a/userland/arch/arm/c/add.c +++ b/userland/arch/arm/c/add.c @@ -1,6 +1,6 @@ /* 1 + 2 == 3 * - * https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly + * https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly */ #include diff --git a/userland/arch/arm/c/freestanding/linux/hello.c b/userland/arch/arm/c/freestanding/linux/hello.c index 5faf904..d27344a 100644 --- a/userland/arch/arm/c/freestanding/linux/hello.c +++ b/userland/arch/arm/c/freestanding/linux/hello.c @@ -1,5 +1,6 @@ -/* arm freestanding C inline assemby Linux hello world - * https://github.com/cirosantilli/linux-kernel-module-cheat#linux-system-calls +/* https://github.com/cirosantilli/linux-kernel-module-cheat#linux-system-calls + * + * arm freestanding C inline assemby Linux hello world. */ #include diff --git a/userland/arch/arm/c/inc.c b/userland/arch/arm/c/inc.c index a9d92fe..9649b13 100644 --- a/userland/arch/arm/c/inc.c +++ b/userland/arch/arm/c/inc.c @@ -1,6 +1,6 @@ /* Increment a variable in inline assembly. * - * https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly + * https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly */ #include diff --git a/userland/arch/arm/c/inc_float.c b/userland/arch/arm/c/inc_float.c index 3fce52b..8de4630 100644 --- a/userland/arch/arm/c/inc_float.c +++ b/userland/arch/arm/c/inc_float.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly-floating-point-arm */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly-floating-point-arm */ #include diff --git a/userland/arch/arm/c/inc_memory.c b/userland/arch/arm/c/inc_memory.c index 542d336..4dd67a1 100644 --- a/userland/arch/arm/c/inc_memory.c +++ b/userland/arch/arm/c/inc_memory.c @@ -14,7 +14,7 @@ * ldr r0, [sp] * .... * - * https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly + * https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly */ #include diff --git a/userland/arch/arm/c/inc_memory_global.c b/userland/arch/arm/c/inc_memory_global.c index 7aaa5cb..41477e0 100644 --- a/userland/arch/arm/c/inc_memory_global.c +++ b/userland/arch/arm/c/inc_memory_global.c @@ -6,7 +6,7 @@ * ldr r0, [r3] * .... * - * https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly + * https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly */ #include diff --git a/userland/arch/arm/c/reg_var.c b/userland/arch/arm/c/reg_var.c index 1e7db16..7629dd5 100644 --- a/userland/arch/arm/c/reg_var.c +++ b/userland/arch/arm/c/reg_var.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly-register-variables */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly-register-variables */ #include #include diff --git a/userland/arch/arm/clz.S b/userland/arch/arm/clz.S index 705ccbe..058e319 100644 --- a/userland/arch/arm/clz.S +++ b/userland/arch/arm/clz.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#data-processing-instructions */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#data-bitwise-instructions */ #include "common.h" diff --git a/userland/arch/arm/cond.S b/userland/arch/arm/cond.S index 88259ae..25098e7 100644 --- a/userland/arch/arm/cond.S +++ b/userland/arch/arm/cond.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#conditional-execution */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-conditional-execution */ #include "common.h" diff --git a/userland/arch/arm/gas_data_sizes.S b/userland/arch/arm/gas_data_sizes.S index 801a271..4e7f91d 100644 --- a/userland/arch/arm/gas_data_sizes.S +++ b/userland/arch/arm/gas_data_sizes.S @@ -1,3 +1,5 @@ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gnu-gas-assembler data sizes */ + #include "common.h" .data diff --git a/userland/arch/arm/hello_driver.S b/userland/arch/arm/hello_driver.S deleted file mode 100644 index 2bd778d..0000000 --- a/userland/arch/arm/hello_driver.S +++ /dev/null @@ -1,23 +0,0 @@ -/* Minimal example using driver. - * - * Controls the exit status of the program. - */ - -.syntax unified -.text -.global asm_main -asm_main: -asm_main_after_prologue: - - /* Set the return value according to the ARM calling convention. */ - mov r0, 0 - - /* Try some whacky value to see tests break. */ - /*mov r0, 77*/ - - /* Branch to the address at register lr. - * That is the return value which was put there by the C driver (likely with a bl). - * - * X means eXchange encoding from thumb back to ARM, which is what the driver uses. - */ - bx lr diff --git a/userland/arch/arm/immediates.S b/userland/arch/arm/immediates.S index a8b79b4..0959a0c 100644 --- a/userland/arch/arm/immediates.S +++ b/userland/arch/arm/immediates.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#gnu-gas-assembler-immediates */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-gnu-instruction-gas-assembler-immediates */ #include "common.h" diff --git a/userland/arch/arm/inc_array.S b/userland/arch/arm/inc_array.S index 8424f85..6c1711c 100644 --- a/userland/arch/arm/inc_array.S +++ b/userland/arch/arm/inc_array.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#loop-over-array */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-loop-instruction-over-array */ #include "common.h" diff --git a/userland/arch/arm/ldmia.S b/userland/arch/arm/ldmia.S index 98cba60..80ea3b4 100644 --- a/userland/arch/arm/ldmia.S +++ b/userland/arch/arm/ldmia.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#loop-over-array */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-loop-instruction-over-array */ #include "common.h" diff --git a/userland/arch/arm/ldr_pseudo.S b/userland/arch/arm/ldr_pseudo.S index 99361ab..800444a 100644 --- a/userland/arch/arm/ldr_pseudo.S +++ b/userland/arch/arm/ldr_pseudo.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#ldr-pseudo-instruction */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-ldr-instruction-pseudo-instruction */ #include "common.h" diff --git a/userland/arch/arm/ldrb.S b/userland/arch/arm/ldrb.S index 93bcf17..569a6fb 100644 --- a/userland/arch/arm/ldrb.S +++ b/userland/arch/arm/ldrb.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#ldrh-and-ldrb */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-ldrh-instruction-and-ldrb */ #include "common.h" diff --git a/userland/arch/arm/ldrh.S b/userland/arch/arm/ldrh.S index f802684..99d00bc 100644 --- a/userland/arch/arm/ldrh.S +++ b/userland/arch/arm/ldrh.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#ldrh-and-ldrb */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-ldrh-instruction-and-ldrb */ #include "common.h" diff --git a/userland/arch/arm/mov.S b/userland/arch/arm/mov.S index 21b288c..c2a7477 100644 --- a/userland/arch/arm/mov.S +++ b/userland/arch/arm/mov.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#mov */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-mov-instruction */ #include "common.h" diff --git a/userland/arch/arm/movw.S b/userland/arch/arm/movw.S index 2b7f957..4fa8d39 100644 --- a/userland/arch/arm/movw.S +++ b/userland/arch/arm/movw.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#movw-and-movt */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-movw-and-movt-instructions */ #include "common.h" diff --git a/userland/arch/arm/mul.S b/userland/arch/arm/mul.S index 7dcb82c..e92538c 100644 --- a/userland/arch/arm/mul.S +++ b/userland/arch/arm/mul.S @@ -1,4 +1,7 @@ -/* Multiplication. */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-data-processing-instructions + * + * Multiplication. + */ #include "common.h" diff --git a/userland/arch/arm/nop.S b/userland/arch/arm/nop.S index 66b18c2..bf0c041 100644 --- a/userland/arch/arm/nop.S +++ b/userland/arch/arm/nop.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#nop */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-nop-instruction */ #include "common.h" diff --git a/userland/arch/arm/push.S b/userland/arch/arm/push.S index fb1db4e..6d226f2 100644 --- a/userland/arch/arm/push.S +++ b/userland/arch/arm/push.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#ldmia */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-ldmia-instruction */ #include "common.h" diff --git a/userland/arch/arm/rbit.S b/userland/arch/arm/rbit.S index a41c1c0..f8826fd 100644 --- a/userland/arch/arm/rbit.S +++ b/userland/arch/arm/rbit.S @@ -1,4 +1,7 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#rbit */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-data-processing-instructions + * + * Reverse bit order. + */ #include "common.h" diff --git a/userland/arch/arm/rev.S b/userland/arch/arm/rev.S index d69f119..05cdd3e 100644 --- a/userland/arch/arm/rev.S +++ b/userland/arch/arm/rev.S @@ -1,4 +1,7 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#data-processing-instructions */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#data-processing-instructions + * + * Reverse byte order. + */ #include "common.h" diff --git a/userland/arch/arm/s_suffix.S b/userland/arch/arm/s_suffix.S index f40ee82..c014964 100644 --- a/userland/arch/arm/s_suffix.S +++ b/userland/arch/arm/s_suffix.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#s-suffix */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-s-suffix */ #include "common.h" diff --git a/userland/arch/arm/shift.S b/userland/arch/arm/shift.S index ff61f4c..4a8694e 100644 --- a/userland/arch/arm/shift.S +++ b/userland/arch/arm/shift.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#shift-suffixes */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-shift-suffixes */ #include "common.h" diff --git a/userland/arch/arm/sub.S b/userland/arch/arm/sub.S index e3fb48c..9a5342c 100644 --- a/userland/arch/arm/sub.S +++ b/userland/arch/arm/sub.S @@ -1,4 +1,7 @@ -/* Subtraction. */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-data-processing-instructions + * + * Subtraction. + */ #include "common.h" diff --git a/userland/arch/arm/thumb.S b/userland/arch/arm/thumb.S index e055eda..6570806 100644 --- a/userland/arch/arm/thumb.S +++ b/userland/arch/arm/thumb.S @@ -1,4 +1,8 @@ -/* Illustrates features that are only available in thumb. */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-instruction-encodings + * + * Illustrates features that are only available in thumb. + * TODO ensure that we are actually inside of thumb. + */ .syntax unified .text diff --git a/userland/arch/arm/tst.S b/userland/arch/arm/tst.S index 831243f..a7dc616 100644 --- a/userland/arch/arm/tst.S +++ b/userland/arch/arm/tst.S @@ -1,4 +1,7 @@ -/* Test. Same as ands, but don't store the result, just update flags. */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-data-processing-instructions + * + * Test. Same as ands, but don't store the result, just update flags. + */ #include "common.h" diff --git a/userland/arch/arm/vadd.S b/userland/arch/arm/vadd.S index 07fced4..fb44d18 100644 --- a/userland/arch/arm/vadd.S +++ b/userland/arch/arm/vadd.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#assembly-simd */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-simd-instruction-assembly */ #include "common.h" diff --git a/userland/arch/arm/vcvt.S b/userland/arch/arm/vcvt.S index 535731a..cae037b 100644 --- a/userland/arch/arm/vcvt.S +++ b/userland/arch/arm/vcvt.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#vcvt */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-vcvt-instruction */ #include "common.h" diff --git a/userland/arch/arm/vcvta.S b/userland/arch/arm/vcvta.S index c6aa5d4..539c31f 100644 --- a/userland/arch/arm/vcvta.S +++ b/userland/arch/arm/vcvta.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#vcvta */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-vcvta-instruction */ #include "common.h" diff --git a/userland/arch/arm/vcvtr.S b/userland/arch/arm/vcvtr.S index e3b1239..0795366 100644 --- a/userland/arch/arm/vcvtr.S +++ b/userland/arch/arm/vcvtr.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#vcvtrr */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-vcvtrr-instruction */ #include "common.h" diff --git a/userland/arch/x86_64/c/add.c b/userland/arch/x86_64/c/add.c index 2cee534..2d3e461 100644 --- a/userland/arch/x86_64/c/add.c +++ b/userland/arch/x86_64/c/add.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly */ #include #include diff --git a/userland/arch/x86_64/c/inc.c b/userland/arch/x86_64/c/inc.c index 7b1001c..5106398 100644 --- a/userland/arch/x86_64/c/inc.c +++ b/userland/arch/x86_64/c/inc.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly */ #include #include diff --git a/userland/arch/x86_64/c/scratch.c b/userland/arch/x86_64/c/scratch.c index 3adc336..7d91ae2 100644 --- a/userland/arch/x86_64/c/scratch.c +++ b/userland/arch/x86_64/c/scratch.c @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly-scratch-registers */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly-scratch-registers */ #include #include diff --git a/userland/arch/x86_64/c/scratch_hardcode.c b/userland/arch/x86_64/c/scratch_hardcode.c index fe1d526..2cd9eac 100644 --- a/userland/arch/x86_64/c/scratch_hardcode.c +++ b/userland/arch/x86_64/c/scratch_hardcode.c @@ -1,5 +1,5 @@ /* This is a worse version of scratch.c with hardcoded scratch. - * https://github.com/cirosantilli/linux-kernel-module-cheat#inline-assembly-scratch-registers + * https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly-scratch-registers */ #include diff --git a/userland/arch/x86_64/gas_data_sizes.S b/userland/arch/x86_64/gas_data_sizes.S index dc13f49..459c167 100644 --- a/userland/arch/x86_64/gas_data_sizes.S +++ b/userland/arch/x86_64/gas_data_sizes.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#gas-data-sizes */ +/* https://github.com/cirosantilli/linux-kernel-module-cheat#gnu-gas-assembler data sizes */ #include "common.h" diff --git a/userland/arch/x86_64/paddq.S b/userland/arch/x86_64/paddq.S index 07b4cbc..ff6b4a4 100644 --- a/userland/arch/x86_64/paddq.S +++ b/userland/arch/x86_64/paddq.S @@ -1,4 +1,4 @@ -/* https://github.com/cirosantilli/linux-kernel-module-cheat#assembly-simd +/* https://github.com/cirosantilli/linux-kernel-module-cheat#simd-assembly * * Add a bunch of integers in one go. *