From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Jinyang He <hejinyang@loongson.cn>
Cc: Huacai Chen <chenhuacai@kernel.org>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: relocatable: Provide kaslr_offset() to get the kernel offset
Date: Mon, 1 Feb 2021 13:50:28 +0100 [thread overview]
Message-ID: <20210201125028.GA8621@alpha.franken.de> (raw)
In-Reply-To: <1611720745-8256-1-git-send-email-hejinyang@loongson.cn>
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 <lkp@intel.com>
> Signed-off-by: Jinyang He <hejinyang@loongson.cn>
> ---
> 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:
<command-line>: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 ]
next prev parent reply other threads:[~2021-02-01 14:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 4:12 [PATCH] MIPS: relocatable: Provide kaslr_offset() to get the kernel offset Jinyang He
2021-02-01 12:50 ` Thomas Bogendoerfer [this message]
2021-02-02 5:55 ` Jinyang He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210201125028.GA8621@alpha.franken.de \
--to=tsbogend@alpha.franken.de \
--cc=chenhuacai@kernel.org \
--cc=hejinyang@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).