Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp46458imm; Thu, 4 Oct 2018 16:12:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV62wRM3tO9lRA8l0o9c9DcQqKrjz+KLpHcPe7PaiTeoXp6WqKLAGtMVxiIQXz9ZKd824G10k X-Received: by 2002:a62:468e:: with SMTP id o14-v6mr8803233pfi.180.1538694740472; Thu, 04 Oct 2018 16:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538694740; cv=none; d=google.com; s=arc-20160816; b=MV9mCTFzH1ondrYGEhIznEF62lzPVMsWcGYK221d6UgqzWuk7j+csv2dp9w05VtwnU TABN0kKPYXuWnqFFrk8iRuIpNfjLHKpkP0mlbRbeldAkmeAuh5P+xkFxPev7kIz27f0d xW0HRgMkCmP7tvyTM0+M+ChF89z2089m8WJK6f/GA6eHlDejYNTax3Qea1gz5eOVyGmK 7ynCcQKOdzXiO29yTzmfb6SXGohYHXFGSBA7ec9HNgkAVe9LxN0gZzVrnmuVu2qPN53M SSIAWcWERS3POzPrvQvlE0w+KN7tQ9+EYPkQvx7kAQsUXZyDNTrPiEm1HkUH42WVWTA4 8ICg== 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=JyJI7/XTxDxDazXayJEUDH1PpVLhxRaYyORbsB/pHKw=; b=D1bp9oblQpxD7Ci5Tt8naHdpwVEDFaooOVcQdOJBt4dtOLBtXG8bd2q4pNhqx7Gwdr J7/NyqTKqHrhVufLnH02l5ejq2+vsBBfOAyXPRcsVDw4nwJTx3Wk4hxfqJUU8N4qJ7Fe eDjIoLuDaG35DTE0Uwz6GrushOfLMH05VcsDqRV/NazO0ifD8SIh8u271QHhmkg0bIQj ragCOQ+OamtK0EgWw1Stv8rVbTrhmZ0M1FOXyb+onrKYx9VWvy1kxlwOBa5yukD00EvF iRrJAiNVpicQgulDqcfQKPFLH1GYX9Qg+aB218MTiPvrGXy7YCfgXgle1ziQstaKItmO tLNg== 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 c10-v6si6762147pla.189.2018.10.04.16.12.04; Thu, 04 Oct 2018 16:12:20 -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 S1727581AbeJEGHm (ORCPT + 99 others); Fri, 5 Oct 2018 02:07:42 -0400 Received: from terminus.zytor.com ([198.137.202.136]:58473 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbeJEGHl (ORCPT ); Fri, 5 Oct 2018 02:07:41 -0400 Received: from hanvin-mobl2.amr.corp.intel.com (jfdmzpr05-ext.jf.intel.com [134.134.139.74]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id w94NBkai2918104 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Thu, 4 Oct 2018 16:11:47 -0700 Subject: Re: [PATCH v9 04/10] x86: refcount: prevent gcc distortions To: Andy Lutomirski Cc: Ingo Molnar , Nadav Amit , Ingo Molnar , LKML , X86 ML , Thomas Gleixner , Jan Beulich , Josh Poimboeuf , Linus Torvalds , Peter Zijlstra References: <20181003213100.189959-1-namit@vmware.com> <20181003213100.189959-5-namit@vmware.com> <20181004075755.GA3353@gmail.com> <20181004083333.GA9802@gmail.com> <10D29A50-C352-4407-A824-0C3C06CD8592@zytor.com> <36D6F606-6922-4057-B1F8-2B30993962AE@zytor.com> <20181004091651.GB21151@gmail.com> From: "H. Peter Anvin" Message-ID: Date: Thu, 4 Oct 2018 16:11:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/04/18 13:29, Andy Lutomirski wrote: >> >> Wonderful. >> >> Here is the horrible code I mentioned yesterday. This is about >> implementing the immediate-patching framework that Linus and others have >> discussed (it helps both performance and kernel hardening): >> > > I'm wondering if a production version should look more like: > > patch_point: > mov $whatever, [target] > .pushsection ".immediate_patches" > .quad .Lpatch_point > .popsection > > and let objtool parse the resulting assembled output and emit an entry > in some table mapping patch_point to the actual address and size of > the immediate to be patched. > Putting the generation of the ersatz code in objtool is an interesting idea, although I'm wondering if these macros, as awful as they are, wouldn't have generic applicability (what they do is they allow the cold branch of an asm to push temporaries to the stack rather than having to have gcc clobber them.) I'll think about it. -hpa