Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1114249yba; Fri, 3 May 2019 16:33:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXhKN9MjzEx4UEDU9qjlABXTpSB8TDaLVpqorFYrr6xQR59p3Z93eFp1mSJEtqsOO5EbWg X-Received: by 2002:aa7:93a7:: with SMTP id x7mr14979025pff.196.1556926432371; Fri, 03 May 2019 16:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556926432; cv=none; d=google.com; s=arc-20160816; b=duqyguRVrshXOhM+hLfMw5For2YVzHGouC5TIFpaEmTZ/ThUmO0I6Vmx7cwBPuKCiH mXCWAoUKtAnMFcO/EpwmOK3u03mVRpcFo6d74ND0IQBRll1/tux4vGq7MFb+YyXKXulv m96CJVVp7qUz9bu+8p7De6vNTtSt+/bFjdMZdTPiQOS3YxbbDyw1NunDWZV9Gy11vOZZ M6wlp6VotD9mlCfWOmNVzkfrvnVvRwo2K6eIJtjNEKiMC+HlH54MEdNp6cyncvNR94qC 9z5Omj9cKLxAHM5ltFcMuP8EYtRwPLgBpC6iU5GHExSfvN8hHAr2HP8IkAfzhqRXps8R TIww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=TtFvUcdRlwxjJeP9GJ9LZ/wpYtYluyY83Ajo3n2tLmk=; b=cMAhSCtQC13B4pWxyzujKJYCkE3jN5lr2RKUuPvEJTct960MDLgCpadacop+JvKUC6 IQOFO5OdtkqZ6SXTbLzsoZTmyNH3YvLVz8i7Gu+R2JqA2e3l9cQTkl0hUg0HLMVmRNT+ y8DhWwJSZby8vSIuxO62DBhB5ERCRFP9/UzopmqcUGrgTfMfWWBoYrbGaXJIjNYtuiQx WjNWS2GWmjPWNVxbf7CHHg5s/i3gLnua9PBhH1c6TPqsZev/n7xPQbbSle/EF1xYjj1x /kYxBJxA0x90bsfrpwvAItj8T8ciOGXaiWnA+H/930kxtNq8lD9HIU6o6/+jb6OAP/8D 2hUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=kqskyXzr; 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 b2si4671801pgn.93.2019.05.03.16.33.37; Fri, 03 May 2019 16:33:52 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=kqskyXzr; 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 S1726538AbfECXcS (ORCPT + 99 others); Fri, 3 May 2019 19:32:18 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35674 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbfECXcS (ORCPT ); Fri, 3 May 2019 19:32:18 -0400 Received: by mail-pg1-f196.google.com with SMTP id h1so3445184pgs.2 for ; Fri, 03 May 2019 16:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=TtFvUcdRlwxjJeP9GJ9LZ/wpYtYluyY83Ajo3n2tLmk=; b=kqskyXzrfDnxR77Tks5uSUi+a2XhUZmNpDID3r72qxt/NRxfhrjv0CokHNdtd+a6cl m7alBdhtieul6RlJNw/MTLNWYFtHDYii/+BV2m5+g/sk4qcggR68NCRigyzZvZrhAFQ/ MnZmbfiAPykM13Tz0riPz34Eir1qlJuTrfUVeKGGZ+zsYPouJsaaPHyrhL0hyqHTzKd7 BUTkKCln6bRieJYk98qtx4OGov0CJzhFT/zakqd68j/M1z3BunVYca4gMFp7sx/JseJK WP3tnvFsi89qihVYRc7m8QPwHNDjiD/+ifQkuvMSRrySXIr/5M/4Xqv5sTSAj0uMkVZM Y/bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=TtFvUcdRlwxjJeP9GJ9LZ/wpYtYluyY83Ajo3n2tLmk=; b=MNNwoQb49Nhg61JfUbuvZQOQtItUZ055UUcwTlYS1gR8ul8c4Z9g9z6nmgziL1BYbP mXrmsRdRD/o2piF16NRlHfiYfFr5NRd3s5Ulj06V371SrgieKHCp0Y1DRv2R78sLJVMo Y7snWV8ceXootGCQdluv1g/d6fRBuB+DYhmAD5iVHkfj+IxoZTW+x/ujNTSdqBZ0uLJE UouA7Jst4tPhqN8TahpB9SJhzDDs4y6d08CedDN3cPvvzJQDHDu1ozF3HEeUv2Ua6CBJ mF/BIG7ASjcyIFn+YVKfqQ+mvQURe9t8/3PeGvBbzlHx3yuMJUuqTfvIQcgs1Nos2t0B I2AQ== X-Gm-Message-State: APjAAAUydso4onnFTeB4wnYgz8IVrqrcBye7gCR1zr4Lnkl070vIReAL IGJN24yGzgO+3Aj4k6bYB+zSLQ== X-Received: by 2002:a63:ef04:: with SMTP id u4mr7647580pgh.96.1556926337031; Fri, 03 May 2019 16:32:17 -0700 (PDT) Received: from [10.145.97.154] ([12.53.65.170]) by smtp.gmail.com with ESMTPSA id q17sm5403159pfi.185.2019.05.03.16.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 16:32:16 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions From: Andy Lutomirski X-Mailer: iPhone Mail (16E227) In-Reply-To: Date: Fri, 3 May 2019 16:32:15 -0700 Cc: Steven Rostedt , 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 Content-Transfer-Encoding: quoted-printable Message-Id: <93546F2D-0DF6-4E6A-98B0-BA49491C00CC@amacapital.net> 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> <20190503152405.2d741af8@gandalf.local.home> <2962A4E4-3B9F-4195-9C6D-9932809D98F9@amacapital.net> To: Linus Torvalds Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 3, 2019, at 4:16 PM, Linus Torvalds = wrote: >=20 >> On Fri, May 3, 2019 at 3:55 PM Andy Lutomirski wrot= e: >>=20 >> But I think this will end up worse than the version where the entry code f= ixes it up. This is because, if the C code moves pt_regs, then we need some= way to pass the new pointer back to the asm. >=20 > What? I already posted that code. Let me quote it again: >=20 > Message-ID: >=20 > # 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 >=20 > It's that easy (this is with the assumption that we've already applied > the "standalone simple int3" case, but I think the above might work > even with the current code model, just the "call do_int3" needs to > have the kernel/not-kernel distinction and do the above for the kernel > case) >=20 > That's *MUCH* easier than your code to move entries around on the > stack just as you return, and has the advantage of not changing any > C-visible layout. >=20 > The C interface looks like this >=20 > /* Note: on x86-32, we can move 'regs' around for push/pop emulation */= > struct pt_regs *kernel_int3(struct pt_regs *regs) > { > .. > .. need to pass regs to emulation functions > .. and call emulation needs to return it > .. > return regs; > } >=20 > and I just posted as a response to Stephen the *trivial* do_int3() > wrapper (so that x86-64 doesn't need to care), and the *trivial* code > to actually emulate a call instruction. >=20 > And when I say "trivial", I obviously mean "totally untested and > probably buggy", but it sure seems *simple*., >=20 > Notice? Simple and minimal changes to entry code that only affect > int3, and nothing else. >=20 > =20 I can get on board with this.=