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: 13465641 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 863C4C61D99 for ; Thu, 23 Nov 2023 00:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8l03tKy8iqOQ9t/2hsxH8qZJgAG+y4sgScHWzN+xMOM=; b=HigkPA4ZnzCttc gTYUmCYVLRLFichwdw3e+eJ1rGMW9l4/kCtYeYzB7F8WfhI7/oRcKslpItcGA4g8lbToTDOugvTG7 OBb8RPHgdrqontAyJp1Vv4N089Xxlydl62HW9OU8cuU31sbA4RwwJk1WW+6OS/xPkXvTm8t4rRL/D Ru1sM5Aj7NCukn9L8KQ3A0tLORk92YpfbfnkTwrbKDVGhQY7m2Bd5g8A/7maXNuOcj8lRsii9h++U Gntbi5HUTiRn7eX7K6sPKz7uUu6qgyjpiAODiOok/THRwmc9LVYkDMhy3b7DCmd44RJ3mFRKBKKD3 G0kAiIGTcgibVvm9kb+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5xhQ-003Q0B-12; Thu, 23 Nov 2023 00:36:08 +0000 Received: from mail-bn8nam11on20600.outbound.protection.outlook.com ([2a01:111:f400:7eae::600] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5xhN-003PyP-0y for linux-arm-kernel@lists.infradead.org; Thu, 23 Nov 2023 00:36:06 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231122_163605_337421_D18EF0DD X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 {