From patchwork Wed Feb 7 13:22:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tong Tiangen X-Patchwork-Id: 13548489 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 788F4C4828D for ; Wed, 7 Feb 2024 13:22:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B7256B007D; Wed, 7 Feb 2024 08:22:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 141D36B007E; Wed, 7 Feb 2024 08:22:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EFD6F6B0080; Wed, 7 Feb 2024 08:22:26 -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 D29976B007D for ; Wed, 7 Feb 2024 08:22:26 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AAF4AC0D2D for ; Wed, 7 Feb 2024 13:22:26 +0000 (UTC) X-FDA: 81765071892.19.1EC0214 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf11.hostedemail.com (Postfix) with ESMTP id 240CF40012 for ; Wed, 7 Feb 2024 13:22:23 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707312144; 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; bh=gXoTR5ohhq/GeXW6QY+CaNA6pgMbd5PecOtf5q6PYXc=; b=uhW2BdIpYyB7++T13ac51KeY806OgDs3Mpo9NqsnA0wFuBlglyUIDFNA5umkMh9QbE5ooX DykEtleBj+0wvYFBmaW9U7pmQkWyzXvplSOvtfHOHDWvPdu1RuFiSwbyGFIHSkfeuglXvK PqiRsjNwnotN3cYca0RujOQna0I18oU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707312145; a=rsa-sha256; cv=none; b=OgvSaTbx7fEQlhvDZsGvX+RTKSNDR74q38brVzvsBACnQnCbKSWY/w4hchfLKubcS+P+3F R8SXR9LqUzKSQKBqrNsMjyzGAr8dThX+9hjAOiujzzcFJOeL+vWDQS24Nrk0d1j8Lc8nBZ 8cybIfVNMs53p0g35tLHAzkGbPtX0fY= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TVLNT3FzMz1xnF1; Wed, 7 Feb 2024 21:21:13 +0800 (CST) Received: from kwepemm600017.china.huawei.com (unknown [7.193.23.234]) by mail.maildlp.com (Postfix) with ESMTPS id 16D2314025A; Wed, 7 Feb 2024 21:22:21 +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.35; Wed, 7 Feb 2024 21:22:19 +0800 From: Tong Tiangen To: Mark Rutland , Catalin Marinas , Will Deacon , Andrew Morton , James Morse , Robin Murphy , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Michael Ellerman , Nicholas Piggin , Andrey Ryabinin , Alexander Potapenko , Christophe Leroy , Aneesh Kumar K.V , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H. Peter Anvin" CC: , , , , Tong Tiangen , , Guohanjun Subject: [PATCH v11 3/5] mm/hwpoison: return -EFAULT when copy fail in copy_mc_[user]_highpage() Date: Wed, 7 Feb 2024 21:22:02 +0800 Message-ID: <20240207132204.1720444-4-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240207132204.1720444-1-tongtiangen@huawei.com> References: <20240207132204.1720444-1-tongtiangen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600017.china.huawei.com (7.193.23.234) X-Rspamd-Queue-Id: 240CF40012 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cpqhidraug3rmtdfpd3keojpgjxaqacu X-HE-Tag: 1707312143-263094 X-HE-Meta: U2FsdGVkX1+QLBaiGBiNwMAL1kizjG0LbbMf5+/h1m7rMSLmS+9Ind7CMpepDuVKTRM+Ij9+WBcxsHaWKbVU1hPr9Xrlf6zMpLaLG2/C2Yb2PkYjCmy6wSS8F7LuqMEWvfypNZLzj1Nm3dnusk1vES2VclOts0zRw5uHhDQsDNLfdQf6f6tdRwx8PrSfnPrnwcvCPDcmCImHkpIlSBjpZj+xVL3BDLpxcEuQpTbXxwn9E/2STA4F2kloUZK5AXaryzKPJh0hEJAQfajcOpM/OoVgkz1KHCz426wS91WITjtwP4ZGzbe7vncL/H6nWw79VJGgbfhjz7HCLc7jWTgeFybK2gj9A2gXc8+f3IcrKDDyjLI9BqMc4m2qaFrSIU2x1W+9sxaUfTXO7FdRdl9tsqRkU7KfWZ6mnui5QK7Yks7K/umvOBoTNN4kcCDljdTZIFMdFgxQx8gKjGq1nTTRRfSg9FiWAW3ZSKeACTqIbQGMVQ5xiGW62GEf0Brd0qOUEFxtLnE0w5uL1zWc1n+NxPipDhy6+VLa+PjxEu8XnLIM3yf6FDBtVLbIsYDyQl1vQBMvYHl7FW496PmvkrEtA9NSYo5HFt2IU/RrYp2TIqXGjzZ1CWefk1gbCpFJ+ajjBVUJ9Ycg/DgB1nJMSeDnhkRpF1l4C75ApzvuMf/OCZ2TCGKPjOO5orD9adTzChj453kmPBJiqfuZjglO/X+NkLa0KMVzdSchpxLiZ92Tsdz3SS8mqX5ysMfkYuTGBCzGma3Xnvq6W4D3fTMW5ZV7Oq4noaX3+VlKTo0NngI8MtCgCbSaS15HkpuZM5Goev15o/+bkzMpFZbL/2RwBi6kyEbQWKsdLmY6zstk4CFNTj6lG6fjnHJHPK/b/kDmAlOmKWH5g2r9J434te+0nqo2le8np9S67y+V4Yedd+l6AOby59juqnS0BuZaOncTl/bOv60EwjpTX1h4AYdzT7H 2/A4tfvy 0+AQ5fHG3m+R53MkycdDIV2vfxqBMRSjOVGohceVyni/upYGOO8fEMmKRdw1ItbawXB0A+83lIUKdNeV7JNO7+P5C4HxnVOyqUsvL0m8gA4z0G97TyR81rfehjbr1vg7SvUzJGr5sVGJDkHtv2CqkTPmlxPixAYRtciOXlvbHhN6Oyzv9TJgFaR81YntnCdaxNQneYhCEJRCKu5Kukupw7w/ST2Umq5IbvIbEE6FpToOMoXtSxatk1Ce685dTlKUZX29unkf+gKznFvA= 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: List-Subscribe: List-Unsubscribe: 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 451c1dff0e87..c5ca1a1fc4f5 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 fe43fbc44525..d0f40c42f620 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -797,7 +797,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; } @@ -2053,7 +2053,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; }