From patchwork Tue May 4 13:03:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 96753 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o44D4MTR004056 for ; Tue, 4 May 2010 13:04:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932141Ab0EDNDi (ORCPT ); Tue, 4 May 2010 09:03:38 -0400 Received: from mail-pw0-f46.google.com ([209.85.160.46]:58456 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932122Ab0EDNDf (ORCPT ); Tue, 4 May 2010 09:03:35 -0400 Received: by pwi5 with SMTP id 5so146944pwi.19 for ; Tue, 04 May 2010 06:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=+mUXD6HaGEREnKVFlrpcLgEs8GWEffbnivRdJLL14eY=; b=ipO/PBBVlU8J2pcxvqezron46GU0iKUbHqYZMv3GcUq4nSXKSHVxdaqOeoeZn6Ve3h MuKChVJNrFdGytYH2K5wZz3Glmx1IUb1InzMKjOCzN9AOBezzwYxQBuogvDh2ZJv6nuh aNRthOrZ1vcU6hV4yi1LhiNR3dIEZxPqwIPJU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=VB45w/Jr9C3KrrrjxD0r99qIeiec0KezJU1Xy90bJu72A+ytzhPXqbeyMpNTjnfoVS +RZY+Lux6yTM2y1QYDQK9s5FJ8MJxXLLo9o4YzYoPTlIyHa7oZNQqY0H145soUUyqHie BsC+iB/zYZ1eGUjbuE/SEl/8H6fuTVWmv6NFk= Received: by 10.141.14.12 with SMTP id r12mr4558887rvi.94.1272978214629; Tue, 04 May 2010 06:03:34 -0700 (PDT) Received: from stein (v079161.dynamic.ppp.asahi-net.or.jp [124.155.79.161]) by mx.google.com with ESMTPS id g14sm1908705rvb.13.2010.05.04.06.03.31 (version=SSLv3 cipher=RC4-MD5); Tue, 04 May 2010 06:03:34 -0700 (PDT) Date: Tue, 4 May 2010 22:03:33 +0900 From: Takuya Yoshikawa To: Takuya Yoshikawa Cc: avi@redhat.com, mtosatti@redhat.com, agraf@suse.de, yoshikawa.takuya@oss.ntt.co.jp, fernando@oss.ntt.co.jp, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, kvm-ia64@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, benh@kernel.crashing.org, paulus@samba.org, linuxppc-dev@ozlabs.org, arnd@arndb.de, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC][PATCH 6/12 not tested yet] PPC: introduce copy_in_user() for 32-bit Message-Id: <20100504220333.61e44128.takuya.yoshikawa@gmail.com> In-Reply-To: <20100504215645.6448af8f.takuya.yoshikawa@gmail.com> References: <20100504215645.6448af8f.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.0; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 04 May 2010 13:04:23 +0000 (UTC) diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index bd0fb84..3a01ce8 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -359,6 +359,23 @@ static inline unsigned long copy_to_user(void __user *to, return n; } +static inline unsigned long copy_in_user(void __user *to, + const void __user *from, unsigned long n) +{ + unsigned long over; + + if (likely(access_ok(VERIFY_READ, from, n) && + access_ok(VERIFY_WRITE, to, n))) + return __copy_tofrom_user(to, from, n); + if (((unsigned long)from < TASK_SIZE) || + ((unsigned long)to < TASK_SIZE)) { + over = max((unsigned long)from, (unsigned long)to) + + n - TASK_SIZE; + return __copy_tofrom_user(to, from, n - over) + over; + } + return n; +} + #else /* __powerpc64__ */ #define __copy_in_user(to, from, size) \