Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1071689pxb; Wed, 6 Apr 2022 08:04:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOtFM6O3t4IQn0SCIVvlCdx5JOrnyQ4yXWy0OgU04ZA6QkphuoEZyFFcCmtOZki3JQiMR6 X-Received: by 2002:a05:6808:124c:b0:2d3:fd47:98a1 with SMTP id o12-20020a056808124c00b002d3fd4798a1mr3784411oiv.75.1649257473299; Wed, 06 Apr 2022 08:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649257473; cv=none; d=google.com; s=arc-20160816; b=uHBI/Zkc4dtM2dSxiQAYX0H0tvibNJh4/WEzUN+2HIF+/HPBBtzHPrJ8FPr9vFMO1w JnfsVi5un4o80QWBNuQ2gcR36ld49ffQPWH9BucO8nF9USBlvHobD2QYiF7z2mnUQy7c 9QEcqExmi9/iYw5pmsWfzKJ5QL7kIODiKDzBq6Qg6bMpYjyukqeFh0J8RS5kXoOZ8rkW RARFgXJuDfRWeXdrIilWOgZVfLXQjjJ2CETu17pHE0OkOZL0YRjhlAnbWjmRsHuGoiVw ZX4G+e6TQCfUkE1A+B3qqiEj3tsJKRKRYRf2dFrkEvalLDRLdvd+tK+rrpEIf+cQ8ZJr RSoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Rox1Sl+vbzoP7OQ8bY9X0kijJICMxcHPrUyzJgdFL1M=; b=l2xsJ6gJ/n2xDRS2Nm75TvJj+sCjyAJUNrqb8A6WgDoWi3cWRYaOhXvqpXdS4Qv0/6 yph3Dg6U9n6HL3V8VY9+iFqXZKh6eZBedhT9uo5Pn/73CgcuwqTxfatZSpuVvIaGxmfu HXKE36xfZgJiSsD4yYOHHJH0sJxIvSBsoNNpP0X4eR8divPN0bH+IWjAIzLeUlfeGc9R Sp+da5Tt08JDe7vHnheGIGrHQ44XAjd7CYy001yYrWo06x77VWqsa5PLO/kwi4kHsY63 fAcCnFlU0c5boLsPLZQA7fjg8zc7F9s4Vo0W+n6YFCrlZgBBNKnO2qZHsZGiSYaKktQc GYvg== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w22-20020a056830111600b005cb2fc137bfsi9179998otq.59.2022.04.06.08.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:04:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B64933D89AA; Wed, 6 Apr 2022 05:51:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbiDFMwC (ORCPT + 99 others); Wed, 6 Apr 2022 08:52:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiDFMuy (ORCPT ); Wed, 6 Apr 2022 08:50:54 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 299FC12AB0 for ; Wed, 6 Apr 2022 01:54:25 -0700 (PDT) Received: from kwepemi500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KYJGD3StlzdZY5; Wed, 6 Apr 2022 16:53:56 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi500002.china.huawei.com (7.221.188.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 6 Apr 2022 16:54:23 +0800 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.2308.21; Wed, 6 Apr 2022 16:54:22 +0800 From: Tong Tiangen To: Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Catalin Marinas , Will Deacon , Alexander Viro , , "H. Peter Anvin" CC: , , , Tong Tiangen Subject: [RFC PATCH -next V2 0/7]arm64: add machine check safe support Date: Wed, 6 Apr 2022 09:13:04 +0000 Message-ID: <20220406091311.3354723-1-tongtiangen@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 This patchset is based on[1]. With the increase of memory capacity and density, the probability of memory error increases. The increasing size and density of server RAM in the data center and cloud have shown increased uncorrectable memory errors. Currently, the kernel has a mechanism to recover from hardware memory errors. This patchset provides an new recovery mechanism. For ARM64, the hardware error handling is do_sea() which divided into two cases: 1. The user state consumed the memory errors, the solution is kill th user process and isolate the error page. 2. The kernel state consumed the memory errors, the solution is panic. For kernelspace, Undifferentiated panic maybe not the optimal choice, it can be handled better. This patchset deals with four sscenarios of hardware memory error consumed in kernelspace: 1. copy_from_user. 2. get_user. 3. cow(copy on write). 4. pagecache reading. These four scenarios have similarities. Although the error is consumed in the kernel state, but the consumed data belongs to the user state. The processing scheme is based on CONFIG_ARCH_HAS_COPY_MC and uses the process killing plus isolate error page to replace kernel panic. [1]https://lore.kernel.org/lkml/20220323033705.3966643-1-tongtiangen@huawei.com/ Since V2: 1.Consistent with PPC/x86, Using CONFIG_ARCH_HAS_COPY_MC instead of ARM64_UCE_KERNEL_RECOVERY. 2.Add two new scenarios, cow and pagecache reading. 3.Fix two small bug(the first two patch). Tong Tiangen (7): x86: fix copy_mc_to_user compile error arm64: fix page_address return value in copy_highpage arm64: add support for machine check error safe arm64: add copy_from_user to machine check safe arm64: add get_user to machine check safe arm64: add cow to machine check safe arm64: add pagecache reading to machine check safe arch/arm64/Kconfig | 1 + arch/arm64/include/asm/asm-extable.h | 25 +++++++ arch/arm64/include/asm/asm-uaccess.h | 16 +++++ arch/arm64/include/asm/esr.h | 5 ++ arch/arm64/include/asm/extable.h | 2 +- arch/arm64/include/asm/page.h | 10 +++ arch/arm64/include/asm/uaccess.h | 17 ++++- arch/arm64/kernel/probes/kprobes.c | 2 +- arch/arm64/lib/Makefile | 2 + arch/arm64/lib/copy_from_user.S | 11 ++-- arch/arm64/lib/copy_page_mc.S | 98 ++++++++++++++++++++++++++++ arch/arm64/lib/copy_to_user_mc.S | 78 ++++++++++++++++++++++ arch/arm64/mm/copypage.c | 36 ++++++++-- arch/arm64/mm/extable.c | 21 +++++- arch/arm64/mm/fault.c | 30 ++++++++- arch/x86/include/asm/uaccess.h | 1 + include/linux/highmem.h | 8 +++ include/linux/uaccess.h | 8 +++ include/linux/uio.h | 9 ++- lib/iov_iter.c | 85 +++++++++++++++++++----- mm/memory.c | 2 +- 21 files changed, 432 insertions(+), 35 deletions(-) create mode 100644 arch/arm64/lib/copy_page_mc.S create mode 100644 arch/arm64/lib/copy_to_user_mc.S -- 2.18.0.huawei.25