Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3364356ybb; Mon, 6 Apr 2020 07:34:31 -0700 (PDT) X-Google-Smtp-Source: APiQypIJQUCTZQV+D8j3SpflzAcJ2Oy+fpHCvW4nCqo1Kvh5qAt7J3rKqPghfPUQJJTAKSAUeXuN X-Received: by 2002:aca:b602:: with SMTP id g2mr12703783oif.82.1586183671062; Mon, 06 Apr 2020 07:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586183671; cv=none; d=google.com; s=arc-20160816; b=sc2azi2kcB8+Ulnay2x0ZEQoWuq7wYZzWNzEj8zZuexFHE7tClJhn/ECnLX70M6C/z SykSZOyv83QuVZTp2zwobW8iwvSBeL7dU5f/8l4WgxOLLSunc6sXiRYs9kdn9yfdAguE l0ZfNlYeRfImwi32VGnpuqC/XXHzlmPXDtfsvlYKgzP033LVJuy/Q6SfoXx413qsySLH ggjsJylx6SUdefZhU6DYfY4rBdobzejMbJh7AYbzOKCrGmyhuH5glthJiS+sO+JmqkGn ySd82lWbULyrceozs/3t6rZjh7ntvD/Tj1/MWL5B/5FDezaG7N4Elc9Mge3tdSW7KXj0 a7+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=VSir/jwIS86Ti+Bjs0dKhCzkqxS9YJ8FGAa/hLbL5NA=; b=xEG36JArPQ0QDMCrXCnwAo+9dgu3TSz1m6TXVW7S36sMEiwN+AYAAl2Mxf5ihv/JKC DDhzVZ4/p3RkLc11Nwo+w5d6xJXXb0cW+ELqnc6IotgeuvRIUG7zDrEaBMpZ+wLkl8Nh vXT7Z2sLBSX6OePfpPSroIHo0h2Hto7cyyS53Fr422tQdP7IsIibVMEffCRD06vMVrD6 wef+qB4koQDmGgRBEW4SRfrqNm3iOMl7CpReOw9OY90MrKIBIrZ8ilee6R3ZAlsG3p0P rh4cwJtYLGRB+2LtzwgWqEdVs1VTZSsdzzUNV73G5e8FOji7W5vDZ1Mp7JysYRbV5QEY EBhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=bRVTtBIN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si7454704oih.157.2020.04.06.07.34.18; Mon, 06 Apr 2020 07:34:31 -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=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=bRVTtBIN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728699AbgDFOcZ (ORCPT + 99 others); Mon, 6 Apr 2020 10:32:25 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:51368 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728406AbgDFOcZ (ORCPT ); Mon, 6 Apr 2020 10:32:25 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 036ERmb5164674; Mon, 6 Apr 2020 14:32:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=VSir/jwIS86Ti+Bjs0dKhCzkqxS9YJ8FGAa/hLbL5NA=; b=bRVTtBINEmWcHUhDlRnrE8XVaBIbv6S9WX3TBCU8hBOXD3+tJzaaK1jy6cK1zoVnPox7 1Nk2WQXUwFgnpTImAxKUsJGT6gR7u05HY3AHD80tRNqMAxYR89wjlgMwNHxqpzsut09y 8U3o2rEzz7C59E0DhySJKqOc4prbZF3w3oObNyhnB3ctdH04yxcGF0gWsGAr27t5WSnk mJ77d7Yjnydfef4+cjLlt1Pwy6/w4j3xj/LAttetfDtrAX3hzx9TVN+xq2pk5No33emG dY56QH6zcQMoWhyiVFyNgfr2LWAFABJXebFHHEWyuHZaaRjK1p789hTjoodgXJff/785 Fg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 306hnqy7m7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 14:32:08 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 036ESQAx170971; Mon, 6 Apr 2020 14:30:08 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 30839q5pqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 14:30:08 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 036EU2eN005591; Mon, 6 Apr 2020 14:30:05 GMT Received: from linux-1.home (/92.157.90.160) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 07:30:02 -0700 Subject: Re: [PATCH 4/7] objtool: Add support for return trampoline call To: Peter Zijlstra Cc: x86@kernel.org, linux-kernel@vger.kernel.org, jpoimboe@redhat.com, jthierry@redhat.com, tglx@linutronix.de References: <20200402082220.808-1-alexandre.chartre@oracle.com> <20200402082220.808-5-alexandre.chartre@oracle.com> <20200402152717.GE20730@hirez.programming.kicks-ass.net> From: Alexandre Chartre Message-ID: <94272807-23c0-3eae-8312-9488607186ca@oracle.com> Date: Mon, 6 Apr 2020 16:34:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20200402152717.GE20730@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060120 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060120 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/2/20 5:27 PM, Peter Zijlstra wrote: > On Thu, Apr 02, 2020 at 10:22:17AM +0200, Alexandre Chartre wrote: >> With retpoline, the return instruction is used to branch to an address >> stored on the stack. So, unlike a regular return instruction, when a >> retpoline return instruction is reached the stack has been modified >> compared to what we have when the function was entered. >> >> Provide the mechanism to explicitly call-out such return instruction >> so that objtool can correctly handle them. > > https://lkml.kernel.org/r/20200331222703.GH2452@worktop.programming.kicks-ass.net > > And also, the split out version: > > https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=core/objtool&id=ec9d9549901dfd2ff411676dfc624e50219e4d5a > HINT_RET_OFFSET works fine when an immediate value is pushed on the stack. However if the value is pushed from a callee-saved register (%rbp, %rbx, %r12-%r15) then we still have a "return with modified stack frame" warning. That's because objtool checks callee-saved registers pushed/popped on the stack, and we have retpoline functions built for each register (see arch/x86/lib/retpoline.S) So that's why I also added a bool to has_modified_stack_frame() to no check registers: @@ -1432,7 +1478,8 @@ static bool is_fentry_call(struct instruction *insn) return false; } -static bool has_modified_stack_frame(struct insn_state *state) +static bool has_modified_stack_frame(struct insn_state *state, + bool check_registers) { int i; @@ -1442,6 +1489,9 @@ static bool has_modified_stack_frame(struct insn_state *state) state->drap) return true; + if (!check_registers) + return false; + for (i = 0; i < CFI_NUM_REGS; i++) if (state->regs[i].base != initial_func_cfi.regs[i].base || state->regs[i].offset != initial_func_cfi.regs[i].offset) alex.