mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
arm sve: enable on baremetal by setting missing bits CPACR_EL1.ZEN
This commit is contained in:
14
README.adoc
14
README.adoc
@@ -14317,9 +14317,9 @@ ARMv8-only, likely because in ARMv8 you can't have conditional suffixes for ever
|
|||||||
|
|
||||||
==== ARM bitwise instructions
|
==== ARM bitwise instructions
|
||||||
|
|
||||||
* link:userland/arch/arm/and.S[]
|
* link:userland/arch/arm/and.S[] AND
|
||||||
* EOR: exclusive OR
|
* EOR: exclusive OR
|
||||||
* ORR: OR
|
* link:userland/arch/arm/orr.S[]: OR
|
||||||
* link:userland/arch/arm/clz.S[]: count leading zeroes
|
* link:userland/arch/arm/clz.S[]: count leading zeroes
|
||||||
|
|
||||||
===== ARM BIC instruction
|
===== ARM BIC instruction
|
||||||
@@ -14741,6 +14741,8 @@ Official spec: https://developer.arm.com/docs/100891/latest/sve-overview/introdu
|
|||||||
|
|
||||||
SVE support is indicated by `ID_AA64PFR0_EL1.SVE` which is dumped from link:baremetal/arch/aarch64/dump_regs.c[].
|
SVE support is indicated by `ID_AA64PFR0_EL1.SVE` which is dumped from link:baremetal/arch/aarch64/dump_regs.c[].
|
||||||
|
|
||||||
|
Using SVE normally requires setting the CPACR_EL1.FPEN and ZEN bits, which as as of lkmc 29fd625f3fda79f5e0ee6cac43517ba74340d513 + 1 we also enable in our <<baremetal-bootloaders>>, see also: <<aarch64-baremetal-neon-setup>>.
|
||||||
|
|
||||||
===== SVE bibliography
|
===== SVE bibliography
|
||||||
|
|
||||||
* https://www.rico.cat/files/ICS18-gem5-sve-tutorial.pdf step by step of a complete code execution examples, the best initial tutorial so far
|
* https://www.rico.cat/files/ICS18-gem5-sve-tutorial.pdf step by step of a complete code execution examples, the best initial tutorial so far
|
||||||
@@ -15803,15 +15805,17 @@ msr cpacr_el1, x1
|
|||||||
isb
|
isb
|
||||||
....
|
....
|
||||||
|
|
||||||
`cpacr_el1` is documented at <<armarm8>> D10.2.29 "CPACR_EL1, Architectural Feature Access Control Register".
|
CPACR_EL1 is documented at <<armarm8>> D10.2.29 "CPACR_EL1, Architectural Feature Access Control Register".
|
||||||
|
|
||||||
Here we touch the FPEN bits to 3, which enable floating point operations:
|
Here we touch the CPACR_EL1.FPEN bits to 3, which enable floating point operations:
|
||||||
|
|
||||||
____
|
____
|
||||||
11 This control does not cause any instructions to be trapped.
|
11 This control does not cause any instructions to be trapped.
|
||||||
____
|
____
|
||||||
|
|
||||||
Without that, the `printf`:
|
We later also added an enable for the CPACR_EL1.ZEN bits, which are needed for <<arm-sve>>.
|
||||||
|
|
||||||
|
Without CPACR_EL1.FPEN, the `printf`:
|
||||||
|
|
||||||
....
|
....
|
||||||
printf("got: %c\n", c);
|
printf("got: %c\n", c);
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ lkmc_start:
|
|||||||
msr vbar_el1, x0
|
msr vbar_el1, x0
|
||||||
|
|
||||||
/* https://cirosantilli.com/linux-kernel-module-cheat#aarch64-baremetal-neon-setup */
|
/* https://cirosantilli.com/linux-kernel-module-cheat#aarch64-baremetal-neon-setup */
|
||||||
|
/* CPACR_EL1.FPEN */
|
||||||
mov x1, 0x3 << 20
|
mov x1, 0x3 << 20
|
||||||
|
/* CPACR_EL1.ZEN */
|
||||||
|
orr x1, x1, 0x3 << 16
|
||||||
msr cpacr_el1, x1
|
msr cpacr_el1, x1
|
||||||
isb
|
isb
|
||||||
|
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
|
|
||||||
LKMC_PROLOGUE
|
LKMC_PROLOGUE
|
||||||
|
|
||||||
/* 0x00 && 0xFF == 0x00 */
|
/* 0x00 & 0xFF == 0x00 */
|
||||||
mov r0, 0x00
|
mov r0, 0x00
|
||||||
and r0, 0xFF
|
and r0, 0xFF
|
||||||
LKMC_ASSERT_EQ(r0, =0x00)
|
LKMC_ASSERT_EQ(r0, =0x00)
|
||||||
|
|
||||||
/* 0x0F && 0xF0 == 0x00 */
|
/* 0x0F & 0xF0 == 0x00 */
|
||||||
mov r0, 0x0F
|
mov r0, 0x0F
|
||||||
and r0, 0xF0
|
and r0, 0xF0
|
||||||
LKMC_ASSERT_EQ(r0, =0x00)
|
LKMC_ASSERT_EQ(r0, =0x00)
|
||||||
|
|
||||||
/* 0x0F && 0xFF == 0x0F */
|
/* 0x0F & 0xFF == 0x0F */
|
||||||
mov r0, 0x0F
|
mov r0, 0x0F
|
||||||
and r0, 0xFF
|
and r0, 0xFF
|
||||||
LKMC_ASSERT_EQ(r0, =0x0F)
|
LKMC_ASSERT_EQ(r0, =0x0F)
|
||||||
|
|
||||||
/* 0xF0 && 0xFF == 0xF0 */
|
/* 0xF0 & 0xFF == 0xF0 */
|
||||||
mov r0, 0xF0
|
mov r0, 0xF0
|
||||||
and r0, 0xFF
|
and r0, 0xFF
|
||||||
LKMC_ASSERT_EQ(r0, =0xF0)
|
LKMC_ASSERT_EQ(r0, =0xF0)
|
||||||
|
|||||||
27
userland/arch/arm/orr.S
Normal file
27
userland/arch/arm/orr.S
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* https://cirosantilli.com/linux-kernel-module-cheat#arm-bitwise-instructions */
|
||||||
|
|
||||||
|
#include <lkmc.h>
|
||||||
|
|
||||||
|
LKMC_PROLOGUE
|
||||||
|
|
||||||
|
/* 0x00 | 0xFF == 0x00 */
|
||||||
|
mov r0, 0x00
|
||||||
|
orr r0, 0xFF
|
||||||
|
LKMC_ASSERT_EQ(r0, =0xFF)
|
||||||
|
|
||||||
|
/* 0x0F | 0xF0 == 0x00 */
|
||||||
|
mov r0, 0x0F
|
||||||
|
orr r0, 0xF0
|
||||||
|
LKMC_ASSERT_EQ(r0, =0xFF)
|
||||||
|
|
||||||
|
/* 0x0F | 0x0F == 0x0F */
|
||||||
|
mov r0, 0x0F
|
||||||
|
orr r0, 0x0F
|
||||||
|
LKMC_ASSERT_EQ(r0, =0x0F)
|
||||||
|
|
||||||
|
/* 0xF0 | 0xF0 == 0xF0 */
|
||||||
|
mov r0, 0xF0
|
||||||
|
and r0, 0xF0
|
||||||
|
LKMC_ASSERT_EQ(r0, =0xF0)
|
||||||
|
|
||||||
|
LKMC_EPILOGUE
|
||||||
Reference in New Issue
Block a user