From 24b08bca030970592bc5241517b0462f603b05b1 Mon Sep 17 00:00:00 2001 From: jkim Date: Wed, 22 Dec 2010 00:18:42 +0000 Subject: Improve PCB flags handling and make it more robust. Add two new functions for manipulating pcb_flags. These inline functions are very similar to atomic_set_char(9) and atomic_clear_char(9) but without unnecessary LOCK prefix for SMP. Add comments about the rationale[1]. Use these functions wherever possible. Although there are some places where it is not strictly necessary (e.g., a PCB is copied to create a new PCB), it is done across the board for sake of consistency. Turn pcb_full_iret into a PCB flag as it is safe now. Move rarely used fields before pcb_flags and reduce size of pcb_flags to one byte. Fix some style(9) nits in pcb.h while I am in the neighborhood. Reviewed by: kib Submitted by: kib[1] MFC after: 2 months --- sys/amd64/amd64/exception.S | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sys/amd64/amd64/exception.S') diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S index 7ffa7a9..2d6f97a 100644 --- a/sys/amd64/amd64/exception.S +++ b/sys/amd64/amd64/exception.S @@ -170,7 +170,7 @@ alltraps: jz alltraps_testi /* already running with kernel GS.base */ swapgs movq PCPU(CURPCB),%rdi - movb $0,PCB_FULL_IRET(%rdi) + andb $~PCB_FULL_IRET,PCB_FLAGS(%rdi) movw %fs,TF_FS(%rsp) movw %gs,TF_GS(%rsp) movw %es,TF_ES(%rsp) @@ -243,7 +243,7 @@ alltraps_noen: jz 1f /* already running with kernel GS.base */ swapgs movq PCPU(CURPCB),%rdi - movb $0,PCB_FULL_IRET(%rdi) + andb $~PCB_FULL_IRET,PCB_FLAGS(%rdi) 1: movw %fs,TF_FS(%rsp) movw %gs,TF_GS(%rsp) movw %es,TF_ES(%rsp) @@ -294,7 +294,7 @@ IDTVEC(page) jz 1f /* already running with kernel GS.base */ swapgs movq PCPU(CURPCB),%rdi - movb $0,PCB_FULL_IRET(%rdi) + andb $~PCB_FULL_IRET,PCB_FLAGS(%rdi) 1: movq %cr2,%rdi /* preserve %cr2 before .. */ movq %rdi,TF_ADDR(%rsp) /* enabling interrupts. */ movw %fs,TF_FS(%rsp) @@ -324,7 +324,7 @@ IDTVEC(prot) jz 2f /* already running with kernel GS.base */ 1: swapgs 2: movq PCPU(CURPCB),%rdi - movb $1,PCB_FULL_IRET(%rdi) /* always full iret from GPF */ + orb $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* always full iret from GPF */ movw %fs,TF_FS(%rsp) movw %gs,TF_GS(%rsp) movw %es,TF_ES(%rsp) @@ -356,7 +356,7 @@ IDTVEC(fast_syscall) movw %es,TF_ES(%rsp) movw %ds,TF_DS(%rsp) movq PCPU(CURPCB),%r11 - movb $0,PCB_FULL_IRET(%r11) + andb $~PCB_FULL_IRET,PCB_FLAGS(%r11) sti movq $KUDSEL,TF_SS(%rsp) movq $KUCSEL,TF_CS(%rsp) @@ -661,8 +661,8 @@ doreti_exit: */ testb $SEL_RPL_MASK,TF_CS(%rsp) jz ld_regs - cmpb $0,PCB_FULL_IRET(%r8) - je ld_regs + testb $PCB_FULL_IRET,PCB_FLAGS(%r8) + jz ld_regs testl $TF_HASSEGS,TF_FLAGS(%rsp) je set_segs -- cgit v1.1