Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3683324ybt; Tue, 23 Jun 2020 08:18:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAIkue1rHQzSNivmUbV1VLHj9GRMwuHP7+D6lRxIj0+HY/Hs8EbfQFvhhuuZOZ+ZoDhpFM X-Received: by 2002:a17:906:7fc8:: with SMTP id r8mr11909325ejs.412.1592925538621; Tue, 23 Jun 2020 08:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592925538; cv=none; d=google.com; s=arc-20160816; b=mexrGiK2PHm+IJeZ+6wNDkjReIQqB6YAe+vSn9Z6KzyuWLriC8x3vSqOIugQJudGol hdLqMdJjevHGhA5pwbuBjqLZnGvCrxXywvklAs5Bq3SY4JAYYCOC9v6pCs3P/vfZY9Al C20SVH8ffPu2tKhcehl9OZKhCR7FQu33zxrXxRvptWLkCA8YI8R3WzbR8TbWCWPkzfW+ F9pZJ1MecKh5ikjGCH0jL2t7ww6BvTmtRyMfvnKkQu8k3mgBeyjyrhNP7CYUNhNXc0AN zJ+w8XOV+8Wgwt0HEcDCF+2Sy5531q82o/J3onyudRdNEK/3VQgPkVYYkYw/EY9MzeyJ SKqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Id637uzu2oPJgbSFSrub5lvl6io8BJJDeJLsBbUH3no=; b=btRy5j867fdKJrFcb4Th2k9T7h+tqb7CoPo0w3EnWEYWBRsSreZvnfwBkAG+gJYxk2 j0gc5+A0LCxVcFQ7jzlfjB2R4bn0f1QlFTp06yvJSZdXMbEmePUvL5DhXQOgC4Byjm4z 1UuCoMXZBth+kTG2y29IiOiV55vIMsqg9SZLi87dz+OsB4xHllhyk06I1Jsrqo9XabNS 7BRYrm+0mOqrn/ISG2oUxwWAcs1abtyIYy3m3S3rTytAvPEIdcg8i/wdU6UPynsp4+ID LiF9GQiMIvqbHTPyJzKnoXbdjZecXjZ+DxlCbudVB8Qgzws+xHBX3/sqkxv+m8zwwObM pndg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=bi0ePU5G; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si11414172eja.574.2020.06.23.08.18.33; Tue, 23 Jun 2020 08:18:58 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=bi0ePU5G; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732934AbgFWPQm (ORCPT + 99 others); Tue, 23 Jun 2020 11:16:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732781AbgFWPQm (ORCPT ); Tue, 23 Jun 2020 11:16:42 -0400 Received: from merlin.infradead.org (unknown [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE227C061755; Tue, 23 Jun 2020 08:16:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Id637uzu2oPJgbSFSrub5lvl6io8BJJDeJLsBbUH3no=; b=bi0ePU5G654k+t0TAm058MHXSd lCqyZOcX6Qodx8rJdBmSj5AAhpyDPz+bOg/LKlMIsTlUsu+PJHSPm5Mwmerm0dt8rhY73XDELOD7f d8s7S6cD8f5p7SHCUnRySBYP5y+C7I9jt3OS5qDNJ8bdyBie87xD3Iko98kPmp41cLlhSCJthd8St GOevS0VrCJIo1gPBKZjIRzYTt4Wv8PU24Svlrfeq2keb1a0vIWIZVi9UtKG2v/QFkvFUXhhY8oui/ gNdfuq+INIKSQfVl6/C4GkEz+FrA9nGYvpJCcXM3WTqlwZYpOK0SiaYA2a5rM96hUuvkJikGeEmV4 0Hksg6bQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jnkeg-0001Bn-C8; Tue, 23 Jun 2020 15:16:10 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 9979230477A; Tue, 23 Jun 2020 17:16:07 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8DE24234EBA61; Tue, 23 Jun 2020 17:16:07 +0200 (CEST) Date: Tue, 23 Jun 2020 17:16:07 +0200 From: Peter Zijlstra To: 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 , Andrew Cooper Subject: Re: Should SEV-ES #VC use IST? (Re: [PATCH] Allow RDTSC and RDTSCP from userspace) Message-ID: <20200623151607.GJ4817@hirez.programming.kicks-ass.net> References: <20200623094519.GF31822@suse.de> <20200623104559.GA4817@hirez.programming.kicks-ass.net> <20200623111107.GG31822@suse.de> <20200623111443.GC4817@hirez.programming.kicks-ass.net> <20200623114324.GA14101@suse.de> <20200623115014.GE4817@hirez.programming.kicks-ass.net> <20200623121237.GC14101@suse.de> <20200623130322.GH4817@hirez.programming.kicks-ass.net> <20200623144940.GE14101@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200623144940.GE14101@suse.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 23, 2020 at 04:49:40PM +0200, Joerg Roedel wrote: > > We're talking about the 3rd case where the only reason things 'work' is > > because we'll have to panic(): > > > > - #MC > > Okay, #MC is special and can only be handled on a best-effort basis, as > #MC could happen anytime, also while already executing the #MC handler. I think the hardware has a MCE-mask bit somewhere. Flaky though because clearing it isn't 'atomic' with IRET, so there's a 'funny' window. It also interacts really bad with the NMI handler. If we get an #MC early in the NMI, where we hard-rely on the NMI-mask being set to set-up the recursion stack, then the #MC IRET will clear the NMI-mask, and we're toast. Andy has wild and crazy ideas, but I don't think we need more crazy here. #VC SNP has a similar problem vs NMI, that needs to die() irrespective of the #VC IST recursion. > > - #DB with BUS LOCK DEBUG EXCEPTION > > If I understand the problem correctly, this can be solved by moving off > the IST stack to the current task stack in the #DB handler, like I plan > to do for #VC, no? Hmm, probably. Would take a bit of care, but should be doable. > > - #VC SNP > > This has to panic for other reasons that can't be worked around. It > boils down to detecting that the HV is doing something fishy and bail > out to avoid further harm (like in the #MC handler). Right, but it doesn't take away that IST-any-time vectors are fundamentally screwy. Both the MCE and NMI have masks that are, as per the above, differently funny, but the other ISTs do not. Also, even if they had masks, the interaction between them is still screwy. #VC would've been so much better if it would've had a mask bit somewhere, then at least we could've had the exception entry covered. Another #VC with the mask set should probably result in #DF or Shutdown, but that's all water under the bridge I suspect.