Check a specific bit in SCTLR_EL1 Register on Rasperry pi 4
Posted: Thu Jul 16, 2020 3:33 pm
Hello.
i have been trying to check the UCI bit (UCI, bit [26]) in SCTLR_EL1 Register on Rasperry Pi 4.
So i wrote a simple kernel module :
and the value of the Register is : 0x0000000034d5d83d (bynary format = 110100110101011101100000111101).
So i wrote a simple c code to check UCI bit value :
Output : 886429757
Is that right ? The value of UCI bit is 1 ?
i mean, if the value is not set, the start and the end values should be different.
i tried checking the value in c code as well :
but the output is : 67108864.
Thank You.
i have been trying to check the UCI bit (UCI, bit [26]) in SCTLR_EL1 Register on Rasperry Pi 4.
So i wrote a simple kernel module :
Code: Select all
#include <linux/module.h>
#include<linux/init.h>
#include <linux/kernel.h>
static inline void write_SCTLR_EL1(uint64_t val){
asm volatile("msr s3_0_c1_c0_0 , %0" : : "r" (val));
asm volatile("isb" : : : "memory");
}
static inline uint64_t read_SCTLR_EL1(void){
uint64_t val;
asm volatile("mrs %0, s3_0_c1_c0_0" : "=r" (val));
return val;
}
int __init enable_cache_instructions(void){
uint64_t value = read_SCTLR_EL1();
printk(KERN_INFO "VALUE IS <0x%016llx> from SCTLR_EL1.", value);
return 0;
}
void disable_cache(void) {
printk(KERN_INFO "Instructions disabled \n");
}
module_init(enable_cache_instructions);
module_exit(disable_cache);
MODULE_LICENSE("GPL");
So i wrote a simple c code to check UCI bit value :
Code: Select all
int main (){
unsigned long register_value = 886429757; // decimal format of the Register value
register_value |= 1ULL << 26; //trying to set UCI bit to 1 if it is disabled
printf("After set : %lu\n",register_value);
return 0;
}
Is that right ? The value of UCI bit is 1 ?
i mean, if the value is not set, the start and the end values should be different.
i tried checking the value in c code as well :
Code: Select all
register_value &= (1ULL << 26);
printf("After check : %lu\n",register_value);
Thank You.