Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4773181rwb; Tue, 20 Sep 2022 20:44:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7s+uOxtaDr/6fy7NgxOIPObb8cWiGcwhdWHHp4zYTvmrHClkS3gfoz9fHzy0ILJL3W22Rb X-Received: by 2002:a17:906:6a07:b0:77d:f99c:5ab8 with SMTP id qw7-20020a1709066a0700b0077df99c5ab8mr19444714ejc.544.1663731871372; Tue, 20 Sep 2022 20:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663731871; cv=none; d=google.com; s=arc-20160816; b=K5sDBocFOwoAFnGO2vUFLuuCCi4OxQF8Cq2Nbd05dIvUCzhZbBMBKSRn/cjIwWpQiC 4NCnIRcyVMOYJQdIijpf0CE5vG+MXCN9oydhRfNXFYU4ipHbWxrnsVaNX/clzsvm1a0C JSLDb6pFbMMJcg15XYFYl2ORjZevhysQpuS5E8cR8CUj3ysBlOnTII1JjEFB4s4Tteoc Knx1g+CYH44q1wZSPlneH8F5lILlvtrLgySmABG+LvuBV38auMKjoxNAROXTxdpggfx3 AhF1SlIsg/MmWvNc0LhnC0++ZNsiOl+eixGQ+R2drD9DbTipNpuinmj9vW09rdQybtaZ CZOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=IGThWZixCebY2IezkYP4mg+Be5CLC47owq/x+lsXDM4=; b=kan/DE67v+7TVboTiRM1BOetzNM0crfMLFaXxGWoNiAxyAw5JRH5/eoR71MdSjsMuG YoXcMMDpG0GkjKw81IcjPOAE/TePMHH4Q+ovtxY9O/Odmn7gzhZagAasfdLg/RkdGgk8 bfbhdqBLBpOVvdRz1Dg4g9LBcIaPhxPxY59tXL9V5K7YULWsV0A7MBqT3+UdZS8aaapu pUhz5AGF214uFol5LqPvWRQrjJ2Mn8an26DasVp38ftQRfcP0/rv02YjCU1r82oG4Ssi SE5bhsjRITnDrJ/sYeoBcpp+LTPsksFl+pPpUUfhnbdZtor2x9CAPmZJ6LgfDPiWlhT5 yIrQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a17090652cc00b00774d0f10566si964532ejn.821.2022.09.20.20.44.05; Tue, 20 Sep 2022 20:44:31 -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; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231316AbiIUDQl (ORCPT + 99 others); Tue, 20 Sep 2022 23:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231238AbiIUDQV (ORCPT ); Tue, 20 Sep 2022 23:16:21 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 084F36F253; Tue, 20 Sep 2022 20:16:09 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MXNk65L9gzlWhP; Wed, 21 Sep 2022 11:11:58 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 21 Sep 2022 11:16:05 +0800 Received: from [10.67.108.67] (10.67.108.67) by dggpemm500013.china.huawei.com (7.185.36.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 21 Sep 2022 11:16:05 +0800 Message-ID: Date: Wed, 21 Sep 2022 11:16:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0 Subject: Re: [RFC] Objtool toolchain proposal: -fannotate-{jump-table,noreturn} Content-Language: en-US To: Ard Biesheuvel , Peter Zijlstra CC: Michael Matz , Borislav Petkov , "Josh Poimboeuf" , , "Indu Bhagat" , Nick Desaulniers , , "Jose E. Marchesi" , Miroslav Benes , Mark Rutland , "Will Deacon" , , , , , Sathvika Vasireddy , Christophe Leroy , Mark Brown References: <20220909180704.jwwed4zhwvin7uyi@treble> <6a61aa57-141f-039c-5a2d-b2d79fecb8c2@huawei.com> From: Chen Zhongjin In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.108.67] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Hi, On 2022/9/21 0:49, Ard Biesheuvel wrote: > On Thu, 15 Sept 2022 at 10:47, Peter Zijlstra wrote: >> On Thu, Sep 15, 2022 at 10:56:58AM +0800, Chen Zhongjin wrote: >> >>> We have found some anonymous information on x86 in .rodata. >> Well yes, but that's still a bunch of heuristics on our side. >> >>> I'm not sure if those are *all* of Josh wanted on x86, however for arm64 we >>> did not found that in the same section so it is a problem on arm64 now. >> Nick found Bolt managed the ARM64 jumptables: >> >> https://github.com/llvm/llvm-project/blob/main/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp#L484 >> >> But that does look like a less than ideal solution too. >> >>> Does the compiler will emit these for all arches? At lease I tried and >>> didn't find anything meaningful (maybe I omitted it). >> That's the question; can we get the compiler to help us here in a well >> defined manner. > Do BTI landing pads help at all here? I.e., I assume that objtool just > treats any indirect call as a dangling edge in the control flow graph, > and the problem is identifying the valid targets. In the BTI case, > those will all start with a 'BTI J' instruction. Maybe not enough, I guess. For switch jump tables we need to know its *own* jump targets so that we can go through all its branches. If there are more than one indirect jump inside one function, only marks targets with BTI J can't help matching the entry and its targets. Anyway I think this job is more for compiler. Switch jump tables is different from other indirect jump/call. It have fixed control flow just as if/else flow and the indirect jump table is just a compiler optimization which hide this. Best, Chen