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=-3.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 00069C433E2 for ; Sat, 12 Sep 2020 08:40:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D078206B8 for ; Sat, 12 Sep 2020 08:40:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aw7itSEe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725834AbgILIkr (ORCPT ); Sat, 12 Sep 2020 04:40:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725800AbgILIkq (ORCPT ); Sat, 12 Sep 2020 04:40:46 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B62F3C061573 for ; Sat, 12 Sep 2020 01:40:44 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id k13so2032888plk.3 for ; Sat, 12 Sep 2020 01:40:44 -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=xtZpYqJi2Eh1iCduCHOJ+h77NknG0j+OKsQgYvK291Q=; b=aw7itSEeTJJzT2wS1waWn3QoWAFE2Rnm8cV2CO7tT69YDo7gEiKozK1mGeNQob02Ii c/lpmqphdvUbCf6NJO96JhB87t1IdfH17rWXMQbMN9nuNsyBtkvi2vD4peBSDiJfKnNn LhiHbyxb+UGBPCoCWciHsyiWAnhYi7pqC2YF0JUgaq+6TsH9iPOah3d/sk4dLvlkhuyO U+s8IyGWITEWrBw3DqZsEDzawfC3D6W9Cm8SolrMGzfSElybJO+ZSb8vKMtkGPXw4NcQ BRKvsvXKGx9LG5iOfH9sHiIBEqBk+dyKw6MaYDh8A1vr/+LnfiLGZsGagf/fahfxFd2i ugzQ== 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=xtZpYqJi2Eh1iCduCHOJ+h77NknG0j+OKsQgYvK291Q=; b=Xq3sHV8Zg3r1WDywvFh9h2kDWqUDgbgIB4J5vDIz2tAfWl1ZICbV3pOBYyRW1FY/wg aMyCni3atbhxCEOWCUCHIkpULU9IH6iaL69k+P99pFIsWA3lX15h+lumTTBKtG2AcPUW o2SelQCDM0+EIOPnHyQc/4sXBKtQsa4KzPG3/yvV2sSMUs35ZZXBCITtksbfyo2sNQRS IAriq8Ecrp5dg5QR1F8UK8+cJyNA04awbymejs7vDRJWKLRaLOa4PIiyevGXmMQctGaS i+BGFvVmBwmY4BrKfN0aOSecVI0i54eZVfT01eCV8vR7l+1KojSByTBRyN6zSGHaXckk LXVA== X-Gm-Message-State: AOAM53395xoo5E2EpUK+DZ8z0zO+apbzzQRAI67i1MEp2k44C5WT8c91 YYrBqaNu92E8YeSPQrxD7+E= X-Google-Smtp-Source: ABdhPJzZcn+s/PFPMGentFcESDpGVRZhUChlRUiTJzIXjPkcJ269s9m/RC3BlMACaK3CVlK8JhLktQ== X-Received: by 2002:a17:90b:4acf:: with SMTP id mh15mr5478887pjb.204.1599900044119; Sat, 12 Sep 2020 01:40:44 -0700 (PDT) Received: from localhost (g168.115-65-169.ppp.wakwak.ne.jp. [115.65.169.168]) by smtp.gmail.com with ESMTPSA id i126sm646895pfc.48.2020.09.12.01.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 01:40:43 -0700 (PDT) Date: Sat, 12 Sep 2020 17:40:41 +0900 From: Stafford Horne To: Luc Van Oostenryck Cc: LKML , Jonas Bonn , Albert Ou , linux-riscv@lists.infradead.org, Stefan Kristiansson , openrisc@lists.librecores.org, Palmer Dabbelt , Greentime Hu , Paul Walmsley , Geert Uytterhoeven , Andrew Morton Subject: Re: [PATCH v3 3/3] openrisc: Fix issue with get_user for 64-bit values Message-ID: <20200912084041.GQ3562056@lianli.shorne-pla.net> References: <20200910233940.2132107-1-shorne@gmail.com> <20200910233940.2132107-4-shorne@gmail.com> <20200911205526.65llro2gnh7zlsu4@ltop.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200911205526.65llro2gnh7zlsu4@ltop.local> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 11, 2020 at 10:55:26PM +0200, Luc Van Oostenryck wrote: > On Fri, Sep 11, 2020 at 08:39:40AM +0900, Stafford Horne wrote: > > A build failure was raised by kbuild with the following error. > > > > drivers/android/binder.c: Assembler messages: > > drivers/android/binder.c:3861: Error: unrecognized keyword/register name `l.lwz ?ap,4(r24)' > > drivers/android/binder.c:3866: Error: unrecognized keyword/register name `l.addi ?ap,r0,0' > > > > The issue is with 64-bit get_user() calls on openrisc. I traced this to > > a problem where in the internally in the get_user macros there is a cast > > to long __gu_val this causes GCC to think the get_user call is 32-bit. > > This binder code is really long and GCC allocates register r30, which > > triggers the issue. The 64-bit get_user asm tries to get the 64-bit pair > > register, which for r30 overflows the general register names and returns > > the dummy register ?ap. > > > > The fix here is to move the temporary variables into the asm macros. We > > use a 32-bit __gu_tmp for 32-bit and smaller macro and a 64-bit tmp in > > the 64-bit macro. The cast in the 64-bit macro has a trick of casting > > through __typeof__((x)-(x)) which avoids the below warning. This was > > barrowed from riscv. > > > > arch/openrisc/include/asm/uaccess.h:240:8: warning: cast to pointer from integer of different size > > > > I tested this is a small unit test to check reading between 64-bit and > > 32-bit pointers to 64-bit and 32-bit values in all combinations. Also I > > ran make C=1 to confirm no new sparse warnings came up. It all looks > > clean to me. > > It looks correct to me too now at C & assembly level. > Feel free to add my: > Reviewed-by: Luc Van Oostenryck Thanks a lot. -Stafford 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=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 25B82C43461 for ; Sat, 12 Sep 2020 08:41:07 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C326C21548 for ; Sat, 12 Sep 2020 08:41:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R36sFbr2"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aw7itSEe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C326C21548 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=khj+rDp0/3TS7tC+wu331o72vcJ1aCC7v5X7yL7haiE=; b=R36sFbr2iynY5z38I45gQJbY9 YGC2As/KjjR2FKiyUBKcip9DSf6QwfpoV2vdL5u1All6tSFlsEsmhLwerSx42uxmJfZtzPpDCwb/E ualOy7LVpUOzOucSeevyKZMJwLOw6o1bgEHtT+bF9GTkeYlX80PplxQA2Pb0EtnoRO5HjQyHpK240 m6fL0lHZHE4rKzRU/wgb78hRtbaV9iFvGZ8oLQMcqo6sKsekxWMDBOkGYeBCC7jVRxEmxgb+1oCRY ABcFsZ6pHmNopaZrWdMcWV/0RVslCcIRrmYH7by1B5prJcQoJ/6Opy3fET56X9owM+87+HaESCYQd ODVujuMGQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kH15V-0004m1-LU; Sat, 12 Sep 2020 08:40:49 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kH15T-0004la-IX for linux-riscv@lists.infradead.org; Sat, 12 Sep 2020 08:40:48 +0000 Received: by mail-pl1-x642.google.com with SMTP id e4so2031737pln.10 for ; Sat, 12 Sep 2020 01:40: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=xtZpYqJi2Eh1iCduCHOJ+h77NknG0j+OKsQgYvK291Q=; b=aw7itSEeTJJzT2wS1waWn3QoWAFE2Rnm8cV2CO7tT69YDo7gEiKozK1mGeNQob02Ii c/lpmqphdvUbCf6NJO96JhB87t1IdfH17rWXMQbMN9nuNsyBtkvi2vD4peBSDiJfKnNn LhiHbyxb+UGBPCoCWciHsyiWAnhYi7pqC2YF0JUgaq+6TsH9iPOah3d/sk4dLvlkhuyO U+s8IyGWITEWrBw3DqZsEDzawfC3D6W9Cm8SolrMGzfSElybJO+ZSb8vKMtkGPXw4NcQ BRKvsvXKGx9LG5iOfH9sHiIBEqBk+dyKw6MaYDh8A1vr/+LnfiLGZsGagf/fahfxFd2i ugzQ== 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=xtZpYqJi2Eh1iCduCHOJ+h77NknG0j+OKsQgYvK291Q=; b=WKBKGLrUjGQTScr3lZanxFQUU6Hk6AgRtFGoidGrs4q1IO9deypLCd42/6wYE4jumO xODIsMRlorrE5Sqg6KC/uq8xzloT24V6BuYtaoR+0H8O1HZ/nHoocrp4UXBrQo615JTh MDHhAgK3FAgXU/UkWTUZCc0x4NjH/fgmm8smzuPthISjYNoXUAiD8IelikWIDxYpgmI9 L5L62NAI+fwUl7GdSL3QN6AABNKUcW9pVdd5nk/DGZshbuA+1v67V4Untwgh/drFtjbn l6/GafoZY8Mgmxgn64NEPDdqVTtxPieH9eb+J5ZprCu6sB7BMxYJCw17t3eqlwKKRbij 8NkQ== X-Gm-Message-State: AOAM533Usfvh7uPnUSHVpF1U3zkHY93X5hAllizLs6TPg9wQeG5U+hNe SW9xCPph7L/ou8dl2tz/oU0= X-Google-Smtp-Source: ABdhPJzZcn+s/PFPMGentFcESDpGVRZhUChlRUiTJzIXjPkcJ269s9m/RC3BlMACaK3CVlK8JhLktQ== X-Received: by 2002:a17:90b:4acf:: with SMTP id mh15mr5478887pjb.204.1599900044119; Sat, 12 Sep 2020 01:40:44 -0700 (PDT) Received: from localhost (g168.115-65-169.ppp.wakwak.ne.jp. [115.65.169.168]) by smtp.gmail.com with ESMTPSA id i126sm646895pfc.48.2020.09.12.01.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2020 01:40:43 -0700 (PDT) Date: Sat, 12 Sep 2020 17:40:41 +0900 From: Stafford Horne To: Luc Van Oostenryck Subject: Re: [PATCH v3 3/3] openrisc: Fix issue with get_user for 64-bit values Message-ID: <20200912084041.GQ3562056@lianli.shorne-pla.net> References: <20200910233940.2132107-1-shorne@gmail.com> <20200910233940.2132107-4-shorne@gmail.com> <20200911205526.65llro2gnh7zlsu4@ltop.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200911205526.65llro2gnh7zlsu4@ltop.local> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200912_044047_670976_8F3CE3F7 X-CRM114-Status: GOOD ( 20.87 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonas Bonn , Albert Ou , LKML , Stefan Kristiansson , openrisc@lists.librecores.org, Palmer Dabbelt , Greentime Hu , Paul Walmsley , Geert Uytterhoeven , linux-riscv@lists.infradead.org, Andrew Morton Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Fri, Sep 11, 2020 at 10:55:26PM +0200, Luc Van Oostenryck wrote: > On Fri, Sep 11, 2020 at 08:39:40AM +0900, Stafford Horne wrote: > > A build failure was raised by kbuild with the following error. > > > > drivers/android/binder.c: Assembler messages: > > drivers/android/binder.c:3861: Error: unrecognized keyword/register name `l.lwz ?ap,4(r24)' > > drivers/android/binder.c:3866: Error: unrecognized keyword/register name `l.addi ?ap,r0,0' > > > > The issue is with 64-bit get_user() calls on openrisc. I traced this to > > a problem where in the internally in the get_user macros there is a cast > > to long __gu_val this causes GCC to think the get_user call is 32-bit. > > This binder code is really long and GCC allocates register r30, which > > triggers the issue. The 64-bit get_user asm tries to get the 64-bit pair > > register, which for r30 overflows the general register names and returns > > the dummy register ?ap. > > > > The fix here is to move the temporary variables into the asm macros. We > > use a 32-bit __gu_tmp for 32-bit and smaller macro and a 64-bit tmp in > > the 64-bit macro. The cast in the 64-bit macro has a trick of casting > > through __typeof__((x)-(x)) which avoids the below warning. This was > > barrowed from riscv. > > > > arch/openrisc/include/asm/uaccess.h:240:8: warning: cast to pointer from integer of different size > > > > I tested this is a small unit test to check reading between 64-bit and > > 32-bit pointers to 64-bit and 32-bit values in all combinations. Also I > > ran make C=1 to confirm no new sparse warnings came up. It all looks > > clean to me. > > It looks correct to me too now at C & assembly level. > Feel free to add my: > Reviewed-by: Luc Van Oostenryck Thanks a lot. -Stafford _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stafford Horne Date: Sat, 12 Sep 2020 17:40:41 +0900 Subject: [OpenRISC] [PATCH v3 3/3] openrisc: Fix issue with get_user for 64-bit values In-Reply-To: <20200911205526.65llro2gnh7zlsu4@ltop.local> References: <20200910233940.2132107-1-shorne@gmail.com> <20200910233940.2132107-4-shorne@gmail.com> <20200911205526.65llro2gnh7zlsu4@ltop.local> Message-ID: <20200912084041.GQ3562056@lianli.shorne-pla.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: openrisc@lists.librecores.org On Fri, Sep 11, 2020 at 10:55:26PM +0200, Luc Van Oostenryck wrote: > On Fri, Sep 11, 2020 at 08:39:40AM +0900, Stafford Horne wrote: > > A build failure was raised by kbuild with the following error. > > > > drivers/android/binder.c: Assembler messages: > > drivers/android/binder.c:3861: Error: unrecognized keyword/register name `l.lwz ?ap,4(r24)' > > drivers/android/binder.c:3866: Error: unrecognized keyword/register name `l.addi ?ap,r0,0' > > > > The issue is with 64-bit get_user() calls on openrisc. I traced this to > > a problem where in the internally in the get_user macros there is a cast > > to long __gu_val this causes GCC to think the get_user call is 32-bit. > > This binder code is really long and GCC allocates register r30, which > > triggers the issue. The 64-bit get_user asm tries to get the 64-bit pair > > register, which for r30 overflows the general register names and returns > > the dummy register ?ap. > > > > The fix here is to move the temporary variables into the asm macros. We > > use a 32-bit __gu_tmp for 32-bit and smaller macro and a 64-bit tmp in > > the 64-bit macro. The cast in the 64-bit macro has a trick of casting > > through __typeof__((x)-(x)) which avoids the below warning. This was > > barrowed from riscv. > > > > arch/openrisc/include/asm/uaccess.h:240:8: warning: cast to pointer from integer of different size > > > > I tested this is a small unit test to check reading between 64-bit and > > 32-bit pointers to 64-bit and 32-bit values in all combinations. Also I > > ran make C=1 to confirm no new sparse warnings came up. It all looks > > clean to me. > > It looks correct to me too now at C & assembly level. > Feel free to add my: > Reviewed-by: Luc Van Oostenryck Thanks a lot. -Stafford