I have never dug into low level things like cpu architectures etc. and decided to give it a try when I learned about cpu.land.

I already was aware of the existence of user and kernel mode but while I was reading site it came to me that “I still can harm my system with userland programs so what does it mean to switch user mode for almost everything other than kernel and drivers?” also we still can do many things with syscalls, what is that stopping us(assuming we want to harm system of course) from damaging our system.

[edit1]: grammar mistakes

  • bassdruminphonebox@beehaw.org
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago

    I think one of the motivations for having separate modes like this, with (some) separate registers for each, is to reduce the time taken to switch contexts between modes. If they didn’t have separate registers, the data in the user mode registers would have to be saved somewhere when making a switch into kernel mode, and then copied back again when switching back to user mode.

    • jarfil@beehaw.org
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      There are no separate registers, every call to kernel mode takes extra time precisely because it has to save all the caller’s registers, then restore them again before returning.

      It involves even more registers than what’s visible to the user, because the kernel also has to change the ones related to memory and device access permissions.