From patchwork Mon Apr 12 08:38:54 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: 419516 Delivered-To: patch@linaro.org Received: by 2002:a02:c4d2:0:0:0:0:0 with SMTP id h18csp1563018jaj; Mon, 12 Apr 2021 02:03:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTpu/cPYwriA1i2dTUho3AsMZF1wLkla4qMsYVhP+dFSxyaKW/yXek+D6wIn2j+y6slEk+ X-Received: by 2002:a17:90a:c281:: with SMTP id f1mr19555692pjt.58.1618218184240; Mon, 12 Apr 2021 02:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618218184; cv=none; d=google.com; s=arc-20160816; b=XMKeREAXf4U6Z7ynNw3+OlYccSrsv0Icw18ub1H8x3nctwm0yKO4SRSpYFO5Qvhes1 01ShFgkMh/NmszcyGpNuMvwGb6ozDoM9D/p41TUJF3fLhOXe1MyFH1FdjC5Bmcumuy+I +lR08xRamB1Fzckb1Dw3S4J7y5axJoXwGOjkiGyGRFYNui+p3Cxkypz5oRJDjQ7pMyIg ql+zIOk8JhZU2mSZ4lO7F7Z4pEV3dMC+pFl1GgIJ2rD2tkmgkVPJ9jx/GXGb0zRx6Nmu +B3gahKs5MAUwB51SvasPW/yLCvXuS337WmsQbLXYvubseLqf7900KGnekipBrOd+niN v+Tw== 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=+0QiRoj3fUSNJh0WGs7h6WbiBP6sFh0lb1XbICR1IiM=; b=dexbOBeG7sf5yISIlLuk8kaHIEziIwO1VI6/+H8HpqJhvm9r3ozvA55lz6Kx3RMdRB llHNxdW61NHwXqN6rPv+EKIM3nVQFGQAxAC1M9ADpOt9p6JjhvVjTLhJQDWliqAon3Yf sOo7+sqcXqHrB9jMz5C0kz6BTy159LMtBLweBZlJd2utZ+Ll7M52JzOQA9bZVT/nKvUf sXtHz1i1uGYfNxc5aHvJvi8i14mi+ds3T/zgpPMO7Aei3GrVIMzvCjSgANO4F8F1po3Q jTuCSTwpsyKK38dBed3trPMNO8OPl4ll3tOHciXY1NdQN/tt7fPkyTDPqGygU2X0DJ+F emyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DdxjbnKF; 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 t22si13189113plr.237.2021.04.12.02.03.03; Mon, 12 Apr 2021 02:03:04 -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=DdxjbnKF; 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 S237448AbhDLJDT (ORCPT + 12 others); Mon, 12 Apr 2021 05:03:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:54864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239870AbhDLJB3 (ORCPT ); Mon, 12 Apr 2021 05:01:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ADB3E6125F; Mon, 12 Apr 2021 08:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217984; bh=kO2E0vSvri/q/aGGjNFCKIdR/saloXrxctn9XBnpA9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DdxjbnKFnwWqmtfzhe98rrDN3ubGW9HnYlPIAESbhmWabjsReDBfcvAG7FBBWDjy2 i2tZhD273dw/7XVlI6+dZXuoGsTHMAAuIrL98sHLMKc28kNOiBvyj+zU8NsL60711G LvLbZQHI2rctCqDbnlAfjqPsH2sUTj3Oth7LJrb4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Prasad Sodagudi , Nick Desaulniers , Nathan Chancellor , Andrew Morton , Linus Torvalds Subject: [PATCH 5.11 029/210] gcov: re-fix clang-11+ support Date: Mon, 12 Apr 2021 10:38:54 +0200 Message-Id: <20210412084016.976892511@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084016.009884719@linuxfoundation.org> References: <20210412084016.009884719@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 9562fd132985ea9185388a112e50f2a51557827d upstream. LLVM changed the expected function signature for llvm_gcda_emit_function() in the clang-11 release. Users of clang-11 or newer may have noticed their kernels producing invalid coverage information: $ llvm-cov gcov -a -c -u -f -b .gcda -- gcno=.gcno 1 : checksum mismatch, \ (, ) != (, ) 2 Invalid .gcda File! ... Fix up the function signatures so calling this function interprets its parameters correctly and computes the correct cfg checksum. In particular, in clang-11, the additional checksum is no longer optional. Link: https://reviews.llvm.org/rG25544ce2df0daa4304c07e64b9c8b0f7df60c11d Link: https://lkml.kernel.org/r/20210408184631.1156669-1-ndesaulniers@google.com Reported-by: Prasad Sodagudi Tested-by: Prasad Sodagudi Signed-off-by: Nick Desaulniers Reviewed-by: Nathan Chancellor Cc: [5.4+] Signed-off-by: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/gcov/clang.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) --- a/kernel/gcov/clang.c +++ b/kernel/gcov/clang.c @@ -70,7 +70,9 @@ struct gcov_fn_info { u32 ident; u32 checksum; +#if CONFIG_CLANG_VERSION < 110000 u8 use_extra_checksum; +#endif u32 cfg_checksum; u32 num_counters; @@ -145,10 +147,8 @@ 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) +void llvm_gcda_emit_function(u32 ident, u32 func_checksum, u32 cfg_checksum) { struct gcov_fn_info *info = kzalloc(sizeof(*info), GFP_KERNEL); @@ -158,12 +158,11 @@ void llvm_gcda_emit_function(u32 ident, 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 +EXPORT_SYMBOL(llvm_gcda_emit_function); void llvm_gcda_emit_arcs(u32 num_counters, u64 *counters) { @@ -293,11 +292,16 @@ int gcov_info_is_compatible(struct gcov_ !list_is_last(&fn_ptr2->head, &info2->functions)) { if (fn_ptr1->checksum != fn_ptr2->checksum) return false; +#if CONFIG_CLANG_VERSION < 110000 if (fn_ptr1->use_extra_checksum != fn_ptr2->use_extra_checksum) return false; if (fn_ptr1->use_extra_checksum && fn_ptr1->cfg_checksum != fn_ptr2->cfg_checksum) return false; +#else + if (fn_ptr1->cfg_checksum != fn_ptr2->cfg_checksum) + return false; +#endif fn_ptr1 = list_next_entry(fn_ptr1, head); fn_ptr2 = list_next_entry(fn_ptr2, head); } @@ -529,17 +533,22 @@ static size_t convert_to_gcda(char *buff list_for_each_entry(fi_ptr, &info->functions, head) { u32 i; - u32 len = 2; - - if (fi_ptr->use_extra_checksum) - len++; pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION); - pos += store_gcov_u32(buffer, pos, len); +#if CONFIG_CLANG_VERSION < 110000 + pos += store_gcov_u32(buffer, pos, + fi_ptr->use_extra_checksum ? 3 : 2); +#else + pos += store_gcov_u32(buffer, pos, 3); +#endif pos += store_gcov_u32(buffer, pos, fi_ptr->ident); pos += store_gcov_u32(buffer, pos, fi_ptr->checksum); +#if CONFIG_CLANG_VERSION < 110000 if (fi_ptr->use_extra_checksum) pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); +#else + pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum); +#endif pos += store_gcov_u32(buffer, pos, GCOV_TAG_COUNTER_BASE); pos += store_gcov_u32(buffer, pos, fi_ptr->num_counters * 2);