Received: by 10.223.185.116 with SMTP id b49csp2793382wrg; Mon, 5 Mar 2018 08:46:18 -0800 (PST) X-Google-Smtp-Source: AG47ELu9kj19k8xnLt/iJMOQwx4FZlv9woA4W2ldakm4jaiqRTG2odRP+9KOuIdgY0QY6vx69pLq X-Received: by 10.101.66.136 with SMTP id j8mr12749514pgp.409.1520268378296; Mon, 05 Mar 2018 08:46:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520268378; cv=none; d=google.com; s=arc-20160816; b=u+cDk2aL5SYqAGOqhkFOI3rP7QUFfCtan/veE7gMTX/QO+qWCbIH1L3ES0EGMQv+B7 g8aJ5ioFE8wHNfhE5BDwGESgLS9qB/vfSe7haplvN4LYA6I4gkFYvhpMPyLNZgrP/NON 0c71wzeWKq53+DaA//cMrFOxc41OULHrnq7qBSJaM32YYgL960t2cxMUmCxZ15Ey6JHt 4U2csZUYd42oP4NgCJHEKJ8hGL3kjV5PPmciTsjOrtUlwO5gW3nfQenCfH+HbSNajuCE CNpPQVny057FrSf44n/lSJWCnq+AiSOVmMfBC+nz4uDupWtCLTau2duVYTTmtZUgEg6B d1Bg== 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=dhSSgF5pqqXrV4zYRkhOmgwj5jsT3zysbHVuXnpd2v4=; b=cUf/u0qW4viKJ/EvfBCRDGq/eALBp/Bz8tNCzxaRxteGUsUUR076YPaV2kQ5ZvGboI nIptn/oBFRspoQPcKGpUV3NF3uG7ZIoG9h4TGW8WFmsRQzzkAH9a6lspisMH5wtRB5Em k08956JDbRBZvAZaRgo4ErkEJrjnXtoA0vipVn42oK/f2vJ+Yj3tq3blcxYNyX0T5OPG 9EtoBH+/VbL/8o6eU3N/22YnnA4VQfT+HXbxrCbMmwwfaCGlPQCx+M1MaFXx+VOZesHC dx/TLWn3Kw8JCDLhzZ5nr28RLDnSaqq2wNw3Hx3+QBo/MNl/VD9RxFgRoX5SlsDWvqB/ zkKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=J5fH9eHF; 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 o24-v6si4503670pll.788.2018.03.05.08.46.03; Mon, 05 Mar 2018 08:46:18 -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=J5fH9eHF; 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 S1751893AbeCEQow (ORCPT + 99 others); Mon, 5 Mar 2018 11:44:52 -0500 Received: from 8bytes.org ([81.169.241.247]:38206 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751462AbeCEQou (ORCPT ); Mon, 5 Mar 2018 11:44:50 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 72FCAD4; Mon, 5 Mar 2018 17:44:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1520268288; bh=iMTOnaOz0y1sn2Ihowwq94QUL3ZYjvHj4EXu/RDNtVg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J5fH9eHFaHlGxWYDytlXov0s/Up/+0hP+QbMK56T9/jlbPfj99mKE70EvZ7adIFwc tewSUweq4rSKsefcRaY8WACrmKVbkGr/txj2lTE7OE/LlegcquH0urwB7LSgFbwCyI Dvu9jxe75UKmpYGZ3n6xRhvQW1pqRGNDtanImHK3Ncl5q9SW/wyj3K/UpRG12nUMW0 WsHOm8CFAEnu5coofj4tpBZUwbs0XikEhbTGQVFUlP+2lRePUA0G3rXtkvQMGCijVy HxuZhhwSHVw/7fV8wM+w6422DmaUMHZoHzvKvEfXptc0PVxJ1HQNC0M0AWMScLsmLz hrjVSdiguEFmQ== Date: Mon, 5 Mar 2018 17:44:48 +0100 From: Joerg Roedel To: Brian Gerst Cc: Linus Torvalds , 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 , 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: <20180305164448.GS16484@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 09:51:29AM -0500, Brian Gerst wrote: > For the IRET fault case you will still need to catch it in the > exception code. See the 64-bit code (.Lerror_bad_iret) for example. > For 32-bit, you could just expand that check to cover the whole exit > prologue after the CR3 switch, including the data segment loads. I had a look at the 64 bit code and the exception-in-kernel case seems to be handled differently than on 32 bit. The 64 bit entry code has checks for certain kinds of errors like iret exceptions. On 32 bit this is implemented via the standard exception tables which get an entry for every EIP that might fault (usually segment loading operations, but also iret). So, unless I am missing something, all the exception entry code has to do is to remember the stack and the cr3 with which it was entered (if entered from kernel mode) and restore those before iret. And this is what I implemented in v3 of this patch-set. Regards, Joerg