Message ID | 20231122092855.4440-3-shijie@os.amperecomputing.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1201648vqb; Wed, 22 Nov 2023 01:33:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHy8zrR5aDlN2Gm24/dzfFvbpQCf2/7iTv16x63o7tkoXTAi//SUG0K7xR7boGuaxJ4KGIL X-Received: by 2002:a17:902:8b85:b0:1cf:665a:926 with SMTP id ay5-20020a1709028b8500b001cf665a0926mr1572889plb.49.1700645601542; Wed, 22 Nov 2023 01:33:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700645601; cv=pass; d=google.com; s=arc-20160816; b=E5AooegNyWK9C4uYcQjveR2w6sBc3JEWaUlchKstax38yrFYcHTALpOyP5K0WqoI/Q tt+ai4IEvhu2qjCq9UcpWqLsuXGWuh1hQe0ockz5bqOwVBkNat8BcIJlL85Nl8aQ2PZA 03zSMKlgxvuFINxvmX8cmNMYou2kIwlS7/5cUZAxujafBnMS3KFC1Yb2Q094J/V/cWAV yKAbBj29/e2W++15N3Kqhh4jTaTvpsAJ33zEA6kZlpXyT4z2lUWvsbRxMRTXkQ1Vi2Gc skcXy/VjV6+ZoXy8EXahme1IQ8jpEFPeTnK6Mybx1z1JhYOcP3lz9YTdiNHqiZSPLv2y xRrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SUn//U9TfDz72Pv19tjJUG4gFENPgF7D5GIy7JZ2GPE=; fh=IFMWg6fVnSyRGoEnT4djvIpOdIiU2mjS7YkNhQGkXP4=; b=MO6cFE/tdYUWVfRW/ygKcrF5KA1z5De2cjhy+CxpNUTqEIufncd7znIKFklELWr4vT OYeJrOr2d+NwEYO78fprXJ1VpeGwsWECaPRXiPEozIfmrvn6bZPMh50brFgUlJ9gp2z7 1Q0rG37F3ZtVPlnNWtwIAR0nT/yD6iH4pdgr2NshwoF4vNP4Gk+k1WRRQKRKb3SJ26wu +yrGKur05Nk+J/F5pw2GtVAuzBZMwzJNjBGiJF04oyzuDBUGPUqRQjmJlU6VnHFgUPB2 24FZT29cMS6Fv8ztNOrMzxabPk0ljGgci0uPMYIN6a8N+aUOvXCTcxgxblaXD0bvmBfW w/Yw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=mLRaBt4N; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j9-20020a170903024900b001b973681493si12632077plh.16.2023.11.22.01.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 01:33:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@os.amperecomputing.com header.s=selector2 header.b=mLRaBt4N; arc=pass (i=1 spf=pass spfdomain=os.amperecomputing.com dkim=pass dkdomain=os.amperecomputing.com dmarc=pass fromdomain=os.amperecomputing.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amperecomputing.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E0F4780792EF; Wed, 22 Nov 2023 01:30:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235202AbjKVJaC (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Wed, 22 Nov 2023 04:30:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235235AbjKVJ34 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 22 Nov 2023 04:29:56 -0500 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2121.outbound.protection.outlook.com [40.107.101.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2AA7193 for <linux-kernel@vger.kernel.org>; Wed, 22 Nov 2023 01:29:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LLlwMUdvihAQH93fCLa5GcBj+KWJSpJ8HxQuYss1ggzTkX+S6apvRVgY7V54JIk4m8j7UecDqyBxWomfQ1ioq5RTo3KzalKhoQMydgUncyKqiefvyYye46E5Egy7L7KFHrlJFGmzHryqH4GKFSOMNSSff3iUDT7Srt6ZUrMF7z010y+fFlWBR4MvOC8MveH7Ebd1v+gY+4KfBQ43y8KDBVT3H0yDg8mxzklBi0lJaXD2TR19wptvw0H5TG3vM+wg9UkavuGqvDP7kwMXSeqJLXuHu3SrSJGYmuwibkTHNkJsDwZew3DQ+5bqf39Sglq+HyE9Cy0mYUd4/qnd81vxqg== 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=SUn//U9TfDz72Pv19tjJUG4gFENPgF7D5GIy7JZ2GPE=; b=RY0g4WF3DlKXqSw0pAMlMdRHj8WND5BEzD6kBdvz5mxTz87ipOOF9+haHbXJp3s9vB4m4eQPhpaxeuRmbLJJEI98C0NfgvIbMpRFec5K3r6nQaYfbCtnrNU0moPNvP3HhkO/n7iZzp4oYYWIbc0nINrI8qBSmEXb4DphpMiPcSJHtzLOiZHmiHup1/sj0J3bMceDO+zDsj3kmN9rEBa+PejWTwcqr3ZhWcuhLLvrX1LZcof670GDmX/Nb1UBlUxMjrFwTGlYA5fCbL+7eyITODa3Orqr3aHkv8iP6N7ctAPXKu7jUgGfmTLjtuMB6DWmJ/N0GjyWwi7K1IQF9cnFJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SUn//U9TfDz72Pv19tjJUG4gFENPgF7D5GIy7JZ2GPE=; b=mLRaBt4NF4bEZbFvCblOULGm3iRwFLc19WHq8sB81H/lIC5XSKed91GWUIURUFbszwzVoGfFJUwuCnUolT9P/oWroa04TUfOXPTXF90gPo5KOeAYv1m5REFcqthvAzuPD7OZfmmGIN4Wj+iH37RvF0bBoGVZLC14kP7G51zsEaQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) by CO1PR01MB6760.prod.exchangelabs.com (2603:10b6:303:f2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18; Wed, 22 Nov 2023 09:29:44 +0000 Received: from PH0PR01MB7975.prod.exchangelabs.com ([fe80::3f45:6905:e017:3b77]) by PH0PR01MB7975.prod.exchangelabs.com ([fe80::3f45:6905:e017:3b77%7]) with mapi id 15.20.7002.027; Wed, 22 Nov 2023 09:29:44 +0000 From: Huang Shijie <shijie@os.amperecomputing.com> To: catalin.marinas@arm.com Cc: will@kernel.org, mark.rutland@arm.com, suzuki.poulose@arm.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, anshuman.khandual@arm.com, robh@kernel.org, oliver.upton@linux.dev, maz@kernel.org, patches@amperecomputing.com, Huang Shijie <shijie@os.amperecomputing.com> Subject: [PATCH 2/4] arm64: alternative: handle the kernel exception table Date: Wed, 22 Nov 2023 17:28:53 +0800 Message-Id: <20231122092855.4440-3-shijie@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231122092855.4440-1-shijie@os.amperecomputing.com> References: <20231122092855.4440-1-shijie@os.amperecomputing.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: CH0PR03CA0247.namprd03.prod.outlook.com (2603:10b6:610:e5::12) To PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7975:EE_|CO1PR01MB6760:EE_ X-MS-Office365-Filtering-Correlation-Id: aa21e5d5-c202-4ad2-8287-08dbeb3d8f90 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QCp8t67fD1sIeBn/PpE8bjsJvqFUMAmsLAmiy/bjbC7mQ5s+40tdnsNEYiawqEmjOYUO2gu0dNFIEU0YAPE7I6CaOc7Wr04F2q88bPmKYxlnNSeO1X2QKeOYowKp9eY4oyCCx7E6JqTTd3jU+VZtjjTy4gjI4JaZuzDjogIfCL+J3vfnhBSpnlMNbx6LZJor+ADs0utlBzPOaSQP0Q1gJ6wbXL9pueV9pU+R1OqF8ITX7TAZNDg6cXRntVDV1fB47k8C4dxXa35mfpRmcLFkI/4H9EYBi7dVi5XsIsF7pXuZQ9iOkkE2DXkQ8xfXW3uzb6a9TyYdJNM60GaWAUZcGBDT2c73pOQ5+I2qjoZaqu3LLc9sqUAu9WOeNOn/p7DV4X3vm/DEeMMUQyPzlcPJN+1meOqPrygbW0FCs6J7NK0COSlNHNnkTgPosB7fLlX62YDrRtSsosQ2AOo8PYorBa2B3dAxbTVjW5l1l40gvPKZlUnFPhN8nRr1bgDuCJDy0aOWI3VFWErCfLwZQkSpbup3bMnaSWP6BfClPaEUsHVlgOleJiTNFIg3f/LnQoJwEj1s6UK0zq1YTl9wlwdF/DjCtRGFDVJuefbXzcp+US0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB7975.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(39850400004)(396003)(136003)(366004)(376002)(346002)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(41300700001)(2906002)(86362001)(7416002)(5660300002)(38350700005)(6512007)(2616005)(1076003)(26005)(478600001)(6486002)(107886003)(6506007)(52116002)(6666004)(38100700002)(66946007)(316002)(4326008)(8676002)(66556008)(8936002)(6916009)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EWKGUL0VhRMabPmxy3qFWoWmeDPfiAeD1DTmts7nn1+6LTWpMf/Vw4L4aiqPR7N/10lTliK7F+JtwbqPvD2Z7i0p99KA7e/SirEbeZRqIMzf8i5sdNc0gtWJAKnHb16Hr1rpzwyQVN7qBaA/M/ceqbz6n0PNBRFca21zXqU7dy+VMe0hmlhkTf4DmofOlvucPBUznZ5qtm69/jYAaW1ydR3/7MVsDssoGAQqXB3Vsmn6bFSguGk8g9cSr3pIoRvA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tw/83qzLNuIYmWWBdL2/RXPTS5LU7lL8f2hEOEe1Uzsu7ssunGG7ZAl3ZO+dvf4kwusOzFtFAXsz9bw9uzQBJd4Z5yR6nPJ5bC890CmT7gnE+Wgjz3fynr3RxYuYe1ADuGCV89W56ZbAbCvuI6lVII25/dxA9sfsak+JvMgvZhAFMpTD2fyVaeT0CX6NnnPbPjBErWP7eP53H0pYQCrepsWdoX1GUBXiE5ePPsQnT4gxvqzjN5WWVq6uI98NaVOJZJnwK4Tr1NuJ4kaCADZtuCLOq1yzVX5MHMc= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa21e5d5-c202-4ad2-8287-08dbeb3d8f90 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7975.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2023 09:29:43.9654 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yo83bd2K29ZBU2doqssWgpeoT6cTPDq3FugHG7cfvsJ19fkgMg8riBQ5K+3w529K72K4I8cYkTz8UjBNpF7UB0Kyf/EQupacCvE1QrwNLlGqor0ScJHVbQ3XpeNKQOn/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR01MB6760 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 01:30:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783256162010680009 X-GMAIL-MSGID: 1783256162010680009 |
Series |
arm64: an optimization for AmpereOne
|
|
Commit Message
Huang Shijie
Nov. 22, 2023, 9:28 a.m. UTC
In arch/arm64/lib/copy_templates.S, some macros involve kernel exception table,
such as ldp1/stp1/strh1/str1,etc. Current alternative_if does not support
to embed them.
This patch adds the support to embed them into alternative_if:
1.) Modify the @insn to the right address,
2.) Sort the kernel exception table.
Signed-off-by: Huang Shijie <shijie@os.amperecomputing.com>
---
arch/arm64/kernel/alternative.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c index 8ff6610af496..4c73f9cc9a85 100644 --- a/arch/arm64/kernel/alternative.c +++ b/arch/arm64/kernel/alternative.c @@ -19,6 +19,7 @@ #include <asm/sections.h> #include <asm/vdso.h> #include <linux/stop_machine.h> +#include <linux/extable.h> #define __ALT_PTR(a, f) ((void *)&(a)->f + (a)->f) #define ALT_ORIG_PTR(a) __ALT_PTR(a, orig_offset) @@ -101,6 +102,22 @@ static __always_inline u32 get_alt_insn(struct alt_instr *alt, __le32 *insnptr, return insn; } +/* Check the kernel exception table */ +static void check_extable(__le32 *origptr, __le32 *updptr, __le32 *replptr) +{ + struct exception_table_entry *e; + unsigned long addr = (unsigned long)replptr; + + e = (struct exception_table_entry *)search_kernel_exception_table(addr); + if (e) { + /* Modify the @insn to the right address */ + e->insn = cpu_to_le32((int)((long)(origptr) - (long)(&e->insn))); + + /* Sort the kernel exception table */ + __sort_main_extable(); + } +} + static noinstr void patch_alternative(struct alt_instr *alt, __le32 *origptr, __le32 *updptr, int nr_inst) { @@ -112,6 +129,7 @@ static noinstr void patch_alternative(struct alt_instr *alt, u32 insn; insn = get_alt_insn(alt, origptr + i, replptr + i); + check_extable(origptr + i, updptr + i, replptr + i); updptr[i] = cpu_to_le32(insn); } }