Skip to contentSkip to conversation

Question about copy_from_user()

DISCUSSION Hiroyuki Machida 2 participants 3 messages Feb 16, 2000 – Feb 21, 2000 MIPS

lore
Share & tools
lore
#0 lore raw

Hi.

I think I found a redundant code in copy_from_user() and __copy_from_user() at current CVS asm-mips/uaccess.h.

I think '*'-marked part in the definiton is obsolete and redundant. It had to used in the exception fixup routine as commented at arch/mips/lib/memcpy.S. (Of course the comment is also obsolete, I think.)

#define __copy_from_user(to,from,n) ({ \
	void *__cu_to; \
	const void *__cu_from; \
	long __cu_len; \
	\
	__cu_to = (to); \
	__cu_from = (from); \
	__cu_len = (n); \
	__asm__ __volatile__( \
		"move\t$4, %1\n\t" \
		"move\t$5, %2\n\t" \
		"move\t$6, %3\n\t" \
*		".set\tnoat\n\t" \
*		"addu\t$1, %2, %3\n\t" \
*		".set\tat\n\t" \
		__MODULE_JAL(__copy_user) \
		"move\t%0, $6" \
		: "=r" (__cu_len) \
		: "r" (__cu_to), "r" (__cu_from), "r" (__cu_len) \
		: "$4", "$5", "$6", "$8", "$9", "$10", "$11", "$12", "$15", \
		  "$24", "$31","memory"); \
	__cu_len; \
})

(Even if $1 is still used at the exception fixup routine, when MODULE is defined, __MODULE_JAL will overwrite $1 at the next line.)

Is my concern correct? Please let me know.

Thanks.
---
Hiroyuki Machida
Creative Station SCE Inc./Sony Corp.

#1 lore raw
Quoted 7 lines · Hiroyuki Machida

I think I found a redundant code in copy_from_user() and __copy_from_user() at current CVS asm-mips/uaccess.h.

I think '*'-marked part in the definiton is obsolete and redundant. It had to used in the exception fixup routine as commented at arch/mips/lib/memcpy.S. (Of course the comment is also obsolete, I think.)

As you say $at is being used for the exception handling, so it obviously isn't redundant as you say. Or do I missunderstand what you were trying to express?

You however made me stump over another bug, the definition of __MODULE_JAL in <asm/uaccess.h> is wrong when compiling a module. In that case the generated code will clobber $at which actually should stay unchanged for the exception handling.

Ralf

#2 lore raw

From: Ralf Baechle <[email protected]>
Subject: Re: Question about copy_from_user()
Date: Fri, 18 Feb 2000 12:19:57 +0100

Quoted 3 lines

As you say $at is being used for the exception handling, so it obviously isn't redundant as you say. Or do I missunderstand what you were trying to express?

Thanks, Ralf.

I had miss-understood. I understood that $AT at the copy_from_user is still meaningful.

---
Hiroyuki Machida