0

I recently compile a kernel module for mint 18 (kernel version:4.4.0-36-generic) and use these functions :

static inline unsigned long rk_disable_wp(void)
{
    unsigned long cr0;

    preempt_disable();

    barrier();
    cr0 = read_cr0();
    write_cr0(cr0 & ~X86_CR0_WP);
    barrier();

    return cr0;
}

when I move this source code to raspbian 9.1 (kernel version: 4.9.59-v7+) I can't compile and this error throws:

error: implicit declaration of function 'read_cr0' [-Werror=implicit-function-declaration]
error: implicit declaration of function 'write_cr0' [-Werror=implicit-function-declaration]
error: 'X86_CR0_WP' undeclared (first use in this function)

is raspberry pi has no CR0 registry ? or kernel version is the reason of the problem ? or something else ?

Mojtaba Kamyabi
  • 3,440
  • 3
  • 29
  • 50

1 Answers1

1

cr0 is a x86 register. The X86_CR0_WP should've been a give-away that this is x86-specific code.

Clearing that bit results in disabling write protection: The kernel may write read-only mapped pages. There's an (unanswered) StackOverflow question about how to do this on ARM. I don't know the answer either.

a3f
  • 8,517
  • 1
  • 41
  • 46