Message ID | 20230720163056.2564824-12-vschneid@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3263272vqt; Thu, 20 Jul 2023 10:10:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEKhPZPimt/PufzBJOGxEHx47YYis85nA5ojpUM+yMvzB2UqOR64k+DbjGm8Xif7YxRfIYB X-Received: by 2002:a05:6512:250f:b0:4fb:a0f1:f8b8 with SMTP id be15-20020a056512250f00b004fba0f1f8b8mr2109862lfb.63.1689873015287; Thu, 20 Jul 2023 10:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689873015; cv=none; d=google.com; s=arc-20160816; b=zgDQzfR8GnDb0RimuxdIThY5A1iljblRusf7SGblWV64tK+5LEwgx5nnmmnKWvlrgT sLZVIt4xyoW3j49otbdRau0zwPFZqaL3TFMpjT8BhE0XeM206GQl2FQajMZHJDE0P1e+ TqziBPdMGUDswUZM1Qcj1GXl/C+NV1DwFzDlntgXofmS5ajfeYlbeRPSB2+R8wqwYc4h cGh9bEYipF0P+UdtpzSy/A9phKsvEdDClZwVkzfz+NC/ofElpCCnWa/kqL7DHgjujgN7 OoLa/AX/NZ2Cus4UYM2STH/6R0yYNn5rVI9MWhRCA+QGe0qGg0VQ6ae0tuyG3i6mmC3J jHtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gxt5b+dw2J3MlRZgV6DoONRBYEDjEJLqkxMRP/UHfXc=; fh=PtaPM/evcxdC1AWAoNYkNA7d0RyqsevCG9x/XhoE/I4=; b=aNh3KALF0Mne2V7yN8IipNx0dxvf4pa23id9cOQlgQC0qlDUUbY16s1/d/CHGPCaP9 Aupq0mvO7mdJghmIZuAmIDmqvNrgSgAhqmxH6j6bqAm/rcB2/xop2lLz0OP71aaU3l/6 MNlNHs0qvTg+Ojv1ahTLlv0HSCfXkCZU5vA1qnXiq+1tD7yVVpqwjg92XHLHgPherTDY 8Is2I1fxL2zbZysepDOccS56EEiOZB4FKExNw5bwzfM/kEafAOTzBEnPVbxvFuGOj4kB vxXSZgdccvyxmqG6DsBIgP+zVRMPFw910njE10YgIUwerkS4849/DLHqtvx6RDRRrfPP APkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PjdDvoll; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020aa7cf82000000b0052026a148cesi1038816edx.44.2023.07.20.10.09.51; Thu, 20 Jul 2023 10:10:15 -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=PjdDvoll; 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 S229890AbjGTQfJ (ORCPT <rfc822;chrisben.tianve@gmail.com> + 99 others); Thu, 20 Jul 2023 12:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231794AbjGTQep (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 20 Jul 2023 12:34:45 -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 DC0E92D41 for <linux-kernel@vger.kernel.org>; Thu, 20 Jul 2023 09:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689870815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gxt5b+dw2J3MlRZgV6DoONRBYEDjEJLqkxMRP/UHfXc=; b=PjdDvollX/T2Ii4kkuzEzolBa4e1MRaE6LhHS576QWUkyRb7AF7Xyr6sX5Iqy6bHw0SkB+ HSORfS0HYkDX740iXXc3ZdZVfSa8dbXpvgUvI67KK3ZskX+zOVCImNKNZRKCPZV172lGfr c5fhW5zw3B797mZMAlrhN6w2773dwZI= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-637-bk8eKh1PMsKjdr3SYosUIQ-1; Thu, 20 Jul 2023 12:33:32 -0400 X-MC-Unique: bk8eKh1PMsKjdr3SYosUIQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 902321C05EAA; Thu, 20 Jul 2023 16:33:25 +0000 (UTC) Received: from vschneid.remote.csb (unknown [10.42.28.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6B9240C2070; Thu, 20 Jul 2023 16:33:18 +0000 (UTC) From: Valentin Schneider <vschneid@redhat.com> To: 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 Cc: Steven Rostedt <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org>, Jonathan Corbet <corbet@lwn.net>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com>, Paolo Bonzini <pbonzini@redhat.com>, Wanpeng Li <wanpengli@tencent.com>, Vitaly Kuznetsov <vkuznets@redhat.com>, Andy Lutomirski <luto@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Frederic Weisbecker <frederic@kernel.org>, "Paul E. McKenney" <paulmck@kernel.org>, Neeraj Upadhyay <quic_neeraju@quicinc.com>, Joel Fernandes <joel@joelfernandes.org>, Josh Triplett <josh@joshtriplett.org>, Boqun Feng <boqun.feng@gmail.com>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Lai Jiangshan <jiangshanlai@gmail.com>, Zqiang <qiang.zhang1211@gmail.com>, Andrew Morton <akpm@linux-foundation.org>, Uladzislau Rezki <urezki@gmail.com>, Christoph Hellwig <hch@infradead.org>, Lorenzo Stoakes <lstoakes@gmail.com>, Josh Poimboeuf <jpoimboe@kernel.org>, Jason Baron <jbaron@akamai.com>, Kees Cook <keescook@chromium.org>, Sami Tolvanen <samitolvanen@google.com>, Ard Biesheuvel <ardb@kernel.org>, Nicholas Piggin <npiggin@gmail.com>, Juerg Haefliger <juerg.haefliger@canonical.com>, Nicolas Saenz Julienne <nsaenz@kernel.org>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Nadav Amit <namit@vmware.com>, Dan Carpenter <error27@gmail.com>, Chuang Wang <nashuiliang@gmail.com>, Yang Jihong <yangjihong1@huawei.com>, Petr Mladek <pmladek@suse.com>, "Jason A. Donenfeld" <Jason@zx2c4.com>, Song Liu <song@kernel.org>, Julian Pidancet <julian.pidancet@oracle.com>, Tom Lendacky <thomas.lendacky@amd.com>, Dionna Glaze <dionnaglaze@google.com>, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= <linux@weissschuh.net>, Juri Lelli <juri.lelli@redhat.com>, Daniel Bristot de Oliveira <bristot@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>, Yair Podemsky <ypodemsk@redhat.com> Subject: [RFC PATCH v2 11/20] objtool: Flesh out warning related to pv_ops[] calls Date: Thu, 20 Jul 2023 17:30:47 +0100 Message-Id: <20230720163056.2564824-12-vschneid@redhat.com> In-Reply-To: <20230720163056.2564824-1-vschneid@redhat.com> References: <20230720163056.2564824-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771960286640739863 X-GMAIL-MSGID: 1771960286640739863 |
Series |
context_tracking,x86: Defer some IPIs until a user->kernel transition
|
|
Commit Message
Valentin Schneider
July 20, 2023, 4:30 p.m. UTC
I had to look into objtool itself to understand what this warning was
about; make it more explicit.
Signed-off-by: Valentin Schneider <vschneid@redhat.com>
---
tools/objtool/check.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Jul 20, 2023 at 05:30:47PM +0100, Valentin Schneider wrote: > I had to look into objtool itself to understand what this warning was > about; make it more explicit. > > Signed-off-by: Valentin Schneider <vschneid@redhat.com> > --- > tools/objtool/check.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/objtool/check.c b/tools/objtool/check.c > index 8936a05f0e5ac..d308330f2910e 100644 > --- a/tools/objtool/check.c > +++ b/tools/objtool/check.c > @@ -3360,7 +3360,7 @@ static bool pv_call_dest(struct objtool_file *file, struct instruction *insn) > > list_for_each_entry(target, &file->pv_ops[idx].targets, pv_target) { > if (!target->sec->noinstr) { > - WARN("pv_ops[%d]: %s", idx, target->name); > + WARN("pv_ops[%d]: indirect call to %s() leaves .noinstr.text section", idx, target->name); > file->pv_ops[idx].clean = false; This is an improvement, though I think it still results in two warnings, with the second not-so-useful warning happening in validate_call(). Ideally it would only show a single warning, I guess that would need a little bit of restructuring the code.
On 28/07/23 10:33, Josh Poimboeuf wrote: > On Thu, Jul 20, 2023 at 05:30:47PM +0100, Valentin Schneider wrote: >> I had to look into objtool itself to understand what this warning was >> about; make it more explicit. >> >> Signed-off-by: Valentin Schneider <vschneid@redhat.com> >> --- >> tools/objtool/check.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/tools/objtool/check.c b/tools/objtool/check.c >> index 8936a05f0e5ac..d308330f2910e 100644 >> --- a/tools/objtool/check.c >> +++ b/tools/objtool/check.c >> @@ -3360,7 +3360,7 @@ static bool pv_call_dest(struct objtool_file *file, struct instruction *insn) >> >> list_for_each_entry(target, &file->pv_ops[idx].targets, pv_target) { >> if (!target->sec->noinstr) { >> - WARN("pv_ops[%d]: %s", idx, target->name); >> + WARN("pv_ops[%d]: indirect call to %s() leaves .noinstr.text section", idx, target->name); >> file->pv_ops[idx].clean = false; > > This is an improvement, though I think it still results in two warnings, > with the second not-so-useful warning happening in validate_call(). > > Ideally it would only show a single warning, I guess that would need a > little bit of restructuring the code. You're quite right - fabricating an artificial warning with a call to __flush_tlb_local(): vmlinux.o: warning: objtool: pv_ops[1]: indirect call to native_flush_tlb_local() leaves .noinstr.text section vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: call to {dynamic}() leaves .noinstr.text section Interestingly the second one doesn't seem to have triggered the "pv_ops" bit of call_dest_name. Seems like any call to insn_reloc(NULL, x) will return NULL. Trickling down the file yields: vmlinux.o: warning: objtool: pv_ops[1]: indirect call to native_flush_tlb_local() leaves .noinstr.text section vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: call to pv_ops[0]() leaves .noinstr.text section In my case (!PARAVIRT_XXL) pv_ops should look like: [0]: .cpu.io_delay [1]: .mmu.flush_tlb_user() so pv_ops[1] looks right. Seems like pv_call_dest() gets it right because it uses arch_dest_reloc_offset(). If I use the above to fix up validate_call(), would we still need pv_call_dest() & co? > > -- > Josh
On Mon, Jul 31, 2023 at 12:16:59PM +0100, Valentin Schneider wrote: > You're quite right - fabricating an artificial warning with a call to __flush_tlb_local(): > > vmlinux.o: warning: objtool: pv_ops[1]: indirect call to native_flush_tlb_local() leaves .noinstr.text section > vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: call to {dynamic}() leaves .noinstr.text section > > Interestingly the second one doesn't seem to have triggered the "pv_ops" > bit of call_dest_name. Seems like any call to insn_reloc(NULL, x) will > return NULL. Yeah, that's weird. > Trickling down the file yields: > > vmlinux.o: warning: objtool: pv_ops[1]: indirect call to native_flush_tlb_local() leaves .noinstr.text section > vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: call to pv_ops[0]() leaves .noinstr.text section > > In my case (!PARAVIRT_XXL) pv_ops should look like: > [0]: .cpu.io_delay > [1]: .mmu.flush_tlb_user() > > so pv_ops[1] looks right. Seems like pv_call_dest() gets it right because > it uses arch_dest_reloc_offset(). > > If I use the above to fix up validate_call(), would we still need > pv_call_dest() & co? The functionality in pv_call_dest() is still needed because it goes through all the possible targets for the .mmu.flush_tlb_user() pointer -- xen_flush_tlb() and native_flush_tlb_local() -- and makes sure they're noinstr. Ideally it would only print a single warning for this case, something like: vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: indirect call to native_flush_tlb_local() leaves .noinstr.text section I left out "pv_ops[1]" because it's already long enough :-) It would need a little bit of code shuffling. But it's really a preexisting problem so don't feel compelled to fix it with this patch set.
On Mon, Jul 31, 2023 at 04:36:31PM -0500, Josh Poimboeuf wrote: > On Mon, Jul 31, 2023 at 12:16:59PM +0100, Valentin Schneider wrote: > > You're quite right - fabricating an artificial warning with a call to __flush_tlb_local(): > > > > vmlinux.o: warning: objtool: pv_ops[1]: indirect call to native_flush_tlb_local() leaves .noinstr.text section > > vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: call to {dynamic}() leaves .noinstr.text section > > > > Interestingly the second one doesn't seem to have triggered the "pv_ops" > > bit of call_dest_name. Seems like any call to insn_reloc(NULL, x) will > > return NULL. > > Yeah, that's weird. > > > Trickling down the file yields: > > > > vmlinux.o: warning: objtool: pv_ops[1]: indirect call to native_flush_tlb_local() leaves .noinstr.text section > > vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: call to pv_ops[0]() leaves .noinstr.text section > > > > In my case (!PARAVIRT_XXL) pv_ops should look like: > > [0]: .cpu.io_delay > > [1]: .mmu.flush_tlb_user() > > > > so pv_ops[1] looks right. Seems like pv_call_dest() gets it right because > > it uses arch_dest_reloc_offset(). > > > > If I use the above to fix up validate_call(), would we still need > > pv_call_dest() & co? > > The functionality in pv_call_dest() is still needed because it goes > through all the possible targets for the .mmu.flush_tlb_user() pointer > -- xen_flush_tlb() and native_flush_tlb_local() -- and makes sure > they're noinstr. > > Ideally it would only print a single warning for this case, something > like: > > vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: indirect call to native_flush_tlb_local() leaves .noinstr.text section But then what for the case where there are multiple implementations and more than one isn't noinstr? IIRC that is where these double prints came from. One is the callsite (always one) and the second is the offending implementation (but there could be more). > I left out "pv_ops[1]" because it's already long enough :-) The index number is useful when also looking at the assembler, which IIRC is an indexed indirect call.
On Mon, Jul 31, 2023 at 11:46:12PM +0200, Peter Zijlstra wrote: > > Ideally it would only print a single warning for this case, something > > like: > > > > vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: indirect call to native_flush_tlb_local() leaves .noinstr.text section > > But then what for the case where there are multiple implementations and > more than one isn't noinstr? The warning would be in the loop in pv_call_dest(), so it would potentially print multiple warnings, one for each potential dest. > IIRC that is where these double prints came from. One is the callsite > (always one) and the second is the offending implementation (but there > could be more). It's confusing to warn about the call site and the destination in two separate warnings. That's why I'm proposing combining them into a single warning (which still could end up as multiple warnings if there are multiple affected dests). > > I left out "pv_ops[1]" because it's already long enough :-) > > The index number is useful when also looking at the assembler, which > IIRC is an indexed indirect call. Ok, so something like so? vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: indirect call to pv_ops[1] (native_flush_tlb_local) leaves .noinstr.text section
On Tue, Aug 01, 2023 at 11:06:36AM -0500, Josh Poimboeuf wrote: > On Mon, Jul 31, 2023 at 11:46:12PM +0200, Peter Zijlstra wrote: > > > Ideally it would only print a single warning for this case, something > > > like: > > > > > > vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: indirect call to native_flush_tlb_local() leaves .noinstr.text section > > > > But then what for the case where there are multiple implementations and > > more than one isn't noinstr? > > The warning would be in the loop in pv_call_dest(), so it would > potentially print multiple warnings, one for each potential dest. > > > IIRC that is where these double prints came from. One is the callsite > > (always one) and the second is the offending implementation (but there > > could be more). > > It's confusing to warn about the call site and the destination in two > separate warnings. That's why I'm proposing combining them into a > single warning (which still could end up as multiple warnings if there > are multiple affected dests). > > > > I left out "pv_ops[1]" because it's already long enough :-) > > > > The index number is useful when also looking at the assembler, which > > IIRC is an indexed indirect call. > > Ok, so something like so? > > vmlinux.o: warning: objtool: __flush_tlb_all_noinstr+0x4: indirect call to pv_ops[1] (native_flush_tlb_local) leaves .noinstr.text section Sure, that all would work I suppose.
diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 8936a05f0e5ac..d308330f2910e 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -3360,7 +3360,7 @@ static bool pv_call_dest(struct objtool_file *file, struct instruction *insn) list_for_each_entry(target, &file->pv_ops[idx].targets, pv_target) { if (!target->sec->noinstr) { - WARN("pv_ops[%d]: %s", idx, target->name); + WARN("pv_ops[%d]: indirect call to %s() leaves .noinstr.text section", idx, target->name); file->pv_ops[idx].clean = false; } }