This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Big problems using DSB, ISB, DMB and SMC mnemonics with armv7 A8 TI Sitara am335x

I implemented the following C snippet as normal  C file:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
* test.c - Demonstrating the Secure Monitor Calls (SMCs) in am335x TI armv7 A8 architecture.
*/
#include <stdio.h>
static inline void asm_enable_L2_ECC(void) {
unsigned int reg_value;
printf("Start\n");
__asm ("dsb"); // data synchronization barrier operation
__asm ("isb"); // instruction synchronization barrier operation
__asm ("dmb"); // data memory barrier operation
printf("End\n");
}
void main (void) {
asm_enable_L2_ECC();
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This code compiles, links, and while being in privileged Supervisor mode does work as expected.

Fullscreen
1
2
3
4
root@beaglebone:~/projects/LKM/cp15_smc# ./test
Start
End
root@beaglebone:~/projects/LKM/cp15_smc#
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Now, if I do from this code a simplistic kernel driver such as:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* cp15_smc.c - Demonstrating the Secure Monitor Calls (SMCs) in am335x TI armv7 A8 architecture.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */
MODULE_LICENSE("GPL"); ///< The license type -- this affects available functionality
MODULE_DESCRIPTION("An armv7 A8 L2 ECC enabling driver"); ///< The description -- see modinfo
MODULE_VERSION("0.01"); ///< A version number to inform users
static inline void asm_enable_L2_ECC(void) {
unsigned int reg_value;
__asm ("mrc p15, 0, %0, c0, c2, 4" : "=r"(reg_value) );
printk(KERN_INFO "Instruction Set Attributes Register 4: 0x%08x\n", reg_value);
if (0x000f0000 & reg_value) {
printk(KERN_INFO "The processor does support DMB, DSB and ISB instructions\n");
}
else {
printk(KERN_INFO "The processor does NOT support DMB, DSB and ISB instructions\n");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I get while compiling the following errors!?

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
root@beaglebone:~/projects/LKM/cp15_smc# make all
make -C /lib/modules/5.0.15-jumpnow/build M=/home/root/projects/LKM/cp15_smc modules
make[1]: Entering directory '/lib/modules/5.0.15-jumpnow/build'
CC [M] /home/root/projects/LKM/cp15_smc/cp15_smc.o
/tmp/ccrM1hRS.s: Assembler messages:
/tmp/ccrM1hRS.s:118: Error: selected processor does not support `dsb' in ARM mode
/tmp/ccrM1hRS.s:122: Error: selected processor does not support `isb' in ARM mode
/tmp/ccrM1hRS.s:126: Error: selected processor does not support `dmb' in ARM mode
/tmp/ccrM1hRS.s:266: Error: selected processor does not support `dsb' in ARM mode
/tmp/ccrM1hRS.s:270: Error: selected processor does not support `isb' in ARM mode
/tmp/ccrM1hRS.s:274: Error: selected processor does not support `dmb' in ARM mode
make[2]: *** [scripts/Makefile.build:283: /home/root/projects/LKM/cp15_smc/cp15_smc.o] Error 1
make[1]: *** [Makefile:1577: _module_/home/root/projects/LKM/cp15_smc] Error 2
make[1]: Leaving directory '/lib/modules/5.0.15-jumpnow/build'
make: *** [Makefile:4: all] Error 2
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I use native gcc on the target BeagleBone Black (manual for silicon TI am335x here: http://www.ti.com/lit/ug/spruh73p/spruh73p.pdf )

Fullscreen
1
2
3
4
5
root@beaglebone:~/projects/LKM/cp15_smc# gcc --version
gcc (GCC) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Why in the first case gcc compiles DSB, ISB, DMB instructions without any problems, while in the second it does not?

The SMC instruction is not recognized in both cases?!

/tmp/ccrM1hRS.s:278: Error: selected processor does not support `smc #1' in ARM mode

Why?

Thank you in advance,

_nobody_

0