Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5586636pxv; Wed, 28 Jul 2021 14:28:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNJrx9tzzxpIZive9n49QIfGhPLKmdl/vzqWtbzOvrQt3pmqzeE9HyY6ngfUn18uSNeFYf X-Received: by 2002:a50:9503:: with SMTP id u3mr2128537eda.135.1627507690436; Wed, 28 Jul 2021 14:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627507690; cv=none; d=google.com; s=arc-20160816; b=abWY13JbTHCJWU+7EszGZNkcrHgzRuoGKtLoS9xsLfSNS2hPuO7we+tNYN/KrDyf5e shrGFXq+myUwWRtSRT1dTOgf7fhPgcoKtyr38uEl12yIrqX+b4XQbMKtKbnuKcObACiT qoiQ1iadEB6bNh9+fX1FW2PpSKsiBmUNryh4jr+TC4fFZEbO/3cu9Tht+VeLKbz0JXhj iyNu4c7+b5/AoXlnJxdlfJ0TEHAwLng+b8mZbw2qnkOylSOlpUUn2rRafwURmNiK9Q5h zE5LnS8Cf0BRKkygmwPyBXLBHdrUkGd39aM0rVznCo41GaJcQ8A3ipQ4uMm4OW8zfxan HsxA== 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=lTQA1G455S3S7/UbaTHLrx8l6pQJVqrPI4OUUJMUnv4=; b=GZF5NoAojaT6Rtv4D+x4xkYtLuVBl3fqPTtKIIeDkyQotjRniegedCM65MQYsXNBpH 9fl76aa3+v2EtEomgRcHtH7ki3REBHOyAhtfgTCcWIJcbqSu4pMJuL2iJJvFzCsDF0St 7POYVLm10c+bPuVeRYo0SGLh4aFitf+fwQ+TDxaMhMIDVOvxW0nuj/Z/mY+SJqXen7VP iGfCd9XTkAIgrriUGzkxHnznFW856OnRMJvJWAx8Od/WKNW8H94F3K8IsvLknNSXZe0T 9AQtgpBVRfGWIjw6+rck8UzIslP5YqgFWG3ZCp9y8lw4VBb6mJ7tdqzOt7xCnhPjmV9i uC/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=rd5ayHjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c5si15088edf.259.2021.07.28.14.27.47; Wed, 28 Jul 2021 14:28:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=rd5ayHjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231829AbhG1V0b (ORCPT + 99 others); Wed, 28 Jul 2021 17:26:31 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37888 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231519AbhG1V03 (ORCPT ); Wed, 28 Jul 2021 17:26:29 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16SK9ros114894; Wed, 28 Jul 2021 17:26:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=lTQA1G455S3S7/UbaTHLrx8l6pQJVqrPI4OUUJMUnv4=; b=rd5ayHjOGFqwZcsZyClFlshopwMw8YxWeevSGwlYLxIlfUAuzF6FFbErNMXvrBTtt0C8 TXRrk1jzyqj3wGgh6FRWm8ScNX8PtQGlBZhAwJzIhSRJiXWNrcrUbEtnKLFXw7Nt4/0i R5DQ9N0eKTBhl3Nvq8KN9jv4LaPL0+mQq501GsiHwkzbeC6dC/75RqKenhYNISqtUJNm KyQW0KDh11/gITkJC/l4NtigOTrDP8nmfIJ5DjuGmSqApE00iXEKTKvj79rEgd4qJgW/ 5w19fuUwabh4N393TX7IRiZ6y19Iv0vIZqBoQLnGpfEWIlP6H8ClPhiW+z4wi+vOxWR1 DA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3a3970t9nt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jul 2021 17:26:01 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 16SKGWmx149064; Wed, 28 Jul 2021 17:26:00 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3a3970t9n6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jul 2021 17:26:00 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16SJo5db010087; Wed, 28 Jul 2021 21:25:59 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3a235m1a3b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jul 2021 21:25:58 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16SLPt6Z24510868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jul 2021 21:25:55 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADF84AE057; Wed, 28 Jul 2021 21:25:55 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C22AAE045; Wed, 28 Jul 2021 21:25:55 +0000 (GMT) Received: from vm.lan (unknown [9.145.77.113]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 28 Jul 2021 21:25:55 +0000 (GMT) From: Ilya Leoshkevich To: Steven Rostedt , Ingo Molnar Cc: linux-kernel@vger.kernel.org, Heiko Carstens , Sven Schnelle , Vasily Gorbik , linux-s390@vger.kernel.org, Ilya Leoshkevich Subject: [PATCH 1/2] ftrace: Introduce ftrace_need_init_nop() Date: Wed, 28 Jul 2021 23:25:45 +0200 Message-Id: <20210728212546.128248-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728212546.128248-1-iii@linux.ibm.com> References: <20210728212546.128248-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4H6YnvIV8U5ZK8s8HaUBHT8TpYDmVQ0P X-Proofpoint-ORIG-GUID: l1xqRmQLSmwZLK6KInKr9z3mPlclVn6D X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-28_10:2021-07-27,2021-07-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 suspectscore=0 clxscore=1015 bulkscore=0 spamscore=0 malwarescore=0 adultscore=0 impostorscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107280113 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implementing live patching on s390 requires each function's prologue to contain a very special kind of nop, which gcc and clang don't generate. However, the current code assumes that if CC_USING_NOP_MCOUNT is defined, then whatever the compiler generates is good enough. Move the CC_USING_NOP_MCOUNT check into the new ftrace_need_init_nop() macro, that the architectures can override. An alternative solution is to disable using -mnop-mcount in the Makefile, however, this makes the build logic (even) more complicated and forces the arch-specific code to deal with the useless __fentry__ symbol. Signed-off-by: Ilya Leoshkevich --- include/linux/ftrace.h | 16 ++++++++++++++++ kernel/trace/ftrace.c | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index a69f363b61bf..f1ea8988a045 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -643,6 +643,22 @@ static inline int ftrace_disable_ftrace_graph_caller(void) { return 0; } extern int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr); +/** + * ftrace_need_init_nop - return whether nop call sites should be initialized + * + * Normally the compiler's -mnop-mcount generates suitable nops, so we don't + * need to call ftrace_init_nop() if the code is built with that flag. + * Architectures where this is not always the case may define their own + * condition. + * + * Return must be: + * 0 if ftrace_init_nop() should be called + * Nonzero if ftrace_init_nop() should not be called + */ + +#ifndef ftrace_need_init_nop +#define ftrace_need_init_nop() (!__is_defined(CC_USING_NOP_MCOUNT)) +#endif /** * ftrace_init_nop - initialize a nop call site diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 7b180f61e6d3..7efbc8aaf7f6 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -3100,6 +3100,7 @@ ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec) static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs) { + bool init_nop = ftrace_need_init_nop(); struct ftrace_page *pg; struct dyn_ftrace *p; u64 start, stop; @@ -3138,8 +3139,7 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs) * Do the initial record conversion from mcount jump * to the NOP instructions. */ - if (!__is_defined(CC_USING_NOP_MCOUNT) && - !ftrace_nop_initialize(mod, p)) + if (init_nop && !ftrace_nop_initialize(mod, p)) break; update_cnt++; -- 2.31.1