From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BA39C5ACCC for ; Thu, 18 Oct 2018 08:34:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DEE121473 for ; Thu, 18 Oct 2018 08:34:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DEE121473 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727714AbeJRQeM (ORCPT ); Thu, 18 Oct 2018 12:34:12 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:40079 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbeJRQeM (ORCPT ); Thu, 18 Oct 2018 12:34:12 -0400 Received: by mail-qk1-f196.google.com with SMTP id x11-v6so993710qkl.7; Thu, 18 Oct 2018 01:34:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BTp085ACR5rAgElxYqUSvdMg4ZMTs+//uTF5ZRDO7Ng=; b=pXadvYyVsmsNdsQ2mRKPqpLBMfzRdK59w0QHhXoPlmPSRmrSZh1ezJ1BIWUNlr+Epv d0A8/zzceUPPnOGdIUy43Kw7XzJrqzUhd9MJmBuYaJ4YDvdJVGyEHs4Z8AAI1GKe2tE3 3jZ88haYIpiIJfdR2an1xzKAdo/LT/kJra65Bm/D6PHvxKQLpOaylovmdo6nY13wdQ0L z13W7T3RPCsJrDewnC9AtHNjUvM99d7887M0RkpTjAaYKvK5lSii554KQQchJKudEk7N FAkX+XOmx7dCy9hn220Hp9wC2Ql+V0OLEt0hg4iXmmEIroJDMQMMO2g15V3CkEPzijfW DokQ== X-Gm-Message-State: ABuFfojnOJsIRdnGnKVohuLrXaA8LiJafk+VLoqs6YgL6aFqZnl4J8pC oiiPa1xhAHO3hPtqWLpngO38WCzaUwAow1CiE2U= X-Google-Smtp-Source: ACcGV61Jsy02oYfm8zVsjo+h82bs0m2M3/6OFHW0ardJMQTGKPeXOkZHkjkuk+5HtTjO4gVX99G/uN9cLG427J0LtEc= X-Received: by 2002:ae9:d801:: with SMTP id u1-v6mr27911206qkf.291.1539851657620; Thu, 18 Oct 2018 01:34:17 -0700 (PDT) MIME-Version: 1.0 References: <4bc11ff0cff5960892a464189605f9bc808383fc.1539655732.git.ren_guo@c-sky.com> <20181018034117.GD15088@guoren-Inspiron-7460> In-Reply-To: <20181018034117.GD15088@guoren-Inspiron-7460> From: Arnd Bergmann Date: Thu, 18 Oct 2018 10:34:00 +0200 Message-ID: Subject: Re: [PATCH V9 21/21] csky: support dword access for get_user_size() To: Guo Ren Cc: Andrew Morton , Daniel Lezcano , David Miller , gregkh , Christoph Hellwig , Marc Zyngier , Mark Rutland , Peter Zijlstra , Rob Herring , Thomas Gleixner , Linux Kernel Mailing List , linux-arch , DTML , Rob Herring , c-sky_gcc_upstream@c-sky.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 18, 2018 at 5:41 AM Guo Ren wrote: > > On Wed, Oct 17, 2018 at 05:44:17PM +0200, Arnd Bergmann wrote: > > On Tue, Oct 16, 2018 at 5:33 AM Guo Ren wrote: > > > > > > Support dword access for get_user_size and redesign put_user_size with > > > the same style of get_user_size. It's Ok to use xxx_user_asm_common for > > > all size of variable with ldb, ldh, ldw, ld.d > > > > > > ld.d rx, (addr, 0) could "rx <= addr" "and r(x+1) <= addr+4" and this also > > > follow abiv2 gcc ABI for dword access. > > > > Are you sure this is correct for this? > > > > static inline u32 get_64_to_32(__u64 __user *p) > > { > > u32 ret; > > get_user(ret, p); > > return ret; > > } > > > > If I read __get_user_asm_common() right, the ld.d would overwrite > > two registers, but the caller only expects one, so it clobbers one > > that might be in use. > Ah... BUG! I only consider the get_user(u64, u64 *) :P > > Change to: > case 8: \ > __get_user_asm_dword((x), ptr, "ld.d", retval); \ > break; > > #define __get_user_asm_dword(x, ptr, err) \ > do { \ > u64 tmp; \ > __get_user_asm_common(tmp, ptr, "ld.d", err); \ > x = typeof(x) tmp; \ > } while(0) > > #define __put_user_asm_dword(x, ptr, err) \ > do { \ > u64 tmp = (u64) x; \ > __put_user_asm_common(tmp, ptr, "st.d", err); \ > } while(0) > I think this will cause warnings for code that passes a pointer. The 64-bit __get_user() is really hard, and most 32-bit architectures don't implement it at all. If you really want to add it, have a look at what x86 and arm do. IIRC they both use __builtin_choose_expr(), Arnd