From patchwork Wed Feb 22 10:43:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandre Ghiti X-Patchwork-Id: 13149020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36B97C6379F for ; Wed, 22 Feb 2023 10:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Os2Qd0Tfm+pRYRiexSnXAtV6GWddqush4tRp1gsdUc0=; b=XQogQAMFcCf+yY Ygd0GY/J7R1ctYuntl6ECjC8R5929JuV2WSFJ+j1ZUz7/zGaxbTf3zm6sI8a593TJ2tDNKVIb3Lko B7Lu4Q6/WjtbTJ0IIGMUmMEj2XvO2cMQyV3ONj872NIKtlGwp73HP1O5TS9Ntx/bnkbe/Oq/tYvM5 xLD7exRg/jZ8zk9V7lpyewFCkg1C2uIcsW2PPb3HmQeU1oROCVRwY406CyZAnj/1u94pMLcvimRiO eXGmMKwkkSiire7Z+tZOxI5xe9Xae3OhpV+mcOb6drcAm4qm8iY23MNq9qVGf4j/jrtbGiFiYytTM vwABaBHJ4n7k7+EjVMnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pUmaz-00C2KC-TL; Wed, 22 Feb 2023 10:43:33 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pUmau-00C2Hh-O4 for linux-riscv@lists.infradead.org; Wed, 22 Feb 2023 10:43:30 +0000 Received: by mail-wr1-x430.google.com with SMTP id c12so7253264wrw.1 for ; Wed, 22 Feb 2023 02:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UhT58sinHFct4qgunNLg5u/XIFyEJ64KsH0nJ4Jq3VI=; b=E3mhp2S/pYriP6lLsQo4TfjWLohTGpgIU2xyChC0o8I7Tvs9Rzs1Z2ECShnsif5isZ p8yChvV92xDtZrlY6vOpN1bUKw2fg4krL8iebjbD5mSa97vZcPEDq/Gy+M1o9i+88SEl qAvCVJb9D0ey+keKZvwPX3JohXCzLuP34j9S1EyaVYHw8BlfgaA9yIyBF0V/HtrkVxvV VDqzl34G0c5PRTA9qkXd4fhFKeyM7i+ApRiewpCnFSQsabhnbuw9N8O+u6+VxYZowzM3 J+t+KVVw1GQKpgWT0E/fmfCu3dxn0qqjjYTHIO3WE5+b3P+Z9xxkKJjOJhMHEj71F8WW QOiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UhT58sinHFct4qgunNLg5u/XIFyEJ64KsH0nJ4Jq3VI=; b=50qA0nTwh/9RW4MQBxbyrmjsJD8zVk6K5bMFXe+q9aVihRKusdIJxGdMUHVMAm5VNX J5qqDdJjq/d/ZREAquVrpspjpZF0qie08ruVd3QaqureKGnsOq32/lAptAnIfLA+s9bc D9R3eXB5lA9a/RoEZcBssDlhvjzgnt+WkbJYxp2Sf9WeIZKnP4QbOomG6zD7rLj+JqAZ bFfNWnK/CLANT7h6FIGtgv3MP8OmOW4EAlgrfsdfOvzghG0fDOXWGgP1+090cqMfhbiF Vdd6MnoxIsxSgKTPGe8S0J7Mh6kcQ599rb7+83KwOyLGLfEpGvbvFpJs/YLH2EufacRB XDXg== X-Gm-Message-State: AO0yUKUdVPpLd6bk4hBUd99i2TuCE/hM2U4j2uyLJ5YnNDVXOennVyqI +OhphBL5jwwQ6N6+Ons2aNH0ZA== X-Google-Smtp-Source: AK7set97crFvqEY9KymyVgzh9ZbKxig7GJ92PiQcr3HEodbwNfUwX5oCC7Jv573SDTcXPhgm66t+IQ== X-Received: by 2002:adf:ea88:0:b0:2c5:5a65:79a0 with SMTP id s8-20020adfea88000000b002c55a6579a0mr4953341wrm.53.1677062606035; Wed, 22 Feb 2023 02:43:26 -0800 (PST) Received: from alex-rivos.ba.rivosinc.com (lfbn-gre-1-235-32.w90-112.abo.wanadoo.fr. [90.112.194.32]) by smtp.gmail.com with ESMTPSA id u9-20020a5d5149000000b002c550eb062fsm5798294wrt.14.2023.02.22.02.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 02:43:25 -0800 (PST) From: Alexandre Ghiti To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Ard Biesheuvel , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Alexandre Ghiti Subject: [PATCH v5 0/1] riscv: Allow to downgrade paging mode from the command line Date: Wed, 22 Feb 2023 11:43:21 +0100 Message-Id: <20230222104322.1197763-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230222_024329_003904_6315EA06 X-CRM114-Status: GOOD ( 13.90 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This new version gets rid of the limitation that prevented KASAN kernels to use the newly introduced parameters. While looking into KASLR, I fell onto commit aacd149b6238 ("arm64: head: avoid relocating the kernel twice for KASLR"): it allows to use the fdt functions very early in the boot process with KASAN enabled by simply compiling a new version of those functions without instrumentation. I had to change the handling of the command line parsing to make the code self-contained in kernel/pi/cmd_early.c to avoid calling too many __pi prefixed functions from outside this file. I'll use this approach like arm64 to handle the extraction of the random seedi from the device tree for KASLR. base-commit-tag: v6.2-rc7 v5: - Handle null command line, Thanks Björn! - Add RB/TB from Björn v4: - Introduce pi/ for KASAN to work v3: - Massage commit log to make no4lvl clearer, as asked by Conor - Add a note to kernel-parameters.txt regarding the impossibility to use those parameters when KASAN is enabled, as suggested by Conor - Add RB from Björn v2: - Honor CMDLINE_EXTEND and CMDLINE_FORCE as noticed by Björn Alexandre Ghiti (1): riscv: Allow to downgrade paging mode from the command line .../admin-guide/kernel-parameters.txt | 5 +- arch/riscv/kernel/Makefile | 2 + arch/riscv/kernel/pi/Makefile | 34 ++++++++++++ arch/riscv/kernel/pi/cmdline_early.c | 55 +++++++++++++++++++ arch/riscv/lib/memcpy.S | 2 + arch/riscv/lib/memmove.S | 2 + arch/riscv/mm/init.c | 36 ++++++++++-- 7 files changed, 129 insertions(+), 7 deletions(-) create mode 100644 arch/riscv/kernel/pi/Makefile create mode 100644 arch/riscv/kernel/pi/cmdline_early.c