0

error:unsupported instruction `mov'

Here is the relevant piece of source code:

static int my_seq_show(struct seq_file *m, void *p)
{
        unsigned int    _cr0,_cr3, _cr4;
    get_pgtable_macro(m);
    printk("the get_pgtable_macro has been output\n");
        if (indata.p !=0 && indata.addr !=0)
        vaddr2paddr(m, indata.addr,indata.p);
        printk("the vaddr2paddr has been done\n");      

    asm( " mov %%cr0, %%eax \n mov %%eax, %0 " : "=m" (_cr0) :: "ax" );
    asm( " mov %%cr3, %%eax \n mov %%eax, %0 " : "=m" (_cr3) :: "ax" );
    asm( " mov %%cr4, %%eax \n mov %%eax, %0 " : "=m" (_cr4) :: "ax" );
    seq_printf(m, "    CR0=0x%08X", _cr0 );
    seq_printf(m, "    CR3=0x%08X", _cr3 );
    seq_printf(m, "    CR4=0x%08X", _cr4 );
    seq_printf(m, "    PE=%X",  (_cr0 >> 1)&1 );
    seq_printf(m, "    PG=%X",  (_cr0 >> 31)&1 );
    seq_printf(m, "    PAE=%X", (_cr4 >> 5)&1 );
    seq_printf(m, "    PSE=%X", (_cr4 >> 4)&1 );
    seq_printf( m, "\n" );
    
    return  0;

}

I am a newbie and my English is not very good, so I don’t know how to describe the problem better. Please forgive me.

If you can directly help modify the code, I would be very grateful.

Su.
  • 1
  • 2
  • It seems you are on 64-bit platform, where register `cr0` is 64-bit register. That register cannot be stored into `eax`, which is 32-bit. You need to store it into `rax`. (Also you need to correct type of variable `_cr0` and others to `unsigned long`). See [that question](https://stackoverflow.com/questions/7415515/how-to-access-the-control-registers-cr0-cr2-cr3-from-a-program-getting-segmenta) for example of reading `cr0`. – Tsyvarev Nov 22 '21 at 12:53
  • You pass an argument `p`, but you use an undefined variable `indata` – stark Nov 22 '21 at 14:04

0 Answers0