Re: swsusp critical code rewritten to assembly

Pavel Machek (pavel@suse.cz)
Sun, 10 Nov 2002 20:22:53 +0100


Hi!

> > do_magic was really too fragile to be written in C. This patch
> > rewrites it into assembly, to make sure C compiler does not generate
> > stack access and corrupt memory that way. Plus it cleans up suspend.c
> > a bit, makes it really free memory it needs, an no longer calls
> > drivers from atomic context.
>
> But this still has stuff in C:
>
> > + asm volatile ("movl %0, %%esp" :: "m" (saved_context_esp));
> > + asm volatile ("movl %0, %%ebp" :: "m" (saved_context_ebp));
> > + asm volatile ("movl %0, %%eax" :: "m" (saved_context_eax));
> > + asm volatile ("movl %0, %%ebx" :: "m" (saved_context_ebx));
> > + asm volatile ("movl %0, %%ecx" :: "m" (saved_context_ecx));
> > + asm volatile ("movl %0, %%edx" :: "m" (saved_context_edx));
> > + asm volatile ("movl %0, %%esi" :: "m" (saved_context_esi));
> > + asm volatile ("movl %0, %%edi" :: "m" (saved_context_edi));
> >
> > - fix_processor_context();
> > + restore_processor_state();
>
> What's up with that? There's no way you can safely restore regular
> registers and _especially_ %%esp from C code, since the compiler may be
> using them for other things.

After applying that patch, this stuff is no longer used for
suspend-to-disk. Its still there for suspend-to-ram; I'll fix that.

Pavel

-- 
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/