Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5503732ybp; Tue, 8 Oct 2019 04:02:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYCco881TAnkKGqegvNCHGWZmQbAq0Ys6SDyYmgQaBuI3TgR+9PZirikSRQMOuBzRp3Ejw X-Received: by 2002:a17:907:215a:: with SMTP id rk26mr27723711ejb.49.1570532546413; Tue, 08 Oct 2019 04:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570532546; cv=none; d=google.com; s=arc-20160816; b=uI2PKkqRUG1C33Xi8Z9l32QmU6GQg5JgILBS0K1H2B8fuMCUhKyL2IqE6FfCKqK93d Sia62gYfc3r+OksZOKSoOVhi+CT7JMp9jPa37ExFEBE57q5fuhKfiuZAbJbotzpht2+z TZPGLL6eGcqB7NLxRUnAF3RDf5pY8zcHKIbrZjl+kdUB2Z7qylozyWJuvcK8DUtgZDYf vN/wLok/tM8zZSU4A/GykaJPm1y02mwwKDfmqwGBNBGwrF6qEryNlUVStqMZoktZYqDq Icun3ImCy38VQREJmlG6ljAxE3+InudCwJ/7x4zeeO/e4ECqSYl0J4fCyffAzVxd9i4V /OZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=yTeggjobz6tIbqd+4/UfVco2lrnAaVmEluwtk5EuXFs=; b=zY4CV8esA5gscGLE4dsEzaUsHPUZnCTMm9e/HuGPuyt18ivXRoiSd1oCsadVOeVy01 DWUtu/iRMoxH7IhwxbbHewf/zOHVPwmfRNfsfIOcy7KlSiDAFi/p8q6/1g1xF8SM1E6e sdcHPZtH2RRQAtZrmBAdufBH93DsjPpMN2yvt4XRnebZBUelIppCpgkiDNtdV1tO33TF ZCUB948C0YwFQrz7XxwFCjFHRRKJ/zbzwjrMzrgvpRO1iD+RvGqtlc6q5cdjzti3bTOH NkS1/r85rDbPBocmpIcMGEOD8KvdBb1gg0ibQgyksiUpgegnvG75rPeiEOGAuFFWQsS6 kPiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si9659330edt.32.2019.10.08.04.01.56; Tue, 08 Oct 2019 04:02:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730332AbfJHLBf (ORCPT + 99 others); Tue, 8 Oct 2019 07:01:35 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3221 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729790AbfJHLBf (ORCPT ); Tue, 8 Oct 2019 07:01:35 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 03AEDD409179B17EE88B; Tue, 8 Oct 2019 19:01:31 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Tue, 8 Oct 2019 19:01:30 +0800 Subject: Re: [PATCH v2] arm64: armv8_deprecated: Checking return value for memory allocation To: Will Deacon CC: , , , , , , , References: <20191007153710.7xpx27kgeewz75kt@willie-the-truck> <20191008102511.pmkqcpf7spkogarp@willie-the-truck> From: Yunfeng Ye Message-ID: <7b70fec7-e232-0d09-fd51-1fdd205823b8@huawei.com> Date: Tue, 8 Oct 2019 19:01:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20191008102511.pmkqcpf7spkogarp@willie-the-truck> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/10/8 18:25, Will Deacon wrote: > On Tue, Oct 08, 2019 at 10:33:17AM +0800, Yunfeng Ye wrote: >> On 2019/10/7 23:37, Will Deacon wrote: >>> On Mon, Oct 07, 2019 at 06:06:35PM +0800, Yunfeng Ye wrote: >>>> @@ -617,25 +624,47 @@ static int t16_setend_handler(struct pt_regs *regs, u32 instr) >>>> */ >>>> static int __init armv8_deprecated_init(void) >>>> { >>>> - if (IS_ENABLED(CONFIG_SWP_EMULATION)) >>>> - register_insn_emulation(&swp_ops); >>>> + int ret = 0; >>>> + int err = 0; >>>> + >>>> + if (IS_ENABLED(CONFIG_SWP_EMULATION)) { >>>> + ret = register_insn_emulation(&swp_ops); >>>> + if (ret) { >>>> + pr_err("register insn emulation swp: fail\n"); >>>> + err = ret; >>>> + } >>>> + } >>> >>> Is there much point in continuing here? May as well just return ret, I >>> think. I also don't think you need to print anything, since kmalloc >>> should already have shouted. >>> >> The registration of each instruction simulation is independent. I think >> that one failure does not affect the registration of other instructions. > > Dunno, I think that if kmalloc() starts failing then it's time to give up! > >> In addition, if return directly, is it need to unregister? Of course, >> the first instruction registration can be directly returned, If the >> following instruction registration fails, is it need unregister operation? >> currently the unregistration of instruction simulation is not be implemented >> yet. > > That's an interesting one -- currently there isn't a way to unregister > an emulation hook afaict. We could add unregister_insn_emulation() to > remove the emulation hook from the insn_emulation list and free it, but > I'm actually now starting to prefer your initial patch after all. The only > way these failures will happen are either because the system is doomed > or kmalloc fault injection is being used; so keeping things simple rather > than add rarely executed complexity is probably best. > >> The purpose of printing information is to replace the direct return, which >> can distinguish which instruction failed to register. There is no need to print >> information if it returns directly. > > What do you expect people to do with that information? > > Are you ok with me applying your original patch? > I agree, it is simple. thanks. > Will > > . >