Received: by 10.223.185.116 with SMTP id b49csp3750424wrg; Tue, 6 Mar 2018 04:28:19 -0800 (PST) X-Google-Smtp-Source: AG47ELtOix7yyoLNmqYt42mzmfa1oFEyaP8DTkoc2hB2XQNkRXVVvHJcNIfr858FIuJgLP01rUQ9 X-Received: by 10.99.117.24 with SMTP id q24mr14836535pgc.53.1520339299614; Tue, 06 Mar 2018 04:28:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520339299; cv=none; d=google.com; s=arc-20160816; b=I1RoqP/kjS7jPAB31LQqwqTzd6NgVNlZTbdKfiUcKyfNtL4NaD8V2JTdj9oyax893j 9Fp9aEvu+JSPaYMgNOhSEfOAc3i5+pIXqbwGFBfyQhrKOWFQjGInLog6c6BZUIAkLAuD N0PEQ3bn8tO3kHzf2eXNkBLb/NoBQZFS5Mp50bm05b5S31nOJPzBuiCqik6mBMOAzQME JwlTzEXl9Z+MRzTEeew0bSisDbC5PFkQNjXEf8/bB2/eeDOKlCLkodvQ9VSToBIc9M2k lVBw6gu6V7/+EB3KpzcrtXM74Rljgfy+c4pDw2JE1JV7eHfjwC4s1T1mA6Gfah9XR3OQ N74Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=gAUgk5GTvx/QzLj6PGcqNbDBun/2G/+8uRjTGFPiius=; b=JZrOYHpmUWnQ8+TP+QUSWGMRqIqJjPoFKdubnbLFFcM71h6mKnGn8ApPAf8I2fRSGD Tq5UU+jlDUb1tMYZEXuxDAb2K+8Vt0hLo31MbJ0BW2scOKh3ZHsZ4WJ/RawMjpW9SXpA eIZtJyOzkvo1hjYhB0mhiJ2zgKopkAEdq1RNClHTssvq9rnDyO6e7ErhH/XuPMIeExB+ ksoEzxTH7DTm3tnmuW8zTUJ2xxamBpjgO6NFJDDpRbDM0f8ZwKkwh8QcEgBp+u/sFNgx wDo/PeqoHQu7RneHMIXNbh2Yby6B0OYwiJqHhrF3vRDm/VG4KXo13oLgLwhb+xR2Nj+O +fMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=Tqaq9a4d; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 13-v6si11102710plb.515.2018.03.06.04.28.05; Tue, 06 Mar 2018 04:28:19 -0800 (PST) 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=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=Tqaq9a4d; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753709AbeCFM1H (ORCPT + 99 others); Tue, 6 Mar 2018 07:27:07 -0500 Received: from 8bytes.org ([81.169.241.247]:59774 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753385AbeCFM1F (ORCPT ); Tue, 6 Mar 2018 07:27:05 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id AC70230C; Tue, 6 Mar 2018 13:27:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1520339221; bh=CDHl/Bi0FHPbbxXnvtGpdAd+1W3hY1ojN94/bQySts8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Tqaq9a4dNow2usulXebdBH6mH7eXVLvwQAZEgEDhzJgAewEuCT+cXm+mbbEV1nCRS D6tjNSZECGhpG5XPVd3Vo36M+u7x2xVAl63MyvlYjwx+Q/14Bvh6qpsOsUiH4b/ba7 KdayiCtb4bw3HdmBRXRl6Iw3uGjjKktSIwuXul8z1hP+ocdnANRfM4A4q1C/KDiU1d Aw5rBtRuhAUGUXJoaiI7BXdd3kE5DSPQhiL5g2EYyD9p7E6bermCsfJRNcxGV5QBot vipaNLAHnT1JXhJc6kz7Eq8RHZWxVk1rcJy+2cDjJoRIaNYr03lIhERSDVSN7RXmg2 9BccqWtdhKxyg== Date: Tue, 6 Mar 2018 13:27:01 +0100 From: Joerg Roedel To: Brian Gerst Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , the arch/x86 maintainers , Linux Kernel Mailing List , Linux-MM , Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , "Liguori, Anthony" , Daniel Gruss , Hugh Dickins , Kees Cook , Andrea Arcangeli , Waiman Long , Pavel Machek , Joerg Roedel Subject: Re: [PATCH 11/34] x86/entry/32: Handle Entry from Kernel-Mode on Entry-Stack Message-ID: <20180306122701.GX16484@8bytes.org> References: <1520245563-8444-1-git-send-email-joro@8bytes.org> <1520245563-8444-12-git-send-email-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Brian, On Mon, Mar 05, 2018 at 11:41:01AM -0500, Brian Gerst wrote: > We can keep the same process as the existing debug/NMI handlers - > leave the current exception pt_regs on the entry stack and just switch > to the task stack for the call to the handler. Then switch back to > the entry stack and continue. No copying needed. I looked into this and things are a bit more complicated than in the NMI and debug handlers. The current code after pt_regs is set up relies on %esp pointing to the pt_regs structure. But if pt_regs could be on another stack we need to carry the pt_regs pointer in another register through the whole ret_from_exception code-path until we actually switch back the stack. Since the code-path is used for all stack/cr3 entry/exit cases we need to setup the extra pt_regs pointer unconditionally and update all places that reference it through %esp. It can certainly be done but it looks like another major surgery in the entry code to optimize a slow-path for handling unlikely segment-loading exceptions and debug traps. I am not sure if it's worth it. Regards, Joerg