Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3737488rwr; Sun, 7 May 2023 19:04:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4s7JZptYVDLuV5ATCuYVa/lA+G1sOEFlmXMV3LRXOPkb2b+3x1kuJvkQbtqCEjua6hd3DX X-Received: by 2002:a05:6a21:99a4:b0:ec:6e2d:5a32 with SMTP id ve36-20020a056a2199a400b000ec6e2d5a32mr10747467pzb.62.1683511456584; Sun, 07 May 2023 19:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683511456; cv=none; d=google.com; s=arc-20160816; b=rGRLcl7gUhE2zwITtrFEg9ilKlvHu3XDxTq6XYj7j1OXb5UN5lbvVr+olNSEMQh55Q d6IdVy8uAcTqkDCgfnnKJ84ov//3q1txdVfPu/JlasLX7lmTYXUakCmHaJqSuwUPTirP /wm1a9vb2buQpLlN7a1+WuhDTULYkT8mQ+zscrTzDlU2DfBxSPw9j8TSSFn65QOICiH8 cTf/TY8B4gxoMvK4lG9lUue0YnXvqI9XxVIADv8AQkkoNX9SNetkf6IEOjE1lod/SFrm hhV0QMs5bL6ZRG7KPjIy4wmIg2Ao6WahXbn2Ld+zzHPLDZf08EfDDIbnQ61b232yty5S +3og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dDxjDtgyFwFbxUTgZqlBdm7TmtNwdDEKJzeF52MA/B8=; b=KRWWWSyxfIBIppYJIQzcDVIx21GgVuTNNVVId7s+gMRh595R9VVyVXM27J3QtU3k6Q NYBICHhC+QPeOkgfi5fs04nb2b3OZMH4LBtgYAu63q/NskThZo8o+Gn8IDLPggzGg71x 02PDeW0YTJ2rJgbneBPkfWdGQcSCrDwXLV/sf8tC9UcgHYafSNk7+uIG0U3zVcRfYvGZ awl5Tp2G1gmL+O8ShwnKxl1XQeDPXXJ41Nb5sGmrCai9/lJn7YsjZMbUq24YsQmVTQ6U euBgFDVdm1w0uVXWyVXQMQXdQjf/j7iwI2Rs5DhfKyvDM60yqo1r6TXuyBiZNXO3s+8l KIkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a621902000000b0063b61b49a29si7451714pfz.251.2023.05.07.19.04.00; Sun, 07 May 2023 19:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232686AbjEHBpT (ORCPT + 99 others); Sun, 7 May 2023 21:45:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbjEHBpK (ORCPT ); Sun, 7 May 2023 21:45:10 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464171437F for ; Sun, 7 May 2023 18:45:01 -0700 (PDT) Received: from kwepemm600017.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QF3tp09PtzLnwc; Mon, 8 May 2023 09:42:09 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 8 May 2023 09:44:57 +0800 From: Tong Tiangen To: Catalin Marinas , Mark Rutland , James Morse , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Robin Murphy , Dave Hansen , Will Deacon , Alexander Viro , , "H . Peter Anvin" CC: , , , Kefeng Wang , Guohanjun , Xie XiuQi , Tong Tiangen Subject: [PATCH -next v9 4/5] mm/hwpoison: return -EFAULT when copy fail in copy_mc_[user]_highpage() Date: Mon, 8 May 2023 09:44:35 +0800 Message-ID: <20230508014436.198717-5-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230508014436.198717-1-tongtiangen@huawei.com> References: <20230508014436.198717-1-tongtiangen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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: X-Mailing-List: linux-kernel@vger.kernel.org If hardware errors are encountered during page copying, returning the bytes not copied is not meaningful, and the caller cannot do any processing on the remaining data. Returning -EFAULT is more reasonable, which represents a hardware error encountered during the copying. Signed-off-by: Tong Tiangen --- include/linux/highmem.h | 8 ++++---- mm/khugepaged.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 4de1dbcd3ef6..c29f51ea8517 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -335,8 +335,8 @@ static inline void copy_highpage(struct page *to, struct page *from) /* * If architecture supports machine check exception handling, define the * #MC versions of copy_user_highpage and copy_highpage. They copy a memory - * page with #MC in source page (@from) handled, and return the number - * of bytes not copied if there was a #MC, otherwise 0 for success. + * page with #MC in source page (@from) handled, and return -EFAULT if there + * was a #MC, otherwise 0 for success. */ static inline int copy_mc_user_highpage(struct page *to, struct page *from, unsigned long vaddr, struct vm_area_struct *vma) @@ -352,7 +352,7 @@ static inline int copy_mc_user_highpage(struct page *to, struct page *from, kunmap_local(vto); kunmap_local(vfrom); - return ret; + return ret ? -EFAULT : 0; } static inline int copy_mc_highpage(struct page *to, struct page *from) @@ -368,7 +368,7 @@ static inline int copy_mc_highpage(struct page *to, struct page *from) kunmap_local(vto); kunmap_local(vfrom); - return ret; + return ret ? -EFAULT : 0; } #else static inline int copy_mc_user_highpage(struct page *to, struct page *from, diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 6b9d39d65b73..ef8b70377292 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -805,7 +805,7 @@ static int __collapse_huge_page_copy(pte_t *pte, continue; } src_page = pte_page(pteval); - if (copy_mc_user_highpage(page, src_page, _address, vma) > 0) { + if (copy_mc_user_highpage(page, src_page, _address, vma)) { result = SCAN_COPY_MC; break; } @@ -2140,7 +2140,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, clear_highpage(hpage + (index % HPAGE_PMD_NR)); index++; } - if (copy_mc_highpage(hpage + (page->index % HPAGE_PMD_NR), page) > 0) { + if (copy_mc_highpage(hpage + (page->index % HPAGE_PMD_NR), page)) { result = SCAN_COPY_MC; goto rollback; } -- 2.25.1