Skip to contentSkip to conversation

Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in arch/i386/kernel/machine_kexec.c

PATCH In review Shani Moideen 4 participants 4 messages Jun 12, 2007 – Jun 13, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in arch/i386/kernel/machine_kexec.c

Hi,
Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in arch/i386/kernel/machine_kexec.c.

----

arch/i386/kernel/machine_kexec.c +1 -1
index 91966ba..ce79a44 100644
@@ -110,7 +110,7 @@ NORET_TYPE void machine_kexec(struct kimage *image)
 	local_irq_disable();
 
 	control_page = page_address(image->control_code_page);
-	memcpy(control_page, relocate_kernel, PAGE_SIZE);
+	copy_page(control_page, relocate_kernel);
 
 	page_list[PA_CONTROL_PAGE] = __pa(control_page);
 	page_list[VA_CONTROL_PAGE] = (unsigned long)relocate_kernel;
Signature · 13 lines
Shani 


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
 
www.wipro.com

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw
Quoted 3 lines · Shani Moideen

Hi,
Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in arch/i386/kernel/machine_kexec.c.

Please no.

People get creative in copy_page (especially mmx_copy_page), and this code path need something simple and stupid, that will work every time, especially when things are messed up elsewhere.

Ideally we would actually do all of the setup before this point. but that is another issue entirely.

Eric
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#2 lore raw
Quoted 6 lines · Eric W. Biederman
Quoted 3 lines · Shani Moideen

Hi,
Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in arch/i386/kernel/machine_kexec.c.

Quoted 7 lines

Please no.

People get creative in copy_page (especially mmx_copy_page), and this code path need something simple and stupid, that will work every time, especially when things are messed up elsewhere.

memcpy() is pretty creative, too. If you want something really dumb and robust, you should probably create an inline:

/*
* Eric sez: his code path need something simple and stupid, that
* will work every time, especially when things are messed up
* elsewhere.
*/
static inline void braindead_copy_page(void *dst, void *src)

{
	unsigned long ctr = PAGE_SIZE >> 2;

	asm volatile("cld; rep; movsl"
			: "+D" (dst), "+S" (src), "+c" (ctr)
			: : "memory");
}

(FWIW, the "cld" is supposed to be redundant, as DF=0 is supposed to be guaranteed by the ABI.)

-hpa
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#3 lore raw

Hi!

Quoted 27 lines
Quoted 9 lines
Quoted 2 lines

Replacing memcpy(dest,src,PAGE_SIZE) with copy_page(dest,src) in arch/i386/kernel/machine_kexec.c.

Please no.

People get creative in copy_page (especially mmx_copy_page), and this code path need something simple and stupid, that will work every time, especially when things are messed up elsewhere.

memcpy() is pretty creative, too. If you want something really dumb and robust, you should probably create an inline:

/*
* Eric sez: his code path need something simple and stupid, that
* will work every time, especially when things are messed up
* elsewhere.
*/
static inline void braindead_copy_page(void *dst, void *src)

{
	unsigned long ctr = PAGE_SIZE >> 2;

	asm volatile("cld; rep; movsl"
			: "+D" (dst), "+S" (src), "+c" (ctr)
			: : "memory");
}
Quoted 2 lines

(FWIW, the "cld" is supposed to be redundant, as DF=0 is supposed to be guaranteed by the ABI.)

Actually, swsusp would be second user for that. We currently do it with for loop in C, but...

...well, we'd probably need it for i386, ppc, x86-64, ppc64 and maybe arm...

(But you should probably add a comment into kexec )
Pavel

Signature · 6 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors