summaryrefslogtreecommitdiff
path: root/i386
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2023-09-30 06:30:58 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-09-30 10:46:13 +0200
commit4492f5358da5a933af270dac7109f689bebe2a37 (patch)
treef58e91e5b2fa804866a9825f1d6c81d91f6ca4c2 /i386
parentb4c888624b40374213adce00d712930ef4d6d908 (diff)
ioapic: Add simple locking for non-atomic accesses
Message-Id: <20230930063032.75232-3-damien@zamaudio.com>
Diffstat (limited to 'i386')
-rw-r--r--i386/i386at/ioapic.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/i386/i386at/ioapic.c b/i386/i386at/ioapic.c
index 57d18789..dcc91eff 100644
--- a/i386/i386at/ioapic.c
+++ b/i386/i386at/ioapic.c
@@ -32,6 +32,7 @@
#include <mach/machine.h>
#include <kern/printf.h>
#include <kern/timer.h>
+#include <kern/lock.h>
static int has_irq_specific_eoi = 0;
int timer_pin;
@@ -42,6 +43,8 @@ uint32_t calibrated_ticks = 0;
spl_t curr_ipl[NCPUS] = {0};
int spl_init = 0;
+def_simple_lock_irq_data(static, ioapic_lock) /* Lock for non-atomic window accesses to ioapic */
+
int iunit[NINTR] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23};
@@ -148,9 +151,11 @@ ioapic_toggle_entry(int apic, int pin, int mask)
{
union ioapic_route_entry_union entry;
+ spl_t s = simple_lock_irq(&ioapic_lock);
ioapic_read_entry(apic, pin, &entry.both);
entry.both.mask = mask & 0x1;
ioapic_write(apic, APIC_IO_REDIR_LOW(pin), entry.lo);
+ simple_unlock_irq(s, &ioapic_lock);
}
static int
@@ -245,6 +250,8 @@ ioapic_irq_eoi(int pin)
if (pin == 0)
goto skip_specific_eoi;
+ spl_t s = simple_lock_irq(&ioapic_lock);
+
if (!has_irq_specific_eoi) {
/* Workaround for old IOAPICs with no specific EOI */
@@ -264,6 +271,8 @@ ioapic_irq_eoi(int pin)
ioapic->eoi.r = entry.both.vector;
}
+ simple_unlock_irq(s, &ioapic_lock);
+
skip_specific_eoi:
lapic_eoi ();
}