Traditional operating systems protect themselves from user programs with a privilege level facility of CPUs. One problem of
the protection-by-hardware approach is that system calls become very slow because heavy operations are required to safely
switch the privilege levels of user programs. To solve the problem, we design an operating system that protects itself with
a type theory. In our approach, user programs are written in a typed assembly language and the kernel performs type-checking
before executing the programs. Then, the user programs can be executed in the kernel mode, because the kernel knows that the
type-checked programs do not violate safety of the kernel. Thus, system calls become mere function calls and can be invoked
very quickly. We implemented Kernel Mode Linux (KML) that realizes our approach. Several benchmarks show effectiveness of
KML.