Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp457675rwb; Thu, 12 Jan 2023 23:15:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXvG9UT1FrgAPgvjPTl07sfVjo8OVJFbIk4NElQDOkqoOsehQk3K+NO49ZHguZJbdbWLQjFi X-Received: by 2002:a17:903:3245:b0:186:95c9:ddc9 with SMTP id ji5-20020a170903324500b0018695c9ddc9mr8942100plb.55.1673594132637; Thu, 12 Jan 2023 23:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673594132; cv=none; d=google.com; s=arc-20160816; b=XDyE8rdlJyUiII6ePYH4BKArvb5QEfst7agG3jDZAxVugTZQvTpTTFFhW9cRPNwUjz qrt8wnoUzu2FqoHGagJtZbsl2MRHAm1o6RbyN7JK+GqieczEBs05y12BC9a6kjwAwxY/ Pfn6/PVKhlC5+P6qxRGW3eKzuV4GhuFCPE9QHeoUNaMZCZpS1rBg5f9sFa5stS2WGpew nbQ5lxVKWEdwgSpo1INyXPe+u6EStFB+qfDvWvVcjGzXWY98zHVKwdUzdiy9IZsLV98G qg6zFza7uTRd4hnFc24wJSqRywQpns24qQD6GZRsuz0gcXvdsAJhlDMDXqGqfmiScALL 9JUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Yxchg1HVEbZY+x/trmdoFoEVno9y37bciOIuNC2Hyvs=; b=szPzlFeEMopVer9Z677ik8gBAjR/0JesrLk26pWjBXGxFxOiQGpfoZr1ixv17Fz/WW QHLV9h9E+WoMeWHJD229r1q2iE5R6pxYIAjBVd++ORQEoP6PjkmjQv12AVo74U5WKAX4 oHdDAL/yYx3AJzpeW17HRVMVtqHIv8z223aO8R1v6l4wTm5Ot10UNyIQyt8JpszHPrz3 wZbsAKZFGGtqszfgL+9/j4Sl4pTKqBYA7EmLtywl7oxgm0iK8PBUCLHtuuDXF/ZYuTvk p0jzLemLPN9UMz4qQDCGq3Q7tTL0iWpEYvEXQRpcbDqADLE5DRR6nWb78iK/ltsj5iML bYNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jTDt0Kdc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a170902d88200b00185466d72e8si18992339plz.320.2023.01.12.23.15.26; Thu, 12 Jan 2023 23:15:32 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jTDt0Kdc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241153AbjAMG76 (ORCPT + 50 others); Fri, 13 Jan 2023 01:59:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240935AbjAMG6z (ORCPT ); Fri, 13 Jan 2023 01:58:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D7DE6B581 for ; Thu, 12 Jan 2023 22:44:39 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6B60E6225F for ; Fri, 13 Jan 2023 06:44:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C53F7C433EF for ; Fri, 13 Jan 2023 06:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673592278; bh=2azx1ixtcOM7V1y+vOPKuldBI1b01fqShEWlRDQ+xnA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jTDt0Kdcnk3Aif1TSyqOp06Z3YBBicYBNBGZwu11VaPlsVIaPcygtlwT/8SS0sE1Y x8rshkUI0uTRhtqzLlHehKkCBCzdC/NzduC2+NJRg1ksoBBV4rU6YFzptjp++MKz1h Fj7ikf4KYnbKWaiuB5O1V11+DC9y1cGkK3FJZmByeZ4noyuysbvaLkj8Fs9BtJ6ojp cp3ViGDXP6uojnEdgfr8SdJuMmy5aWfp7+OUct8wERd/r2RwTzo3jNanXMYbmodnz6 XpQrXtmaVIaxOwvHcIYLiGVzGO1Rur1g3b0lRUbHCF5qLFj697x5tGzP3dattS7Euo LgPDtZYRWFaxg== Received: by mail-ej1-f48.google.com with SMTP id ud5so50117975ejc.4 for ; Thu, 12 Jan 2023 22:44:38 -0800 (PST) X-Gm-Message-State: AFqh2kpAtU37s60E7S+IBAvPXDP/BVx/uvwNBdS0lheJ4FopI9twV2q3 juqMR0HjYJ6b3PzQRBpuwcAQpGIBB58Mer/PmgE= X-Received: by 2002:a17:906:168d:b0:7c0:ff76:7866 with SMTP id s13-20020a170906168d00b007c0ff767866mr4895290ejd.272.1673592277047; Thu, 12 Jan 2023 22:44:37 -0800 (PST) MIME-Version: 1.0 References: <1673255274-18238-1-git-send-email-tangyouling@loongson.cn> In-Reply-To: <1673255274-18238-1-git-send-email-tangyouling@loongson.cn> From: Huacai Chen Date: Fri, 13 Jan 2023 14:44:25 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/4] LoongArch: Add kernel relocation and KASLR support To: Youling Tang Cc: Xi Ruoyao , Jinyang He , Xuerui Wang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Hi, Ruoyao and Jinyang, Could you please take some time to review this patchset? Huacai On Mon, Jan 9, 2023 at 5:08 PM Youling Tang wrote: > > This patch series to support kernel relocation and KASLR (only 64bit). > > Both old[1] and new[2] toolchains support this feature, and the test results > are as follows: > 1) Enable CONFING_RELOCATABLE > # cat /proc/iomem > 00000000-0fffffff : System RAM > 00000000-002c3fff : Reserved > 002c4000-008c3fff : Reserved > 02000000-02f4ffff : Kernel code > 02f50000-0381cbff : Kernel data > 0381cc00-0394ae37 : Kernel bss > > 2) Enable CONFING_RANDOMIZE_BASE (KASLR) > first: > # cat /proc/iomem > 00000000-0fffffff : System RAM > 00000000-002c3fff : Reserved > 002c4000-008c3fff : Reserved > 02550000-0349ffff : Kernel code > 034a0000-03d6cbff : Kernel data > 03d6cc00-03e9ae37 : Kernel bss > > second: > # cat /proc/iomem > 00000000-0fffffff : System RAM > 00000000-002c3fff : Reserved > 002c4000-008c3fff : Reserved > 02ad0000-03a1ffff : Kernel code > 03a20000-042ecbff : Kernel data > 042ecc00-0441ae37 : Kernel bss > > Thanks to @Ruoyao's and @Jinyang's for their help and suggestions. > > Links: > [1]: https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/5.0/loongarch64-clfs-5.1-cross-tools-c-only.tar.xz > [2]: https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/download/6.0/loongarch64-clfs-6.3-cross-tools-c-only.tar.xz > > Xi Ruoyao (1): > LoongArch: Use trampoline for exception handlers and kill la.abs > > Youling Tang (3): > LoongArch: Add JUMP_LINK_ADDR macro implementation to avoid using > la.abs > LoongArch: Add support for kernel relocation > LoongArch: Add support for kernel address space layout randomization > (KASLR) > > arch/loongarch/Kconfig | 37 +++++ > arch/loongarch/Makefile | 5 + > arch/loongarch/include/asm/page.h | 6 + > arch/loongarch/include/asm/stackframe.h | 16 +- > arch/loongarch/include/asm/uaccess.h | 1 - > arch/loongarch/kernel/Makefile | 2 + > arch/loongarch/kernel/entry.S | 6 +- > arch/loongarch/kernel/genex.S | 20 +-- > arch/loongarch/kernel/head.S | 30 +++- > arch/loongarch/kernel/relocate.c | 210 ++++++++++++++++++++++++ > arch/loongarch/kernel/setup.c | 3 + > arch/loongarch/kernel/traps.c | 4 +- > arch/loongarch/kernel/vmlinux.lds.S | 11 +- > arch/loongarch/mm/tlbex.S | 28 +--- > arch/loongarch/power/suspend_asm.S | 5 +- > 15 files changed, 333 insertions(+), 51 deletions(-) > create mode 100644 arch/loongarch/kernel/relocate.c > > -- > 2.37.1 >