Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4309646rwb; Mon, 31 Jul 2023 05:09:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGyTRdH0wamomCcmZ1o8AMK6b7uzioyO6qymBTpUPiynrnE5P0LOZhFoalIyDVCCkxAzYwp X-Received: by 2002:ac2:5f43:0:b0:4fb:8680:138a with SMTP id 3-20020ac25f43000000b004fb8680138amr5190279lfz.22.1690805379195; Mon, 31 Jul 2023 05:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690805379; cv=none; d=google.com; s=arc-20160816; b=Iz/DZIGHoXGtI9V6LJP+KMxnVmx7h435JQJDbHJWGgMviLLUcbfUpXQeGLXYCM8usQ qjuAp5W0scjwOksBv5/KxGkPREMVaVJji2QYUfMldDibU/2oYM/25/5RSv0jQq25EUpt 6ETWnyMkEiC7zJXSF7TnsZQbbEI0Okl4UQt3+hlPcHwCneV0JFCYq74cDiY3tvFYl8Av jJaJKMs65XhJ/3oaxD3xtpdmhFRl55fNQ6JHsPm+SSRYbjVqGE1H2urRGT2m6aIzc2IE t/HHj6rRrNgQPBZt8aeOI22feTnwNOjWu+bSKgM0YuvxHSfq0eAQNs6FFfpaNa0EcJxq ZKtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=liRJKw+opNrXfUwr+Bq4QbRM7UJXeuw3tZj+4BJUEBU=; fh=Ca6MqPOYSayI4Sg4B/MZBPQOunlFSSul4YyzDiXd33k=; b=F9AkmZxaAktkcWzDc7latOFGVBtbRWNbwwTS+8QJyilSvrJ8iqja9PTC29Xfq5M/OG T+BhCaGvpHqLl7rALHUPu7hkPhmS7j4Pj144gChU/dEE+FGERPGMpH9g5fq3Ch24Ph4I sBFN9FW4ykAq5y9PSCKP8sexNmMZZoLF8XNUwFdELqsPRT09PojGEbRVNKbCr7/5R3EM sdE7uDPjlQQVXDJwVCCAMctx79eKPiY5eTX9Niyk1d6HNvpbpcoq1AGdE1qrFCVP8rug l0pPxu0Pdi3+yyC9SY2bDFCH/lehVm/PfkFJvkUPkDpe5Lp+C6AzX6FhpvfK7eGcjPI6 V/Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SHuY2zU4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z14-20020aa7cf8e000000b00522564d9e4esi6479697edx.486.2023.07.31.05.09.12; Mon, 31 Jul 2023 05:09: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=@redhat.com header.s=mimecast20190719 header.b=SHuY2zU4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbjGaLT7 (ORCPT + 99 others); Mon, 31 Jul 2023 07:19:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjGaLT6 (ORCPT ); Mon, 31 Jul 2023 07:19:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A4B8CD for ; Mon, 31 Jul 2023 04:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690802348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=liRJKw+opNrXfUwr+Bq4QbRM7UJXeuw3tZj+4BJUEBU=; b=SHuY2zU4BUpamVxGw/r7pnJuyKm8LyP1WTnrkDe+P30+qsHN8DQDvknKa59Aew3t9Sj7FU QWSk40s3e9SwlK82ygQLfy5Pzp/pheJpMfEdxEBay0/KjTy/q9U2KBb/bcC4oRPeQCrm8O M9hCORDcLWDs+iCWCziIEjizFe+MS1I= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-371-POE8_IQfOM-JGcfr6E5Ahw-1; Mon, 31 Jul 2023 07:19:07 -0400 X-MC-Unique: POE8_IQfOM-JGcfr6E5Ahw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-76843c4b0f3so350629485a.2 for ; Mon, 31 Jul 2023 04:19:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690802346; x=1691407146; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=liRJKw+opNrXfUwr+Bq4QbRM7UJXeuw3tZj+4BJUEBU=; b=GjMHbgm1Jbh5Vrb5b6UvkNpoosvfGTJfkZ0Ljpti7Txkzn3k+A6jpXzsXTPafDlT02 lnFYMI93AipVvEt9UjRCcacZ3ROA4GmFmO8uvL8ALkn4yAYT7WmQjVbpPjlHFR0IkWtB tb6TYiLQsa4rFihPgem46YfgDRUwrfYKg08A1gUK+bhAsxmx+/pX6OF7yAOkUSzFFmrP WukeT3FT6t/nYG3tvzJFcsvQQb18ipQhOTaFmf9oqLlIXNCTSl3kNSYX1C4XLlZySXSw orsDjvCZDLUSuCCZ2KNLjxfyAZoYop/CcRT1szn0IgFTVIZwt1uvA2S2XnZQJp3mqkRI xVCg== X-Gm-Message-State: ABy/qLZ1KyCcOErVk+H5z1nzjrd2D/dOUZvDXax/KX0wwSSxjYmvIBvk tXa3HXC6t/lqTvuIx7AKatIRT5YIyoeRYYObQT5Icg7Nb9qeHJXosdAUbAeVg+J3TDXPn8KGopi zVaxexpCl10l2HLJ+52hYO8w9 X-Received: by 2002:a05:620a:4083:b0:766:68cd:d9dc with SMTP id f3-20020a05620a408300b0076668cdd9dcmr8634434qko.19.1690802346551; Mon, 31 Jul 2023 04:19:06 -0700 (PDT) X-Received: by 2002:a05:620a:4083:b0:766:68cd:d9dc with SMTP id f3-20020a05620a408300b0076668cdd9dcmr8634382qko.19.1690802346102; Mon, 31 Jul 2023 04:19:06 -0700 (PDT) Received: from vschneid.remote.csb ([149.12.7.81]) by smtp.gmail.com with ESMTPSA id f7-20020a05620a15a700b007682634ac20sm3177128qkk.115.2023.07.31.04.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 04:19:05 -0700 (PDT) From: Valentin Schneider To: Josh Poimboeuf Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org, x86@kernel.org, rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, Josh Poimboeuf , Steven Rostedt , Masami Hiramatsu , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Andy Lutomirski , Peter Zijlstra , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Jason Baron , Kees Cook , Sami Tolvanen , Ard Biesheuvel , Nicholas Piggin , Juerg Haefliger , Nicolas Saenz Julienne , "Kirill A. Shutemov" , Nadav Amit , Dan Carpenter , Chuang Wang , Yang Jihong , Petr Mladek , "Jason A. Donenfeld" , Song Liu , Julian Pidancet , Tom Lendacky , Dionna Glaze , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: Re: [RFC PATCH v2 12/20] objtool: Warn about non __ro_after_init static key usage in .noinstr In-Reply-To: <20230728153557.frzmaayyy3auibx3@treble> References: <20230720163056.2564824-1-vschneid@redhat.com> <20230720163056.2564824-13-vschneid@redhat.com> <20230728153557.frzmaayyy3auibx3@treble> Date: Mon, 31 Jul 2023 12:18:40 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 28/07/23 10:35, Josh Poimboeuf wrote: > On Thu, Jul 20, 2023 at 05:30:48PM +0100, Valentin Schneider wrote: >> +static int validate_static_key(struct instruction *insn, struct insn_state *state) >> +{ >> + if (state->noinstr && state->instr <= 0) { >> + if ((strcmp(insn->key_sym->sec->name, ".data..ro_after_init"))) { >> + WARN_INSN(insn, >> + "Non __ro_after_init static key \"%s\" in .noinstr section", > > For consistency with other warnings, this should start with a lowercase > "n" and the string literal should be on the same line as the WARN_INSN, > like > > WARN_INSN(insn, "non __ro_after_init static key \"%s\" in .noinstr section", > ... > >> diff --git a/tools/objtool/special.c b/tools/objtool/special.c >> index 91b1950f5bd8a..1f76cfd815bf3 100644 >> --- a/tools/objtool/special.c >> +++ b/tools/objtool/special.c >> @@ -127,6 +127,9 @@ static int get_alt_entry(struct elf *elf, const struct special_entry *entry, >> return -1; >> } >> alt->key_addend = reloc_addend(key_reloc); >> + >> + reloc_to_sec_off(key_reloc, &sec, &offset); >> + alt->key_sym = find_symbol_by_offset(sec, offset & ~2); > > Bits 0 and 1 can both store data, should be ~3? > Quite so, that needs to be the same as jump_entry_key(). > -- > Josh