Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp985837rdh; Fri, 24 Nov 2023 02:47:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnHr6eHouTumobz5vc9tFH/IrAfH7A5idL8WWC0N5ZnqKjlGm5ZgKnEREPvLu6TGEqRG2M X-Received: by 2002:a17:903:2805:b0:1cc:43a9:5ce9 with SMTP id kp5-20020a170903280500b001cc43a95ce9mr2308857plb.58.1700822872926; Fri, 24 Nov 2023 02:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700822872; cv=none; d=google.com; s=arc-20160816; b=K7Hiz2Nymg/GN3+5YajQoPGaelnr4Z06LxNe8tEIln0Mx5eNCku+TCg6w5B0SEP3vo khQ+c/iI11tmyGUhkJdkHIJn9xabpisYCSBMtByN0DdzXhwfShWIguf8dtVgXlELdq4U D76yWPQWmd/48AvR+RZkonLtRengNVxlu3r57lVIDlPz/Qh0K63bLTZQzaHm7HAblW5b slqlBA/QN/hyM5ssL5hbVPhe0OHdw2OqOu7KUgx9SJbq9sZRrevwlRu1LJRUOgrWkPIf 6zr0mwVwXPqEam+6z+AN9HEHr1aS67EEmVKhZtYcPkEYWWOxeCq3hj7vP28yOyiHvMLe iZuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=AmiGlj96IFtlJWedK6S19XGZRl2qB+TgVTNmtgUUI8g=; fh=BVX+esJdtIrrH2pR60rrQkTefljMAV6/WRoNFCqjL8A=; b=x85IUb6LDGenVPNRUJU2RXpczYSkVLGYvfnSz1X86HRPxTlm/FKHdOjWgE1cOtVy+d IEtWidraKQ8yP5hdfRTZ5gRm0YhTorDSJTtTu9xGNjgtWIecbeXgBk+aL+CUpwad5tMI CZS3TZXKjzEMALSNJ7ajPNTUh7w5tUDYnBc11p6p3hlFWCMccT7PGtwH7NF8yN16OG+N oTy1SW8gRUEXMxRlh0lyXGoJCev1/4hStQGvQZ3/d0VqfZVDMFSS+xnDfs91hC8UAGFu luDS0yGoXFPUPCqp4XbBomtDuNW8RZ3WyVl8OzeClV0O+frAjPhyuR8aqDLDHKFeWUY/ xsVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=qbHNfOqm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d12-20020a170902cecc00b001cf640d2017si3236595plg.346.2023.11.24.02.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 02:47:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=qbHNfOqm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C603080ADF30; Fri, 24 Nov 2023 02:45:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345713AbjKXKpJ (ORCPT + 99 others); Fri, 24 Nov 2023 05:45:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345372AbjKXKo6 (ORCPT ); Fri, 24 Nov 2023 05:44:58 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70848D7D for ; Fri, 24 Nov 2023 02:45:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=AmiGlj96IFtlJWedK6S19XGZRl2qB+TgVTNmtgUUI8g=; b=qbHNfOqmV7NK8ehhm3Fr5JG1yj dNvwJMLvu19xEiNCB+Pz0qYxRqtKmtUgnhAMF67ykfjRtARf/OWKv5Pv/Nf+ibqV0vn1sEhrqyQy4 +rv8qdsgtLVI8LyDdLzKh9pd/Pt2bhz5P6S8ZlpR6vL/19m+/et87XliTZ99TaPWGUIfQi67t9+46 5q8rZ22IBSitVEZ9RPltdavy3MX1XKsGl9ugfxi+MXzNUgURgVgYuIOq3OfoWr3owDeWp5xoiiULn aTmdrNFYOzJ1ZMbnNBcHD/OpjjY+iqghFrfJgSgWsFkR33pv/dnk82paie+33WCA9TklXHLlVCQSN m/puwjFw==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6TgC-006u6Y-0k; Fri, 24 Nov 2023 10:45:00 +0000 Date: Fri, 24 Nov 2023 02:45:00 -0800 From: Christoph Hellwig To: =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= Cc: Christoph Hellwig , Ben Dooks , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu Subject: Re: [PATCH] riscv: fix __user annotation in traps_misaligned.c Message-ID: References: <20231123141617.259591-1-ben.dooks@codethink.co.uk> <7232f08e-dfe3-43d6-a4f7-abf8360bbfc1@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7232f08e-dfe3-43d6-a4f7-abf8360bbfc1@rivosinc.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 24 Nov 2023 02:45:25 -0800 (PST) On Fri, Nov 24, 2023 at 11:28:08AM +0100, Cl?ment L?ger wrote: > I sent a similar patch two days ago with the same modification. I'm not > sure to get it. Why is it better to pass the "unsigned long" type from > the caller ? I mean, the resulting code would look like this right ? Because you're legimitizing casting between address_space, which is a horrible idea. By casting either from the unsigned long you make it very clear that deep magic is coming in and you make an informed decisions based on the user_mode() predicate. Witht a blind cast to add/remove a __user you don't. I'm actually surprised sparse even allows __user casts without __force.