From patchwork Mon Mar 29 07:57:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 410798 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3421320jai; Mon, 29 Mar 2021 01:14:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxegWsJHfdLYQjVMwlaKewNVECa29epVVaBVV+rnip2GP4D3YtwAFiR3rSuGhbs4BZPbJcW X-Received: by 2002:a05:6402:1d1a:: with SMTP id dg26mr27033663edb.266.1617005645166; Mon, 29 Mar 2021 01:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617005645; cv=none; d=google.com; s=arc-20160816; b=KNYUstm9RtkFkh+K5JT5eSbssTcGvcfDvdL45k2QBI5LPMC7+MJehtkVO/+UOJ9xsG JTMCEv11WceIcqjexNJolMD9rOjJzjdrb1NyRpYe1fk6lvMJA1SPMcKArSM9RyFPvc0C el2x72Q8i1ldU5npX2Zs0FDtP8chhyGJ74IbB6kHyiq6EmG6Pe9/XHfmi3wbKgyp9lbw +V1/Z+l07TyqrHF61j58r+Cq6QvyuWwhaltEUCnfO2g2ApqXcntpU9vFzw+3zhn/J/Da zrXu85HNXIeSh+hCFms3L9TUfvlPnNvOUqGu7tL6Rd8OnVVPpaGYDnUzBEn5TlZ5Sbph 08Jg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ern/Ke2VOyhdplvj0BV8Gpd9rYvPwwfc//9Ds+0VWbI=; b=PmUqA7SN0FKw54DgW4vuz4SjKAcoB/6quScuShLJyTPdv7xORrbwcPcKZlQdUnMoVu fZYpsLMEgg0MgVYs38WeHXzWwu57afsfquTE0FUV2vXErlgtFxzuQaBYTPqJNowuP4TS hjU+qBZBUAe9SDMgg/YU0pQfrOWla14VbGBvGHt02V4kP+krsUaEnktIm8MM5jzCaEjN x/Ehlf4hG8NdYygsXCPlRMoQVuB+6PJXHTw8BB3pbFQae6uHF6TYhp8S+M1cv1051/Cl NpUy3R17kl3cuPVxBJXSH3Cckn8Jwdmtpro56DWeCANwxrtl4dPdIt9vH18OrYydOg7f wc+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="YiA4/0PM"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n24si12391682eds.571.2021.03.29.01.14.05; Mon, 29 Mar 2021 01:14:05 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b="YiA4/0PM"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232629AbhC2INk (ORCPT + 12 others); Mon, 29 Mar 2021 04:13:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:56226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233030AbhC2IMv (ORCPT ); Mon, 29 Mar 2021 04:12:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 67E6D61932; Mon, 29 Mar 2021 08:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005570; bh=TQSv2BXvLW+3o1IcqsLwhZpUcIGkmdd0YbR3yohtGzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YiA4/0PMtcqPm7aIlbJCgXZUnMkKzB2q/kveVQCmDL4ErIOjEft/aFSuUoqMFNq2s QskHCpfswbBMsblvWqI5/mA8GKKYXLX4ggLGXdoWKJpFtk6CrTrCo310qDQLZ+npFg LX68S+54SxKIN6OV453PJAuqjbbq2wgDDkdedJZo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Desaulniers , Prasad Sodagudi , Nathan Chancellor , Fangrui Song , Peter Oberparleiter , Andrew Morton , Linus Torvalds Subject: [PATCH 5.4 044/111] gcov: fix clang-11+ support Date: Mon, 29 Mar 2021 09:57:52 +0200 Message-Id: <20210329075616.640904517@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075615.186199980@linuxfoundation.org> References: <20210329075615.186199980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nick Desaulniers commit 60bcf728ee7c60ac2a1f9a0eaceb3a7b3954cd2b upstream. LLVM changed the expected function signatures for llvm_gcda_start_file() and llvm_gcda_emit_function() in the clang-11 release. Users of clang-11 or newer may have noticed their kernels failing to boot due to a panic when enabling CONFIG_GCOV_KERNEL=y +CONFIG_GCOV_PROFILE_ALL=y. Fix up the function signatures so calling these functions doesn't panic the kernel. Link: https://reviews.llvm.org/rGcdd683b516d147925212724b09ec6fb792a40041 Link: https://reviews.llvm.org/rG13a633b438b6500ecad9e4f936ebadf3411d0f44 Link: https://lkml.kernel.org/r/20210312224132.3413602-2-ndesaulniers@google.com Signed-off-by: Nick Desaulniers Reported-by: Prasad Sodagudi Suggested-by: Nathan Chancellor Reviewed-by: Fangrui Song Tested-by: Nathan Chancellor Acked-by: Peter Oberparleiter Reviewed-by: Nathan Chancellor Cc: [5.4+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/gcov/clang.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) --- a/kernel/gcov/clang.c +++ b/kernel/gcov/clang.c @@ -75,7 +75,9 @@ struct gcov_fn_info { u32 num_counters; u64 *counters; +#if CONFIG_CLANG_VERSION < 110000 const char *function_name; +#endif }; static struct gcov_info *current_info; @@ -105,6 +107,7 @@ void llvm_gcov_init(llvm_gcov_callback w } EXPORT_SYMBOL(llvm_gcov_init); +#if CONFIG_CLANG_VERSION < 110000 void llvm_gcda_start_file(const char *orig_filename, const char version[4], u32 checksum) { @@ -113,7 +116,17 @@ void llvm_gcda_start_file(const char *or current_info->checksum = checksum; } EXPORT_SYMBOL(llvm_gcda_start_file); +#else +void llvm_gcda_start_file(const char *orig_filename, u32 version, u32 checksum) +{ + current_info->filename = orig_filename; + current_info->version = version; + current_info->checksum = checksum; +} +EXPORT_SYMBOL(llvm_gcda_start_file); +#endif +#if CONFIG_CLANG_VERSION < 110000 void llvm_gcda_emit_function(u32 ident, const char *function_name, u32 func_checksum, u8 use_extra_checksum, u32 cfg_checksum) { @@ -133,6 +146,24 @@ void llvm_gcda_emit_function(u32 ident, list_add_tail(&info->head, ¤t_info->functions); } EXPORT_SYMBOL(llvm_gcda_emit_function); +#else +void llvm_gcda_emit_function(u32 ident, u32 func_checksum, + u8 use_extra_checksum, u32 cfg_checksum) +{ + struct gcov_fn_info *info = kzalloc(sizeof(*info), GFP_KERNEL); + + if (!info) + return; + + INIT_LIST_HEAD(&info->head); + info->ident = ident; + info->checksum = func_checksum; + info->use_extra_checksum = use_extra_checksum; + info->cfg_checksum = cfg_checksum; + list_add_tail(&info->head, ¤t_info->functions); +} +EXPORT_SYMBOL(llvm_gcda_emit_function); +#endif void llvm_gcda_emit_arcs(u32 num_counters, u64 *counters) { @@ -295,6 +326,7 @@ void gcov_info_add(struct gcov_info *dst } } +#if CONFIG_CLANG_VERSION < 110000 static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn) { size_t cv_size; /* counter values size */ @@ -322,6 +354,28 @@ err_name: kfree(fn_dup); return NULL; } +#else +static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn) +{ + size_t cv_size; /* counter values size */ + struct gcov_fn_info *fn_dup = kmemdup(fn, sizeof(*fn), + GFP_KERNEL); + if (!fn_dup) + return NULL; + INIT_LIST_HEAD(&fn_dup->head); + + cv_size = fn->num_counters * sizeof(fn->counters[0]); + fn_dup->counters = vmalloc(cv_size); + if (!fn_dup->counters) { + kfree(fn_dup); + return NULL; + } + + memcpy(fn_dup->counters, fn->counters, cv_size); + + return fn_dup; +} +#endif /** * gcov_info_dup - duplicate profiling data set @@ -362,6 +416,7 @@ err: * gcov_info_free - release memory for profiling data set duplicate * @info: profiling data set duplicate to free */ +#if CONFIG_CLANG_VERSION < 110000 void gcov_info_free(struct gcov_info *info) { struct gcov_fn_info *fn, *tmp; @@ -375,6 +430,20 @@ void gcov_info_free(struct gcov_info *in kfree(info->filename); kfree(info); } +#else +void gcov_info_free(struct gcov_info *info) +{ + struct gcov_fn_info *fn, *tmp; + + list_for_each_entry_safe(fn, tmp, &info->functions, head) { + vfree(fn->counters); + list_del(&fn->head); + kfree(fn); + } + kfree(info->filename); + kfree(info); +} +#endif #define ITER_STRIDE PAGE_SIZE