Received: by 10.223.185.116 with SMTP id b49csp2914323wrg; Mon, 5 Mar 2018 10:39:16 -0800 (PST) X-Google-Smtp-Source: AG47ELtAQBzG5PpKyuEebf9sN6/DVx8ws+biM6bLkGOR3EPJtkWQRaOkVJ5a89JpNXRc++6lCynZ X-Received: by 2002:a17:902:167:: with SMTP id 94-v6mr14147070plb.294.1520275156626; Mon, 05 Mar 2018 10:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520275156; cv=none; d=google.com; s=arc-20160816; b=jCVIwyGDKLXbFnei8kGvAyQB6pWMLtqEYKCyhHYPI5dRM1fnGVDH6MMW8gkGUcQsTG Opm+8v72tAdeeP45pUOyaTDp8m7shrqlpJcC1YhbTxLdLcmNgI9NJzCqlgAnuMOiQBTA 3NZ3kkP0sf1asOyKRjcbtd6LOMw6bkXL47g+ZjFjk6phXHvPTNmDk6PlT8TO28LOONRN ZNHWi9veN20/8wxgZQwXVH2cw+4N7loyVJU4u9ytzChprBlF9uCixvpdk89mcLl/jSyf PYWU2mjldUSmheZbD2CbDWifPkPjDa2Ks67K5jdv9SQlWGIbqfFTVA3kAVbHzmOqc5NF w80A== 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=2ic6XS+pXr5PPVVEjxOoFt+kkql0Sa2jTA5+W/8nhIM=; b=Q9LwlPCCPXcwCH9AkmuUd9SJXbuoCseOiiucV1CqHWBTgHDFD3SuAbA2bHwcRiS2KG kgfAGzabz2C/M83uwnL4Gs0ALU8w+dGJBYLfdZOnXTYEMovCAIm1jWNgrH/UiDDjeTnM dUKvGpPiKfx9wF1eFHu5C1lzNG/DAAYxkDdNgCY09AeXyeiPdRxC9/osorBn94PGgi2m yWHm5mMkWv05o1T2/rvDSRwGu1kqBGRtnBDxVaa7RnE9OamKpKGIiUGnE3E444cVKU4Q DXl8Td5NBuL2jyAkUp2G9u9dXZxUi4C5EiKYENBtDy54EU4vHjMZHLtqN/NriZLRSsD/ Yeaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=nbTfsFLT; 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 b6-v6si2604396plk.189.2018.03.05.10.39.02; Mon, 05 Mar 2018 10:39:16 -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=nbTfsFLT; 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 S1752676AbeCESgu (ORCPT + 99 others); Mon, 5 Mar 2018 13:36:50 -0500 Received: from 8bytes.org ([81.169.241.247]:38962 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751311AbeCESgt (ORCPT ); Mon, 5 Mar 2018 13:36:49 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id B7BE0D4; Mon, 5 Mar 2018 19:36:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1520275007; bh=AGWT4zSlZsaX9XJwqu/ZIu7wImTaX388OEKEwC7OSBM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nbTfsFLTeFjVnRkVJJVu1sCLys9IcGJKwdk/1A3XhVaUYPl7jTrUNpR9KABMCuMVl Hmfq0YoBbEjp6BhADhQ1DwRzXS2qDdjXf7WPh5eL8l277k22xUPjVEM0t4vhXT67Ld c9sVsaqYya/Aw0e5PSw2edGm7LWIf8jNPIDFCulOvW54jEiVO1aNSAk77cCKg+mmC6 KK2mmcMXkiymEdQsB5FmVMWyDo4Cv5gxgzSdsA/IWobMiPv94sWAVM6TuLUycdzu9B p8BzRLdRgT8mJXncnUcFAQ8s6ZSWRK4SzfF/f/icJxGhafYTqdNbon3QaQEtnmWTHN Czdeu2x0dX2NQ== Date: Mon, 5 Mar 2018 19:36:47 +0100 From: Joerg Roedel To: Linus Torvalds Cc: Thomas Gleixner , Ingo Molnar , Peter Anvin , the arch/x86 maintainers , Linux Kernel Mailing List , linux-mm , Andrew Lutomirski , Dave Hansen , Josh Poimboeuf , =?iso-8859-1?Q?J=FCrgen_Gro=DF?= , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg Kroah-Hartman , Will Deacon , "Liguori, Anthony" , Daniel Gruss , Hugh Dickins , Kees Cook , Andrea Arcangeli , Waiman Long , Pavel Machek , Joerg Roedel Subject: Re: [PATCH 07/34] x86/entry/32: Restore segments before int registers Message-ID: <20180305183647.GU16484@8bytes.org> References: <1520245563-8444-1-git-send-email-joro@8bytes.org> <1520245563-8444-8-git-send-email-joro@8bytes.org> <20180305131231.GR16484@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 On Mon, Mar 05, 2018 at 10:23:59AM -0800, Linus Torvalds wrote: > On Mon, Mar 5, 2018 at 5:12 AM, Joerg Roedel wrote: > > > >> The things is, we *know* that we will restore two segment registers with the > >> user cr3 already loaded: CS and SS get restored with the final iret. > > > > Yeah, I know, but the iret-exception path is fine because it will > > deliver a SIGILL and doesn't return to the faulting iret. > > That's not so much my worry, as just getting %cr3 wrong. The fact is, > we still take the exception, and we still have to handle it, and that > still needs to get the user<->kernel cr3 right. Right, as I said, up to v2 of this series I thought I could avoid the whole from-kernel-with-user-cr3 game, but that turned out to be wrong. Now I added the necessary check and handling for it, as at least the #DB handler needs it. > So then the whole "restore segments early" must be wrong, because > *that* path must get it all right too, no? > > And it appears that the code *does* get it right, and you can just > avoid this patch entirely? Right, I will drop this patch. > > > The iret-exception case is tested by the ldt_gdt selftest (the > > do_multicpu_tests subtest). But I didn't actually tested single-stepping > > through sysenter yet. I just re-ran the same tests I did with v2 on this > > patch-set. > > Ok. Maybe we should have a test for the "take DB on first instruction > of sysenter". I put a selftest for that on my list of things to look into. I'll have no idea how difficult this will be, but I certainly find out :) Regards, Joerg