summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2022-08-07 23:56:07 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2022-08-07 23:56:07 +0000
commit0c8247ed5964e19635468babae4a52679dcd3860 (patch)
treee8363970386362a22cd73543f3640ff48d4484d6
parent025fbf5e05ee214384cc1c3ff7468dab430df555 (diff)
Start to add annotations to the cpu_info members, doing I/a/o for
immutable/atomic/owned ala <sys/proc.h>. Move CPUF_USERSEGS and CPUF_USERXSTATE, which really are private to the CPU, into a new ci_pflags and rename s/CPUF_/CPUPF_/. Make all (remaining) ci_flags alterations via atomic_{set,clear}bits_int(), so its annotation isn't a lie. Delete ci_info member as unused all the way from rev 1.1 ok jsg@ mlarkin@
-rw-r--r--sys/arch/amd64/amd64/acpi_machdep.c6
-rw-r--r--sys/arch/amd64/amd64/cpu.c14
-rw-r--r--sys/arch/amd64/amd64/fpu.c10
-rw-r--r--sys/arch/amd64/amd64/genassym.cf8
-rw-r--r--sys/arch/amd64/amd64/identcpu.c14
-rw-r--r--sys/arch/amd64/amd64/ipifuncs.c4
-rw-r--r--sys/arch/amd64/amd64/locore.S26
-rw-r--r--sys/arch/amd64/amd64/machdep.c20
-rw-r--r--sys/arch/amd64/amd64/vm_machdep.c4
-rw-r--r--sys/arch/amd64/amd64/vmm.c10
-rw-r--r--sys/arch/amd64/include/cpu.h107
11 files changed, 115 insertions, 108 deletions
diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c
index 373466415dd..db68939ed1e 100644
--- a/sys/arch/amd64/amd64/acpi_machdep.c
+++ b/sys/arch/amd64/amd64/acpi_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi_machdep.c,v 1.103 2022/02/21 11:03:39 mpi Exp $ */
+/* $OpenBSD: acpi_machdep.c,v 1.104 2022/08/07 23:56:06 guenther Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -406,7 +406,7 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state)
*/
if (acpi_savecpu()) {
/* Suspend path */
- KASSERT((curcpu()->ci_flags & CPUF_USERXSTATE) == 0);
+ KASSERT((curcpu()->ci_pflags & CPUPF_USERXSTATE) == 0);
wbinvd();
#ifdef HIBERNATE
@@ -547,7 +547,7 @@ resume_mp(void)
ci->ci_idepth = 0;
ci->ci_handled_intr_level = IPL_NONE;
- ci->ci_flags &= ~CPUF_PRESENT;
+ atomic_clearbits_int(&ci->ci_flags, CPUF_PRESENT);
cpu_start_secondary(ci);
}
cpu_boot_secondary_processors();
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index 4778347a12e..413938981b6 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.156 2022/04/26 08:35:30 claudio Exp $ */
+/* $OpenBSD: cpu.c,v 1.157 2022/08/07 23:56:06 guenther Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -593,7 +593,8 @@ cpu_attach(struct device *parent, struct device *self, void *aux)
switch (caa->cpu_role) {
case CPU_ROLE_SP:
printf("(uniprocessor)\n");
- ci->ci_flags |= CPUF_PRESENT | CPUF_SP | CPUF_PRIMARY;
+ atomic_setbits_int(&ci->ci_flags,
+ CPUF_PRESENT | CPUF_SP | CPUF_PRIMARY);
cpu_intr_init(ci);
#ifndef SMALL_KERNEL
cpu_ucode_apply(ci);
@@ -610,7 +611,8 @@ cpu_attach(struct device *parent, struct device *self, void *aux)
case CPU_ROLE_BP:
printf("apid %d (boot processor)\n", caa->cpu_apicid);
- ci->ci_flags |= CPUF_PRESENT | CPUF_BSP | CPUF_PRIMARY;
+ atomic_setbits_int(&ci->ci_flags,
+ CPUF_PRESENT | CPUF_BSP | CPUF_PRIMARY);
cpu_intr_init(ci);
identifycpu(ci);
#ifdef MTRR
@@ -762,7 +764,7 @@ cpu_init(struct cpu_info *ci)
#endif /* NVMM > 0 */
#ifdef MULTIPROCESSOR
- ci->ci_flags |= CPUF_RUNNING;
+ atomic_setbits_int(&ci->ci_flags, CPUF_RUNNING);
/*
* Big hammer: flush all TLB entries, including ones from PTEs
* with the G bit set. This should only be necessary if TLB
@@ -833,7 +835,7 @@ cpu_start_secondary(struct cpu_info *ci)
int i;
u_long s;
- ci->ci_flags |= CPUF_AP;
+ atomic_setbits_int(&ci->ci_flags, CPUF_AP);
pmap_kenter_pa(MP_TRAMPOLINE, MP_TRAMPOLINE, PROT_READ | PROT_EXEC);
pmap_kenter_pa(MP_TRAMP_DATA, MP_TRAMP_DATA, PROT_READ | PROT_WRITE);
@@ -946,7 +948,7 @@ cpu_hatch(void *v)
* off at this point.
*/
wbinvd();
- ci->ci_flags |= CPUF_PRESENT;
+ atomic_setbits_int(&ci->ci_flags, CPUF_PRESENT);
ci->ci_tsc_skew = 0; /* reset on resume */
tsc_sync_ap(ci);
diff --git a/sys/arch/amd64/amd64/fpu.c b/sys/arch/amd64/amd64/fpu.c
index 1fc1e5f5cac..438de255bd6 100644
--- a/sys/arch/amd64/amd64/fpu.c
+++ b/sys/arch/amd64/amd64/fpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpu.c,v 1.42 2020/11/30 02:56:42 jsg Exp $ */
+/* $OpenBSD: fpu.c,v 1.43 2022/08/07 23:56:06 guenther Exp $ */
/* $NetBSD: fpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*-
@@ -99,8 +99,8 @@ fputrap(int type)
u_int32_t mxcsr, statbits;
u_int16_t cw;
- KASSERT(ci->ci_flags & CPUF_USERXSTATE);
- ci->ci_flags &= ~CPUF_USERXSTATE;
+ KASSERT(ci->ci_pflags & CPUPF_USERXSTATE);
+ ci->ci_pflags &= ~CPUPF_USERXSTATE;
fpusavereset(sfp);
if (type == T_XMM) {
@@ -149,8 +149,8 @@ fpu_kernel_enter(void)
struct cpu_info *ci = curcpu();
/* save curproc's FPU state if we haven't already */
- if (ci->ci_flags & CPUF_USERXSTATE) {
- ci->ci_flags &= ~CPUF_USERXSTATE;
+ if (ci->ci_pflags & CPUPF_USERXSTATE) {
+ ci->ci_pflags &= ~CPUPF_USERXSTATE;
fpusavereset(&curproc->p_addr->u_pcb.pcb_savefpu);
} else {
fpureset();
diff --git a/sys/arch/amd64/amd64/genassym.cf b/sys/arch/amd64/amd64/genassym.cf
index 0db65e55cb6..c9e4ced195c 100644
--- a/sys/arch/amd64/amd64/genassym.cf
+++ b/sys/arch/amd64/amd64/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.42 2021/06/18 06:17:28 guenther Exp $
+# $OpenBSD: genassym.cf,v 1.43 2022/08/07 23:56:06 guenther Exp $
# Written by Artur Grabowski art@openbsd.org, Public Domain
include <sys/param.h>
@@ -120,7 +120,7 @@ member CPU_INFO_MUTEX_LEVEL ci_mutex_level
endif
member CPU_INFO_GDT ci_gdt
member CPU_INFO_TSS ci_tss
-member CPU_INFO_FLAGS ci_flags
+member CPU_INFO_PFLAGS ci_pflags
member CPU_INFO_KERN_CR3 ci_kern_cr3
member CPU_INFO_USER_CR3 ci_user_cr3
member CPU_INFO_KERN_RSP ci_kern_rsp
@@ -128,8 +128,8 @@ member CPU_INFO_INTR_RSP ci_intr_rsp
member CPU_INFO_MDS_BUF ci_mds_buf
member CPU_INFO_MDS_TMP ci_mds_tmp
-export CPUF_USERSEGS
-export CPUF_USERXSTATE
+export CPUPF_USERSEGS
+export CPUPF_USERXSTATE
struct intrsource
member is_recurse
diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c
index e633f932a65..e1748de7bc1 100644
--- a/sys/arch/amd64/amd64/identcpu.c
+++ b/sys/arch/amd64/amd64/identcpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: identcpu.c,v 1.125 2022/07/12 04:46:00 jsg Exp $ */
+/* $OpenBSD: identcpu.c,v 1.126 2022/08/07 23:56:06 guenther Exp $ */
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*
@@ -580,25 +580,23 @@ identifycpu(struct cpu_info *ci)
if (!strcmp(cpu_vendor, "GenuineIntel")) {
if ((ci->ci_family == 0x0f && ci->ci_model >= 0x03) ||
(ci->ci_family == 0x06 && ci->ci_model >= 0x0e)) {
- ci->ci_flags |= CPUF_CONST_TSC;
+ atomic_setbits_int(&ci->ci_flags, CPUF_CONST_TSC);
}
} else if (!strcmp(cpu_vendor, "CentaurHauls")) {
/* VIA */
if (ci->ci_model >= 0x0f) {
- ci->ci_flags |= CPUF_CONST_TSC;
+ atomic_setbits_int(&ci->ci_flags, CPUF_CONST_TSC);
}
} else if (!strcmp(cpu_vendor, "AuthenticAMD")) {
if (cpu_apmi_edx & CPUIDEDX_ITSC) {
- /* Invariant TSC indicates constant TSC on
- * AMD.
- */
- ci->ci_flags |= CPUF_CONST_TSC;
+ /* Invariant TSC indicates constant TSC on AMD */
+ atomic_setbits_int(&ci->ci_flags, CPUF_CONST_TSC);
}
}
/* Check if it's an invariant TSC */
if (cpu_apmi_edx & CPUIDEDX_ITSC)
- ci->ci_flags |= CPUF_INVAR_TSC;
+ atomic_setbits_int(&ci->ci_flags, CPUF_INVAR_TSC);
tsc_identify(ci);
}
diff --git a/sys/arch/amd64/amd64/ipifuncs.c b/sys/arch/amd64/amd64/ipifuncs.c
index b04e15e3912..277d727c75f 100644
--- a/sys/arch/amd64/amd64/ipifuncs.c
+++ b/sys/arch/amd64/amd64/ipifuncs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipifuncs.c,v 1.36 2021/08/31 17:40:59 dv Exp $ */
+/* $OpenBSD: ipifuncs.c,v 1.37 2022/08/07 23:56:06 guenther Exp $ */
/* $NetBSD: ipifuncs.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*-
@@ -124,7 +124,7 @@ x86_64_ipi_halt(struct cpu_info *ci)
intr_disable();
lapic_disable();
wbinvd();
- ci->ci_flags &= ~CPUF_RUNNING;
+ atomic_clearbits_int(&ci->ci_flags, CPUF_RUNNING);
wbinvd();
for(;;) {
diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S
index ef5c27256ee..2944720cc40 100644
--- a/sys/arch/amd64/amd64/locore.S
+++ b/sys/arch/amd64/amd64/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.127 2021/12/31 10:40:30 jsg Exp $ */
+/* $OpenBSD: locore.S,v 1.128 2022/08/07 23:56:06 guenther Exp $ */
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
/*
@@ -374,7 +374,7 @@ ENTRY(cpu_switchto)
* If the old proc ran in userspace then save the
* floating-point/"extended state" registers
*/
- testl $CPUF_USERXSTATE,CPUVAR(FLAGS)
+ testl $CPUPF_USERXSTATE,CPUVAR(PFLAGS)
jz .Lxstate_reset
movq %r13, %rdi
@@ -394,16 +394,16 @@ switch_exited:
CODEPATCH_START
fxrstor64 (%rdi)
CODEPATCH_END(CPTAG_XRSTOR)
- andl $~CPUF_USERXSTATE,CPUVAR(FLAGS)
+ andl $~CPUPF_USERXSTATE,CPUVAR(PFLAGS)
.Lxstate_reset:
/*
* If the segment registers haven't been reset since the old proc
* ran in userspace then reset them now
*/
- testl $CPUF_USERSEGS,CPUVAR(FLAGS)
+ testl $CPUPF_USERSEGS,CPUVAR(PFLAGS)
jz restore_saved
- andl $~CPUF_USERSEGS,CPUVAR(FLAGS)
+ andl $~CPUPF_USERSEGS,CPUVAR(PFLAGS)
/* set %ds, %es, %fs, and %gs to expected value to prevent info leak */
movw $(GSEL(GUDATA_SEL, SEL_UPL)),%ax
@@ -642,11 +642,11 @@ IDTVEC_NOALIGN(syscall)
jne intr_user_exit_post_ast
/* Restore FPU/"extended CPU state" if it's not already in the CPU */
- testl $CPUF_USERXSTATE,CPUVAR(FLAGS)
+ testl $CPUPF_USERXSTATE,CPUVAR(PFLAGS)
jz .Lsyscall_restore_xstate
/* Restore FS.base if it's not already in the CPU */
- testl $CPUF_USERSEGS,CPUVAR(FLAGS)
+ testl $CPUPF_USERSEGS,CPUVAR(PFLAGS)
jz .Lsyscall_restore_fsbase
.Lsyscall_restore_registers:
@@ -712,13 +712,13 @@ KUTEXT_PAGE_END
_ALIGN_TRAPS
/* in this case, need FS.base but not xstate, rarely happens */
.Lsyscall_restore_fsbase: /* CPU doesn't have curproc's FS.base */
- orl $CPUF_USERSEGS,CPUVAR(FLAGS)
+ orl $CPUPF_USERSEGS,CPUVAR(PFLAGS)
movq CPUVAR(CURPCB),%rdi
jmp .Lsyscall_restore_fsbase_real
_ALIGN_TRAPS
.Lsyscall_restore_xstate: /* CPU doesn't have curproc's xstate */
- orl $(CPUF_USERXSTATE|CPUF_USERSEGS),CPUVAR(FLAGS)
+ orl $(CPUPF_USERXSTATE|CPUPF_USERSEGS),CPUVAR(PFLAGS)
movq CPUVAR(CURPCB),%rdi
movq xsave_mask(%rip),%rdx
movl %edx,%eax
@@ -812,7 +812,7 @@ GENTRY(intr_user_exit)
intr_user_exit_post_ast:
/* Restore FPU/"extended CPU state" if it's not already in the CPU */
- testl $CPUF_USERXSTATE,CPUVAR(FLAGS)
+ testl $CPUPF_USERXSTATE,CPUVAR(PFLAGS)
jz .Lintr_restore_xstate
#ifdef DIAGNOSTIC
@@ -822,7 +822,7 @@ intr_user_exit_post_ast:
#endif /* DIAGNOSTIC */
/* Restore FS.base if it's not already in the CPU */
- testl $CPUF_USERSEGS,CPUVAR(FLAGS)
+ testl $CPUPF_USERSEGS,CPUVAR(PFLAGS)
jz .Lintr_restore_fsbase
.Lintr_restore_registers:
@@ -911,7 +911,7 @@ KTEXT_PAGE_END
.text
_ALIGN_TRAPS
.Lintr_restore_xstate: /* CPU doesn't have curproc's xstate */
- orl $CPUF_USERXSTATE,CPUVAR(FLAGS)
+ orl $CPUPF_USERXSTATE,CPUVAR(PFLAGS)
movq CPUVAR(CURPCB),%rdi
#if PCB_SAVEFPU != 0
addq $PCB_SAVEFPU,%rdi
@@ -921,7 +921,7 @@ KTEXT_PAGE_END
testl %eax,%eax
jnz .Lintr_xrstor_faulted
.Lintr_restore_fsbase: /* CPU doesn't have curproc's FS.base */
- orl $CPUF_USERSEGS,CPUVAR(FLAGS)
+ orl $CPUPF_USERSEGS,CPUVAR(PFLAGS)
movq CPUVAR(CURPCB),%rdx
movq PCB_FSBASE(%rdx),%rdx
movl %edx,%eax
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 53e2e0a0aee..932b1dfeb47 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.278 2022/06/29 07:51:54 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.279 2022/08/07 23:56:06 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -604,8 +604,8 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
sss = (sizeof(ksc) + 15) & ~15;
/* Save FPU state to PCB if necessary, then copy it out */
- if (curcpu()->ci_flags & CPUF_USERXSTATE) {
- curcpu()->ci_flags &= ~CPUF_USERXSTATE;
+ if (curcpu()->ci_pflags & CPUPF_USERXSTATE) {
+ curcpu()->ci_pflags &= ~CPUPF_USERXSTATE;
fpusavereset(&p->p_addr->u_pcb.pcb_savefpu);
}
sp -= fpu_save_len;
@@ -646,7 +646,7 @@ sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip,
tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
/* The reset state _is_ the userspace state for this thread now */
- curcpu()->ci_flags |= CPUF_USERXSTATE;
+ curcpu()->ci_pflags |= CPUPF_USERXSTATE;
return 0;
}
@@ -694,8 +694,8 @@ sys_sigreturn(struct proc *p, void *v, register_t *retval)
return (EINVAL);
/* Current state is obsolete; toss it and force a reload */
- if (curcpu()->ci_flags & CPUF_USERXSTATE) {
- curcpu()->ci_flags &= ~CPUF_USERXSTATE;
+ if (curcpu()->ci_pflags & CPUPF_USERXSTATE) {
+ curcpu()->ci_pflags &= ~CPUPF_USERXSTATE;
fpureset();
}
@@ -1110,8 +1110,8 @@ reset_segs(void)
* This operates like the cpu_switchto() sequence: if we
* haven't reset %[defg]s already, do so now.
*/
- if (curcpu()->ci_flags & CPUF_USERSEGS) {
- curcpu()->ci_flags &= ~CPUF_USERSEGS;
+ if (curcpu()->ci_pflags & CPUPF_USERSEGS) {
+ curcpu()->ci_pflags &= ~CPUPF_USERSEGS;
__asm volatile(
"movw %%ax,%%ds\n\t"
"movw %%ax,%%es\n\t"
@@ -1137,12 +1137,12 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
memcpy(&p->p_addr->u_pcb.pcb_savefpu,
&proc0.p_addr->u_pcb.pcb_savefpu, fpu_save_len);
- if (curcpu()->ci_flags & CPUF_USERXSTATE) {
+ if (curcpu()->ci_pflags & CPUPF_USERXSTATE) {
/* state in CPU is obsolete; reset it */
fpureset();
} else {
/* the reset state _is_ the userspace state now */
- curcpu()->ci_flags |= CPUF_USERXSTATE;
+ curcpu()->ci_pflags |= CPUPF_USERXSTATE;
}
/* To reset all registers we have to return via iretq */
diff --git a/sys/arch/amd64/amd64/vm_machdep.c b/sys/arch/amd64/amd64/vm_machdep.c
index e8c7ac59f29..212865a1c61 100644
--- a/sys/arch/amd64/amd64/vm_machdep.c
+++ b/sys/arch/amd64/amd64/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.45 2022/02/05 09:37:06 kettenis Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.46 2022/08/07 23:56:06 guenther Exp $ */
/* $NetBSD: vm_machdep.c,v 1.1 2003/04/26 18:39:33 fvdl Exp $ */
/*-
@@ -72,7 +72,7 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb,
struct switchframe *sf;
/* Save the fpu h/w state to p1's pcb so that we can copy it. */
- if (p1 != &proc0 && (ci->ci_flags & CPUF_USERXSTATE))
+ if (p1 != &proc0 && (ci->ci_pflags & CPUPF_USERXSTATE))
fpusave(&pcb1->pcb_savefpu);
p2->p_md.md_flags = p1->p_md.md_flags;
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c
index 84da19438b7..354cfac206f 100644
--- a/sys/arch/amd64/amd64/vmm.c
+++ b/sys/arch/amd64/amd64/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.318 2022/07/12 04:52:38 jsg Exp $ */
+/* $OpenBSD: vmm.c,v 1.319 2022/08/07 23:56:06 guenther Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@@ -1548,7 +1548,7 @@ start_vmm_on_cpu(struct cpu_info *ci)
}
}
- ci->ci_flags |= CPUF_VMM;
+ atomic_setbits_int(&ci->ci_flags, CPUF_VMM);
}
/*
@@ -1587,7 +1587,7 @@ stop_vmm_on_cpu(struct cpu_info *ci)
lcr4(cr4);
}
- ci->ci_flags &= ~CPUF_VMM;
+ atomic_clearbits_int(&ci->ci_flags, CPUF_VMM);
}
/*
@@ -4632,8 +4632,8 @@ vmm_fpurestore(struct vcpu *vcpu)
rw_assert_wrlock(&vcpu->vc_lock);
/* save vmm's FPU state if we haven't already */
- if (ci->ci_flags & CPUF_USERXSTATE) {
- ci->ci_flags &= ~CPUF_USERXSTATE;
+ if (ci->ci_pflags & CPUPF_USERXSTATE) {
+ ci->ci_pflags &= ~CPUPF_USERXSTATE;
fpusavereset(&curproc->p_addr->u_pcb.pcb_savefpu);
}
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 6916915a446..e504cea14c2 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.145 2022/07/12 04:46:00 jsg Exp $ */
+/* $OpenBSD: cpu.h,v 1.146 2022/08/07 23:56:06 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -89,6 +89,12 @@ union vmm_cpu_cap {
struct svm vcc_svm;
};
+/*
+ * Locks used to protect struct members in this file:
+ * I immutable after creation
+ * a atomic operations
+ * o owned (read/modified only) by this CPU
+ */
struct x86_64_tss;
struct cpu_info {
/*
@@ -98,32 +104,36 @@ struct cpu_info {
* the part that is *not* visible begins, so don't put anything
* above it that must be kept hidden from userspace!
*/
- u_int64_t ci_kern_cr3; /* U+K page table */
- u_int64_t ci_scratch; /* for U<-->K transition */
+ u_int64_t ci_kern_cr3; /* [o] U+K page table */
+ u_int64_t ci_scratch; /* [o] for U<-->K transition */
#define ci_PAGEALIGN ci_dev
- struct device *ci_dev;
- struct cpu_info *ci_self;
+ struct device *ci_dev; /* [I] */
+ struct cpu_info *ci_self; /* [I] */
struct schedstate_percpu ci_schedstate; /* scheduler state */
- struct cpu_info *ci_next;
+ struct cpu_info *ci_next; /* [I] */
- struct proc *ci_curproc;
- u_int ci_cpuid;
- u_int ci_apicid;
- u_int ci_acpi_proc_id;
- u_int32_t ci_randseed;
+ struct proc *ci_curproc; /* [o] */
+ u_int ci_cpuid; /* [I] */
+ u_int ci_apicid; /* [I] */
+ u_int ci_acpi_proc_id; /* [I] */
+ u_int32_t ci_randseed; /* [o] */
- u_int64_t ci_kern_rsp; /* kernel-only stack */
- u_int64_t ci_intr_rsp; /* U<-->K trampoline stack */
- u_int64_t ci_user_cr3; /* U-K page table */
+ u_int64_t ci_kern_rsp; /* [o] kernel-only stack */
+ u_int64_t ci_intr_rsp; /* [o] U<-->K trampoline stack */
+ u_int64_t ci_user_cr3; /* [o] U-K page table */
/* bits for mitigating Micro-architectural Data Sampling */
- char ci_mds_tmp[32]; /* 32byte aligned */
- void *ci_mds_buf;
+ char ci_mds_tmp[32]; /* [o] 32byte aligned */
+ void *ci_mds_buf; /* [I] */
struct pmap *ci_proc_pmap; /* last userspace pmap */
- struct pcb *ci_curpcb;
- struct pcb *ci_idle_pcb;
+ struct pcb *ci_curpcb; /* [o] */
+ struct pcb *ci_idle_pcb; /* [o] */
+
+ u_int ci_pflags; /* [o] */
+#define CPUPF_USERSEGS 0x01 /* CPU has curproc's segs and FS.base */
+#define CPUPF_USERXSTATE 0x02 /* CPU has curproc's xsave state */
struct intrsource *ci_isources[MAX_INTR_SOURCES];
u_int64_t ci_ipending;
@@ -136,38 +146,37 @@ struct cpu_info {
int ci_mutex_level;
#endif
- volatile u_int ci_flags;
- u_int32_t ci_ipis;
-
- u_int32_t ci_feature_flags;
- u_int32_t ci_feature_eflags;
- u_int32_t ci_feature_sefflags_ebx;
- u_int32_t ci_feature_sefflags_ecx;
- u_int32_t ci_feature_sefflags_edx;
- u_int32_t ci_feature_amdspec_ebx;
- u_int32_t ci_feature_tpmflags;
- u_int32_t ci_pnfeatset;
- u_int32_t ci_efeature_eax;
- u_int32_t ci_efeature_ecx;
- u_int32_t ci_brand[12];
- u_int32_t ci_signature;
- u_int32_t ci_family;
- u_int32_t ci_model;
- u_int32_t ci_cflushsz;
-
- int ci_inatomic;
+ volatile u_int ci_flags; /* [a] */
+ u_int32_t ci_ipis; /* [a] */
+
+ u_int32_t ci_feature_flags; /* [I] */
+ u_int32_t ci_feature_eflags; /* [I] */
+ u_int32_t ci_feature_sefflags_ebx;/* [I] */
+ u_int32_t ci_feature_sefflags_ecx;/* [I] */
+ u_int32_t ci_feature_sefflags_edx;/* [I] */
+ u_int32_t ci_feature_amdspec_ebx; /* [I] */
+ u_int32_t ci_feature_tpmflags; /* [I] */
+ u_int32_t ci_pnfeatset; /* [I] */
+ u_int32_t ci_efeature_eax; /* [I] */
+ u_int32_t ci_efeature_ecx; /* [I] */
+ u_int32_t ci_brand[12]; /* [I] */
+ u_int32_t ci_signature; /* [I] */
+ u_int32_t ci_family; /* [I] */
+ u_int32_t ci_model; /* [I] */
+ u_int32_t ci_cflushsz; /* [I] */
+
+ int ci_inatomic; /* [o] */
#define __HAVE_CPU_TOPOLOGY
- u_int32_t ci_smt_id;
- u_int32_t ci_core_id;
- u_int32_t ci_pkg_id;
+ u_int32_t ci_smt_id; /* [I] */
+ u_int32_t ci_core_id; /* [I] */
+ u_int32_t ci_pkg_id; /* [I] */
- struct cpu_functions *ci_func;
- void (*cpu_setup)(struct cpu_info *);
- void (*ci_info)(struct cpu_info *);
+ struct cpu_functions *ci_func; /* [I] */
+ void (*cpu_setup)(struct cpu_info *); /* [I] */
- struct device *ci_acpicpudev;
- volatile u_int ci_mwait;
+ struct device *ci_acpicpudev; /* [I] */
+ volatile u_int ci_mwait; /* [a] */
#define MWAIT_IN_IDLE 0x1 /* don't need IPI to wake */
#define MWAIT_KEEP_IDLING 0x2 /* cleared by other cpus to wake me */
#define MWAIT_ONLY 0x4 /* set if all idle states use mwait */
@@ -175,8 +184,8 @@ struct cpu_info {
int ci_want_resched;
- struct x86_64_tss *ci_tss;
- void *ci_gdt;
+ struct x86_64_tss *ci_tss; /* [o] */
+ void *ci_gdt; /* [o] */
volatile int ci_ddb_paused;
#define CI_DDB_RUNNING 0
@@ -224,9 +233,7 @@ struct cpu_info {
#define CPUF_IDENTIFIED 0x0020 /* CPU has been identified */
#define CPUF_CONST_TSC 0x0040 /* CPU has constant TSC */
-#define CPUF_USERSEGS 0x0080 /* CPU has curproc's segs and FS.base */
#define CPUF_INVAR_TSC 0x0100 /* CPU has invariant TSC */
-#define CPUF_USERXSTATE 0x0200 /* CPU has curproc's xsave state */
#define CPUF_SYNCTSC 0x0800 /* Synchronize TSC */
#define CPUF_PRESENT 0x1000 /* CPU is present */