On Sat, Jun 19, 1999 at 01:08:38PM -0400, Jay Estabrook wrote: > Any progress on the ASN/TLB stuff we were discussing? Yes. I sent a message to axp-list in the wee hours Friday morning, but sent it from the wrong account and it bounced. It's because we made no effort to validate p->tss.asn, only p->mm->context. This is a mistake whenever there exist multiple processes that share VM, as with threads or vfork. Consider two processes A and B sharing a VM. Allow that both have slept across the asn rollover. Process A gets scheduled first, notes that A->mm->context is out of date, allocates a new one, and updates A->tss.asn and A->mm->context. Process B gets scheduled, notes that B->mm->context is up to date, and proceeds to use an out of date asn, causing all sorts of havok. A similar problem occurs on SMP when a pair of threads migrates to a different processor. I've played around with a couple of variations on a patch. Attached is my favourite so far. A variant that I'm considering relies on the fact that the PALcode only reads tss.asn, and that the hardware ignores bits outside the supported range. As it is, we have to also keep a shadow field in tss with the full context. One problem that variant is that it narrows the context from 64 bits to 32 bits, due to the field width of tss.asn. Which means there are now only 19 instead of 51 bits of serial number, which means that the possibility of a process sleeping through serial number rollover and running with an invalid asn is real. I'm half convinced that the cure (detecting serial number rollover and walking the process list to reset everyone's context) is worse than just keeping a second field in the tss. (Linus, this is different from the patch I sent Friday -- that one had a silly thinko that allocated asn contexts more often than needed, and in the SMP case where two threads run on different processors would allocate new contexts every time they are scheduled.) In addition to solving this problem, the patch also fixes EV4, which was broken when the tbia was removed from alpha_switch_to. Also, the SMP last_asn array is dispersed into per-cpu local data to avoid fighting over cache lines. Also, __reload_tss is cleaned up to properly use virt_to_phys instead of doing some silly masking thing. r~