Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1308347imu; Thu, 13 Dec 2018 12:51:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQTabd5/tJEDEClLNbZhrVKPxZayrBL+wXM+M5vj2xYlh1dhIyDw3anQCzK0BcONqdHG27 X-Received: by 2002:a65:5c02:: with SMTP id u2mr280213pgr.13.1544734278483; Thu, 13 Dec 2018 12:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544734278; cv=none; d=google.com; s=arc-20160816; b=SAtIgXnWt7ZXJNO5hSh8g3D6UzqaD+O23S3G/kT41VXmRujnZUMUY4ab7VS61o42mC pgWdaijy+S+n4nilBoa4JoUAXeKo6yzQF5ejrzfWqWT6xP/88RZJKhSFD+vxj3xaDGuw qNGGu0IJFXkhB7HHuQVWl6QS+wnj1G7DUHWttXPXw5dt91BCRxJDslrwy2mytAAC2EJ8 60hTwjFfvya7Tm2piHwoXRnjsgmj9zeVeMSsTRbVQaV6qrsx722i8Xb1KRDWONsa3U7c Qb60ZNwPY21IFGVsnYpmWfAcLJJpNYx7m/ygJXxTXSnEqMe6XQMIReGD2DtUFXlN/x94 59zg== 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; bh=DS0smfLy2ms9q6PCi01xWmSFA8QFLybLpNAofNvkQ+0=; b=m/1fU8GYdxnUSHf2AXkGyO0rexf59ppQSXy+yD8ivy42CJNxXZq4oWQi1DplK/wz5T BTo4uV/sx69TEH4EdjBOPkB4L9N8Vy7WqxV9F+9TcbNFt8o9Z6L2CzL0m5AS5E45XSKX 5gmOGhMo+xe84iLgkbx/0zMOLR9Gl7Qy7SQ9KFiVSk0mJu4dchFE6BK5o9bTQiDzgxBm AIAyeK6F50z95B/F1X48mZPW+BtPBJfVylx6edR/UkNKcGXcUTPMAiAbaAGKUaucrtXW KnVgEYrKVN7LV+TyaGpVgUh0xAyle2cagwzaWxybFCm249RgnhQtEVzSraEL5pKkZF/f 5gKA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f61si2344660plb.51.2018.12.13.12.51.03; Thu, 13 Dec 2018 12:51:18 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727363AbeLMUuF (ORCPT + 99 others); Thu, 13 Dec 2018 15:50:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55598 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbeLMUuF (ORCPT ); Thu, 13 Dec 2018 15:50:05 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED861A4023; Thu, 13 Dec 2018 20:50:04 +0000 (UTC) Received: from treble (ovpn-120-195.rdu2.redhat.com [10.10.120.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74AB6104C529; Thu, 13 Dec 2018 20:50:00 +0000 (UTC) Date: Thu, 13 Dec 2018 14:49:58 -0600 From: Josh Poimboeuf To: Joe Lawrence Cc: Nicholas Mc Guire , Nicholas Mc Guire , Jessica Yu , Jiri Kosina , Miroslav Benes , Petr Mladek , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2 V2] livepatch: handle kzalloc failure properly Message-ID: <20181213204958.tkapx6qi7fnm5t6h@treble> References: <1544709956-16701-1-git-send-email-hofrat@osadl.org> <1544709956-16701-2-git-send-email-hofrat@osadl.org> <20181213153954.GA9816@osadl.at> <2d712c92-e661-a32c-06cf-4de93ad93f77@redhat.com> <20181213185126.GA24202@osadl.at> <7aa8369b-0e64-ecf4-79a1-986c6ffeb59b@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <7aa8369b-0e64-ecf4-79a1-986c6ffeb59b@redhat.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 13 Dec 2018 20:50:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 13, 2018 at 03:39:20PM -0500, Joe Lawrence wrote: > Ahh, I understand the question now. Yeah, by making those routines local > static, the compiler applied optimizations that renamed the symbols: > > noinline static > % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_ > 5: 0000000000000000 20 FUNC LOCAL DEFAULT 1 dummy_check.isra.0 > 7: 0000000000000020 52 FUNC LOCAL DEFAULT 1 dummy_free.constprop.1 > 12: 00000000000000c0 32 OBJECT LOCAL DEFAULT 3 dummy_list_mutex > 13: 00000000000000e0 16 OBJECT LOCAL DEFAULT 3 dummy_list > 15: 0000000000000160 115 FUNC LOCAL DEFAULT 1 dummy_alloc > > > I can avoid that optimization (and successfully load all the modules) > by using either: > > __attribute__((optimize("O0"))) noinline static > % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_ > 6: 0000000000000000 6016 FUNC LOCAL DEFAULT 1 dummy_alloc > 11: 00000000000000c0 32 OBJECT LOCAL DEFAULT 3 dummy_list_mutex > 12: 00000000000000e0 16 OBJECT LOCAL DEFAULT 3 dummy_list > 14: 0000000000001810 73 FUNC LOCAL DEFAULT 1 dummy_free > 16: 0000000000001860 108 FUNC LOCAL DEFAULT 1 dummy_check > > or: > > __noclone noinline static > % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_ > 5: 0000000000000000 22 FUNC LOCAL DEFAULT 1 dummy_check > 7: 0000000000000020 51 FUNC LOCAL DEFAULT 1 dummy_free > 12: 00000000000000c0 32 OBJECT LOCAL DEFAULT 3 dummy_list_mutex > 13: 00000000000000e0 16 OBJECT LOCAL DEFAULT 3 dummy_list > 15: 0000000000000160 115 FUNC LOCAL DEFAULT 1 dummy_alloc > > but I'm not sure if either is the definitive way to avoid such > optimization. Anyone know for sure? Yeah, for now I think "static __noclone" is the way to go. Soon we'll have a GCC flag which disables such optimizations for all functions. And the dummy_list* variables can just be "static". -- Josh