Received: by 10.213.65.68 with SMTP id h4csp1252237imn; Wed, 4 Apr 2018 15:42:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+OE3F0euW/ZDwlEn+qtgPvgHkCx2ONO0Jk/4bAzE5a8uW77u3Km2KTVSJjoYvor+df5036 X-Received: by 2002:a17:902:7888:: with SMTP id q8-v6mr20287311pll.108.1522881748331; Wed, 04 Apr 2018 15:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522881748; cv=none; d=google.com; s=arc-20160816; b=eBNNf+tfXtcdptjXQaC9MwrvX8184ywXB160R9yQszV0AkvfIaO9+rtgtu/nQ7dsxD 4+jXbhebjp/3aNIsjWIGMPmGTI4djTo+3pJKejycwbgSpfmqR8mklmDHq+RX8WLndNOS s5tOMwShG4DuftANSnMxw2bWJJnwr4crEbAgbxpsoFYtYsmObA2qjE+tNVw03mrF5D0U r+eFUoaK+sJRbYmBZcoZZnadVbKV8pupphbYYkML8Wlrj1LbcmzK87ZomvtLJ3hNJcic DkZ0A/d/sshglim+1ZB41OTr2m+Ucwy8HPwktzpjnbHqxMhsFza9kt3U5iGWRjZvCccW xWGQ== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=muszaI0ozkhkdqv+TpGh4YzE88H9hnH+B0tBaUVhPeI=; b=wJryUV9k4ufyVBTnsiLo5gHReKmleWtfljZICo5i0RZEVOW0TA4298ugPdQSi4ha6q E1Z1iANZhB2oXgfDvP+WXbt9h8/BFdY48KY+w+A2Faal/ZtfMFfQsMoZZTQ90wEl7dtE 5q2hWbtoPAdEfvD3mSe/J+8dPDhPg+hwNXjTfbwrpPNNpi63IDvUpEZ0Yom5T1ze7FSa QFyAvWs/nh/JAWr6Tht6GaTUPlEsfWhb4F7X/6+oh9djTPuq7GYRxQ6GS/hYY7kjLdDy XfAj264EXnQEHjLf/oI2bJa7rclJiUw+dPLyP2lsKDBheHkvqO6G3Kqbl5deaSGudkFj 00Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=AaylBK+C; dkim=fail header.i=@linux-foundation.org header.s=google header.b=THAx61AS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19si2747883pgv.479.2018.04.04.15.42.13; Wed, 04 Apr 2018 15:42:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=AaylBK+C; dkim=fail header.i=@linux-foundation.org header.s=google header.b=THAx61AS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752652AbeDDWj1 (ORCPT + 99 others); Wed, 4 Apr 2018 18:39:27 -0400 Received: from mail-it0-f54.google.com ([209.85.214.54]:36781 "EHLO mail-it0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752300AbeDDWjZ (ORCPT ); Wed, 4 Apr 2018 18:39:25 -0400 Received: by mail-it0-f54.google.com with SMTP id 15-v6so816755itl.1 for ; Wed, 04 Apr 2018 15:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=muszaI0ozkhkdqv+TpGh4YzE88H9hnH+B0tBaUVhPeI=; b=AaylBK+C60ei3uR/59RNcv2H5a9pA8HKHk08CvmdTS1eEodQ8uuCfiGEom35uyUdZp oy2xuV7jnhF/ZA4Yw8lXoT1RCOf32sw5/qh9IgcyCUEF8bACXS4IiNEGPvgcWQQalydN +5qsB0Qd3EWXBdL4Clf3LbL3dLu9OGi1X8jXZ+cQe6ar+N9yzWOwyz7J4uS46ZpAZ6mw 70SjX/+mkdlqkEBvWiMkr75Ult0J/+sZwg15Qn3wNiKQQRs2YdWTg0GC9f2NZXzLHcjY gGEuGd62CV4dTSOGXpo/cLTkBhaTtOu4y8VQhRK0lbR/7Rnr3nh9puaDOau0OHKIUVVP eVKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=muszaI0ozkhkdqv+TpGh4YzE88H9hnH+B0tBaUVhPeI=; b=THAx61ASinwE0/hUDRwvgPVEQQkrvQbQcwQYl3ODhn0rNqSZuooDUNSVkQclkw5Bht XUK+UNmDsVapSk42kJzbOoS0WMRl2l7pl1pXhbkv2lvIsr8qZIhxD0p0MwZcRUyrRdsH of4N/GcYw2CWoTVZaJp/pOOZZbseqYDX0JOW4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=muszaI0ozkhkdqv+TpGh4YzE88H9hnH+B0tBaUVhPeI=; b=RCs8jJu4N9MDsdhzMLH+hsRnWFKzucbe31z0op82tEFP1k6Tu6xYcY43CvbbPO2yq8 W0t4yxYi0sAZxjIkpH6rv8req0OMGsQXz0m0SljwaVmJVEIgLENXYvTXqeXtSE2hLEl1 RRe5QJrU2ge2FH8vGdIFU3rtwVhPN3+i+INhdDt9NopgGPdsQzQwthZItyuIohWUWgFQ yPjvGgqeiceOv5783ao+mEivB/X46xP+k5KUCn3iNeFZikB12X08B/JAZH6HpLQDFmov CItA0d6Itehq8qEGKi82ruxaE9PvV/1qPAgPyEjApIxWAzqI4CS4Qdea83ik2vbnYZaS vHfg== X-Gm-Message-State: ALQs6tD0DJP+dMEFMogcimQEM8qbsxY4oWjZ+5pKOAdfvUpG2CsmrMtn oEGGXp/qbb7BqGH8HNvk9SNowGpFbSRLRac/HFs= X-Received: by 2002:a24:5852:: with SMTP id f79-v6mr11570313itb.108.1522881564627; Wed, 04 Apr 2018 15:39:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Wed, 4 Apr 2018 15:39:24 -0700 (PDT) In-Reply-To: <20180404221744.GI87376@google.com> References: <20180403085904.GY4082@hirez.programming.kicks-ass.net> <20180403095118.rpf7tj577dppvx7d@gmail.com> <20180403180658.GE87376@google.com> <20180404093007.GI4082@hirez.programming.kicks-ass.net> <20180404191724.GF87376@google.com> <20180404205848.GG87376@google.com> <20180404214639.GH87376@google.com> <20180404221744.GI87376@google.com> From: Linus Torvalds Date: Wed, 4 Apr 2018 15:39:24 -0700 X-Google-Sender-Auth: 6ljjgnJx3mAvca2-vPvzVmt9v5o Message-ID: Subject: Re: [GIT PULL] x86/build changes for v4.17 To: Matthias Kaehlcke Cc: Arnd Bergmann , Peter Zijlstra , Ingo Molnar , Linux Kernel Mailing List , Thomas Gleixner , Andrew Morton , James Y Knight , Chandler Carruth , Stephen Hines , Nick Desaulniers , Kees Cook , Guenter Roeck , Greg Hackmann , Greg Kroah-Hartman 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 On Wed, Apr 4, 2018 at 3:17 PM, Matthias Kaehlcke wrote: > > Getting our compiler team high to look into this might affect a timely > (and correct ...) implementation of asm-goto and others important > features. Arnd, do you have another, preferably simple instance to > keep our compiler folks (halfway) sane? I don't know if clang actually already gets this right or not, but as an example of a case where we have a semantic difference between "is this a constant or not", a much simpler case is in - arch/x86/include/asm/uaccess.h: /* * Test whether a block of memory is a valid user space address. * Returns 0 if the range is valid, nonzero otherwise. */ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, unsigned long limit) { /* * If we have used "sizeof()" for the size, * we know it won't overflow the limit (but * it might overflow the 'addr', so it's * important to subtract the size from the * limit, not add it to the address). */ if (__builtin_constant_p(size)) return unlikely(addr > limit - size); /* Arbitrary sizes? Be careful about overflow */ addr += size; if (unlikely(addr < size)) return true; return unlikely(addr > limit); } where the actual check itself is simplified for the constant size case (because we know that constant sizes are never going to have the overflow issue with the address size limit) That inline function itself is then wrapped with a couple of macros, and the usual use-case is through "access_ok()", which then typically just gets either a sizeof(), or a non-constant length. Of course, we've been walking away from having people do "access_ok() + __copy_from_user()" (the latter does some conceptually similar optimizations on constant sizes), so those probably simply don't matter much any more in practice. But they are certainly a lot simpler to look at than the more exciting 32-bit asm-generic "do_div()" case is ;) Linus