Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5149341imb; Thu, 7 Mar 2019 08:48:28 -0800 (PST) X-Google-Smtp-Source: APXvYqz4pu36A3vugCo7H356AHRuSwzJlVZFBZf4iZ+PahOXlNPXgDFbjB5+7+WxLGdNg4GypaVC X-Received: by 2002:a65:50cc:: with SMTP id s12mr12127766pgp.130.1551977308601; Thu, 07 Mar 2019 08:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551977308; cv=none; d=google.com; s=arc-20160816; b=vj+wsap55qg93LvmooXOgSoyeNB/rMVtrkJzW1szFsXoqTJgA89fER5lJgs/NjH2Nr z2W2qhzhbTsXo2QjvWt+T3ilZiaJtkG3UeL0Ri68sSOQ9maqrlkxjRiCkZ1xGjgOvc0z LH0YpiWLGnTUNNF5YthNsbhXdMoHr6mTCE33pUh2bY3bscVEMCEQmOoydJPxRE+ePKhH 32EeOx7wn16exW+YRXWG6POnaumoCM9A/WLScyvNxC+84NV39iLi3IX/tgugeY0UFOwL uNEwaPCzuy40h2f47pBv4LuhAbtipyK+SkSQjL1yOL+4s7y3pk5UxxRewink3A+peTLE UNaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1lNqk+qr8MU7n7QesPjCEoudF5c15VBGHjlGWQd+ic0=; b=f65fvYOUl16A6VCBHh1FZAssAn+tCdrrhiiNaTrYaLUgqJiVABCJppwA1au33HCPwE eEXkYrYCriRb6nJ955b8Lo/yoOlXVmnZJU8TOHFj9gu0+v5K8ynTSgMwZIayfJW0NCfU aI4ogeuatYnMHAQdK89hsrGEgrMuGB/3e1SbvX0+ezlI9JafwuZKDcgbSsdbsTFTV+oz 5aaD2/KbQe6cxZs9eRB31JQr7jq692QD1lqReZ6Vv2Sed/yY/yUGAZnkhIwHBFHlVXvu 10pgoUhbXTDZII0nI689081n5SfWI8/kUFZNVb58DpoGjt9TwSiImA+gpN1t41hD1bqF kXzQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f75si4498733pfh.164.2019.03.07.08.48.13; Thu, 07 Mar 2019 08:48:28 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726429AbfCGQrM (ORCPT + 99 others); Thu, 7 Mar 2019 11:47:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44976 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbfCGQrM (ORCPT ); Thu, 7 Mar 2019 11:47:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9522830D78C5; Thu, 7 Mar 2019 16:47:11 +0000 (UTC) Received: from treble (ovpn-120-61.rdu2.redhat.com [10.10.120.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F16395C1B5; Thu, 7 Mar 2019 16:47:08 +0000 (UTC) Date: Thu, 7 Mar 2019 10:47:05 -0600 From: Josh Poimboeuf To: Peter Zijlstra Cc: torvalds@linux-foundation.org, tglx@linutronix.de, hpa@zytor.com, julien.thierry@arm.com, will.deacon@arm.com, luto@amacapital.net, mingo@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, valentin.schneider@arm.com, brgerst@gmail.com, luto@kernel.org, bp@alien8.de, dvlasenk@redhat.com, linux-kernel@vger.kernel.org, dvyukov@google.com, rostedt@goodmis.org Subject: Re: [PATCH 00/20] objtool: UACCESS validation v3 Message-ID: <20190307164705.qbu4ytdfdmsighas@treble> References: <20190307114511.870090179@infradead.org> <20190307120317.GD32477@hirez.programming.kicks-ass.net> <20190307125526.GB32534@hirez.programming.kicks-ass.net> <20190307131312.GC32534@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190307131312.GC32534@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 07 Mar 2019 16:47:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 07, 2019 at 02:13:12PM +0100, Peter Zijlstra wrote: > On Thu, Mar 07, 2019 at 01:55:26PM +0100, Peter Zijlstra wrote: > > On Thu, Mar 07, 2019 at 01:03:17PM +0100, Peter Zijlstra wrote: > > > > > 01be 20d3: 31 c0 xor %eax,%eax > > > 01c0 20d5: 4c 39 eb cmp %r13,%rbx > > > 01c3 20d8: 77 08 ja 20e2 <__do_sys_waitid+0x1cd> > > randconfig-build/kernel/exit.o: warning: objtool: __do_sys_waitid()+0x1c3: (branch) > > > > 01cd 20e2: 83 f0 01 xor $0x1,%eax > > > 01d0 20e5: 48 89 c2 mov %rax,%rdx > > > 01d3 20e8: 83 e2 01 and $0x1,%edx > > > 01d6 20eb: 48 83 c2 02 add $0x2,%rdx > > > 01da 20ef: 48 ff 04 d5 00 00 00 incq 0x0(,%rdx,8) > > > 01e1 20f6: 00 > > > 01de 20f3: R_X86_64_32S _ftrace_branch+0x148 > > > 01e2 20f7: 84 c0 test %al,%al > > > 01e4 20f9: 75 2d jne 2128 <__do_sys_waitid+0x213> > > > > we do not take this branch and fall-through. > > And that is the error, I think. We should've taken it and went to: > > return -EFAULT; > > because: > > +1be xor %eax,%eax eax=0 > +1cd xor $0x1,%eax eax=1 > +1e2 test %al,%al 1&1==1 -> ZF=0 > +1e4 jnz > > Is an unconditional code sequence, but there's no way objtool can do > that without becoming a full blown interpreter :/ > > > > 0213 2128: 49 c7 c7 f2 ff ff ff mov $0xfffffffffffffff2,%r15 > > > ffffffffffffe0eb } > > > 021a 212f: 48 8d 65 d8 lea -0x28(%rbp),%rsp > > > 021e 2133: 4c 89 f8 mov %r15,%rax > > > 0221 2136: 5b pop %rbx > > > 0222 2137: 41 5c pop %r12 > > > 0224 2139: 41 5d pop %r13 > > > 0226 213b: 41 5e pop %r14 > > > 0228 213d: 41 5f pop %r15 > > > 022a 213f: 5d pop %rbp > > > 022b 2140: c3 retq This "fixes" it, and also seems to help -Os make much code: diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 445348facea9..8de63db58fdd 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -67,7 +67,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, .line = __LINE__, \ }; \ ______r = !!(cond); \ - ______f.miss_hit[______r]++; \ + if (______r) ______f.miss_hit[1]++; else ______f.miss_hit[0]++; \ ______r; \ })) #endif /* CONFIG_PROFILE_ALL_BRANCHES */