Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3700020ybt; Tue, 23 Jun 2020 08:42:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH6MOQKtyGibGJTCu2aYq87zuTp6rf2pPzlTCCnfKvwAFRT38HhPT45JvwfDE0zxtslyIG X-Received: by 2002:aa7:c81a:: with SMTP id a26mr23390993edt.353.1592926923452; Tue, 23 Jun 2020 08:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592926923; cv=none; d=google.com; s=arc-20160816; b=sKcjZqcUzXYghNO6R2IarGm5DvOSZwMUa+dkExbVeY/gJVQ1oIMY61Z8kOt9iNtReH RY9wWXrvs11y3D+S5Go86HdKr7Z03ih4N83SDZCOto7txLCoo/BrY5lcmMRIq/BB3zaF 2l/0pe5hLVfLEuHfdr9lfK6RuBxwzDIrepaXFxYxZzzr8Sk35I4Zb0Bm7HJl5GZvmaN1 z5lLqyxo74Db7/rxzeHY4hm7y8MPp74X6dxpr0WSNXSzj/bFoHUleowwd29lngTPU1Ex JC2syUbUV0V2Ln4TLwLIL5jyJ/YQ2UL5qOKOgrVCzW9JBvjTBt/ZOeE7Yvax7CQzUptO dnHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr; bh=z0yf+Ufk4APMp2NeDJgiw7/eRjDPbsour42La9Ij2oY=; b=gFA8HaTJSM5GY2bRQnFnSesermz1aXcqP7koTAE/OrdIt+tx7pm4nX9UB+1MbGILJ/ VkMMYEdBcoRqKKWwB2bgNvlR5sHr7S8MkHqVcogEpdfkInzjo7Db3j93c4iv607o18k1 71RAaX5OEDqWwCgVKnxtR3Rz2gcUYCSWb0WKWCYNxwMwPHSBGRqTTvEtyNaynpV5ooAB L+yiGfSTrQkU8ywPj3jbrEEQUQMtG+ymQjruoRqAIdYTx5sHQ/LXw+E9LtDb6t/AbaCS xMMNMc84j8EHCfV5+qypMKn5W9rd1HrOLfaBust/eQ+n1Lds/VyMBlBD+k2wZAQ0vFm/ 2jXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=citrix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m23si780921ejd.62.2020.06.23.08.41.40; Tue, 23 Jun 2020 08:42:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=citrix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733044AbgFWPjd (ORCPT + 99 others); Tue, 23 Jun 2020 11:39:33 -0400 Received: from esa1.hc3370-68.iphmx.com ([216.71.145.142]:56281 "EHLO esa1.hc3370-68.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732978AbgFWPjc (ORCPT ); Tue, 23 Jun 2020 11:39:32 -0400 Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: eiqxVBWKC88b1iIh5nTj/f7V8Jh2ethNUebZFkujWdRGxn9kUdey47KybRdBPzpPU3UaTmRUbu hhEzIKGB0mKgn/ZmC+NiJ8ZJHLfOksnJ/vSslBnIPYj9seYdLRSUz7dZQO5BZc0yl6bA4IjueI bn/dF7MfxrIDT5AJWZamzmm2rM+4+z+TgKWNEpAvbpz8sL4gjqSGcJ87E0t/npmOhY35o2I+VS bM3rkhL4sTcknZFOm6T2ilmQIhGnWQVAsmrT/yXfdhHaHKXse6ioUbmCYLyCKwuA42B/Hhy1WM Epo= X-SBRS: 2.7 X-MesageID: 21039380 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,271,1589256000"; d="scan'208";a="21039380" Subject: Re: Should SEV-ES #VC use IST? (Re: [PATCH] Allow RDTSC and RDTSCP from userspace) To: Peter Zijlstra , Joerg Roedel CC: Andy Lutomirski , Joerg Roedel , "Dave Hansen" , Tom Lendacky , "Mike Stunes" , Dan Williams , "Dave Hansen" , "H. Peter Anvin" , Juergen Gross , Jiri Slaby , Kees Cook , kvm list , LKML , Thomas Hellstrom , Linux Virtualization , X86 ML , Sean Christopherson References: <20200428075512.GP30814@suse.de> <20200623110706.GB4817@hirez.programming.kicks-ass.net> <20200623113007.GH31822@suse.de> <20200623114818.GD4817@hirez.programming.kicks-ass.net> <20200623120433.GB14101@suse.de> <20200623125201.GG4817@hirez.programming.kicks-ass.net> <20200623134003.GD14101@suse.de> <20200623135916.GI4817@hirez.programming.kicks-ass.net> <20200623145344.GA117543@hirez.programming.kicks-ass.net> <20200623145914.GF14101@suse.de> <20200623152326.GL4817@hirez.programming.kicks-ass.net> From: Andrew Cooper Message-ID: <56af2f70-a1c6-aa64-006e-23f2f3880887@citrix.com> Date: Tue, 23 Jun 2020 16:39:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200623152326.GL4817@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS01.citrite.net (10.69.22.112) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/06/2020 16:23, Peter Zijlstra wrote: > On Tue, Jun 23, 2020 at 04:59:14PM +0200, Joerg Roedel wrote: >> On Tue, Jun 23, 2020 at 04:53:44PM +0200, Peter Zijlstra wrote: >>> +noinstr void idtentry_validate_ist(struct pt_regs *regs) >>> +{ >>> + if ((regs->sp & ~(EXCEPTION_STKSZ-1)) == >>> + (_RET_IP_ & ~(EXCEPTION_STKSZ-1))) >>> + die("IST stack recursion", regs, 0); >>> +} >> Yes, this is a start, it doesn't cover the case where the NMI stack is >> in-between, so I think you need to walk down regs->sp too. > That shouldn't be possible with the current code, I think. NMI; #MC; Anything which IRET but isn't fatal - #DB, or #BP from patching, #GP from *_safe(), etc; NMI Sure its a corner case, but did you hear that IST is evil? ~Andrew P.S. did you also hear that with Rowhammer, userspace has a nonzero quantity of control over generating #MC, depending on how ECC is configured on the platform.