Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7660387yba; Thu, 2 May 2019 13:56:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzy6hsP0JrGoqhNU1+k6CRLVV1uUnio8FJCuCcnLxBJKIDb8Hy9n+dCEPTcCyOzFt3W5ozn X-Received: by 2002:a17:902:56d:: with SMTP id 100mr2359445plf.246.1556830606694; Thu, 02 May 2019 13:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556830606; cv=none; d=google.com; s=arc-20160816; b=TRj6QxieowHTXqNBnztKIDjVgqUFxCfWhyXl4MKnCoOgjAh/AjkSKYil5IGdYzlzeW kLxl3cF7u4kt3s/WAoXwHt37PIuqJPGTis5Uzk45bDBw+InJku9eZruxTFmgsbf4qXeR tYnihtBk1hZZxlc9/u0SOwfAN5k42WOQvwpcmPUYQG0JxCwIhNc2qPcpS8Ufpz2rXYvq mPsV9jYgE/zMoN/KxWOOPuTRq3W7+8ywl4hY3iBEXeQ2fCVBewJ6Tfu/okXRlze4ApbO QL6Td9Jl1Z8ixAif4vrwq2r1QEQJZh8Qg1famVLSHPuISmTSEGN8UD0x5p6vvi1z6eK/ 7L+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9eWa5vFKZPEJ8DW2XaC7JXAPKdGCG2IN2Y9wVvZv45s=; b=erHLrkJQaPKI6/17EXZd0ClFovXl8EmkxPxxlIx77j6g+osKtDtWeq188NCSytV9nZ e0yUQRbxuVtI43AqneucZbVppDaxZaasZ7FVd3y9k/1BSDbWpcAqjL4WHSxQw6hv9Otn dzWrYsPHXtI90aiTNoCUUAU5z0cMtSzALTSWz3bj3Hv38e6dJLVGnt2U+/ZheeEJPrWl jO+dwGNAAXwSXLiWGyoNIaVJgGvEw6NMhoM10GMt/he/AGiJlyiMfSzVFJQT+jne3ICm /1NK0b8+ZriLmGvGozLeNMwk8ymdJDK9VO6dYJcwTW1Pkr2VXSKkgoD8EsEZigCxJSQc 5biA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Cx3zQ0UK; 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 s7si122808pgr.287.2019.05.02.13.56.30; Thu, 02 May 2019 13:56:46 -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=@linux-foundation.org header.s=google header.b=Cx3zQ0UK; 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 S1726278AbfEBUzi (ORCPT + 99 others); Thu, 2 May 2019 16:55:38 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41262 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbfEBUzi (ORCPT ); Thu, 2 May 2019 16:55:38 -0400 Received: by mail-lf1-f67.google.com with SMTP id d8so2907294lfb.8 for ; Thu, 02 May 2019 13:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9eWa5vFKZPEJ8DW2XaC7JXAPKdGCG2IN2Y9wVvZv45s=; b=Cx3zQ0UKjjMz51LsOvr1ic+6VE8tQ4HPzkevgcUly/S86/MNpxZqSG4o20EQv0So+W xHmowGihlJAYSjpRF77/Gi8EjbFtkwBPUA5dnvni2jvpBKK7LKBaOoNVRF0Hc3/Mrf0r AikJgVeOLVaZ2oVA0t3qkDKimhPFDbi9a26ks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9eWa5vFKZPEJ8DW2XaC7JXAPKdGCG2IN2Y9wVvZv45s=; b=UhR/uRO3E88lH39I9M/fu0cXnDDOykNyLUQNpvM+NhRXS72CPua8QLFh5GlavrcTd7 p+KDDNzZvo1h0AipRF5UiTdBZew8C+VD2CFq6tfGV6bRbbIqZfY03TeYyfjrhhxjviGJ 1qG/0vhUvQ1WMTvvjHX2I+RsqnNvpLbECNTcQvd/hlm/kFbPAOEcVozBlOI/lZDty3x4 aWuMLFVL8pWPmfhG5cNILfMKwDfvfF9jPiqDbuTsGvqZ4O7LO8zdxnO1tJXwZ7fVgJ5q 594THYpigmrqDelM/OvXCt2bcn1vq439bMA2exvTif7WifLnV5GsAgmHndsHqu92KLWt BBOg== X-Gm-Message-State: APjAAAWGfdnhHQIHPug/gsasmqKt4uHZ+p2N7pNQ+BXdNEhdl06XspSO U/FbsW0Q4+ECRfZHwUo7tbRFQow46KM= X-Received: by 2002:a19:c216:: with SMTP id l22mr3001231lfc.112.1556830536162; Thu, 02 May 2019 13:55:36 -0700 (PDT) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com. [209.85.167.52]) by smtp.gmail.com with ESMTPSA id s6sm13014ljh.65.2019.05.02.13.55.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 13:55:35 -0700 (PDT) Received: by mail-lf1-f52.google.com with SMTP id v18so725433lfi.1 for ; Thu, 02 May 2019 13:55:35 -0700 (PDT) X-Received: by 2002:ac2:598b:: with SMTP id w11mr3275555lfn.62.1556830185843; Thu, 02 May 2019 13:49:45 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <20190502202146.GZ2623@hirez.programming.kicks-ass.net> From: Linus Torvalds Date: Thu, 2 May 2019 13:49:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions To: Peter Zijlstra Cc: Steven Rostedt , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Linus