Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp991604imu; Fri, 11 Jan 2019 12:52:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN6frsb53tBvinRnwt1kcQolg0iutV0Cln2Z3bfNpqO+lrQhYW17zSiZmhFQJqQ319C74Hgs X-Received: by 2002:a17:902:5066:: with SMTP id f35mr16211058plh.78.1547239930418; Fri, 11 Jan 2019 12:52:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547239930; cv=none; d=google.com; s=arc-20160816; b=Ro+HjedeZ549P3JyGdHz2E8XGIxZYMpOVnMa0l0m9UCqhzsCZ6XbDXKXwmSJ48KFY0 Pgqi14x56KGd/zofYqh7pXF7S6d9BrTlIz+nAF7zqMwwMyVSe3JDJLgFYmcIOS9YU/t8 V5g5ZJ4Sn7hPxmDx19mjOen/PGmmSP8kzAcXFg0sG2Cya7hRt0tG3OP1Whm+IKX3hZWx UB0e81Pq0jzCg31JdC2a7RE+vFYvjlpQwal9p7omfvUDKckwYKMUzSn5gFvON1MWBBAC oORnM4d2XvTtR3AXc+/MmAzsgDhj3JMmeXO/cgoHeynZXkHjq59mRJo6+bKjEfJEetWM DIZw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=rVvojYTpftONxtEcaOVF4a98nBf0bgIFTSaAktqdUoI=; b=z61x1gPfFZiaXRIv7I47kcwHObD229/m2wZ9w7CBmZeej7r3P2j8NzLS+Gz+H89VJq 2mhz0u+8PBjRkZhkHUAbMcIrlmQslkvdZUhaa3jCnPk2N1GVftcPwoNQ+tbI+WmsXMkq TQ8GVZuihcO979zDdYXh8g/MoWTZKYthq+OyzANK9pNCx1vGr9qnao9OE1WFnu1uDDI+ qa0E5eG1MwXCfCdijZQeaCFvqEThay//w5S9sYoaxaj8B3XGuUZ7plBZwhHOiNpwPI60 uuTgYSfP052w318Z5XE2S6pZ43mffw4+Ykmzu8nyhPq9uDWSBdYu1taxGk9naDbf/slr B/kA== 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 a193si15951599pfa.214.2019.01.11.12.51.55; Fri, 11 Jan 2019 12:52:10 -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 S1732075AbfAKQHs (ORCPT + 99 others); Fri, 11 Jan 2019 11:07:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18232 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728498AbfAKQHr (ORCPT ); Fri, 11 Jan 2019 11:07:47 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAFF758E46; Fri, 11 Jan 2019 16:07:46 +0000 (UTC) Received: from treble (ovpn-122-231.rdu2.redhat.com [10.10.122.231]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6648F413B; Fri, 11 Jan 2019 16:07:41 +0000 (UTC) Date: Fri, 11 Jan 2019 10:07:39 -0600 From: Josh Poimboeuf To: Nadav Amit Cc: Andy Lutomirski , Linus Torvalds , Peter Zijlstra , the arch/x86 maintainers , Linux List Kernel Mailing , Ard Biesheuvel , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Masami Hiramatsu , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov , Julia Cartwright , Jessica Yu , "H. Peter Anvin" , Rasmus Villemoes , Edward Cree , Daniel Bristot de Oliveira Subject: Re: [PATCH v3 0/6] Static calls Message-ID: <20190111160739.h3zyn2sakiq3ci3e@treble> References: <20190110203023.GL2861@worktop.programming.kicks-ass.net> <20190110205226.iburt6mrddsxnjpk@treble> <20190111151525.tf7lhuycyyvjjxez@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 11 Jan 2019 16:07:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 11, 2019 at 03:48:59PM +0000, Nadav Amit wrote: > > I liked the idea, BUT, how would it work for callee-saved PV ops? In > > that case there's only one clobbered register to work with (rax). > > That’s would be more tricky. How about using a per-CPU trampoline code to > hold a direct call to the target and temporarily disable preemption (which > might be simpler by disabling IRQs): > > Static-call modifier: > > 1. synchronize_sched() to ensure per-cpu trampoline is not used > 2. Patches the jmp in a per-cpu trampoline (see below) > 3. Saves the call source RIP in [per-cpu scratchpad RIP] (below) > 4. Configures the int3 handler to use static-call int3 handler > 5. Patches the call target (as it currently does). > > Static-call int3 handler: > 1. Changes flags on the stack to keep IRQs disabled on return > 2. Jumps to per-cpu trampoline on return > > Per-cpu trampoline: > push [per-CPU scratchpad RIP] > sti > jmp [ target ] (this one is patched) > > Note that no IRQ should be possible between the STI and the JMP due to STI > blocking. > > What do you say? This could work, but it's more complex than I was hoping for. My current leading contender is to do call emulation in the #BP handler, either by making a gap or by doing Andy's longjmp-style thingie. -- Josh