Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1078084yba; Fri, 3 May 2019 15:44:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdCQEXZPUgN87bF5VVrSqUCiptpLC55kDHalhEl8PewE6tCrUnLzCRUyiT5sdshk6gXF3C X-Received: by 2002:a17:902:7d91:: with SMTP id a17mr14135750plm.338.1556923468053; Fri, 03 May 2019 15:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556923468; cv=none; d=google.com; s=arc-20160816; b=zxYalLh7m6nbwFUVkQgcV5Myl3Dvc91nvjGkqxuimdVSW8QYMQpfFqrO4UofoXycLd ZoCKl9ZCdkch/BZ34pYqOMxaaua1Gdy4+hkGqhmtQMURFMIM6mn4rXd1griZzEe8kddl z44fRkKd0AYJIoGnUBAx3EEwkWxwbcfcWL75QgPE8+84Ne3n41KN7QM+v4J2SZHuneQc JADn+IWjdKU2HpekwfxBcod6eqY6F4vzqUdss/dC2aStwuPNw7bWwNbfFSs5EHF+7yPZ 6RBmgwItiKqK2C5hsHu1bhLk7aCURz2aKGdb3V0vjuMdnrk2fYltRaC8jwaqrWpO0L0e 19xg== 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=OHPmorpbDxR0+1cD6Wtpm6wssS7c1TjAnKQ3VKbd0q0=; b=vr4uf6EzCZOpV7SdLnNEtKBLqsz/yXi3wRq6JDb+7q1qKK1O6I6MK7SlgDoPrk7FdX nRHiO7U6rpo2wtKB+UeKhfTpjPtB1ASmghfS+pxAwvlyRlIpWL0TbgQ+fKsOXBRjvNuW AE8zG97RBAhjBKk4S8nhCVN59ZXbU+1bEeBXer8FlsadBxLzABbwFkguudm3M6cNq9rX rLnuVm/oTyKWxII3BnZEbU7t524kH/EaE+LkOOsP17Nl+Rm30bNxiDyxOGlmLL4EesOA yStRZnYdh3Kdx9k2oKaJq0LYnDv3GEeFNk3gDf0ePx/CJlXJypQbXnLTDiomXKWQR9Po y0AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=GaGzUULh; 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 f4si5084750plm.278.2019.05.03.15.44.10; Fri, 03 May 2019 15:44:28 -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=GaGzUULh; 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 S1726755AbfECVvj (ORCPT + 99 others); Fri, 3 May 2019 17:51:39 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43880 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbfECVvj (ORCPT ); Fri, 3 May 2019 17:51:39 -0400 Received: by mail-lf1-f65.google.com with SMTP id u27so5118633lfg.10 for ; Fri, 03 May 2019 14:51:38 -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=OHPmorpbDxR0+1cD6Wtpm6wssS7c1TjAnKQ3VKbd0q0=; b=GaGzUULhqjMmt9UB2McFPzy2KoE/vIFjOEPyZeAs9LRhzauYSNsf4aU/gnQ5NxPU7J 78zVHJUH87faGstKDBEUoXudrE+Qtbp+EbYiXzb8OH5UHhhrvTdjAblZfz0SoEfmZTLA matHI53RRosv8whVcU1MDV9SaOQjdTK4xIaJU= 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=OHPmorpbDxR0+1cD6Wtpm6wssS7c1TjAnKQ3VKbd0q0=; b=Y/ddUWq/fRC0TSpq9RP9DOeL59BxPWpKy5qDheU8qDeiS2MioBiY9wIDSkyZCuSgOn RiYeI6grza19IJb60XVHDB468AO4LjUQr6qpjvL5T85Jg8QzY5D521K9TyBe9pZT1PKP sf2Nd7KjnEK5lg+ROloBtSn5A/nqK87xuraEhmnh5qQeeJd2MXiplLAO54wDoXPk9/fp yygsgmd2ATLmM15/7WBJOYy3Be/PPtdmMZos5ajNX9ZKLCwkIXVHBpnc4rYivOhhMyqt okblbsWXGjQA5j8JP4GynrYdLV+z7nBDqyKsLUe76aEomv6geBE5V8ff/68HiQLlIo1e p7zA== X-Gm-Message-State: APjAAAVUF7xTnnUYyKntf5OSuYh5mysjjAoG2E3fycYUoLcRCNrpuCQW 2EXW5oPAtKzIL73XvmL2qiKvzN++hTU= X-Received: by 2002:ac2:5501:: with SMTP id j1mr6202061lfk.89.1556920296907; Fri, 03 May 2019 14:51:36 -0700 (PDT) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id u11sm95702lfb.60.2019.05.03.14.51.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 14:51:36 -0700 (PDT) Received: by mail-lf1-f41.google.com with SMTP id h126so5391604lfh.4 for ; Fri, 03 May 2019 14:51:36 -0700 (PDT) X-Received: by 2002:a19:ca02:: with SMTP id a2mr6303975lfg.88.1556919987963; Fri, 03 May 2019 14:46:27 -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> <20190503152405.2d741af8@gandalf.local.home> In-Reply-To: <20190503152405.2d741af8@gandalf.local.home> From: Linus Torvalds Date: Fri, 3 May 2019 14:46:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions To: Steven Rostedt 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 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 Fri, May 3, 2019 at 12:24 PM Steven Rostedt wrote: > > 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. That argument is weakened by the fact that we have to do _other_ things differently on 32-bit and 64-bit anyway. So we might as well have a "on 32-bit, the call emulation needs to move the pt_regs to make space" special case in the call emulation code. It's very easy to explain why. And then we'd limit the special case to where it matters (with a big comment about what's going on), rather than adding random special case handling to random _other_ places. Having to add s magic special case to "kernel_stack_pointer() is certainly not obvious. Neither is adding magic special cases to system call exit paths etc. This has been why I've been arguing against the entry code changes. Exactly because they tend to have these kind of odd cascading effects. The entry code is fragile not just because it's a complex hardware interface, but also because we know about those complex hardware interfaces in random other places. I'd much rather have the code that does special things be in one place, and be the place that *needs* to do the special thing. If we copy the pt_regs around when we do the "call" emulation, it's *really* easy to explain *exactly* what we're doing and why in *exactly* that one context where we are doing it. And it won't affect anything else, and our existing code that looks at pt_regs will work both before and after. Would it need a #ifdef CONFIG_X86_32 around it because it's not needed on x86-64? Sure. But that #ifdef would be right there, and the comment that explains why the pt_regs need to be moved would also make it very obvious why it is only needed for x86-32. There's a lot of advantages to keeping your problems localized, instead of letting your random hacks escape and become problems for other, entirely unrelated, code. Linus