From patchwork Thu Nov 23 00:35:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Agrawal X-Patchwork-Id: 13465621 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 4F1EAC61D99 for ; Thu, 23 Nov 2023 00:36:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9D8A6B05BF; Wed, 22 Nov 2023 19:36:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D26448D0002; Wed, 22 Nov 2023 19:36:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA0806B05C3; Wed, 22 Nov 2023 19:36:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A53326B05BF for ; Wed, 22 Nov 2023 19:36:05 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8A938A17E9 for ; Thu, 23 Nov 2023 00:36:05 +0000 (UTC) X-FDA: 81487351890.30.30E0146 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2082.outbound.protection.outlook.com [40.107.94.82]) by imf02.hostedemail.com (Postfix) with ESMTP id 941708001C for ; Thu, 23 Nov 2023 00:36:02 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=CpNtRGSp; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf02.hostedemail.com: domain of ankita@nvidia.com designates 40.107.94.82 as permitted sender) smtp.mailfrom=ankita@nvidia.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=1700699762; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3/bZyWHQoKEw5iy9xhVjRwl4/N9WhdB8iG6w+9HFKPQ=; b=6FbnkK01c4doDJpdhEQd3O0ii3nhVTDBWfHkUdOUa0kIUkxnEwAl2ALp7s+IukbSEUceZP HjxdSkRivFGDNvwTPNIvBUNeiR2kDOrtQujqin98Jp6HyHgpjKyRF+TKDNE3qxcXtfmvj8 NSK0/zRcZMrtvJHOOm9AM6qP5JhGHCM= ARC-Authentication-Results: i=2; imf02.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=CpNtRGSp; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf02.hostedemail.com: domain of ankita@nvidia.com designates 40.107.94.82 as permitted sender) smtp.mailfrom=ankita@nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1700699762; a=rsa-sha256; cv=pass; b=fcAKXPKaxkSGyQJ1I6oQtvETfQHmTFMGA7dVZaREy/c/7rtqdkeax5qPX6jPUh0Mb8HA++ uJViAo5I70VX68xfxDNx87ovm6QwnVCjqBoKWWaSH+4LVpVv8d1GliNLiOhcQd5XeDv9lQ hN9F8+wgoArb8hHYh/YcDhovY4qAVEA= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T795ru13brCgtgGycGGwVlrOk9/jtMK6jgNuRbjsiI7wEfMJsAwOK9KuXmRD254ylZsvUwfNt/KtSozC+Bb7u1xKQ8DRAz0qRUkV/9TZn5HJZv/kpbc7goyGdVtUpyazg9bvBRy1SajmzDjiu3yt8V0VuMajd+jqtCmTdVNbZHkF981py3TdKaWgqKwmFdU7JPL0eL307/OkOyQcQTt1wgKEUe+1iIO2hVvCMbjOiaStOxQGCj/8jvLycFdUcE4AYUD5Mujm6LhupyAAlZ+8g3LFUWunTX42uiDdj6k/MscN0C8/7yYYZa2lMUVeyTtSQgaGACRgOpkp/BPRWRP/jw== 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=3/bZyWHQoKEw5iy9xhVjRwl4/N9WhdB8iG6w+9HFKPQ=; b=j02nSSEIVVSWLIsSG1oaoYWkcBiV/SynQm58HWSAhTVmFkvQlSO/5txqAhVifpKyptkkB6CJaR/X/ydxaR5tB37cPrAj2LweI1aRcTOxJVQbGIu4AxRVga1WeTMaG9/bWgPCirlCTgbSN2n94x9eA9Owt7yffcOCmd+EyxiryxpZ2siUYShmBC9LuQv5qQVlWIpI0z0vE5hgV/wg+HyZr6L22mzwso5RESYoED41mXRNoDGGEjLvuldElWXUPe9rSBr0wKESLJTRm7BPFSfiVHbMzZ9wMEAvWqetslnL+kRSGYuRUZ+fnWMg7GvFXSd28NQQkvVMHZwSSf6izqeBsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kvack.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3/bZyWHQoKEw5iy9xhVjRwl4/N9WhdB8iG6w+9HFKPQ=; b=CpNtRGSpPfd6YgUdsJFWiQv50qtgpjXd1ZLAzfVLG1i+6yOtV4y4pG9Bd/yC+1C5ZojnhKNRTrSHF60HENgY0vefFnr+OI7Gqa44yVFxo1q3/J4FjRCMIJ12Dp1am4bUa5TaRMyd5TB5gT8rCJ4Vk9DyJD06P2zksS8jKAdUqtPCebwkO/5QKRCPBmdPS+QH9chEA+3L88S/n5bdrNBL5W1IU3udSMzcohkQ7JKzf2CDZyZ+ePoECyVxLaEOGCJu1kt8AIvjYOlji/e9whoBjS6JjFcZLwpZHG4a9T4xOD48XmHNgTaUgWonRhCsOFXhu17buCSmXyGxZ6F0cyQPCA== Received: from PH7PR10CA0012.namprd10.prod.outlook.com (2603:10b6:510:23d::26) by IA1PR12MB8518.namprd12.prod.outlook.com (2603:10b6:208:447::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Thu, 23 Nov 2023 00:35:58 +0000 Received: from SN1PEPF0002BA51.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::81) by PH7PR10CA0012.outlook.office365.com (2603:10b6:510:23d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.19 via Frontend Transport; Thu, 23 Nov 2023 00:35:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF0002BA51.mail.protection.outlook.com (10.167.242.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.12 via Frontend Transport; Thu, 23 Nov 2023 00:35:57 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 22 Nov 2023 16:35:44 -0800 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 22 Nov 2023 16:35:43 -0800 Received: from sgarnayak-dt.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41 via Frontend Transport; Wed, 22 Nov 2023 16:35:35 -0800 From: To: , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , Subject: [PATCH v2 2/4] mm: Add poison error check in fixup_user_fault() for mapped pfn Date: Thu, 23 Nov 2023 06:05:10 +0530 Message-ID: <20231123003513.24292-3-ankita@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231123003513.24292-1-ankita@nvidia.com> References: <20231123003513.24292-1-ankita@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA51:EE_|IA1PR12MB8518:EE_ X-MS-Office365-Filtering-Correlation-Id: 41f53125-461b-4c1f-db98-08dbebbc2911 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EY9H1jv+Y3CS+Oo0Z12esoY6jKBtgObbS6VLgRO+a1sYZa6HurFqt4BTb4ZwjRTzHyHt962CZ7KF8vOORuclbCC96P0F4697PrIjSm69QDfe5Gy29V8zkY2YManNfCUcVBhmL4zYBiu3AgQQKa9E9Iw2hiKhLm6dpgZQENnrC/XeHk5gwIo8ctHzIXqh9Mz/LVNmc1sMpTpAONvOL85IccvTDfat/JqUE092g09nMT2j6K6h8GKIjXgoQWZ2RAtiUhO6XV+bpasbuQr69UHxUcN+socMn0rvCs3HOSRIEcRWcKdSIVWMIE4bnB3YV8wI4xdq6RkYv2dybGUTBJma7hJpVf15er3aRqBp0h611FtAhJd1//9mKaTpG3QzESyClQq8ogrFwoEpPB6oDnvSq1QxJxjseC7f5SW9/N9h0r8NnNgxpxLXvhoqpVxaYqVLoHRF8oGIXsLosLAvz+n2H03WteVYNePRMakxZ9KluRnaq8YxsGy1NiHZGACNpOAAZXmQcYVqNdh0EHiQnqzV7WYDcQngGAs4+8LgPzSKNV5iZr/+JkFkM92AQHs1Ap6MWOeLlLb7Q34ZmtOlTEptkzH4wmWP08+Ry0/dZX9JWQZ5zrSNBjwPEW6o8sxZtz11GzacngEs32CqT5lC3o2JTwL955OkFKdIUWKik8DGZgn8UXhWY0woy3IBZSGGNAtNZq0O30vwCwemAHS9uKXy1SlgkcI9PJ1YndYjSVoxNwahrt+9aODgQ4n+CR7m1dzSXLxxrosQZady6+E6D73lOA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(136003)(376002)(396003)(230922051799003)(64100799003)(451199024)(186009)(82310400011)(1800799012)(46966006)(36840700001)(40470700004)(40460700003)(110136005)(316002)(54906003)(70586007)(70206006)(7696005)(36756003)(426003)(6666004)(336012)(26005)(1076003)(2616005)(478600001)(921008)(82740400003)(7636003)(356005)(83380400001)(36860700001)(86362001)(47076005)(2876002)(2906002)(7416002)(5660300002)(40480700001)(8676002)(8936002)(41300700001)(4326008);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2023 00:35:57.7222 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41f53125-461b-4c1f-db98-08dbebbc2911 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002BA51.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8518 X-Rspamd-Queue-Id: 941708001C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: uuhud3jn1hqg5638y53r3szc8rprtehh X-HE-Tag: 1700699762-813004 X-HE-Meta: U2FsdGVkX181bFU1ThVAOS7O3D7oAHooYtsoWAl0Nm+3lOLRmXKRtEys4AYftdEIsBpxp3Ufecf/gNUAJorg+3Cgi56B1P1UaVvXQFaOpz619DPgkbKyix9BKeDRr/U3Dq9pWugAsLLCrRnEnfNU+IovVBQBRLJrtlU+4Oiqtgq8llWNGAufMnNqkn272zxMpoSmsdkmlBZQGAyfrDgUX+fC+oQY0u2oRC2HXJ9C1i7bNy6gDbqoIozsXuqT40q6G/W4W4ybTqjSdiDIeY35XX2PXSu4/hIwONTCL/zsvFaO4sXMPciGkSij+SzGileu06ft8jbsMp7O85rKa3djT07keoNzNZbS1q0J5EjMwSt9uRFx0j5+iDZbXiqdwke0NsqAHv7ZIod8y0pLK0lz6nFIg9h5vAWSlBzzo5QZS6Ai5oPMu5yjzTKY4ht4iO8i8OqRMqnLM/3EcuHGqU9wXdFw0gD/zkyF0F4KhjQ3pIeU1EG6Tk5aWjbxTsIBuK1YfP5ZmEuhSWG2rAFWlxmUw/y1/l+t8lF4Ey9KKH1+vEARcfeDKBsxaYj0Y4UEOxdrw+CWoWBiFRF7Fm7DyWPMXqR1Mf52Z2cl+I1n83xdI1KvTkJ/a5Zn7twplW2IUFihoVQFdF+TmTOXM5GMMl/sYzZW8vMX6Q6J3FeYZbeU5KEyecFmgazfgMNdz8yp+iVQ9SZLb1MYUK5U3whWwoXHnC3rMEirwuHhsMdKnb04Di7Izn9l7iCgn0HjL65sgIk2KlD/bAfnBipjGhsW/PFZlRkZoN+WOGkKvgXCByYN+VTdzzzRopgiQcMBY3XtQV0lyf47I74pXb2agwLEaOlSLHbZKHNo/uwQn5wpUXLZm1zuocTHMpAaoDepjwu/hLi12y/1rL3DVSoObyoRNdUEVN+eFqOifBT3SOLAdtzwm8wPaGu37o95Vw58oN/WTT42A8B9W4ke2ijziG9K/7H Z9kMG8f8 OSSawCkCKwgRVk7LH6YLqpDc5cL8z+G4yvvNlNL2GABEjZDmpUa1WEPInVbnBqLYzv05CsA1RjaAlZfHJL9e+B6ILZQRvlO8H0hAaw45/cE69lsWP8Sv7kaOHjld6FrrxMmHMuadX77x1epICGG5uo6WvI+sZN9P5AbCLylAr7Q3rqAVe07VfBlsUPzXNualB7CIO4m/NV9iZtKQgKkwpUtijkaUIGrIz2msOcF9qwdTyxEO+zSeAdyS3LRYeykQM/iIi36NoAK4Nx6VGAUixIHtrPg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Ankit Agrawal The fixup_user_fault() currently does not expect a VM_FAULT_HWPOISON and hence does not check for it while calling vm_fault_to_errno(). Since we now have a new code path which can trigger such case, change fixup_user_fault to look for VM_FAULT_HWPOISON. Also make hva_to_pfn_remapped check for -EHWPOISON and communicate the poison fault up to the user_mem_abort(). Signed-off-by: Ankit Agrawal --- mm/gup.c | 2 +- virt/kvm/kvm_main.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/gup.c b/mm/gup.c index 231711efa390..b78af20a0f52 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -1414,7 +1414,7 @@ int fixup_user_fault(struct mm_struct *mm, } if (ret & VM_FAULT_ERROR) { - int err = vm_fault_to_errno(ret, 0); + int err = vm_fault_to_errno(ret, FOLL_HWPOISON); if (err) return err; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 486800a7024b..2ff067f21a7c 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2731,6 +2731,12 @@ kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool interruptible, r = hva_to_pfn_remapped(vma, addr, write_fault, writable, &pfn); if (r == -EAGAIN) goto retry; + + if (r == -EHWPOISON) { + pfn = KVM_PFN_ERR_HWPOISON; + goto exit; + } + if (r < 0) pfn = KVM_PFN_ERR_FAULT; } else {