Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2795722pxk; Sun, 6 Sep 2020 14:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjGApCK5qERs51UXp93ThP7aK5l2GPsijt8cAywvjqRLA1itmkwLEyZ7nYPX34hsUnAX9e X-Received: by 2002:a17:906:6010:: with SMTP id o16mr17457959ejj.320.1599426152421; Sun, 06 Sep 2020 14:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599426152; cv=none; d=google.com; s=arc-20160816; b=cl4pshL6+9FMSTXLThPLjE1qYgXbafebSG/v6HqmswUY1y01iCmwxbBSjS6pYU/+ti hbeOJA1Syn5rtZ1xEl8/2x9o75J6cY2OCxMCC84O6eWtVdzx0b2ezQfSysKRM7W2Gr7S 1xuYHHaOmk2QdjeKSTvaWAEX0HmF5WvKY25FD/cMsn7rMhFTtB4wQzD5ZWe0VhM5ZLQL KmpGZ3qC7D6VPfMyuH842/ghT7J7PEjC4MK6zLMkLxpLeADPNVMlKWTlnDc2rN7ie11I ql2nHTHLybuhMdRKvVLJCfRRmRUYhPAuh+z8RB3UgHTuTiUVEo0FVstj4Rrkt5y9E4fI u7tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=T1oB7ySbJzhXfoNWBmNgQXBWcU1mfNfTlC7+qBvtFhg=; b=DMiI9LJ37aIYlHc98cp/42Etpl8nAOnC7rujIRu5/xnWy7dRmQRhk9o3784JAkKNDa p9rn4A01e9ytlYBXWje29oigvBK4iy3d262RNE2HpyNg43krbEQmJ8zLjqPioqRwIsU9 W/l+qDHIpRbnLefQkHT8EzWpBqkCAb/h3UKU2G29O8wSJbu7BpzSVuIHgXo1f8I+GZnx JZ0itCCG8YKxRLSZ27Xn/P3cvcPLTiaEn4gOCtZPbVWudsJ3qYX3vuhj8Pw6TbBBUMzR UiP3+niJVNNjgub5lKdOX+BKK6AbVavG6+pBpeQgtGk0VsgfeNl7ruZ/fnHUpUZIFFNp EIWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=efpaYjdt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si8460625edy.380.2020.09.06.14.02.08; Sun, 06 Sep 2020 14:02:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=efpaYjdt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbgIFVAp (ORCPT + 99 others); Sun, 6 Sep 2020 17:00:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgIFVAp (ORCPT ); Sun, 6 Sep 2020 17:00:45 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B9CAC061573 for ; Sun, 6 Sep 2020 14:00:45 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id g6so5483455pjl.0 for ; Sun, 06 Sep 2020 14:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=T1oB7ySbJzhXfoNWBmNgQXBWcU1mfNfTlC7+qBvtFhg=; b=efpaYjdt9SVm2ywPYXlj4yrrEvq8AVqERON4d0w7DHu2Skfekh0oQMMAYAFfCMb8P1 h2n0esJ4V/5c0rGuu4S1EoQZOtob1qxllezT2Dri2t4Mk2PZGpmzxn5tBuTGMql9iIuh axheouI4/HX4AxNdVpHqfDYP/5uaicuN7ApqaZoiaUjle/4kzSFQAUPLJKDEdpa0FgPq eTtqyVJA6nrODrackky1vhZxUaA9Ox7LDC6Am2D4Ok4dKcoSzoa7Ns5WaKfnFxEXYmnv 79exXkd2NlQqq1dncuYZhePJifPjCqvaY+wnZQFNztNxY5lzWSbZBCNN7UmxVTyy50vI BQkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=T1oB7ySbJzhXfoNWBmNgQXBWcU1mfNfTlC7+qBvtFhg=; b=kmVlqi8WSTbxpSFGwBKZJwnISLdrAxHdsY25tYyZW8WA4yuie/96s3O4yMOFge1LDl ECy6RM5egLHf+06K1PjCJAgHSR0HLidOhtUSuEcG5cehRDdoLULFkNj4vnkuaBTsb2vX uhnqd3tq6d5JCV8Qkg2CahzRRjcdNtqRnvWYXzctX8/Inj9bluRBv4kC/nN0Ykv19Dp4 xvxVeNpj3+X1zqMhI4uQ8T2t+xZGUbW/09D2UfYdNK6GH15V1l16paVTBPFNyb2YkDT0 aMpGxA0K4JsWz3i/89CiCBR+9Ff5JVBvYLVaFzW/cAAibTpxTKdb6ua/MgmYJ5D43g3g 7WZg== X-Gm-Message-State: AOAM530c15ONllAbP6ChTteo6eXaI/HPQCNswgEggBqycoOFbM46FCgT zKaTzUONVRrwVCNFubw+u78= X-Received: by 2002:a17:90a:7487:: with SMTP id p7mr6789220pjk.189.1599426044575; Sun, 06 Sep 2020 14:00:44 -0700 (PDT) Received: from localhost (g223.115-65-55.ppp.wakwak.ne.jp. [115.65.55.223]) by smtp.gmail.com with ESMTPSA id m25sm12735683pfa.32.2020.09.06.14.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Sep 2020 14:00:43 -0700 (PDT) Date: Mon, 7 Sep 2020 06:00:41 +0900 From: Stafford Horne To: Luc Van Oostenryck Cc: Jonas Bonn , LKML , openrisc@lists.librecores.org, Greentime Hu , Andrew Morton Subject: Re: [OpenRISC] [PATCH v2 3/3] openrisc: Fix issue with get_user for 64-bit values Message-ID: <20200906210041.GK3562056@lianli.shorne-pla.net> References: <20200905131935.972386-1-shorne@gmail.com> <20200905131935.972386-4-shorne@gmail.com> <20200905135714.74bsr5h423k7guw4@ltop.local> <20200905213408.GI3562056@lianli.shorne-pla.net> <20200906002228.mrbs7pdyrf5ooi3c@ltop.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200906002228.mrbs7pdyrf5ooi3c@ltop.local> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 06, 2020 at 02:22:28AM +0200, Luc Van Oostenryck wrote: > On Sun, Sep 06, 2020 at 06:34:08AM +0900, Stafford Horne wrote: > > On Sat, Sep 05, 2020 at 03:57:14PM +0200, Luc Van Oostenryck wrote: > > > On Sat, Sep 05, 2020 at 10:19:35PM +0900, Stafford Horne wrote: > > > > > > Hi, > > > > > > The change for 64-bit get_user() looks good to me. > > > But I wonder, given that openrisc is big-endian, what will happen > > > you have the opposite situation: > > > u32 *ptr; > > > u64 val; > > > ... > > > get_user(val, ptr); > > > > > > Won't you end with the value in the most significant part of > > > the register pair? > > > > Hi Luc, > > > > The get_user function uses the size of the ptr to determine how to do the load , > > so this case would not use the 64-bit pair register logic. I think it should be > > ok, the end result would be the same as c code: > > > > var = *ptr; > > Hi, > > Sorry to insist but both won't give the same result. > The problem comes from the output part of the asm: "=r" (x). > > The following code: > u32 getp(u32 *ptr) > { > u64 val; > val = *ptr; > return val; > } > will compile to something like: > getp: > l.jr r9 > l.lwz r11, 0(r3) > > The load is written to r11, which is what is returned. OK. > > But the get_user() code with a u32 pointer *and* a u64 destination > is equivalent to something like: > u32 getl(u32 *ptr) > { > u64 val; > > asm("l.lwz %0,0(%1)" : "=r"(val) : "r"(ptr)); > return val; > } > and this compiles to: > getl: > l.lwz r17,0(r3) > l.jr r9 > l.or r11, r19, r19 > > The load is written to r17 but what is returned is the content of r19. > Not good. > > I think that, in the get_user() code: > * if the pointer is a pointer to a 64-bit quantity, then variable > used in as the output in the asm needs to be a 64-bit variable > * if the pointer is a pointer to a 32-bit quantity, then variable > used in as the output in the asm needs to be a 64-bit variable > At least one way to guarantee this is to use a temporary variable > that matches the size of the pointer. Hello, Thanks for taking the time to explain. I see your point, it makes sense I will fix this up. -Stafford