From patchwork Wed Sep 27 14:01:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13400863 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 B69AAE80AAF for ; Wed, 27 Sep 2023 14:04:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36E5C8D0085; Wed, 27 Sep 2023 10:04:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F6588D0087; Wed, 27 Sep 2023 10:04:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 171A58D0085; Wed, 27 Sep 2023 10:04:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EDACE8D0087 for ; Wed, 27 Sep 2023 10:04:15 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A4D4F80989 for ; Wed, 27 Sep 2023 14:04:15 +0000 (UTC) X-FDA: 81282546870.05.CCFFEBC Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2041.outbound.protection.outlook.com [40.107.6.41]) by imf09.hostedemail.com (Postfix) with ESMTP id 7F0A3140036 for ; Wed, 27 Sep 2023 14:04:09 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=C3G5pwol; dkim=pass header.d=armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=C3G5pwol; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of Joey.Gouly@arm.com designates 40.107.6.41 as permitted sender) smtp.mailfrom=Joey.Gouly@arm.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695823449; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CtQhUKKAeciLMz8eOcAzcWfX0r2cwo1XnqJpJwevaOw=; b=AZ/bQpr0SQRId/GlnSLf0fazi7xP+4QTvc2hcF2LkN/n5xUfA1QxifHfbP16uKs7YFLivT 6B7oKV9s/c+9tnTtlYpALdlscMi5LzjFcyRP4kDyV0vdo6dF/da5w+enZdVSJ+1oxVpOIE 4s4XM4VOoLZRXzF/U73RtZc2Lwka4Vc= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=C3G5pwol; dkim=pass header.d=armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=C3G5pwol; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of Joey.Gouly@arm.com designates 40.107.6.41 as permitted sender) smtp.mailfrom=Joey.Gouly@arm.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1695823449; a=rsa-sha256; cv=pass; b=WJRIsqUBHEfxexJSKQfUj35vhm2b+ezN9YKw0B9P3phuzzg9aS+n1M+hN5XTgSUzuQ4q8G KOw4yyjKXojErL3b+OjctV6Vb4SpBWYa3dcU547ujEqiiIc4DlZWeM+16/y3dJAOKH/M1N GYDB3vv3F8ldwCJJNp/DqYZAgVNp/rk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CtQhUKKAeciLMz8eOcAzcWfX0r2cwo1XnqJpJwevaOw=; b=C3G5pwolId6E0/SNrrLGnc5x3R1MZyvrL8fUc//Aucc+Rp0cbtgWoO1K5JSvnE0gSgs8TUA6iLfslmrqm3K/UMw2ULdd8blsEcq93AxrzIUxSBETZH0fAiuBMhnSnTwNE4ly2I15D3fyE3naBrvVP0r/KwjmOtEw+zbbgMao6AA= Received: from DUZPR01CA0171.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::17) by VE1PR08MB5678.eurprd08.prod.outlook.com (2603:10a6:800:1a0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 14:03:59 +0000 Received: from DBAEUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::e8) by DUZPR01CA0171.outlook.office365.com (2603:10a6:10:4b3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.21 via Frontend Transport; Wed, 27 Sep 2023 14:03:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT047.mail.protection.outlook.com (100.127.143.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.21 via Frontend Transport; Wed, 27 Sep 2023 14:03:59 +0000 Received: ("Tessian outbound 0ae75d4034ba:v211"); Wed, 27 Sep 2023 14:03:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8c0c49c206008a61 X-CR-MTA-TID: 64aa7808 Received: from e06e0c146651.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 705B4AD0-0930-4F3A-A271-0479D60E97DC.1; Wed, 27 Sep 2023 14:01:54 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e06e0c146651.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 27 Sep 2023 14:01:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iTgipIyIGLUaqx8CnxNrhipBpXF/SlrTYhzx+lH3ilrA1+fF0PQmV+dG+MuIuVXfkobWhfBqy1LhokCWi6HOyUjX9a+TkB4qGNQz9lDmyeTlBtAqEQNwVVawk1RdrWNP4cwftkiefK9xaQ+dDmShdj3mdZ/8RTNNGb667Tf8kfezTjGYnHr76peXYeG5+hN2q+UL+IVqj8Pyx3KxjFAZsx3TLeD9qKRBdRwCR56l94es7tudaEt9n0CF+adVncu6ptJalZKKxDbyZFoiFiUhZ/j1JlPOIbIp/WCdyDK5jJXg9jMEQ0dJpxuOc2tQEGzOLmf/9+n/qfgha3idczB79A== 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=CtQhUKKAeciLMz8eOcAzcWfX0r2cwo1XnqJpJwevaOw=; b=VKAOf1uaRWHTU7wrOMiDdqGz9B8/CKRUVV77bPVlDM/zZZV4/4RRDeUCJfLDzOKmqwBuyPKLR3ZVvksBkIx3a1ojM/zcFyURIWRZ67JyyBeqKllZmAq9Yc5zdt6s8+SNHTZgGplOkY+5j0TBR+GJOXBJg3w36F88JLbTSaPZjmS865rVtRoDkDjnYKmATneYozMd+1WU6VIbs050S03jlleqbK6M+95WkFQC9rtXvL+oYC/dyxdqZRuAp/vi+hjCfCMQ3Xu4IK1iB65EyGzZG9ijFUuSvuuMOFBoQ25krnwwo4zPSNHwOyioyLUhFzZNBtJpav1PYSevnqjC+NUWiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CtQhUKKAeciLMz8eOcAzcWfX0r2cwo1XnqJpJwevaOw=; b=C3G5pwolId6E0/SNrrLGnc5x3R1MZyvrL8fUc//Aucc+Rp0cbtgWoO1K5JSvnE0gSgs8TUA6iLfslmrqm3K/UMw2ULdd8blsEcq93AxrzIUxSBETZH0fAiuBMhnSnTwNE4ly2I15D3fyE3naBrvVP0r/KwjmOtEw+zbbgMao6AA= Received: from AS9PR05CA0256.eurprd05.prod.outlook.com (2603:10a6:20b:493::23) by PA4PR08MB7595.eurprd08.prod.outlook.com (2603:10a6:102:271::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Wed, 27 Sep 2023 14:01:52 +0000 Received: from AM7EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:493:cafe::a2) by AS9PR05CA0256.outlook.office365.com (2603:10a6:20b:493::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.21 via Frontend Transport; Wed, 27 Sep 2023 14:01:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT046.mail.protection.outlook.com (100.127.140.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Wed, 27 Sep 2023 14:01:52 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 27 Sep 2023 14:01:39 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Wed, 27 Sep 2023 14:01:39 +0000 From: Joey Gouly To: CC: , , , , , , , , , , , , , Subject: [PATCH v1 12/20] arm64: handle PKEY/POE faults Date: Wed, 27 Sep 2023 15:01:15 +0100 Message-ID: <20230927140123.5283-13-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230927140123.5283-1-joey.gouly@arm.com> References: <20230927140123.5283-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT046:EE_|PA4PR08MB7595:EE_|DBAEUR03FT047:EE_|VE1PR08MB5678:EE_ X-MS-Office365-Filtering-Correlation-Id: db7e54f5-eac8-47ef-819e-08dbbf6298b4 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AzNW/jfyN/py6pQnyO+mnLYMGlf7+Ka8Zv3VNpmpyhalAKo+iPntU4LF5pPlWJHLVa+H9foC/UAzAZekswYuh9DhOMQvNLtCNTd7pqvjWlQWpfVLvEUR1IbBBdrLH4vAhADdmadNdn8OIjNPwrDyJRwQgkdFRs4MSrf6rYt7Ilk6rZZZf7XyGHV3x8ZGmG4rFqlQ+4TkyWppjFU2Vw2TH5qwHM2GdRrfzfXudmGP6nCVLYmBq+W0m2bKEQrzDE+xs1LEWYfmh3ytpTHYs6ubNZUM+356zQc7b+LYbN6fQVYCm+9UZsSpIiCXKxSnoLwOc3qGPIOo3izhCE3MmHmeB6ZFY+Scl9Ayjo2N48+xoIlRHM5LsY+EVj/NSWweZ3mGPcOYwH4KQrS90v4XRF1TPYVucrOabF8ZkipQ/e7gGvuTQU8bhaoMNrO07c7dFGDGnKP4oncbJJRE0upySoaUxybRCB3iwGLdOMDf2OXBxeNxNbrit8dL7xJlhtlGU1ISug/ut0Ub5u2+MgSM0iigG0HnFB1LL382f7sFPvHF5tgJ+YuMNCrY6UafBt6duiEx+jW7s047dxAftF4qB+AVWihAWljEkAYa4xoDpu+EGbz1rjLMp5owpcCQQe8SbJEOo9Ux2aj2txihbg1RZWABNL+hDio4QpIqbJg86Q7hLx61kkN7iNWlGsg+La/1BZOfPGbXvSl4NzAABNmHMzblgepjqSpRL0taZZIz9YlBd97NJ8mCRpelrZLKX4cpybGVvyb98KlL8DIo0H3ILHTfig== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(346002)(396003)(39860400002)(376002)(230922051799003)(186009)(451199024)(1800799009)(82310400011)(40470700004)(36840700001)(46966006)(2906002)(36756003)(86362001)(40480700001)(5660300002)(44832011)(26005)(70206006)(54906003)(70586007)(2616005)(336012)(316002)(1076003)(426003)(41300700001)(6916009)(478600001)(7696005)(8676002)(4326008)(8936002)(47076005)(40460700003)(82740400003)(356005)(6666004)(36860700001)(81166007)(83380400001)(7416002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7595 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4725d3bd-55f8-4bd3-0ad8-08dbbf624d42 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sy5J3ItjMB3RGoprMFaNZFr92fFrE0Xy8ubYy/rYQDnyesj10z+DGMhXxRFLQscFqoc0cGGXY3x1jSWc2m5EstAY4pnY+txO23xr/pPRPKhuvvNE08yNepdmKY5RJ1bqHo/901Y9LznKwgRoIGrXGEoYjFBk3MmD2K8jRBICwGGi1VWp79Vw1pVUxHOGoNeeVlKaPiPEsVqbowsAEXQEOSSkW1Y2bbBNRGOw4osJvMZxnyKfyQHq0tlVX+mFt/BXO5wKzqYt1dE6U0QJHVKdFNoSG+jhIPcBCytQeiZsJXnx/rHmKecgqxCEK2suvCU3A6aZapKnK/HBw3PBmHmO4m4/QvPmXhOs4plbbpMLFjGGryHNeThYK1cOJjxTUBonM6FhIjLMxeDuA2BmvMCvgvrVFMuCtHA65s7lCjq26o9ZqEqV6NJUIuwhrLhEsbA5jCFoGtBhNBiwK2S2z4qGMs4sAPZWPSr/qhDVzdT+sPXzUb9VP0qy2U/UH3214+IAxeZtRYa5VTvydhBF6EOhuxaTL/aZT0jgkuEFgIm6JCo1ylGDmXQT6hYRuvlkJ2/YfQyUpaH4vmmm1qkJpaPS6mXjLse7ngen5HB5M2dw5ecUntJgK6i1IvTm/KlE5AYPK59KZD4ceBbzql8Igiw6Q+iRheoe+6qaLHnmivUve88FXKH2bd7ouTbYSKGfjRel+U/oxpvCiXqj1yawK/qGPb9OKVm6oH2Q9Gy8kMruj/TgEEdUTOqoY71Uif9yq2Ou X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(396003)(39860400002)(346002)(230922051799003)(451199024)(82310400011)(1800799009)(186009)(36840700001)(46966006)(40470700004)(107886003)(6666004)(7696005)(41300700001)(40480700001)(1076003)(81166007)(478600001)(336012)(316002)(2616005)(26005)(426003)(5660300002)(83380400001)(44832011)(8676002)(70206006)(70586007)(54906003)(4326008)(6862004)(8936002)(47076005)(36860700001)(2906002)(40460700003)(86362001)(36756003)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 14:03:59.2411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db7e54f5-eac8-47ef-819e-08dbbf6298b4 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5678 X-Rspamd-Queue-Id: 7F0A3140036 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: pfcw8kou4moqukbjpfira5xm78f38y87 X-HE-Tag: 1695823449-297427 X-HE-Meta: U2FsdGVkX18urF5pR+vcqGiI+rfZDsydCVUgUX+nJ1kvSsSzdblAdB60GVtZ/V1EnZeWlpSKdrJWrcPpUAQKBgASAf2zxD486wMqPuy39XHVtyVHKFRMcOToysuKL4xFGrxISap4Rj9MRIb2Dc5cekt/hH0xQxUnPegg5I8F/lMoSO5MGT3I67Dv6tEqDo4E/OXHOvKnQb7R3qynVpq0yqKr1IqQD9uw3Vp/LSAntRjBa2KG3r0xE8WR3bapcoeVPpU6WF4XivCQl1NQyEphBdR59+lLXNLR6wAjlrpg7e5vDMk6kbe+iBQdQNyWICxcp8qtC573GSYYjxZUIVguRihz3Dn921csnbE0t3KjiaS6x48snzyUAsLFgUwpszC9KUuulO/g/6T106fuBk8XqdwKas21pChq4osrU2FjS3g6yipbIgDkRC1cB17jVCbTenR+lWs+7f0G0l5iY4G4LEH2R2Gh/h4nmikpX17BkZxbaoFc3Qum4vcmegmXRs0ExqDhp/GglHhaHVMYiBzRoKVLervyWbRbcrc15USl/JUS4vMCkL+VB8djs6sl6n8V9oDKpodC8DCFwcjgUEFpcISGAJPQjNOXODg8ajE+T/RpuxcNM8xZPFFNgjwRovDXNYgc/f73hrPEr8Gf2zv7ocf5fZ5ksD7fkiY03mwAall8kX5ipqRpWK33V86XUcFCrQHIXf7/UadSKKcIeclX+nbSq1cxvipJoCJeIwmwoffGSH0kUq2B2ua9f3N7evXgjxM2LVa3/EbZ+40AtFugBl4237jPZ87WZRg6Fgps/gnlqTRbFhe/3zAOorjfp2LbDMVddCYWksxgi+pebpwOXQggBkAhBoJevTfinaG3bP3Mh/VF/Tym6XYJW13MEyH/biQZ3bAWOoAlpg+xGDJ3eU1DGDYiwVI5/T78QMRxmmX4EXNm5pEsAenjZi5m8zSzLwL+krcpFIhukpKptK8 YZOQ6+y7 GavU8amTDKgHth7l3W7yS3Grt+ESBxdq7tiPMomHF8hdNBYnUZBDnABUsggMLNadq5dbdEnGwASgos9lk7lJ6a47vXgZ61qJaPcfkT1d5Z1iILUX6zB/JnYdarjLtpfvRWBebQ03OMRLO4tBGpKnlKjZUHdsAWruLtn8e4l5APtg1QYmYB/0cOo01SuebeV1bag0YeIhtsDI5chXmF5hoU3Si4nrTwnr/FdZxnyvKwT0VyHB9bG1DPJCeLDcSEetuxZN7yhNq/g4psK6G8oPcKBuFXMmokDyfXJ+TDjYm9lXCKGFB7NX322bTpyVK6rX8CypZfW1s/IvGxoE12fh1XG51iGyeElsYGJsNUAFsAwboslyRJxTSMsJty3eNXMc5BR34l0VwWrdw36tDzhnVG8+3zdYFHUmtOs5pcVTfFSxCpzPrOd/WVQKi9FPThjwkp+Gk9tud15cYgMUH1eTYLhxRoGx3MGZNbxre1NZQEI3PmcQTGus56j9C6rZ3RD1Lz1gryyoHnkFUWIQKoYGQrQYp990yIMf3Ujps1ag7qSfa5bpebaiXq1agoEM7MtsDWP8A 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: If a memory fault occurs that is due to an overlay/pkey fault, report that to userspace with a SEGV_PKUERR. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/include/asm/traps.h | 1 + arch/arm64/kernel/traps.c | 12 ++++++++-- arch/arm64/mm/fault.c | 44 +++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/traps.h b/arch/arm64/include/asm/traps.h index d66dfb3a72dd..dae51eccfc19 100644 --- a/arch/arm64/include/asm/traps.h +++ b/arch/arm64/include/asm/traps.h @@ -26,6 +26,7 @@ try_emulate_armv8_deprecated(struct pt_regs *regs, u32 insn) void force_signal_inject(int signal, int code, unsigned long address, unsigned long err); void arm64_notify_segfault(unsigned long addr); void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *str); +void arm64_force_sig_fault_pkey(int signo, int code, unsigned long far, const char *str, int pkey); void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str); void arm64_force_sig_ptrace_errno_trap(int errno, unsigned long far, const char *str); diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 8b70759cdbb9..b68682c284a2 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -263,16 +263,24 @@ static void arm64_show_signal(int signo, const char *str) __show_regs(regs); } -void arm64_force_sig_fault(int signo, int code, unsigned long far, - const char *str) +void arm64_force_sig_fault_pkey(int signo, int code, unsigned long far, + const char *str, int pkey) { arm64_show_signal(signo, str); if (signo == SIGKILL) force_sig(SIGKILL); + else if (code == SEGV_PKUERR) + force_sig_pkuerr((void __user *)far, pkey); else force_sig_fault(signo, code, (void __user *)far); } +void arm64_force_sig_fault(int signo, int code, unsigned long far, + const char *str) +{ + arm64_force_sig_fault_pkey(signo, code, far, str, 0); +} + void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str) { diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 2e5d1e238af9..a76906199479 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -497,6 +498,23 @@ static void do_bad_area(unsigned long far, unsigned long esr, #define VM_FAULT_BADMAP ((__force vm_fault_t)0x010000) #define VM_FAULT_BADACCESS ((__force vm_fault_t)0x020000) +static bool fault_from_pkey(unsigned long esr, struct vm_area_struct *vma, + unsigned int mm_flags) +{ + unsigned long iss2 = ESR_ELx_ISS2(esr); + + if (!arch_pkeys_enabled()) + return false; + + if (iss2 & ESR_ELx_Overlay) + return true; + + return !arch_vma_access_permitted(vma, + mm_flags & FAULT_FLAG_WRITE, + mm_flags & FAULT_FLAG_INSTRUCTION, + mm_flags & FAULT_FLAG_REMOTE); +} + static vm_fault_t __do_page_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned int mm_flags, unsigned long vm_flags, @@ -688,9 +706,29 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, * Something tried to access memory that isn't in our memory * map. */ - arm64_force_sig_fault(SIGSEGV, - fault == VM_FAULT_BADACCESS ? SEGV_ACCERR : SEGV_MAPERR, - far, inf->name); + int fault_kind; + /* + * The pkey value that we return to userspace can be different + * from the pkey that caused the fault. + * + * 1. T1 : mprotect_key(foo, PAGE_SIZE, pkey=4); + * 2. T1 : set AMR to deny access to pkey=4, touches, page + * 3. T1 : faults... + * 4. T2: mprotect_key(foo, PAGE_SIZE, pkey=5); + * 5. T1 : enters fault handler, takes mmap_lock, etc... + * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really + * faulted on a pte with its pkey=4. + */ + int pkey = vma_pkey(vma); + + if (fault_from_pkey(esr, vma, mm_flags)) + fault_kind = SEGV_PKUERR; + else + fault_kind = fault == VM_FAULT_BADACCESS ? SEGV_ACCERR : SEGV_MAPERR; + + arm64_force_sig_fault_pkey(SIGSEGV, + fault_kind, + far, inf->name, pkey); } return 0;