Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6771712yba; Wed, 1 May 2019 20:25:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyia7p5ra/5JWiOlCgtTJ9WDCpMRNq2zh89CaC9ZsX3iYGtMB7N9pYsRDYyvZiku6aEI/73 X-Received: by 2002:a65:5c8c:: with SMTP id a12mr1470685pgt.452.1556767520718; Wed, 01 May 2019 20:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556767520; cv=none; d=google.com; s=arc-20160816; b=rNL+6nlv1vy4t9RjwTx0Q0KTkzqkzF7WrgLKjT98UMnD9nGYm1dK6rhItQzYB7Ogjw Y/Dh7HUp0boe6CtrOPrgn9yppZNxdlJyaPFcRiKtOn4T3P944Ff5miX8Gu2jqt0kCivN KvD6uMJNIkdr5ImwHNhX2yYf5BL1vrfLOhY72lNAS1kiTfjRlgn51soZ0CLBClXrwi+x qnc67nIx8dRgBroOeu/D7YcIIE9vvgCdU6OxdnFFGVrscC4nsy33sdsMc7L5t4lmpdKh HgWN/M1ixlWDQk9qNg73G5jDzzNc2rG6ENqsW1SLKjFfgLhsb7uoo+9R/9xmLXMPTaem n8sw== 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=jc8GWOxxKaRnR87GnO3PiEUj1N8wN2+lq+tU8j7+A5k=; b=zjBv1kU8oJIVfQkd/eljcl0y9Lvxj+2PGR829bIwjlWi3sKrBf46OPxriBTzSI8dLV w2pbhpAe2Z86tK0uX4ohYLqgzxz0pZjvblThE2JR4Yogrr9JCh38x2Td/mB1rO9LYUQY UWGSFdRXwHe05vU6JuB9TQK2hOyGYXDpxS+K7pIlqFIB9oXrlg7rh1JwD82wV43FKU2H vW0WZe0Esj9IJ8C4qu4h/PJ4ul/6WA5dc7PGDFnubaKkW96z5OxJgTDxAW059KigwEVE I/uV+pEMJO71x6qCpLNl/aqZCvQDom7Mpt9Ohh+fCb1uWoaLPkzAJz3AztyqM5qxyCXj Qmvw== 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 w6si42744906pll.213.2019.05.01.20.25.05; Wed, 01 May 2019 20:25:20 -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 S1726328AbfEBDYR (ORCPT + 99 others); Wed, 1 May 2019 23:24:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:51034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbfEBDYR (ORCPT ); Wed, 1 May 2019 23:24:17 -0400 Received: from oasis.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 578FE20675; Thu, 2 May 2019 03:24:14 +0000 (UTC) Date: Wed, 1 May 2019 23:24:12 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Ingo Molnar , Andrew Morton , Peter Zijlstra , 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@vger.kernel.org Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions Message-ID: <20190501232412.1196ef18@oasis.local.home> In-Reply-To: <20190501203152.397154664@goodmis.org> References: <20190501202830.347656894@goodmis.org> <20190501203152.397154664@goodmis.org> 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 Wed, 01 May 2019 16:28:31 -0400 Steven Rostedt wrote: > diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S > index d309f30cf7af..50bbf4035baf 100644 > --- a/arch/x86/entry/entry_32.S > +++ b/arch/x86/entry/entry_32.S > @@ -1478,6 +1478,17 @@ ENTRY(int3) > ASM_CLAC > pushl $-1 # mark this as an int > > +#ifdef CONFIG_VM86 > + testl $X86_EFLAGS_VM, PT_EFLAGS(%esp) > + jnz .Lfrom_usermode_no_gap > +#endif > + testl $SEGMENT_RPL_MASK, PT_CS(%esp) > + jnz .Lfrom_usermode_no_gap > + .rept 6 > + pushl 5*4(%esp) > + .endr > +.Lfrom_usermode_no_gap: > + > SAVE_ALL switch_stacks=1 > ENCODE_FRAME_POINTER > TRACE_IRQS_OFF This failed to work on 32 bit at all (crashed and burned badly - triple fault!). Looking at it I found one issue. This code is done before the regs are saved, and PT_EFLAGS(%esp) and PT_CS(%esp) expect %esp to contain them. I applied this patch against this but it didn't totally fix the problems. It still constantly crashes (although, with this update I can put in some printks to get some ideas). I haven't spent too much time on it, but it looks like there's an issue with the entry-stack that int3 switches to. I'm not sure its handling the copy well. -- Steve diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 50bbf4035baf..4f427285e421 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -1479,10 +1479,10 @@ ENTRY(int3) pushl $-1 # mark this as an int #ifdef CONFIG_VM86 - testl $X86_EFLAGS_VM, PT_EFLAGS(%esp) + testl $X86_EFLAGS_VM, PT_EFLAGS-PT_ORIG_EAX(%esp) jnz .Lfrom_usermode_no_gap #endif - testl $SEGMENT_RPL_MASK, PT_CS(%esp) + testl $SEGMENT_RPL_MASK, PT_CS-PT_ORIG_EAX(%esp) jnz .Lfrom_usermode_no_gap .rept 6 pushl 5*4(%esp)