[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] Add user interrupt handling code for mach pathway
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 1/2] Add user interrupt handling code for mach pathway |
Date: |
Mon, 29 Mar 2021 22:16:29 +0200 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Getting closer! :D
Damien Zammit, le mar. 30 mars 2021 01:23:55 +1100, a ecrit:
> + struct intr_list *handler;
> + struct intr_list **prev = &user_intr_handlers[id];
> + user_intr_t *e;
> + spl_t s;
> +
> + s = splhigh();
> +
> + for (handler = user_intr_handlers[id]; handler; handler = handler->next)
I'd say use *prev in the initialization part of the for loop, that will
be more robust to maintenance.
> + for (iter = *head; iter; iter = iter->next)
> + {
> + if (!(iter->flags & flags & SA_SHIRQ))
> + {
You don't actually need to iterate: if the first entry has flags without
SA_SHIRQ, we can't share. Otherwise (empty or several entries and the
first has SA_SHIRQ), we can share.
> + mach_print ("Cannot share irq\n");
> + return D_ALREADY_OPEN;
> + }
> + }
> +
> + new = (struct intr_list *)kalloc (sizeof (struct intr_list));
> + new->user_intr = user_intr;
> + new->flags = flags;
> + new->next = *head;
> + *head = new;
I believe you need to update next and *head in the splhigh section,
otherwise you risk getting interrupted, user intr delivery code to
trigger, and mayhem happen.
> + s = splhigh();