From patchwork Tue Jan 30 10:34:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13537190 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A38AC46CD2 for ; Tue, 30 Jan 2024 10:36:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 85C646B0075; Tue, 30 Jan 2024 05:36:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 80CF16B007E; Tue, 30 Jan 2024 05:36:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D4926B0081; Tue, 30 Jan 2024 05:36:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5C1146B007E for ; Tue, 30 Jan 2024 05:36:31 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2BA5812017F for ; Tue, 30 Jan 2024 10:36:31 +0000 (UTC) X-FDA: 81735623382.12.9463416 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf11.hostedemail.com (Postfix) with ESMTP id EE2434001B for ; Tue, 30 Jan 2024 10:36:28 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706610989; a=rsa-sha256; cv=none; b=3dAYDdDpARS/1ox3/fo3eQn40Qzoo3RLLhzQvsVC5IH+tppNd/tLFwyag39CY6iuRq8BCw zL8W9Tj8xBmgaktYhvREVIJ914cQ9e+8O93Vmc9U03XKLynq9kJErjPJgntrDf3zjOYsQM 82ulHBfxjrOT8OqhuRjBZ5GaOOPulYw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706610989; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=jC0BRywmSP/veLOofnZjRXwvuK0o98v3xPNtaVXGifE=; b=UjqmZK2wnkARF5V4VdIkRrfrfWrbnF07tPJRcvniUE5O6Q+PGyAHZxM1XqEkIul/WXtOvY thkL5ibbZTHmtXOsd1qZIGV2G8Wtl2iaJ8HKhCLC1TkaQv7EbltOVzSj8ngif0yLdj221o GmjnRvQ+kCMvO40rUQqITIbTJr+1BdY= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4TPM625ppBz9sB6; Tue, 30 Jan 2024 11:36:26 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ws_uhNN709Je; Tue, 30 Jan 2024 11:36:26 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4TPM4R4bMWz9vDl; Tue, 30 Jan 2024 11:35:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 93C778B76E; Tue, 30 Jan 2024 11:35:03 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 5Vre96fi8PyS; Tue, 30 Jan 2024 11:35:03 +0100 (CET) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.134]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D09B58B763; Tue, 30 Jan 2024 11:35:01 +0100 (CET) From: Christophe Leroy To: Andrew Morton , Kees Cook Cc: Christophe Leroy , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Gerald Schaefer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-mm@kvack.org, steven.price@arm.com, Phong Tran , mark.rutland@arm.com, Greg KH Subject: [PATCH v2 0/5] mm: ptdump: Refactor CONFIG_DEBUG_WX and check_wx_pages debugfs attribute Date: Tue, 30 Jan 2024 11:34:31 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706610876; l=2737; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=GLnDgyafe3Abwdfr1jBJzmg1hyqpqoPnd3cHPH0oxrY=; b=tIZe4XZQjVwWyWqJ6WaH1FMomnKnFXJjNxF+XKnvH0G3eYwBTTFLAyHmPCAqyI2HJixgHIMEp +ciHrtrDDPHBl9BQwIT71a8HT+O9hvNWFDyEfO0KDZbwbPjdDLV5qLD X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EE2434001B X-Stat-Signature: t9u8pfx9r9upy95d1gqy3yp8w9757q7r X-HE-Tag: 1706610988-659132 X-HE-Meta: U2FsdGVkX19E/lU1DSQ1isF8W9pez1DQgUhIZ3XnWOqRKoQgqcwrMZCe5ybZcwjEI34MVwFcxhVDfn1V0S+PHbE9xMaGjzJjZPL3zuhpVh7vahLR+yGK70u39HAiSEBUnhkfRmhjcZ0tm6V/3VeR3v9R8AR8TH3qt/Rajp12nxgg3D8QtTlKsBYZjoF+iu6+JF5b6mFKSyoL/O+J2O0wfgD9KDpmzt7AUwxNlt8bqC+BnyaWsgldH7+ritK98Bk20x65ZWlg8dXZmIowFGVPw0nL3ssm7MY9ociUJwhLyl3mMD21cHa9s26EPu6k+BbiMHSuIIGUrR//5KOUaAWzXLihmDSRNOVETXzOKuOipr3NETqdnf9TWrJ8T/MZ3wQAs+eVxLeStjvmxmRbjKuJi2vRT2VURkfOu1+ZAjBBzLZ4jkX1hYAHdV7CvflOfEt39fmsbqXFMu+jrdPLRxAYcqKSMPAGByWAUYAs+2QdsmpyFxxgi+Gd/GmMCy5PTFlL/r7aIh3o7SJFPNXMXxnbSp1JS6zTd2kGp7dDHO9ZHqBzNlAsIdMESGyrhvNzDpvk8DGraNvVFbgrC834khnD24uP+Jxq0OFzNaGLTrwJeUuGWsVCjFV0ELmZD2K2c/3BpNkH3nLZ3+toomTZcS8GyBFEhFKktWAFZNCFWRMZCDhUrWPsLvC7kHNeRJprRvhPgluLydr/Fx3+Vv6vFBUlbZcw1IkOiHUqdXnz/gX0UfSlkpZfIwxSTawL9fibZAE6eRuMjci84/rlUiqUBuopjJ5V/xcJUKtwu1YcXlMwZwVLIlKx52yzQvKlCgJBz2n5M5fQq76cDFF2av2PCXaa2xj/4RL90yI5nU1Hx1eqYL7PWdGawpwAMlNkz8qVgiDeX/CbUJUte8FJaW074E9ZnNfzMfXiWne62u8KwtzLQBC0kqKbrmg8uwPxeyzHFEcZaeypv37fQwbOap+LCk3 A67lnc8k /DyFHCAIFKuMyDYqEpJX2wbEKtzJHjynPjA+HQ7nTIYSfNSCADg3XnxEnATYu7OAFX8AiHz3dtfnscVxc+Onp8uii4c68DHtcvTFz960sa+Qa2lAAsFdmlK8sOF5c+w6mv4UHf5SjcJKGwZtIkcMPgkQmuceVM13pHF3V/tY6a5EX+Pk2JSchMUFOAhEFuw8cx+tI0uWlzv/GCpZzB1SP4A6/d1StPk667cHqmOsYkv37E8yajfF+T09Du9SWQyNAAAjyuaEiOkGPCWyBOPBgXWHH2Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Refer old discussion at https://lore.kernel.org/lkml/20200422152656.GF676@willie-the-truck/T/#m802eaf33efd6f8d575939d157301b35ac0d4a64f And https://github.com/KSPP/linux/issues/35 This series refactors CONFIG_DEBUG_WX for the 5 architectures implementing CONFIG_GENERIC_PTDUMP First rename stuff in ARM which uses similar names while not implementing CONFIG_GENERIC_PTDUMP. Then define a generic version of debug_checkwx() that calls ptdump_check_wx() when CONFIG_DEBUG_WX is set. Call it immediately after calling mark_rodata_ro() instead of calling it at the end of every mark_rodata_ro(). Then implement a debugfs attribute that can be used to trigger a W^X test at anytime and regardless of CONFIG_DEBUG_WX Changes in v2: - Fixed a few build failures (patch 1 and 2) - Added patch 4 - Make the attribute return SUCCESS/FAILURE as suggested by Heiko (patch 5) Christophe Leroy (5): arm: ptdump: Rename CONFIG_DEBUG_WX to CONFIG_ARM_DEBUG_WX arm64, powerpc, riscv, s390, x86: ptdump: Refactor CONFIG_DEBUG_WX powerpc,s390: ptdump: Define ptdump_check_wx() regardless of CONFIG_DEBUG_WX mm: ptdump: Have ptdump_check_wx() return bool mm: ptdump: add check_wx_pages debugfs attribute arch/arm/Kconfig.debug | 2 +- arch/arm/configs/aspeed_g4_defconfig | 2 +- arch/arm/configs/aspeed_g5_defconfig | 2 +- arch/arm/include/asm/ptdump.h | 6 +++--- arch/arm/mm/init.c | 2 +- arch/arm64/include/asm/ptdump.h | 7 ------- arch/arm64/mm/mmu.c | 2 -- arch/arm64/mm/ptdump.c | 11 ++++++++--- arch/powerpc/mm/mmu_decl.h | 6 ------ arch/powerpc/mm/pgtable_32.c | 4 ---- arch/powerpc/mm/pgtable_64.c | 3 --- arch/powerpc/mm/ptdump/ptdump.c | 21 ++++++++++++++------- arch/riscv/include/asm/ptdump.h | 22 ---------------------- arch/riscv/mm/init.c | 3 --- arch/riscv/mm/ptdump.c | 12 ++++++++---- arch/s390/include/asm/ptdump.h | 14 -------------- arch/s390/mm/dump_pagetables.c | 21 +++++++++++---------- arch/s390/mm/init.c | 2 -- arch/x86/include/asm/pgtable.h | 5 ++--- arch/x86/mm/dump_pagetables.c | 20 ++++++++++++++------ arch/x86/mm/init_32.c | 2 -- arch/x86/mm/init_64.c | 2 -- include/linux/ptdump.h | 7 +++++++ init/main.c | 2 ++ mm/ptdump.c | 22 ++++++++++++++++++++++ 25 files changed, 95 insertions(+), 107 deletions(-) delete mode 100644 arch/riscv/include/asm/ptdump.h delete mode 100644 arch/s390/include/asm/ptdump.h