Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp259096ima; Wed, 24 Oct 2018 00:18:43 -0700 (PDT) X-Google-Smtp-Source: AJdET5exUXnZXlWNNDqAKmMkBQ8rhx/GB+nuGq2F3P6zSsUujgB5TqJk6VfLcTKYAJucooNwe3fa X-Received: by 2002:a62:3911:: with SMTP id g17-v6mr1593528pfa.170.1540365523524; Wed, 24 Oct 2018 00:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540365523; cv=none; d=google.com; s=arc-20160816; b=oxICJKPzZ7ZCGKFnnJCR8hDx2507DfyrWDcWP7DfWpj9lWEi924Tv95IATGncdW3cQ mxu81me/An0dC07yCtK4/Mi1139veFMNgF5EE/sFPsTUOerbuxBQJRw7wneg9Q34xdRg mk6vdui529Bor9HbSQiXSi2difpJH/NTKGBwx8VRtcP3d4zJxyAFacQ1aKVAdGTHJ5ux A9m7A2jamE/SBll20ZGz1viHu2Jy+MQr0cUl5cl9NpXLHgvPaDcpw6Y0k+jF7OxqcV/s TzVqG8PZmcDUD5w0Mdb7y1/Umjb5YKG/MJ7aUKNpvQj4OLl59I1+g0HGG9vPfVyfqTRj eNDg== 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=bUfE7UK4/4993o7af1RIjKubupPwwVSdCsKkJD48d7E=; b=yiMLkZTdyPB8NzGjaWKeiaJLLw+gHsTv6ob9cUIUe4ZZ+lElHyW4yy9d3yrZ+if4/9 C0yC+Ajy1KFHe6CzcfDH0Zo+NEuUjLy80EVk8U/OAB6UvkBmYRj4w4x4WXYgyEEYIq39 +aZdj+Gw5DZ7B9WQ9af7hOmkDRWbi9hUA83myYqIufN5B3iBVK94yz7ObYh6AHfxhUcb mSOFMRh4ZXYpLWUz6vxjP/wW5JmHVTRt8dkb0hLsEbW0Hbigm0rOk0rHXDQRe68mnueH xSAF3RinKPnqssjVHC22p3j228uL3m4KvVcxy9d7qAZjUXS7zE7byKx/ZDKh4qQRCBfR nwxw== 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 w14-v6si3429675plq.327.2018.10.24.00.18.27; Wed, 24 Oct 2018 00:18:43 -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 S1726812AbeJXPoy (ORCPT + 99 others); Wed, 24 Oct 2018 11:44:54 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:39388 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726279AbeJXPoy (ORCPT ); Wed, 24 Oct 2018 11:44:54 -0400 Received: by mail-qt1-f194.google.com with SMTP id g10-v6so4595893qtq.6; Wed, 24 Oct 2018 00:18:05 -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=bUfE7UK4/4993o7af1RIjKubupPwwVSdCsKkJD48d7E=; b=JaYHMZzmlwxCYJh3XZx9vsQBR70H5CEn9o6eiLxyu/GiOS3J9qaYDUhQC6q9DpROTE kz9rQWbkXcf7e6zYyLYNco9LOe/4AjyYt5pvA4W/2p1wOndhEd6OLxRB7G8f/24rpCy5 DTjKoSCyAxNiNHnVM7/TQRvPsSnekR4vz/HTVOwQdbz+01Gbjz7SMBOCkaXqo4n3rR2n ZZasGFJxwteB3ihD5oKE6Kb/SeFJgULtWeO7u36oZLctxpz+Zo1s6OQ3y7edgFgdg4l0 67gmOw0u30QbSskF58bOv1F1LEhcJP3ppsF7rPSnOp4LfWdmHqMdF4Cm1xWOjKvhr1uM QEnQ== X-Gm-Message-State: AGRZ1gLyJNraU6sNeExjLHukuQkzWlorZ4Rugd1N4HBW7gw8WYxFMIxP RiMM3IC5wcGaI2+oj7yjGDu01LiNSb25ILF+EXA= X-Received: by 2002:a0c:e150:: with SMTP id c16mr1347874qvl.161.1540365484888; Wed, 24 Oct 2018 00:18:04 -0700 (PDT) MIME-Version: 1.0 References: <4bc11ff0cff5960892a464189605f9bc808383fc.1539655732.git.ren_guo@c-sky.com> <20181018034117.GD15088@guoren-Inspiron-7460> <20181018085751.GA21934@guoren-Inspiron-7460> In-Reply-To: <20181018085751.GA21934@guoren-Inspiron-7460> From: Arnd Bergmann Date: Wed, 24 Oct 2018 08:17:47 +0100 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 9:57 AM Guo Ren wrote: > > On Thu, Oct 18, 2018 at 10:34:00AM +0200, Arnd Bergmann wrote: > > 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(), > Thx for the tips and I'll drop the patch first for the upstream. > > I want to implement it because of make allmodconfig and > drivers/android/binder.c need it. I'll learn __builtin_choose_expr() > and prepare patch next. I think we should fix binder.c instead. Many other architectures have the same problem. Arnd