ARM Cortex A8的PMNC读也使..任何想法/建议后给出0?(ARM Cortex A8

2019-08-17 17:47发布

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("user-mode access to performance registers");

int __init arm_init(void)

{
    unsigned int value;

    /* enable user-mode access */
    printk(KERN_INFO "enable user-mode access\n");
    asm ("MCR p15, 0, %0, C9, C14, 0\n\t" :: "r"(1));

    /* Reading the value here--just to check */

    asm ("MRC p15, 0, %0, c9, c14, 0\t\n": "=r"(value));
    printk("value: %d\n", value);


    /* disable counter overflow interrupts (just in case)*/
    printk(KERN_INFO "disable counter overflow interrupts (just in case)\n");
    asm ("MCR p15, 0, %0, C9, C14, 2\n\t" :: "r"(0x8000000f));

    printk(KERN_INFO "user-mode access to performance registers enabled\n");
    return 0;
}


void arm_exit(void)
{
    unsigned int value;
    asm ("MRC p15, 0, %0, c9, c14, 0\t\n": "=r"(value));
    printk("value: %d\n", value);
    printk(KERN_INFO "user-mode access to performance registers disabled\n");
}

module_init(arm_init);
module_exit(arm_exit);

在初始化模块读给1,但在清理模块读取变量提供0任何想法,它是如何得到更新?

文章来源: ARM Cortex A8 PMNC read gives 0 after enabling also.. Any Idea/Suggestions?