Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1113540pxb; Wed, 6 Apr 2022 09:02:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJiREosLdxexTzyvbc8hTJisGjcoxd3sD3a+4wqU9YqYy0GjYgCanK0Wx4I2AYFrLlnC8j X-Received: by 2002:aca:2b0d:0:b0:2d9:dc99:38a2 with SMTP id i13-20020aca2b0d000000b002d9dc9938a2mr3673659oik.198.1649260973067; Wed, 06 Apr 2022 09:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649260973; cv=none; d=google.com; s=arc-20160816; b=i3TQ1EzkwDkBmfmId+h8U65+QGg1Di2d3DyRJWwMYEstpBVtUVQ7QqrQiSGRxLxxLJ hzcAZ7lYF0aITSYN/vboGG92ySb3/kUJTO61S3cwTZghhiqttHG19MT/XOUqKlIvpQ7B KpfsxWuRyvx4jS3cgn+15rhijepoeVv91Zjne+H1DQYS6dZsp73gRXVNwHT3mQnsk9VO d7hB4eiSCzA/62+mKa9UN1oEeA2lbbzefXHLl3bHtSvaZgS9uslzNcU0RBdQsVjJHQfG 1+f29MPiWn0Pz3+6uaXFbD/x39JUXaTBJI5shgVfVLju2QmEAp9+4EhYgqJ0Q3gA2+VN 01gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=jA5GWT2U/THPIKIkVR/fFToUKswtxT2dz9+EFGjVHW0=; b=fjwQFuiFGjUqKIwAwC63h/uw3t2z8yKzlLPbW0zYhDafSWdopquKwa9ivT0YjJCda+ VOoUUSYp7l5NxflyruoLrsNrbaTcO4qmnL2KisKZ/zZ41D2igZACE91L+Sk0CpTlCmOZ YDoRZID6SXkf2MH990xA0dA55ZyagM+sjDCjSrHwa1jnDXbH/3Pgi7Wsugl21eCvaDes /wgLejgP4qKYoTk39dB0WOPyvqmsXoa72nstcjQ+J7ZzWhH4Q2cwJfD0OwCxmlduXyaj 3gE0KCFuyrIagN3U4y/sPqaYoF7vsMxFO5ES6ZYpEYgTC0M8PFVemP2yLZtHBCT+lwPy +Stw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i131-20020aca3b89000000b002ef458fd361si9414279oia.306.2022.04.06.09.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:02:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A31F8475869; Wed, 6 Apr 2022 07:49:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235019AbiDFOvE (ORCPT + 99 others); Wed, 6 Apr 2022 10:51:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235075AbiDFOuT (ORCPT ); Wed, 6 Apr 2022 10:50:19 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 085A846C6A4 for ; Wed, 6 Apr 2022 04:22:49 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A5E1B23A; Wed, 6 Apr 2022 04:22:49 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.10.98]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7B3B53F718; Wed, 6 Apr 2022 04:22:47 -0700 (PDT) Date: Wed, 6 Apr 2022 12:22:43 +0100 From: Mark Rutland To: Tong Tiangen Cc: Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Catalin Marinas , Will Deacon , Alexander Viro , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH -next V2 5/7] arm64: add get_user to machine check safe Message-ID: References: <20220406091311.3354723-1-tongtiangen@huawei.com> <20220406091311.3354723-6-tongtiangen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220406091311.3354723-6-tongtiangen@huawei.com> 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 On Wed, Apr 06, 2022 at 09:13:09AM +0000, Tong Tiangen wrote: > Add scenarios get_user to machine check safe. The processing of > EX_TYPE_UACCESS_ERR_ZERO and EX_TYPE_UACCESS_ERR_ZERO_UCE_RECOVERY is same > and both return -EFAULT. Which uaccess cases do we expect to *not* be recoverable? Naively I would assume that if we're going to treat a memory error on a uaccess as fatal to userspace we should be able to do that for *any* uacesses. The commit message should explain why we need the distinction between a recoverable uaccess and a non-recoverable uaccess. Thanks, Mark. > > Signed-off-by: Tong Tiangen > --- > arch/arm64/include/asm/asm-extable.h | 14 +++++++++++++- > arch/arm64/include/asm/uaccess.h | 2 +- > arch/arm64/mm/extable.c | 1 + > 3 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/asm-extable.h b/arch/arm64/include/asm/asm-extable.h > index 74d1db74fd86..bfc2d224cbae 100644 > --- a/arch/arm64/include/asm/asm-extable.h > +++ b/arch/arm64/include/asm/asm-extable.h > @@ -10,8 +10,11 @@ > > /* _MC indicates that can fixup from machine check errors */ > #define EX_TYPE_FIXUP_MC 5 > +#define EX_TYPE_UACCESS_ERR_ZERO_MC 6 > > -#define IS_EX_TYPE_MC(type) (type == EX_TYPE_FIXUP_MC) > +#define IS_EX_TYPE_MC(type) \ > + (type == EX_TYPE_FIXUP_MC || \ > + type == EX_TYPE_UACCESS_ERR_ZERO_MC) > > #ifdef __ASSEMBLY__ > > @@ -77,6 +80,15 @@ > #define EX_DATA_REG(reg, gpr) \ > "((.L__gpr_num_" #gpr ") << " __stringify(EX_DATA_REG_##reg##_SHIFT) ")" > > +#define _ASM_EXTABLE_UACCESS_ERR_ZERO_MC(insn, fixup, err, zero) \ > + __DEFINE_ASM_GPR_NUMS \ > + __ASM_EXTABLE_RAW(#insn, #fixup, \ > + __stringify(EX_TYPE_UACCESS_ERR_ZERO_MC), \ > + "(" \ > + EX_DATA_REG(ERR, err) " | " \ > + EX_DATA_REG(ZERO, zero) \ > + ")") > + > #define _ASM_EXTABLE_UACCESS_ERR_ZERO(insn, fixup, err, zero) \ > __DEFINE_ASM_GPR_NUMS \ > __ASM_EXTABLE_RAW(#insn, #fixup, \ > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > index e8dce0cc5eaa..24b662407fbd 100644 > --- a/arch/arm64/include/asm/uaccess.h > +++ b/arch/arm64/include/asm/uaccess.h > @@ -236,7 +236,7 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr) > asm volatile( \ > "1: " load " " reg "1, [%2]\n" \ > "2:\n" \ > - _ASM_EXTABLE_UACCESS_ERR_ZERO(1b, 2b, %w0, %w1) \ > + _ASM_EXTABLE_UACCESS_ERR_ZERO_MC(1b, 2b, %w0, %w1) \ > : "+r" (err), "=&r" (x) \ > : "r" (addr)) > > diff --git a/arch/arm64/mm/extable.c b/arch/arm64/mm/extable.c > index f1134c88e849..7c05f8d2bce0 100644 > --- a/arch/arm64/mm/extable.c > +++ b/arch/arm64/mm/extable.c > @@ -95,6 +95,7 @@ bool fixup_exception(struct pt_regs *regs, unsigned int esr) > case EX_TYPE_BPF: > return ex_handler_bpf(ex, regs); > case EX_TYPE_UACCESS_ERR_ZERO: > + case EX_TYPE_UACCESS_ERR_ZERO_MC: > return ex_handler_uaccess_err_zero(ex, regs); > case EX_TYPE_LOAD_UNALIGNED_ZEROPAD: > return ex_handler_load_unaligned_zeropad(ex, regs); > -- > 2.18.0.huawei.25 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel