From 719325db8ed25677bdf619fbb7ee846e7bc71efb Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Sat, 20 Sep 2003 20:34:58 +0000 Subject: [PATCH] Fix the last remaining problem encountered by KSE: apparently it is not guaranteed that the RSE writes the NaT collection immediately, sort of atomically, to the backing store when it writes the register immediately prior to the NaT collection point. This means that we cannot assume that the low 9 bits of the backingstore pointer do not point to the NaT collection. This is rather a surprise and I don't know at this time if it's a bug in the Merced or that it's actually a valid condition of the architecture. A quick scan over the sources does not indicate that we depend on the false assumption elsewhere, but it's something to keep in mind. The fix is to write the saved contents of the ar.rnat register to the backingstore prior to entering the loop that copies the dirty registers from the kernel stack to the user stack. --- sys/ia64/ia64/machdep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index e08cea3e14b..064fe0fbd90 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -1076,8 +1076,12 @@ get_mcontext(struct thread *td, mcontext_t *mc, int clear_ret) if (bspst - td->td_kstack < s.ndirty) __asm __volatile("flushrs;;"); __asm __volatile("mov ar.rsc=3"); - ustk = (uint64_t*)s.bspstore; kstk = (uint64_t*)td->td_kstack; + ustk = (uint64_t*)s.bspstore; + if ((s.bspstore & 0x1ff) == 0x1f8) { + suword64(ustk++, s.rnat); + s.rnat = 0; + } while (s.ndirty > 0) { suword64(ustk++, *kstk++); if (((uintptr_t)ustk & 0x1ff) == 0x1f8)