summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/amd64_mem.c14
-rw-r--r--sys/arch/amd64/amd64/cpu.c4
-rw-r--r--sys/arch/amd64/amd64/hibernate_machdep.c6
-rw-r--r--sys/arch/amd64/amd64/i8259.c7
-rw-r--r--sys/arch/amd64/amd64/ipifuncs.c4
-rw-r--r--sys/arch/amd64/amd64/lapic.c22
-rw-r--r--sys/arch/amd64/amd64/machdep.c7
-rw-r--r--sys/arch/amd64/amd64/tsc.c9
-rw-r--r--sys/arch/amd64/amd64/vmm.c9
-rw-r--r--sys/arch/amd64/include/cpufunc.h18
-rw-r--r--sys/arch/amd64/isa/clock.c17
11 files changed, 55 insertions, 62 deletions
diff --git a/sys/arch/amd64/amd64/amd64_mem.c b/sys/arch/amd64/amd64/amd64_mem.c
index bb11fcdda7d..27d9c7576a1 100644
--- a/sys/arch/amd64/amd64/amd64_mem.c
+++ b/sys/arch/amd64/amd64/amd64_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amd64_mem.c,v 1.13 2016/04/26 15:27:32 mlarkin Exp $ */
+/* $OpenBSD: amd64_mem.c,v 1.14 2018/07/27 21:11:31 kettenis Exp $ */
/*
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -274,12 +274,14 @@ mrt2mtrr(u_int64_t flags)
void
mrstore(struct mem_range_softc *sc)
{
- disable_intr(); /* disable interrupts */
+ u_long s;
+
+ s = intr_disable();
#ifdef MULTIPROCESSOR
x86_broadcast_ipi(X86_IPI_MTRR);
#endif
mrstoreone(sc);
- enable_intr();
+ intr_restore(s);
}
/*
@@ -616,7 +618,9 @@ mrinit_cpu(struct mem_range_softc *sc)
void
mrreload_cpu(struct mem_range_softc *sc)
{
- disable_intr();
+ u_long s;
+
+ s = intr_disable();
mrstoreone(sc); /* set MTRRs to match BSP */
- enable_intr();
+ intr_restore(s);
}
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c
index 67626ed9c38..3e1e888a561 100644
--- a/sys/arch/amd64/amd64/cpu.c
+++ b/sys/arch/amd64/amd64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.125 2018/07/12 14:11:11 guenther Exp $ */
+/* $OpenBSD: cpu.c,v 1.126 2018/07/27 21:11:31 kettenis Exp $ */
/* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */
/*-
@@ -800,7 +800,7 @@ cpu_hatch(void *v)
s = splhigh();
lcr8(0);
- enable_intr();
+ intr_enable();
nanouptime(&ci->ci_schedstate.spc_runtime);
splx(s);
diff --git a/sys/arch/amd64/amd64/hibernate_machdep.c b/sys/arch/amd64/amd64/hibernate_machdep.c
index 03471ae27ef..ca442b40d10 100644
--- a/sys/arch/amd64/amd64/hibernate_machdep.c
+++ b/sys/arch/amd64/amd64/hibernate_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hibernate_machdep.c,v 1.44 2018/07/04 01:41:56 mlarkin Exp $ */
+/* $OpenBSD: hibernate_machdep.c,v 1.45 2018/07/27 21:11:31 kettenis Exp $ */
/*
* Copyright (c) 2012 Mike Larkin <mlarkin@openbsd.org>
@@ -440,13 +440,13 @@ hibernate_inflate_skip(union hibernate_info *hib_info, paddr_t dest)
void
hibernate_enable_intr_machdep(void)
{
- enable_intr();
+ intr_enable();
}
void
hibernate_disable_intr_machdep(void)
{
- disable_intr();
+ intr_disable();
}
#ifdef MULTIPROCESSOR
diff --git a/sys/arch/amd64/amd64/i8259.c b/sys/arch/amd64/amd64/i8259.c
index ac6fd735619..875d22053ef 100644
--- a/sys/arch/amd64/amd64/i8259.c
+++ b/sys/arch/amd64/amd64/i8259.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i8259.c,v 1.10 2017/10/14 04:44:43 jsg Exp $ */
+/* $OpenBSD: i8259.c,v 1.11 2018/07/27 21:11:31 kettenis Exp $ */
/* $NetBSD: i8259.c,v 1.2 2003/03/02 18:27:15 fvdl Exp $ */
/*
@@ -162,8 +162,9 @@ i8259_hwunmask(struct pic *pic, int pin)
{
unsigned port;
u_int8_t byte;
+ u_long s;
- disable_intr(); /* XXX */
+ s = intr_disable();
i8259_imen &= ~(1 << pin);
#ifdef PIC_MASKDELAY
delay(10);
@@ -176,7 +177,7 @@ i8259_hwunmask(struct pic *pic, int pin)
byte = i8259_imen & 0xff;
}
outb(port, byte);
- enable_intr();
+ intr_restore(s);
}
static void
diff --git a/sys/arch/amd64/amd64/ipifuncs.c b/sys/arch/amd64/amd64/ipifuncs.c
index d8b01111354..c5e4b27cd36 100644
--- a/sys/arch/amd64/amd64/ipifuncs.c
+++ b/sys/arch/amd64/amd64/ipifuncs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipifuncs.c,v 1.31 2018/06/05 06:39:10 guenther Exp $ */
+/* $OpenBSD: ipifuncs.c,v 1.32 2018/07/27 21:11:31 kettenis Exp $ */
/* $NetBSD: ipifuncs.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*-
@@ -111,7 +111,7 @@ x86_64_ipi_halt(struct cpu_info *ci)
SCHED_ASSERT_UNLOCKED();
KASSERT(!_kernel_lock_held());
- disable_intr();
+ intr_disable();
lapic_disable();
wbinvd();
ci->ci_flags &= ~CPUF_RUNNING;
diff --git a/sys/arch/amd64/amd64/lapic.c b/sys/arch/amd64/amd64/lapic.c
index 493b783c728..222ad6fbf15 100644
--- a/sys/arch/amd64/amd64/lapic.c
+++ b/sys/arch/amd64/amd64/lapic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lapic.c,v 1.51 2018/04/20 07:27:54 mlarkin Exp $ */
+/* $OpenBSD: lapic.c,v 1.52 2018/07/27 21:11:31 kettenis Exp $ */
/* $NetBSD: lapic.c,v 1.2 2003/05/08 01:04:35 fvdl Exp $ */
/*-
@@ -174,13 +174,14 @@ lapic_cpu_number(void)
void
lapic_map(paddr_t lapic_base)
{
- int s;
pt_entry_t *pte;
vaddr_t va;
u_int64_t msr;
+ u_long s;
+ int tpr;
- disable_intr();
- s = lapic_tpr;
+ s = intr_disable();
+ tpr = lapic_tpr;
msr = rdmsr(MSR_APICBASE);
@@ -208,7 +209,7 @@ lapic_map(paddr_t lapic_base)
x2apic_enabled = 1;
codepatch_call(CPTAG_EOI, &x2apic_eoi);
- lapic_writereg(LAPIC_TPRI, s);
+ lapic_writereg(LAPIC_TPRI, tpr);
va = (vaddr_t)&local_apic;
} else {
/*
@@ -226,7 +227,7 @@ lapic_map(paddr_t lapic_base)
*pte = lapic_base | PG_RW | PG_V | PG_N | PG_G | pg_nx;
invlpg(va);
- lapic_tpr = s;
+ lapic_tpr = tpr;
}
/*
@@ -240,7 +241,7 @@ lapic_map(paddr_t lapic_base)
DPRINTF("%s: entered lapic page va 0x%llx pa 0x%llx\n", __func__,
(uint64_t)va, (uint64_t)lapic_base);
- enable_intr();
+ intr_restore(s);
}
/*
@@ -479,7 +480,7 @@ lapic_calibrate_timer(struct cpu_info *ci)
{
unsigned int startapic, endapic;
u_int64_t dtick, dapic, tmp;
- long rf = read_rflags();
+ u_long s;
int i;
if (mp_verbose)
@@ -493,7 +494,7 @@ lapic_calibrate_timer(struct cpu_info *ci)
lapic_writereg(LAPIC_DCR_TIMER, LAPIC_DCRT_DIV1);
lapic_writereg(LAPIC_ICR_TIMER, 0x80000000);
- disable_intr();
+ s = intr_disable();
/* wait for current cycle to finish */
wait_next_cycle();
@@ -505,7 +506,8 @@ lapic_calibrate_timer(struct cpu_info *ci)
wait_next_cycle();
endapic = lapic_gettick();
- write_rflags(rf);
+
+ intr_restore(s);
dtick = hz * rtclock_tval;
dapic = startapic-endapic;
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 0467a4d994c..05c91e3def1 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.248 2018/07/12 14:11:11 guenther Exp $ */
+/* $OpenBSD: machdep.c,v 1.249 2018/07/27 21:11:31 kettenis Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -1705,7 +1705,7 @@ init_x86_64(paddr_t first_avail)
softintr_init();
splraise(IPL_IPI);
- enable_intr();
+ intr_enable();
#ifdef DDB
db_machine_init();
@@ -1718,8 +1718,7 @@ init_x86_64(paddr_t first_avail)
void
cpu_reset(void)
{
-
- disable_intr();
+ intr_disable();
if (cpuresetfn)
(*cpuresetfn)();
diff --git a/sys/arch/amd64/amd64/tsc.c b/sys/arch/amd64/amd64/tsc.c
index 028641ce8f7..e799240e799 100644
--- a/sys/arch/amd64/amd64/tsc.c
+++ b/sys/arch/amd64/amd64/tsc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tsc.c,v 1.9 2018/04/08 18:26:29 mikeb Exp $ */
+/* $OpenBSD: tsc.c,v 1.10 2018/07/27 21:11:31 kettenis Exp $ */
/*
* Copyright (c) 2016,2017 Reyk Floeter <reyk@openbsd.org>
* Copyright (c) 2017 Adam Steen <adam@adamsteen.com.au>
@@ -120,7 +120,7 @@ uint64_t
measure_tsc_freq(struct timecounter *tc)
{
uint64_t count1, count2, frequency, min_freq, tsc1, tsc2;
- u_long ef;
+ u_long s;
int delay_usec, i, err1, err2, usec, success = 0;
/* warmup the timers */
@@ -133,14 +133,13 @@ measure_tsc_freq(struct timecounter *tc)
delay_usec = 100000;
for (i = 0; i < 3; i++) {
- ef = read_rflags();
- disable_intr();
+ s = intr_disable();
err1 = get_tsc_and_timecount(tc, &tsc1, &count1);
delay(delay_usec);
err2 = get_tsc_and_timecount(tc, &tsc2, &count2);
- write_rflags(ef);
+ intr_restore(s);
if (err1 || err2)
continue;
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c
index a007e7272e5..4abe6d584ae 100644
--- a/sys/arch/amd64/amd64/vmm.c
+++ b/sys/arch/amd64/amd64/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.217 2018/07/26 10:05:02 job Exp $ */
+/* $OpenBSD: vmm.c,v 1.218 2018/07/27 21:11:31 kettenis Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@@ -3905,6 +3905,7 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
struct vmx_invvpid_descriptor vid;
uint64_t eii, procbased, int_st;
uint16_t irq;
+ u_long s;
resume = 0;
irq = vrp->vrp_irq;
@@ -4099,9 +4100,9 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
#endif /* VMM_DEBUG */
/* Disable interrupts and save the current host FPU state. */
- disable_intr();
+ s = intr_disable();
if ((ret = vmm_fpurestore(vcpu))) {
- enable_intr();
+ intr_restore(s);
break;
}
@@ -4116,7 +4117,7 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
*/
vmm_fpusave(vcpu);
- enable_intr();
+ intr_restore(s);
exit_reason = VM_EXIT_NONE;
if (ret == 0) {
diff --git a/sys/arch/amd64/include/cpufunc.h b/sys/arch/amd64/include/cpufunc.h
index 395250c3ba5..8a483549f25 100644
--- a/sys/arch/amd64/include/cpufunc.h
+++ b/sys/arch/amd64/include/cpufunc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpufunc.h,v 1.29 2018/07/24 14:49:44 guenther Exp $ */
+/* $OpenBSD: cpufunc.h,v 1.30 2018/07/27 21:11:31 kettenis Exp $ */
/* $NetBSD: cpufunc.h,v 1.3 2003/05/08 10:27:43 fvdl Exp $ */
/*-
@@ -152,18 +152,6 @@ void setidt(int idx, /*XXX*/caddr_t func, int typ, int dpl);
/* XXXX ought to be in psl.h with spl() functions */
-static __inline void
-disable_intr(void)
-{
- __asm volatile("cli");
-}
-
-static __inline void
-enable_intr(void)
-{
- __asm volatile("sti");
-}
-
static __inline u_long
read_rflags(void)
{
@@ -182,7 +170,7 @@ write_rflags(u_long ef)
static __inline void
intr_enable(void)
{
- enable_intr();
+ __asm volatile("sti");
}
static __inline u_long
@@ -191,7 +179,7 @@ intr_disable(void)
u_long ef;
ef = read_rflags();
- disable_intr();
+ __asm volatile("cli");
return (ef);
}
diff --git a/sys/arch/amd64/isa/clock.c b/sys/arch/amd64/isa/clock.c
index 0516e12b8d4..db516d9ecde 100644
--- a/sys/arch/amd64/isa/clock.c
+++ b/sys/arch/amd64/isa/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.27 2018/07/09 19:38:33 kettenis Exp $ */
+/* $OpenBSD: clock.c,v 1.28 2018/07/27 21:11:31 kettenis Exp $ */
/* $NetBSD: clock.c,v 1.1 2003/04/26 18:39:50 fvdl Exp $ */
/*-
@@ -201,18 +201,17 @@ rtcintr(void *arg)
int
gettick(void)
{
- u_long ef;
+ u_long s;
u_char lo, hi;
/* Don't want someone screwing with the counter while we're here. */
mtx_enter(&timer_mutex);
- ef = read_rflags();
- disable_intr();
+ s = intr_disable();
/* Select counter 0 and latch it. */
outb(IO_TIMER1+TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
lo = inb(IO_TIMER1+TIMER_CNTR0);
hi = inb(IO_TIMER1+TIMER_CNTR0);
- write_rflags(ef);
+ intr_restore(s);
mtx_leave(&timer_mutex);
return ((hi << 8) | lo);
}
@@ -632,10 +631,9 @@ i8254_get_timecount(struct timecounter *tc)
{
u_char hi, lo;
u_int count;
- u_long ef;
+ u_long s;
- ef = read_rflags();
- disable_intr();
+ s = intr_disable();
outb(IO_TIMER1+TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
lo = inb(IO_TIMER1+TIMER_CNTR0);
@@ -649,7 +647,8 @@ i8254_get_timecount(struct timecounter *tc)
}
i8254_lastcount = count;
count += i8254_offset;
- write_rflags(ef);
+
+ intr_restore(s);
return (count);
}