2

I have read that the kernel can allow a process (which is running in user mode) to execute the IN and OUT CPU instructions (which are privileged instructions I think).

But can the kernel allow a process to execute the other privileged instructions (for example: HLT, RDTSC, etc.)?

1
  • If a process is running in ring3, I don't executing privileged instructions is possible. You have to use syscall to enter ring0. This is a CPU restriction, not a kernel restriction. Apr 1, 2019 at 2:20

1 Answer 1

1

Yes and No

No

Some instructions must be restricted to the kernel, e.g. configuring the MMU.

Yes

When a privileged instruction is executed, it causes a trap (exception). This trap can be handled by the kernel. The kernel can choose to run the instruction on behalf of the user-mode-process (possibly after checking and sensitisation).

No

On the x86, some privileged instructions are not privileged, so don't trap. They do however give the correct answer. This can be a pain for virtualisation, when virtualisation privileged code. (E.g. asking what mode am I in, and being told user-mode).

2
  • Sorry, I didn't quite understand the last paragraph, how can a privileged instruction be not privileged?
    – user344653
    Apr 2, 2019 at 13:28
  • @user344653 yet the last bit in confusing. Intel messed up in their architecture. It made no difference, until someone tried to make virtualisation software. If you are not trying to make virtualisation software (that runs a guest kernel, in user-mode), then you can safely ignore the last paragraph. Apr 3, 2019 at 6:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .