Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1072578pxb; Wed, 6 Apr 2022 08:05:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzg0bRM/oB9hjfco3FvPMkskGB7nlJo5dVCeRLbLZW0AJVerJNAEJ1sxAUbyO2q94sSLh3x X-Received: by 2002:a17:902:ba8e:b0:151:ed65:fda4 with SMTP id k14-20020a170902ba8e00b00151ed65fda4mr9171291pls.127.1649257531404; Wed, 06 Apr 2022 08:05:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649257531; cv=none; d=google.com; s=arc-20160816; b=M8SyaGf1xX4Hm/0awO/0zn/qWt0OmDCNXS4NAF/NYiC4CcCEnhqxJbypVg7WgsSyAx KpdNPDAM02teIO5Ls10HTiJC9o7ceSYuYsyS0tiaqj5ennIETYuIzMnw1a/xYxLt7w+l mgKDAEAwKTs/Xba0uhxLROTmbGd7Ymy/b6rK9BtVUiS1E0fMtwOscnlv8pyU6HI9lVJJ rTsYNI5ibdIrVNOeNlUQ+jQLm6DkgK4n684qnUKtP+8OykxVBF5E+epUX+ABawHfbZqv IP5UscL7yjL7vcQOta6oAwUNMWH64luE9LWBdh5fHSXwPugjIy2hrFm1iU9V9+1Vl6e+ AGbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=FFMzJtPgb+Hdqv7NqaHXvCVW5YqztuGUngIZdfM1bUI=; b=fdn0LV6+xaRBJbWhDZAfyWhNhWO+eHFFec3Zx4hbQxh85xnw+iUYpNWBN2z3lXKfRt lkJcHsOYL9qE2S7gVVo2NxhbCzRN25o+ygfbjA6jZc/Exov17VduqmBflM2btfmeGWgQ hYYnsXyQauudVV3QYDlXMF15TgpOs3Vgm6Za7J29jkMRYTSfitYnwGV4KoJxGdbaCEW6 MaVfusJAhdXErrHUSTnoVBRoIYCtc2SIbDmx+aktxQ3xvKYIWKiw0AXtRocBYmUivoVh +DKPywUsaxkH8iCBdgKeh+zd+qaZ8Ex5SL2DfQqMmX7s2NPaNdGLZQ5YU0j1CEjL0FIF 1mjg== 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 b23-20020a63d317000000b0039908cd81b8si11016519pgg.133.2022.04.06.08.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:05:31 -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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DDE353C76EB; Wed, 6 Apr 2022 05:52:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbiDFMwz (ORCPT + 99 others); Wed, 6 Apr 2022 08:52:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbiDFMv5 (ORCPT ); Wed, 6 Apr 2022 08:51:57 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8942F5C365 for ; Wed, 6 Apr 2022 01:54:32 -0700 (PDT) Received: from kwepemi100009.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KYJGM5tRfzdZZq; Wed, 6 Apr 2022 16:54:03 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi100009.china.huawei.com (7.221.188.242) 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:30 +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:29 +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 4/7] arm64: add copy_from_user to machine check safe Date: Wed, 6 Apr 2022 09:13:08 +0000 Message-ID: <20220406091311.3354723-5-tongtiangen@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20220406091311.3354723-1-tongtiangen@huawei.com> References: <20220406091311.3354723-1-tongtiangen@huawei.com> 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 Add scenarios copy_from_user to machine check safe. The data copied is user data and is machine check safe, so just kill the user process and isolate the error page, not necessary panic. Signed-off-by: Tong Tiangen --- arch/arm64/include/asm/asm-uaccess.h | 16 ++++++++++++++++ arch/arm64/lib/copy_from_user.S | 11 ++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/asm-uaccess.h b/arch/arm64/include/asm/asm-uaccess.h index 0557af834e03..f31c8978e1af 100644 --- a/arch/arm64/include/asm/asm-uaccess.h +++ b/arch/arm64/include/asm/asm-uaccess.h @@ -92,4 +92,20 @@ alternative_else_nop_endif _asm_extable 8888b,\l; .endm + + .macro user_ldp_mc l, reg1, reg2, addr, post_inc +8888: ldtr \reg1, [\addr]; +8889: ldtr \reg2, [\addr, #8]; + add \addr, \addr, \post_inc; + + _asm_extable_mc 8888b, \l; + _asm_extable_mc 8889b, \l; + .endm + + .macro user_ldst_mc l, inst, reg, addr, post_inc +8888: \inst \reg, [\addr]; + add \addr, \addr, \post_inc; + + _asm_extable_mc 8888b, \l; + .endm #endif diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S index 34e317907524..d9d7c5291871 100644 --- a/arch/arm64/lib/copy_from_user.S +++ b/arch/arm64/lib/copy_from_user.S @@ -21,7 +21,7 @@ */ .macro ldrb1 reg, ptr, val - user_ldst 9998f, ldtrb, \reg, \ptr, \val + user_ldst_mc 9998f, ldtrb, \reg, \ptr, \val .endm .macro strb1 reg, ptr, val @@ -29,7 +29,7 @@ .endm .macro ldrh1 reg, ptr, val - user_ldst 9997f, ldtrh, \reg, \ptr, \val + user_ldst_mc 9997f, ldtrh, \reg, \ptr, \val .endm .macro strh1 reg, ptr, val @@ -37,7 +37,7 @@ .endm .macro ldr1 reg, ptr, val - user_ldst 9997f, ldtr, \reg, \ptr, \val + user_ldst_mc 9997f, ldtr, \reg, \ptr, \val .endm .macro str1 reg, ptr, val @@ -45,7 +45,7 @@ .endm .macro ldp1 reg1, reg2, ptr, val - user_ldp 9997f, \reg1, \reg2, \ptr, \val + user_ldp_mc 9997f, \reg1, \reg2, \ptr, \val .endm .macro stp1 reg1, reg2, ptr, val @@ -62,7 +62,8 @@ SYM_FUNC_START(__arch_copy_from_user) ret // Exception fixups -9997: cmp dst, dstin +9997: cbz x0, 9998f // Check machine check exception + cmp dst, dstin b.ne 9998f // Before being absolutely sure we couldn't copy anything, try harder USER(9998f, ldtrb tmp1w, [srcin]) -- 2.18.0.huawei.25