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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBE0EC433FE for ; Mon, 20 Dec 2021 16:38:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238887AbhLTQiR convert rfc822-to-8bit (ORCPT ); Mon, 20 Dec 2021 11:38:17 -0500 Received: from mail-eopbgr90041.outbound.protection.outlook.com ([40.107.9.41]:24304 "EHLO FRA01-MR2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238654AbhLTQiP (ORCPT ); Mon, 20 Dec 2021 11:38:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CAsJFGFbR/hGWxQ9hn3Jyzg4I5hYl11OO/Un484QuMq0p81sGkUDaRv9kNthUhI1cMPKtacgFS26pOY+mcQm94qlgo2Y6+1PLpC4MSuksLznHfEjAiNDL0Ad8slsbqy5zTkGxiDMwpoutBglePA6y1RJdOCe0QaSfQKJoRWjhAclunZheBvXDXAPUbq+b9o0JWHqZWXqOd0lvmU58iVIEup2VaYCa1Q6B7i70VmaKl1R7egI+R3+K0zrX0lBpjgkkUwzArr3K3nBQXNeeHU5NDmlzNvTVY+mvhEWWmdbaXtyRF8RqBCU55PYlm2vzTo4GZF1Btqlj8wfqTCYnxYJRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DJ6UOweLhpPyHW7Ov2ppI5esOA38y9Gtnzd62Q9XXDg=; b=oMe8M2TNINBl2sSqfjMk7ljx4Z4CuM6Da3W14SwGh8mvaeg2nH/A6qr5Pg1vlNrCv3nOFsp3ob6wSC2WfK4QEafmtbXcLJqbVDfuCeICXeLyHtN8pDw9P/lbp2ejH/ht/E7j/79oCOFRWI5CuCHyb3YALT0q3Z78vjlNzoq5im3gkiBGz3F99fCb3MhaCZCYVRyXts2JtCmx5I2RUHF3WyXznWfDxnF0G4Mt7hpCjjrFnGELSjNr2DH2vOEvgewLjkb+Ppth9EBKbIvdfa6NuUio6J6tKYeuruKvJd5dDWp6pUXlfiILhKRMih4o06cOVjMRr9IgT3nKe0VL6PJhIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=csgroup.eu; dmarc=pass action=none header.from=csgroup.eu; dkim=pass header.d=csgroup.eu; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by MRZP264MB2924.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:1a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.14; Mon, 20 Dec 2021 16:38:13 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::f0ef:856d:b0de:e85d]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::f0ef:856d:b0de:e85d%5]) with mapi id 15.20.4801.020; Mon, 20 Dec 2021 16:38:13 +0000 From: Christophe Leroy To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Steven Rostedt , Ingo Molnar , "Naveen N . Rao" CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "live-patching@vger.kernel.org" Subject: [PATCH v2 04/13] powerpc/ftrace: Add support for livepatch to PPC32 Thread-Topic: [PATCH v2 04/13] powerpc/ftrace: Add support for livepatch to PPC32 Thread-Index: AQHX9b/6eBLNZiqJgUWhrC7ryztVNA== Date: Mon, 20 Dec 2021 16:38:12 +0000 Message-ID: <63cb094125b6a6038c65eeac2abaabbabe63addd.1640017960.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=csgroup.eu; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e2addbaa-6311-4300-5c8d-08d9c3d71d84 x-ms-traffictypediagnostic: MRZP264MB2924:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:635; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: IkGsHx6eu98pU5+TtsUf8mWC4FAQJ7dDJmBf+IazsjkjpZWe0Skx1yQ+JwEqa7PrbkTMxc8uHxF53S8BOU70vWjtr6jHf5E14R0E4uGJC6rhBkF8LeSkrxGsFYL0BfqUv837zK7LfWTsHlXvwilXt7HpoIIH9qhhuMy/ovpIOhpbKt1RGgRvnrWrpiO4hLwn6T+lwFtWS8Wtiy6xIA2Zcr/uAA2Il20Oe7I02dRqLep8McWfDAFxhjRKfOceUfahd1Lomcta+XKo41LoQxvjlnVtXR5u7+sGpyhySiuT8B7vq02H1OOsqIHq09saYZW0khKr4FgaTu73RZSQERZK9/PqW5+rR/m9qEEuMNayqu8WdoPdVjNTDWnklO6meeSf4JT7PjGJIDlORTWHsLRMwCB4s+DYcoWH0gp7gmet/Jt2vakCyJRUe2IAVAw6PN0vtQEc2EZ/E3nQ1VqjzRYV/APd51o14memmMUeCwW5/BtXjLzmHtk3Gg9/CqWEvnD5EoJjIBzo0C+HXWDmHFN9Gb3S8ATyuinSC6e2hcRSsB+ICf6+CgDFnUp3gpntHky8x0WCf3sjHnm8GsKskYfBXSunlKwL1V+R5gW+RGGEBg+IgXK/pt+xyVOwLmxOOH40SVAJ7Dzev7XamsAsOnveGqqPTpJbiA1QsFYfv0BGFTwT8CT7th9se7kkNutfq5ssLRbYYTsiRAtImlRcddOsNQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(2616005)(6512007)(7416002)(44832011)(2906002)(83380400001)(6486002)(66946007)(186003)(26005)(66556008)(64756008)(38100700002)(66476007)(8676002)(8936002)(122000001)(66446008)(76116006)(86362001)(91956017)(316002)(6506007)(508600001)(54906003)(4326008)(110136005)(71200400001)(38070700005)(36756003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ka2bGgJtLnZN2CA2CQumpwoG36Uz6X4rVGWGH/o7wbunC3Cdrg6DKHjW62?= =?iso-8859-1?Q?ty0UJFEOMdRZ3jnGUTVre22qcivXEOxSi9xLeBg8ULCxXiB3ixOYVoRx2q?= =?iso-8859-1?Q?RsjRvIdzf+r7gv5wdcxC3nYKT8+H6gCsB88inejWCPWkehBZjE9Jc+YWLh?= =?iso-8859-1?Q?ilm8FiOzwVzsyL41E+xAeTj0jrdlbZImg3EWdQTaLA8kkGVr7mHNHw76kz?= =?iso-8859-1?Q?OkH3JWxQGsYYglsurE3caOF0BN9VfTncjB8xl0fUBDYAF3IxI1yw/U5Cy6?= =?iso-8859-1?Q?AyqgTNXosy8PX+g5lnGlK18LaD6kZ3o0Eqbsh7/OSsBaLQUUHN4/q+SM4U?= =?iso-8859-1?Q?t03NKlIT95QwVzZlTgK2iojOQcqiV+dsP7ellXBwcLJmdE0Rz5BIwjTtAy?= =?iso-8859-1?Q?mbiSK3+GlOS80bCjndm2i+94JRRRInCsZZyHt9Zf/KYf7Vcm0tnUCHy5wz?= =?iso-8859-1?Q?dKn7RsdVnX3LbAZCP/1T5OinfrCtuzL2rBe2gsxJrHWld1yHLmMb5N8vmE?= =?iso-8859-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rPGRg+BzJxLFLQ?= =?iso-8859-1?Q?WteBesLAyWweJ5BTNRu5gxmU1gPFciGZMYpTf2c163Lbe/8v9DguBwHR03?= =?iso-8859-1?Q?eHnNp6RkbDUceshzwMtAkRKmhTeOeWWL7z2lGYW/2PPTVroPo+NmfWzTQb?= =?iso-8859-1?Q?QSRU1/thAT2Ej3DNSYCQOBrHflBkRKVqfliMW0E4MeArX6sf9UAfHoa3tr?= =?iso-8859-1?Q?XkTAQcCY+CHpaNX+94+GKA/LOXMz/4SfnC84eZAWutEueKHe52KTRZDUZF?= =?iso-8859-1?Q?99c4wB4MWK73HpWl1Gefy14UXG5iMHfWJhv4+6qKXcIpSHjh9YkzGUYQv6?= =?iso-8859-1?Q?YgzObRikG/gjQae7rJavYJghY=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: e2addbaa-6311-4300-5c8d-08d9c3d71d84 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Dec 2021 16:38:12.9297 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ChFmWvWOABelcK9FVA5CY/jemslILH9HrJKlFWvJrU/THHALjlfOvWr/epV4BVLBynysYBJSCHF0RiFzaHXAvF+74PCzGav04vtBbcHJyKY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRZP264MB2924 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PPC64 needs some special logic to properly set up the TOC. See commit 85baa095497f ("powerpc/livepatch: Add live patching support on ppc64le") for details. PPC32 doesn't have TOC so it doesn't need that logic, so adding LIVEPATCH support is straight forward. Add CONFIG_LIVEPATCH_64 and move livepatch stack logic into that item. Livepatch sample modules all work. Signed-off-by: Christophe Leroy --- arch/powerpc/Kconfig | 6 +++++- arch/powerpc/include/asm/livepatch.h | 8 +++++--- arch/powerpc/include/asm/thread_info.h | 2 +- arch/powerpc/kernel/asm-offsets.c | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0631c9241af3..cdac2115eb00 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -9,6 +9,10 @@ config 64BIT bool default y if PPC64 +config LIVEPATCH_64 + def_bool PPC64 + depends on LIVEPATCH + config MMU bool default y @@ -230,7 +234,7 @@ config PPC select HAVE_KPROBES_ON_FTRACE select HAVE_KRETPROBES select HAVE_LD_DEAD_CODE_DATA_ELIMINATION - select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS && PPC64 + select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS select HAVE_MOD_ARCH_SPECIFIC select HAVE_NMI if PERF_EVENTS || (PPC64 && PPC_BOOK3S) select HAVE_OPTPROBES diff --git a/arch/powerpc/include/asm/livepatch.h b/arch/powerpc/include/asm/livepatch.h index 4fe018cc207b..37af961eb74c 100644 --- a/arch/powerpc/include/asm/livepatch.h +++ b/arch/powerpc/include/asm/livepatch.h @@ -23,12 +23,14 @@ static inline void klp_arch_set_pc(struct ftrace_regs *fregs, unsigned long ip) static inline unsigned long klp_get_ftrace_location(unsigned long faddr) { /* - * Live patch works only with -mprofile-kernel on PPC. In this case, - * the ftrace location is always within the first 16 bytes. + * Live patch works on PPC32 and only with -mprofile-kernel on PPC64. In + * both cases, the ftrace location is always within the first 16 bytes. */ return ftrace_location_range(faddr, faddr + 16); } +#endif /* CONFIG_LIVEPATCH */ +#ifdef CONFIG_LIVEPATCH_64 static inline void klp_init_thread_info(struct task_struct *p) { /* + 1 to account for STACK_END_MAGIC */ @@ -36,6 +38,6 @@ static inline void klp_init_thread_info(struct task_struct *p) } #else static inline void klp_init_thread_info(struct task_struct *p) { } -#endif /* CONFIG_LIVEPATCH */ +#endif #endif /* _ASM_POWERPC_LIVEPATCH_H */ diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h index 5725029aaa29..42f8a1f99036 100644 --- a/arch/powerpc/include/asm/thread_info.h +++ b/arch/powerpc/include/asm/thread_info.h @@ -51,7 +51,7 @@ struct thread_info { unsigned int cpu; #endif unsigned long local_flags; /* private flags for thread */ -#ifdef CONFIG_LIVEPATCH +#ifdef CONFIG_LIVEPATCH_64 unsigned long *livepatch_sp; #endif #if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC32) diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 7582f3e3a330..eec536aef83a 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -94,7 +94,7 @@ int main(void) OFFSET(TASK_CPU, task_struct, thread_info.cpu); #endif -#ifdef CONFIG_LIVEPATCH +#ifdef CONFIG_LIVEPATCH_64 OFFSET(TI_livepatch_sp, thread_info, livepatch_sp); #endif -- 2.33.1