Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1644903imm; Thu, 18 Oct 2018 01:34:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV61gzYYcAwvwy/JYXrkmJTBh915/WjX+w91jNUOo0AU26cuesn/SnT1sjyjwTMSf8B+YkAZq X-Received: by 2002:a63:8343:: with SMTP id h64-v6mr26164322pge.368.1539851699119; Thu, 18 Oct 2018 01:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539851699; cv=none; d=google.com; s=arc-20160816; b=i6TSd/gCtOI+Ae3CMkvvEd+U6yii1ok6137VdCKCc0c4YHe68W856TXXJynwJ6u5UE zaPQUOfkzzKaGR/cd27QCcmN21XszYW2difb5xYLzRlKOqZJfpklQ0ZGNFWpnujeyAuO p8CKuTxWQt0ZrFVQmsTiCN6MkoCRe3i2T5z1cRd7UM6YGsml4ZaTcBXTJ/5xqA4hHdZx FSe58or0D89Z5mMbxUxS/qVUJvNxiNufsDeC0DoM4wQn/lFygiuQ2G85hMa5uCXc8111 l5LSgO1Dfs3uZLJsUvloVcqJYsmhHGCcfiUD8zZtAWiWbeL28cTP9y0TRu1ou6ZaHR+r lI6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=BTp085ACR5rAgElxYqUSvdMg4ZMTs+//uTF5ZRDO7Ng=; b=gCBbMlJ4I1X1wnqXqdwbbPmZe5if8yBX+2VdSgBUX+NXxnSe+W9PzV2/fnWG28MwFa qQUGZ8lgIF4ljSbdGc0FrO2d+/OihC2+Ey0gUIx51ZGNo2F5oaRcWUUWzonZCaS0H22k dAg0nXh1lYl7UgFRKW4bkwGnSBXlFzwTTprFnOVoY6apP5TevGsJdsoe8UyR22hcK6bI 3FWc2N/4ycsj7wLJvYldtaECD8Y3hIyTes85vu8+JLkjxxjBXu7sW+aB3KCl/BUp6WZ1 gkJn5vBOvsXC7yAHxkvPBvX1sKFrRzouYTHw82nLfTXRKYe6ZoJYpDJ0+zXDH59o7Rqy 6W/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x186-v6si21224159pfx.19.2018.10.18.01.34.42; Thu, 18 Oct 2018 01:34:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727653AbeJRQeM (ORCPT + 99 others); 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-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