Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5470672ybp; Tue, 8 Oct 2019 03:26:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMzxMGicsNgv6TnqXy3FmpAaz+ZUrfstA868OMdhj6zSBqSpljeR/dCY6BiOBhnjw8GeaL X-Received: by 2002:a50:aa8e:: with SMTP id q14mr33505252edc.155.1570530366622; Tue, 08 Oct 2019 03:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570530366; cv=none; d=google.com; s=arc-20160816; b=ORMoWwkrsWO1lvaWmFVd2wMBz/6pQ0oYo+RiUYWy8JWF3SyWJ97d81qs7llZz9GFI/ gM4CC/9WcmIXM7+YkUl7cXd0s71Thfdb2QI+sxSyNmOg6hlBQWhWlhMZakz8GVRDUzf3 1Qvn9GfhZ9DLqn9zB8WhOkwODA8Pxr2/ARiLuFQVQurgNZmZqJumD6FUUBFuy8J0kKm6 DuDYphL7ZQ5ToxLEfJWGNYjW/MXCa6RtoGIFNiJulRAO3TnhLWhmGOxA2DFQW8vQD+c/ m6NgIUqlStZw4t7wahaMeFtLEJ6mzTtshcWwFB4Zb4fVyOmkuER8IfMfIIWkpt2ISaAg qX0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nKVvHhKZibn582vWE1LLtqcIwQdz6R5c83ff0zEpEtA=; b=LcxPTGP6JD7dAOmLBXa6KpJfFuOWKcyVvIWkIKFalV/z21MN3+5lTf+s6prj5Nt7OD t0AAF6oeh3py3hkNiPfwgv0tx3zFjHIp4fwH188c7sYJf9l6qhTyVjwH0ciBQBsLp/VQ SiMvFWQzgz9LuaV3SM8RxFwo29XOHoxT4SgBRyE3mauv8Ip5UeTlXDDsurbshvQy+QvO I+qs9PwDxinlolo5WtFrYAjVHvd31my5qyoOEX5LjJBqgtU13ItasBX/iiqemEwd8CCx gQjmI2vuzOJDpvBWtrljVp+DSRP50qei6skFzR31z3jOtaFBwweaLuugezXYJ1eVV+Tq dG6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=egWENj8P; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gh16si9198058ejb.150.2019.10.08.03.25.43; Tue, 08 Oct 2019 03:26:06 -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; dkim=pass header.i=@kernel.org header.s=default header.b=egWENj8P; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730434AbfJHKZR (ORCPT + 99 others); Tue, 8 Oct 2019 06:25:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:59970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730416AbfJHKZR (ORCPT ); Tue, 8 Oct 2019 06:25:17 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D277D206BB; Tue, 8 Oct 2019 10:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570530316; bh=xvQs2o0EkBO2YHBiV+0D/Vc9/Ghl0Vhxiv3685TLTIY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=egWENj8PwMc2WcACRDBMWTlZGkW2pxt0YBJ7nm9KJu66YC/B3eUUpWGJru2vDHShm y8GbOMhvNSP5KfEG7Mn2kqQJwJp9SJwvvvQdIjqT0GBG/zr9n9qbrMqb5DU+wnlPMN uVv8njYO0qCDjrf5+MVm+HJGhXvh6DjojbuhonbA= Date: Tue, 8 Oct 2019 11:25:12 +0100 From: Will Deacon To: Yunfeng Ye Cc: catalin.marinas@arm.com, will.deacon@arm.com, kstewart@linuxfoundation.org, gregkh@linuxfoundation.org, tglx@linutronix.de, info@metux.net, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2] arm64: armv8_deprecated: Checking return value for memory allocation Message-ID: <20191008102511.pmkqcpf7spkogarp@willie-the-truck> References: <20191007153710.7xpx27kgeewz75kt@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Will