Allow BP and OF can be called from user space

Change the DPL from 0 to 3 for Breakpoint and Overflow,
then user space could trigger Breakpoint and Overflow
as excepected.

Change-Id: Ibead65fb8c98b32b7737f316db93b3a8d9dcd648
PiperOrigin-RevId: 239736648
This commit is contained in:
Yong He 2019-03-21 22:03:34 -07:00 committed by Shentubot
parent 7d0227ff16
commit 45ba52f824
1 changed files with 7 additions and 1 deletions

View File

@ -27,9 +27,15 @@ func (k *Kernel) init(opts KernelOpts) {
// Setup the IDT, which is uniform. // Setup the IDT, which is uniform.
for v, handler := range handlers { for v, handler := range handlers {
// Allow Breakpoint and Overflow to be called from all
// privilege levels.
dpl := 0
if v == Breakpoint || v == Overflow {
dpl = 3
}
// Note that we set all traps to use the interrupt stack, this // Note that we set all traps to use the interrupt stack, this
// is defined below when setting up the TSS. // is defined below when setting up the TSS.
k.globalIDT[v].setInterrupt(Kcode, uint64(kernelFunc(handler)), 0 /* dpl */, 1 /* ist */) k.globalIDT[v].setInterrupt(Kcode, uint64(kernelFunc(handler)), dpl, 1 /* ist */)
} }
} }