Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2636440rwr; Fri, 28 Apr 2023 13:21:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79bspNMAMqgLdI8FBSjmMvR9f/Fs5ucwS8KWWTAiHhpRcGROREq4ynK/vxQFQB/ESteW0m X-Received: by 2002:a17:902:ceca:b0:1a6:dc1f:6230 with SMTP id d10-20020a170902ceca00b001a6dc1f6230mr7167533plg.55.1682713299615; Fri, 28 Apr 2023 13:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682713299; cv=none; d=google.com; s=arc-20160816; b=MZ4XH2eISq3S7a9SG7ch+E0+YoSjILOB9iR4bGpfYnhymb2DVj4sJaasurAKf+HFsj ui27FoXJP27/XmVNn8iyIl8iw5vdBd1fUaUKeB9SXPR0LzIWrUsyiKhvub6dlbdtaWiX xp97XzZ9sUAafJvmVz8ZnE/xzM0YD3vv2ktu9bqmVfEzwumhuWgbqdVbQ6kkhDnRqwKb M3QmhngtyEEQ1y30fTJjUcX7DHogw6M8sJcK+NQkfNd8znQbay1FRUHQOg5CcuMVQr/V Z1RhDl7BrcoPTbnTDWJMprF3vn39sWGbGdp3wik00xtKY/H16tZ+ZZqnQ76fU/dKGJKN Yklw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=HUIWX3sGJnBrImpfMXQlWdZnoxCUJzr5qJ00uMkbMW4=; b=y0K//VhCPpvU07kOEAKXZTznUHM/Z0KCS4t0bMwzbvB8maY5pw7tpnM0GWMl20RfWl IvoYuSC09/1K1P6FkLc5j20rkK2jC652zpwturGTmEtW2D8fPIUBuTPnL/LqGgJr8zKQ ivXOuLgiPX511e6JWLS4broBqaGl8BAq+9etYyF7v4lc8CFPTkkju/xfyWtkiZsoYGzr yzFsMmEO/YqkgqoR1jOus5KZI1GiClrriLhs68Aaxeos4BRF3kHvVpWGzWLLJWxzCmEI jK7Z4/ZQRVXqNSFwXdazfvx/PvcRKtfZtjrIrBcvJchAONgLUVF806uSxnZnwvFZ6n+O sm1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=FNV0xFYL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id li12-20020a170903294c00b0019cec50618csi19872822plb.159.2023.04.28.13.21.22; Fri, 28 Apr 2023 13:21:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=FNV0xFYL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbjD1UPz (ORCPT + 99 others); Fri, 28 Apr 2023 16:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbjD1UPy (ORCPT ); Fri, 28 Apr 2023 16:15:54 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7030F26B1 for ; Fri, 28 Apr 2023 13:15:53 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-94eff00bcdaso39511666b.1 for ; Fri, 28 Apr 2023 13:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1682712952; x=1685304952; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HUIWX3sGJnBrImpfMXQlWdZnoxCUJzr5qJ00uMkbMW4=; b=FNV0xFYLhSTM1MJhlQVhXI7rE7KfxNE2O9moJ9l47IDzM5oyHBu24cENZxcykYS3Re 7bc6W6hbtUmvW6T1ll6W5ah2J1NL1QcriOoySzii5vDMkS8FaMzqc7+kOZQZ23cY5k1V YqPn2su66+zEtVacvnhwSMo7sUPnXivoatiWM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682712952; x=1685304952; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HUIWX3sGJnBrImpfMXQlWdZnoxCUJzr5qJ00uMkbMW4=; b=QlBWMpcGhyISzk8jY29EbJ6DN7jj1FcEiN9cPpbvKzex7XxIfNfBTSR/CSdqROlWLR gZbFVI5/EH1iuCN67dTeCgAvR8a4poJgPFYFdGlEqJKYz8IbFFLOI9+QACpSH+tGHRo2 34AqKW1x4gB2KBFNZ5Jep2FQx/rdcWKfbPdzHaNF/BomLLJYeHiXMcaXn4gNjYGCHBzX M8z/uXoZzDnf/LPM/jLTkplrBJRvWRxBqMkSE0m5UKZyXnQl0Unw7ewql/N+p05gv9i5 KdjfaCC6bYFFBfEbFF4+KyHmCYAgwHgDbUxSjH3F8Ttdv0H0osGuA6UVfKJg3BnIJK2m qUuA== X-Gm-Message-State: AC+VfDwHZ145NWwCFgvbLWc3chyoS/OUtzApCJhvRzl/0inYb3WlK78y QdPbyAUCwX8Ecqf3PI4eOVb1oUbOBdeohD1qJUIssg== X-Received: by 2002:a17:907:7b93:b0:953:517a:8f1a with SMTP id ne19-20020a1709077b9300b00953517a8f1amr6662375ejc.58.1682712951792; Fri, 28 Apr 2023 13:15:51 -0700 (PDT) Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com. [209.85.208.54]) by smtp.gmail.com with ESMTPSA id x19-20020a1709065ad300b0095381e27d13sm11448526ejs.184.2023.04.28.13.15.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Apr 2023 13:15:50 -0700 (PDT) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-504eac2f0b2so172994a12.3 for ; Fri, 28 Apr 2023 13:15:50 -0700 (PDT) X-Received: by 2002:a17:906:eec8:b0:94f:444c:fc25 with SMTP id wu8-20020a170906eec800b0094f444cfc25mr6300392ejb.12.1682712949981; Fri, 28 Apr 2023 13:15:49 -0700 (PDT) MIME-Version: 1.0 References: <20230427225647.1101172-1-dave.hansen@linux.intel.com> In-Reply-To: From: Linus Torvalds Date: Fri, 28 Apr 2023 13:15:33 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [GIT PULL] x86/mm for 6.4 To: Dave Hansen Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com, Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 On Fri, Apr 28, 2023 at 1:07=E2=80=AFPM Linus Torvalds wrote: > > So here's my suggested change on top of the current tree. Comments? Oh, and I wanted to particularly mention that We could probably just do that "check only starting address" for any arbitrary range size: realistically all kernel accesses to user space will be done starting at the low address. But let's leave that kind of optimization for later. As it is, this already allows us to generate simpler code and not worry about any tag bits in the address. part of the commit log. Right now that patch only simplifies the range check for when the compiler statically knows that the range is small (which does happen, but not very often, because 'copy_to/from_user()' isn't inlined on x86-64, so the compiler doesn't actually see the constant size case that is very common there). However, that "check the end of the range" is sometimes actually fairly complicated code, and it would be nice to drop that entirely. See for example the fs/readdir.c case, where the length of the access is kind of annoying: if (!user_write_access_begin(dirent, (unsigned long)(dirent->d_name + namlen + 1) - (unsigned long)dirent)) goto efault; and there really isn't any actual reason to check the end of the access on x86: if the beginning address has the low bit clear, it doesn't really matter what the end is, because we'll either have a good area, or we'll fault in the non-canonical area even if the sign changes. So being careful about the range is kind of annoying, when we don't really need it. Linus