Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2624247rwb; Fri, 16 Dec 2022 04:40:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf66y1Msb2jSVzk3dnHX4ogj4Ld/OCsEt3Z7uE83k6ur8ylnuX1EC9YVdWhY+HQogQUavS2T X-Received: by 2002:a17:906:d15a:b0:7c1:32:3574 with SMTP id br26-20020a170906d15a00b007c100323574mr27456130ejb.12.1671194411801; Fri, 16 Dec 2022 04:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671194411; cv=none; d=google.com; s=arc-20160816; b=SkzEX4EQT/3vBip4aIjBS1rgJDdo/5ByTBhltjx9+imkTi4kiwicRaghKxMQTAbf/M jIdoxtHtvLFhB4TnFAZCOrAtzGuVQqYjbKH7sHSo6UtxCLvuVgqECoFpGrYvd7+YHlF5 XbloJXEFVVh6UOnn9NewZyy2qdRWNSHx18lAtO2BPDaGzAr2nveSH4M89N5AQnBPsCY8 tgi3oKzJ8neC9L4py3aS9XqWLeZCRMQfLfPoI6jl16exUEV48IEC4ip8wovAUf8El+fC FouWUpBEjItkLMQ+94Z1HCb+S54pw9Jk8OKQiC4M0ArudFAWZ6XIeZtX0QBKKNFB8XLd hJlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=4E/3ai3KVhBzygt+7zqxWgpghmRAAFPb7fbPBx6NUno=; b=qphGtfXBLwnRikL5PmOm2OzZznakJlZuOsqjp1Zmhm1PVuhWkY3Y8NbsVlxAbTzm8o cZjMEcsDCuWnlkgo7V0qn7BZ5tSb5v5syort5FVI3uWM1RBxU0JbLHC9KPN6x7hZPU+w 8dCE8LzjtR1vwDqiSxL5M20qJlXTMW7GKa7WSYGsMe9GdjPdVkepOWAGfAzKxB/H3Dz0 znoN0XC9hcaPv4f6nvomCBBQPY/ZdYBDcpDTU0Xq3ZAIYKtfQrHy375KZbcMkFEhP55o mFKgoqTvBchgR83hdghkeGlIS2SKJk91rIKULF1vlerlXLi4/fnTzcWHK39nTOOGy1sY Kr8A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg31-20020a170907a41f00b007b7eb087819si2462162ejc.200.2022.12.16.04.39.55; Fri, 16 Dec 2022 04:40:11 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbiLPMCD (ORCPT + 68 others); Fri, 16 Dec 2022 07:02:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbiLPMBo (ORCPT ); Fri, 16 Dec 2022 07:01:44 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9751D3F045; Fri, 16 Dec 2022 04:01:42 -0800 (PST) Received: from dggpemm500006.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NYSJc28k9zqSxx; Fri, 16 Dec 2022 19:57:20 +0800 (CST) Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 16 Dec 2022 20:01:38 +0800 Subject: Re: [PATCH v9] kallsyms: Add self-test facility To: Geert Uytterhoeven CC: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , , , Masahiro Yamada , Alexei Starovoitov , Jiri Olsa , Kees Cook , Andrew Morton , Luis Chamberlain , , Steven Rostedt , Ingo Molnar , David Laight , linux-m68k , "Jason A. Donenfeld" References: <20221115083349.1662-1-thunder.leizhen@huawei.com> <49070ac3-02bb-a3b3-b929-ede07e3b2c95@huawei.com> <4aaede14-8bd3-6071-f17b-7efcb5f0de42@huawei.com> <66ec4021-b633-09ba-73ee-b24cdb3fa25a@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <06345dca-0afb-00a5-c9e9-5ba830d8ad05@huawei.com> Date: Fri, 16 Dec 2022 20:01:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 2022/12/16 19:28, Geert Uytterhoeven wrote: > Hi Zhen, > > On Fri, Dec 16, 2022 at 10:43 AM Leizhen (ThunderTown) > wrote: >> On 2022/12/16 15:42, Leizhen (ThunderTown) wrote: >>> On 2022/12/15 22:51, Geert Uytterhoeven wrote: >>>> On 30f3bb09778de64 with your debug patch v2: >>> I've set up the qemu environment, and I'll try to solve it by tomorrow at the latest. >> >> It seems that the problem is still strcmp(). After I commented strcmp() in >> arch/m68k/include/asm/string.h, and force it to use the one in lib/string.c, >> it works well. > > I can confirm that. > > One difference is that the one in lib/string.c always return -1/0/1, > while the m68k version can return other negative or positive numbers. > > However, adding: > > if (res < 0) return -1; > if (res > 0) return 1; > > to the m68k version doesn't make a difference. > > Renaming the m68k version (changed to -1/0/1) to m68k_strcmp(), and > the generic version to lib_strcmp(), and adding a wrapper that calls > and compares both, shows that both functions do return the same value, > and the test succeeds. > > Moving the m68k version inside lib/string.c makes the test pass, too. > So it must be related to the function being inline, and gcc making > (incorrect) assumptions... Yes, it's the compiler's fault. I just replied David Laight: I added 'volatile' to prevent compiler optimizations, and it's OK now. diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h index f759d944c449940..3db81e5a783c72a 100644 --- a/arch/m68k/include/asm/string.h +++ b/arch/m68k/include/asm/string.h @@ -42,9 +42,9 @@ static inline char *strncpy(char *dest, const char *src, size_t n) #define __HAVE_ARCH_STRCMP static inline int strcmp(const char *cs, const char *ct) { - char res; + signed char res; - asm ("\n" + asm volatile ("\n" "1: move.b (%0)+,%2\n" /* get *cs */ " cmp.b (%1)+,%2\n" /* compare a byte */ " jne 2f\n" /* not equal, break out */ > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds > > . > -- Regards, Zhen Lei