how does linux kernel prevents the BIOS system calls?

爷,独闯天下 提交于 2019-12-06 11:15:47

问题


BIOS calls are not available in linux OS. I wonder how does a kernel prevents execution of such instructions that contains call to the BIOS subroutines?


回答1:


The BIOS is mostly available in 16 bits mode, not in the 32 or 64 bits mode of x86 on which Linux runs.

A Linux process is running in user mode, using virtual memory, it has its own virtual address space.

Some machine instructions (notably INT which is used to go to BIOS) are privileged so cannot be run in user mode. If you try running them in user mode, the processor makes a machine exception, and the kernel handles it by sending some signal. (some INT is also used for syscalls, but the SYSENTER instruction is preferred).

An application uses syscalls to interact with the kernel (perhaps thru the VDSO).

Read the assembly howto




回答2:


The INT n instruction generates a call to the interrupt or exception handler specified with the destination operand. The destination operand specifies an interrupt vector number from 0 to 255, encoded as an 8-bit unsigned intermediate value. Each interrupt vector number provides an index to a gate descriptor in the IDT.

The selected interrupt descriptor in turn contains a pointer to an interrupt or exception handler procedure. In protected mode (linux works in protected mode only), the IDT contains an array of 8-byte descriptors, each of which is an interrupt gate, trap gate, or task gate.

This IDT is set by the OS. Linux sets it up so that descriptors point to its own handlers, not the BIOS handlers at all.



来源:https://stackoverflow.com/questions/19535056/how-does-linux-kernel-prevents-the-bios-system-calls

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!