Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1599114pxb; Thu, 4 Feb 2021 18:08:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJze40Zvm76FnN5K/4oD4WA2BI+96GzZ2XhstGze+Ni8TqE06zf5sP5GQWjJ2shz8wNrrejt X-Received: by 2002:a17:906:7191:: with SMTP id h17mr1969629ejk.54.1612490889694; Thu, 04 Feb 2021 18:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612490889; cv=none; d=google.com; s=arc-20160816; b=q/HdtwssHvriE5ySnBKp1n3ABAiQV7qZoZziw4N7AiL3h8NYBrfw8bRAfHlKhSm7o/ l/qSnRuiinooHnxIQCSnmRZlKvOa82b3ijWoj3bomu9CjCHB3yKvf665jGhnie4n4tcn W1wXq6TtDlQl8tTCnORlnr0zjtf1hxcwJpnjfNbiI+ORrDbzI8L98fkn46FFGcWFatG/ clva9xYwbVxi/oB69V9BQmUWX+lJUT3sEdHkRL9vJdu8TfmYy8Y33Dm5IJooOwrCTkCO nH379erLpvsi3P8xqmxejePDPuK+iHv8l1h7ExTvr8bi3eQxY00d/HCHZvuPiqxBrX2t 1kLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=s/RqY58PHape80PZsA24QBdqQuOExmaoqZHnpdFwj0Q=; b=pVZISDFWcbIPsXTtBa7jhm7Yb792fZkiJ2eTRd7P811xd0FCP+9nLmZIisXpqdP90p M5Kv8LmjclY8815SE6DWDhrQpv/B9FImMI1pcjPM8R7TUsXQSq4A1Keq9SoKuwRGZD3t TXiJHV6TWk6iOmIFpm1m0LY/KlF0hLPXc6zQQeRaZjY0Iabxja5Tw4UgS/jQP7NHr60s hxsLpsWq8F/8JXXJYUi1xsE1RMtdBedD4hTsR1SqCrtYXdwCCL579H74pgh/AaMDRv5l f2hOUOHQcCo0R+hLPZrxV+XiPQa+G9e5cYUpmB3yOM8/hSLNuVNX+PbmLyDAundfcFzG ToCQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r18si5268941edi.216.2021.02.04.18.07.45; Thu, 04 Feb 2021 18:08:09 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbhBEBz7 (ORCPT + 99 others); Thu, 4 Feb 2021 20:55:59 -0500 Received: from mail.loongson.cn ([114.242.206.163]:35620 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229618AbhBEBzw (ORCPT ); Thu, 4 Feb 2021 20:55:52 -0500 Received: from [10.130.0.55] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxb_N1pRxgVQAFAA--.6185S3; Fri, 05 Feb 2021 09:55:02 +0800 (CST) Subject: Re: [PATCH v2 2/2] MIPS: relocatable: Use __kaslr_offset in show_kernel_relocation To: Thomas Bogendoerfer References: <1612348510-29569-1-git-send-email-hejinyang@loongson.cn> <1612348510-29569-2-git-send-email-hejinyang@loongson.cn> <20210204153623.GA14818@alpha.franken.de> Cc: Huacai Chen , Jiaxun Yang , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org From: Jinyang He Message-ID: Date: Fri, 5 Feb 2021 09:55:01 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20210204153623.GA14818@alpha.franken.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: AQAAf9Dxb_N1pRxgVQAFAA--.6185S3 X-Coremail-Antispam: 1UD129KBjvJXoW7try8Jry8uF4kWFy7Ar4DCFg_yoW8XF17pr srJ3WDtFsIgrWDGa9Fq34ku34UX3yqqrWfuFsFk3yrXasavF15Jayrur1rW3y2vFy09F4x ZF98XFW29w4vyaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvSb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjc xK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40E FcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr 0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxv r21lc2xSY4AK67AK6w4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2 IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v2 6r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2 IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43 ZEXa7IU59Z2DUUUUU== X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/04/2021 11:36 PM, Thomas Bogendoerfer wrote: > On Wed, Feb 03, 2021 at 06:35:10PM +0800, Jinyang He wrote: >> The type of the VMLINUX_LOAD_ADDRESS macro is the (unsigned long long) >> in 32bits kernel but (unsigned long) in the 64-bit kernel. Although there >> is no error here, avoid using it to calculate kaslr_offset. And here we >> may need is that the address of __kaslr_offset rather than (void *)offset. >> >> Signed-off-by: Jinyang He >> --- >> arch/mips/kernel/relocate.c | 8 ++------ >> 1 file changed, 2 insertions(+), 6 deletions(-) >> >> diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c >> index 95abb9c..52018a3 100644 >> --- a/arch/mips/kernel/relocate.c >> +++ b/arch/mips/kernel/relocate.c >> @@ -430,13 +430,9 @@ void *__init relocate_kernel(void) >> */ >> static void show_kernel_relocation(const char *level) >> { >> - unsigned long offset; >> - >> - offset = __pa_symbol(_text) - __pa_symbol(VMLINUX_LOAD_ADDRESS); >> - >> - if (IS_ENABLED(CONFIG_RELOCATABLE) && offset > 0) { >> + if (__kaslr_offset > 0) { >> printk(level); >> - pr_cont("Kernel relocated by 0x%pK\n", (void *)offset); >> + pr_cont("Kernel relocated by 0x%pK\n", &__kaslr_offset); > are you sure ? I would have expected (void *)__kaslr_offset here. > > Thomas. > It is my fault. I misunderstood the meaning of 'by' and '@' because of my poor English. Thank you for pointing out my fault. I'll send v3 later. Thanks, Jinyang