Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3834845pxb; Mon, 1 Feb 2021 06:04:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyRQKpzitWZGEzF+A14VAVF5/VAMbb8Umwq/mw165DbexThbHPsC0tSEnn5kIY9LXha8rr X-Received: by 2002:aa7:c755:: with SMTP id c21mr6164231eds.47.1612188268962; Mon, 01 Feb 2021 06:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612188268; cv=none; d=google.com; s=arc-20160816; b=GwhMgVtjxLPsJI2GmMdZTkDLRgcQDPEoE5UCPFvNIcGSb8H/a3qlS5G+UJsoYWccdD PTEoXHzAs6ruGUZIiiUj/O4pNT72xNqt0CpvysYKriQPHKWrXMqJL8tCfz9SJBht38cX 4IuwFPYSPEnbmLWl98dqSma7/3cciSraBoNdr18xD6zipFEJ0fJoupPsXsUQNdjoyEBN ogCtcPaBX4vn7oljkVAvxstTsEQyrM4zz7rDlnPaotg6HWkDST0pElEhxUwgPsnLEDxO +J7OtF//VmEFOUKUc8E0HLtIRWVwTq1sfb5yLVEGWE6wGjeH5uvy/7uvRARxtu20kwrX V2TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8oLuN+GX4azkKAlXLJ+58FhTGJyif/lcMUsf9CIWFwU=; b=Tb+SQ6jTTIFnw0c512/LsYokb2yj8IKzGe+HKmo8acWt0ViXybm4Dpq0eaYWzDKenL MIUEwCxktPlnzunWyIo/oeZNWvut5uSe+c9IjDRvhP3Kugl6ONxQ8HKyzss/twmCsac1 s2OzyIb5y7cuJUjDPpr6SgXIbR5027JBelyk4E8+r5HA/u7tP9whPg80iFS0Vn+WAlAI OE1ETNVKlBywaO0IWD/LuPaINC8esc8gPBoYlGu/KCsZl1S8dzvgzO4AmKdFQDkria0G hkgOD4Tp4dzQ5RY3Zwo8+uq4d25PKiKyxu5ZYORJghCGrnyGXNlIpJWZ3/4umpSDUYhG ZLIg== 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 w12si10901540edf.27.2021.02.01.06.03.36; Mon, 01 Feb 2021 06:04:28 -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 S231405AbhBAN7o (ORCPT + 99 others); Mon, 1 Feb 2021 08:59:44 -0500 Received: from elvis.franken.de ([193.175.24.41]:43717 "EHLO elvis.franken.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232031AbhBAN7i (ORCPT ); Mon, 1 Feb 2021 08:59:38 -0500 Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1l6ZjC-0001Qe-00; Mon, 01 Feb 2021 14:58:54 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id 57C92C0D38; Mon, 1 Feb 2021 13:50:28 +0100 (CET) Date: Mon, 1 Feb 2021 13:50:28 +0100 From: Thomas Bogendoerfer To: Jinyang He Cc: Huacai Chen , Jiaxun Yang , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] MIPS: relocatable: Provide kaslr_offset() to get the kernel offset Message-ID: <20210201125028.GA8621@alpha.franken.de> References: <1611720745-8256-1-git-send-email-hejinyang@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1611720745-8256-1-git-send-email-hejinyang@loongson.cn> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 12:12:25PM +0800, Jinyang He wrote: > Use kimage_vaddr to indicate kernel start address. Provide kaslr_offset() > to get the kernel offset when KASLR is enabled. Error may occur before > update_kimage_vaddr(), so put it at the end of the offset branch. > > Fixes: a307a4ce9ecd ("MIPS: Loongson64: Add KASLR support") > Reported-by: kernel test robot > Signed-off-by: Jinyang He > --- > arch/mips/include/asm/page.h | 6 ++++++ > arch/mips/kernel/relocate.c | 12 ++++++++++++ > arch/mips/kernel/setup.c | 3 +++ > 3 files changed, 21 insertions(+) > > diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h > index 6a77bc4..9429520 100644 > --- a/arch/mips/include/asm/page.h > +++ b/arch/mips/include/asm/page.h > @@ -255,6 +255,12 @@ extern bool __virt_addr_valid(const volatile void *kaddr); > > #define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_TSK_EXEC > > +extern unsigned long kimage_vaddr; > +static inline unsigned long kaslr_offset(void) > +{ > + return kimage_vaddr - VMLINUX_LOAD_ADDRESS; > +} this breaks for 32bit kernels: :0:22: error: large integer implicitly truncated to unsigned type [-Werror=overflow] /local/tbogendoerfer/korg/linux/arch/mips/kernel/setup.c:87:41: note: in expansion of macro ‘VMLINUX_LOAD_ADDRESS’ unsigned long kimage_vaddr __initdata = VMLINUX_LOAD_ADDRESS; ^~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]