Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1832727ybh; Tue, 14 Jul 2020 08:28:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc266d4UCifvrM4rZtZSVcQ0bvjmOfyk7R636y30RPkKzs1RaeF3OiGL6JFVgWGfgaiQB+ X-Received: by 2002:aa7:cdca:: with SMTP id h10mr5157402edw.285.1594740491603; Tue, 14 Jul 2020 08:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594740491; cv=none; d=google.com; s=arc-20160816; b=qoQyhmSkpcP3ODF3v08pPC1dCg9uB2VN7gu9yFDP535WHEZ1OuoRukX7KUKKk/nLYp o0VbXVpyqA0Hz1Y30GjsrvYZKm3cyv8ETtsaD29NfQDvD+8Bu236eWVPkIDsJR5uMbOY c99k7kWlH0HX8Sy0GKxl/+LjnmpB5Lz2Y9JkhF1xwEIIu7T4d6+ciNbtewjRDJDvnoFR bhcyC8sLB9up3ylnajejRxV8wHekRefiMNdgSg7cMmGcLlgL0UlSqqDaEbJ/DRcNkttT YAgAAawlJeA+jfOQUzznxIlaYrEF27Q8ov4yl6+Pw8fK40ol3yeysm4+NAD0nBQxeMfi XMcg== 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:dkim-signature; bh=jCyLOhQV57mz1Tz9y5V98kqwmWTue4420M9y+zk47sY=; b=UB4oKZTjHzIU2n2BXHjt+EGYBSPXMMx7HFi33AWeuupO9ywJIwB77jvJx77UbTV8JV rRsefnDhEEmrJCdVgbVV7D1RwQewP91RmDA/xn9WOTh1n4aWwhHL0CVltVb62VQjtaJZ wWrwgCCqNIJwfi8VNojvz+syHJLlN0Z1hfDtU6MdZc6oDFwnw0PrKqZdbIbrySiJixkn CF6lwQMdR2ehJ990f2akWhM0kOI0Yet32htjza/l0EG6urs0hZ46dvjH6rOB9bykx5Uy KNdvYgREaGyDa9WDY1q1SuJ5RI+P8BdoqP2327Wf93i5E53lqOrdzJ7TIP93II1qj8Jk zvrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=JrWgTBRd; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i26si10283820ejy.58.2020.07.14.08.27.45; Tue, 14 Jul 2020 08:28:11 -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=@linux-foundation.org header.s=google header.b=JrWgTBRd; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726600AbgGNP1g (ORCPT + 99 others); Tue, 14 Jul 2020 11:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbgGNP1f (ORCPT ); Tue, 14 Jul 2020 11:27:35 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7714C061755 for ; Tue, 14 Jul 2020 08:27:34 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id k15so11967494lfc.4 for ; Tue, 14 Jul 2020 08:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jCyLOhQV57mz1Tz9y5V98kqwmWTue4420M9y+zk47sY=; b=JrWgTBRdBX1cUe5aCb73+TsaK4ECM13FS6SYZxjTTs/VcET75Za3d/5OpAFolMLiG2 rmM293nxQKfX4PiAjnofjoAJ6qAZh+dcMJ5TZE8IAzVTRLCvzUlr0FPZQ4Ha2hKtav0P Hy7ruQElpq2zZYq8uOxErUU6Ocv4g8NOdw6hg= 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=jCyLOhQV57mz1Tz9y5V98kqwmWTue4420M9y+zk47sY=; b=WizdoWNSRMJ421eUGh0fLK7a1QQKCZmE2FauMsZQGds0pMm+6Bjp2Ll+JnTBMzXMFz UydDUu0y+7gASEJI4TX5u5WT1XdpDYu13/Ry/hU87FLEhXvwxrVWqaihZrg5k707w2pI FT0WjFQU4pqmL+niAEnYD9Pbi5xTqfd9AMDihS6X0gtYpP+uBV3BDFYTuFo8FsY9Smno 0Zajvb/Z1CGdmczYAH2NKQnBqu8R6CisorjqTSydUtJNWWPPZgOPW1KdWulm9gDBKc2z u4kH0WoPFdqP4g5W6k0GZjZkvhhZbhO61zKeTZVMCpRhtov0HYQtP9ic+oMWbhHu3FRV 8H/A== X-Gm-Message-State: AOAM533TUO1+mnaxM3iVjK5MU3DXezsRQsmIl4/78q5jn26ARMpTa3jR Dz8SK7xtMKIC3RmKzndhFhFbkGGjvh8= X-Received: by 2002:ac2:5c09:: with SMTP id r9mr2508857lfp.176.1594740452658; Tue, 14 Jul 2020 08:27:32 -0700 (PDT) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com. [209.85.208.171]) by smtp.gmail.com with ESMTPSA id m25sm4715009ljj.128.2020.07.14.08.27.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jul 2020 08:27:31 -0700 (PDT) Received: by mail-lj1-f171.google.com with SMTP id x9so13295628ljc.5 for ; Tue, 14 Jul 2020 08:27:30 -0700 (PDT) X-Received: by 2002:a2e:86c4:: with SMTP id n4mr2701790ljj.312.1594740450439; Tue, 14 Jul 2020 08:27:30 -0700 (PDT) MIME-Version: 1.0 References: <20200714105505.935079-1-hch@lst.de> <20200714105505.935079-5-hch@lst.de> In-Reply-To: <20200714105505.935079-5-hch@lst.de> From: Linus Torvalds Date: Tue, 14 Jul 2020 08:27:14 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 4/6] uaccess: remove segment_eq To: Christoph Hellwig Cc: Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Andrew Morton , linux-riscv@lists.infradead.org, linux-arch , Linux Kernel Mailing List , Geert Uytterhoeven 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 Ack, just with a note: On Tue, Jul 14, 2020 at 4:06 AM Christoph Hellwig wrote: > > --- a/arch/x86/include/asm/uaccess.h > +++ b/arch/x86/include/asm/uaccess.h > @@ -33,7 +33,7 @@ static inline void set_fs(mm_segment_t fs) > set_thread_flag(TIF_FSCHECK); > } > > -#define segment_eq(a, b) ((a).seg == (b).seg) > +#define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg) > #define user_addr_max() (current->thread.addr_limit.seg) This "uaccess_kernel()" interface is a better model anyway, because at least on x86 (and from a quick glance at others), we might avoid the exact equality comparison, and instead do simpler/better things. On x86-64, for example, checking whether the limit has the high bit set is not only more flexible and correct, it's much cheaper too. Of course, trying to get rid of all this means that it doesn't matter so much, but it would probably have been good to do this part years ago regardless. Linus