Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp925117yba; Fri, 3 May 2019 12:47:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVqefynKGWQz60UjoTUtcOc1OKEFZxU7IhlDp1HpLS1Q9erco5o5w3Yz6mqO6zrkUvRY7B X-Received: by 2002:a62:fb0a:: with SMTP id x10mr13338137pfm.179.1556912870357; Fri, 03 May 2019 12:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556912870; cv=none; d=google.com; s=arc-20160816; b=0mV71rtaY6Y97LQcz202+9JfS/hHBUIfRILCzIBpocFp8RDcDsVaAF6qOe7j+gY6KB iCVc3sgx8UoTdaeVdXzp4A5OMdzB9aj/urK/iUnnxuFKMxbcIUpoG7IpKmT7xKK+jWL5 fhQJekJTFOboBT0Va+8KatLOmyec6hs3jwUoLAdHfH8UXKcTwzuuXwiPbsNxn7oCRKcs 3ptWVpE54ygLq3ezxEVz5bPQML5O0KUU+jrXILq/52MTQowOvv/RllaSTTkuXuupoq2f lthUvQPRQE/aiU1S5xkWmzIYm9V/dpNYb7dB34oW5NlK8r+1FQPRuJ4x24aVkwKolRNT byOw== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=NbEOyb6gKAbayfnredWA+lpN5msmVUb5vpcnCoJhL+k=; b=TLvx18/q//0nb1tj4VMCplERNtKibv+Vni55PSVFUmsTaAr3EiZB6H7ugMu+CRONsq GQTqhHTmbkSe7S0SbhjvCHAxZ/Pyt3jBS/kgZZcnhOH276syjb7CmdjeE3IutZ7FOdw+ Kdc/RIUIQDukN5TKu7flmeMrjBaIiDAFke98sJQJRnC87ahKzHQ1UMmTO0O/duj4E3eS bDFddIXzRCmWzNDIoohlrss2x7aLAiQVkt+xFG+K6VYovDCQ/uFikH5Dvpti5WVuAQvq 8Atv5gyv4Rp3MJhVuJYSx4UIIZMt8ktbLWL164Rnwz1geLSrG0yfFVxogcezxmw5HoCd Jt6Q== 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 x2si3721481pgf.272.2019.05.03.12.47.34; Fri, 03 May 2019 12:47:50 -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 S1727148AbfECTYK (ORCPT + 99 others); Fri, 3 May 2019 15:24:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:33752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbfECTYK (ORCPT ); Fri, 3 May 2019 15:24:10 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 DC5E02075C; Fri, 3 May 2019 19:24:06 +0000 (UTC) Date: Fri, 3 May 2019 15:24:05 -0400 From: Steven Rostedt To: Linus Torvalds Cc: Peter Zijlstra , Linux List Kernel Mailing , Ingo Molnar , Andrew Morton , Andy Lutomirski , Nicolai Stange , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "the arch/x86 maintainers" , Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan , Konrad Rzeszutek Wilk , Tim Chen , Sebastian Andrzej Siewior , Mimi Zohar , Juergen Gross , Nick Desaulniers , Nayna Jain , Masahiro Yamada , Joerg Roedel , "open list:KERNEL SELFTEST FRAMEWORK" , stable Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions Message-ID: <20190503152405.2d741af8@gandalf.local.home> In-Reply-To: References: <20190501202830.347656894@goodmis.org> <20190501203152.397154664@goodmis.org> <20190501232412.1196ef18@oasis.local.home> <20190502162133.GX2623@hirez.programming.kicks-ass.net> <20190502181811.GY2623@hirez.programming.kicks-ass.net> <20190502202146.GZ2623@hirez.programming.kicks-ass.net> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 May 2019 13:49:29 -0700 Linus Torvalds wrote: > On Thu, May 2, 2019 at 1:22 PM Peter Zijlstra wrote: > > > > Something like so; it boots; but I could've made some horrible mistake > > (again). > > This actually looks much better to me. > > Maybe it's more lines (I didn't check), but it's a lot simpler in that > now the magic of the int3 stack doesn't get exposed to anything else. > > We *could* also make this kernel-mode-only do_int3() be a special > function, and do something like > > # args: pt_regs pointer (no error code for int3) > movl %esp,%eax > # allocate a bit of extra room on the stack, so that > 'kernel_int3' can move the pt_regs > subl $8,%esp > call kernel_int3 > movl %eax,%esp > > and not do any stack switching magic in the asm code AT ALL. We'd do > > struct pt_regs *kernel_int3(struct pt_regs *regs) > { > .. > return regs; > } > > and now you the rule for call emulation ends up being that you need to > "memmove()" the ptregs up and down properly, and return the new > pt_regs pointer. > > Hmm? That would simplify the asm code further, but some people might > find it objectionable? > The problem with this approach is that it would require doing the same for x86_64, as the int3 C code is the same for both. And that may be a bit more difficult on the x86_64 side because it's all done with a simple flag in the idtentry macro to add the gap. -- Steve