Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1206047ybz; Sat, 25 Apr 2020 13:26:03 -0700 (PDT) X-Google-Smtp-Source: APiQypKyLsDTCF6I6nJ0aBcZGvnCHjY8YzUdy5UAWfqNdliOCFdJfVV7ZWJko0mQ6dtd72+Yk970 X-Received: by 2002:a17:906:cf8a:: with SMTP id um10mr12606818ejb.60.1587846363127; Sat, 25 Apr 2020 13:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587846363; cv=none; d=google.com; s=arc-20160816; b=rw1JU1A9KUgZFTqFV8dtQZgtPJuSE6X3YUA6cv0SsC0guvVjqdZGE+HNRm4iJudK16 eeEcnWiE/Sd/gMOohDLVknE2tzof2PFMYZ9JmJA+Tk3Z2TqxIv0sOq5IHYkNbdx4L1za s68k/8oXILELpgfTQkWIiw6qfYMaryzW89KeS4XhWBQ2KsdpNNmtLrXNxemoFdb38NxJ 0lvL6DR0qsu7ChpmMyUDNMy/O3TizRZCZ2ulrEF6bah9d+xf3CkiCrAbSX87pLkIFqKF LQjjcisxFbLnrYW066/363+n3M+5OUK4QGJBZQ7zjKJWmY2XamIKp45SpOJcP7KFrRc7 51PA== 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; bh=IoY5hFnmjisTdtwp/7GQGNCMqp5LIazpRK5eJZXMgsw=; b=U3L1U2JRyl++gz0nZfFYrR5EevBfWXhgc/PKbnsMYXVskOXMOfHAAL4uVAGYhKmE2l /kVt9NFz53bCOrLAoPsDj82zcrb0IHfuJcSPc8CUJTpBVdJZQ7U+AY1NxK0RYkSM3E7U rnqpoBzxjnDbAyzcI8Km/TaOztoqibGEilAfOEeecg6oxL+p2JbNk5r+ElOigkAEvWgU M1eBR7Q04Nq+0/BesFOVOLEocxhvP7KLZAokHh2Tn53FlIhzuEa4L3qvBjE6eq2Fgywf nOGk0ppCTPWfUdr/9mRiFo2ej0jdL6134MYRSpgh++s33l1gVBtGSxeuSLS6KxO3dq5A EArg== 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=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v28si248837edd.176.2020.04.25.13.25.39; Sat, 25 Apr 2020 13:26: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=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbgDYUXT (ORCPT + 99 others); Sat, 25 Apr 2020 16:23:19 -0400 Received: from 8bytes.org ([81.169.241.247]:37050 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726190AbgDYUXT (ORCPT ); Sat, 25 Apr 2020 16:23:19 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id D1C8E433; Sat, 25 Apr 2020 22:23:17 +0200 (CEST) Date: Sat, 25 Apr 2020 22:23:16 +0200 From: Joerg Roedel To: Andy Lutomirski 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 , Peter Zijlstra , Thomas Hellstrom , Linux Virtualization , X86 ML , Sean Christopherson Subject: Re: [PATCH] Allow RDTSC and RDTSCP from userspace Message-ID: <20200425202316.GL21900@8bytes.org> References: <20200425191032.GK21900@8bytes.org> <910AE5B4-4522-4133-99F7-64850181FBF9@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <910AE5B4-4522-4133-99F7-64850181FBF9@amacapital.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 25, 2020 at 12:47:31PM -0700, Andy Lutomirski wrote: > I assume the race you mean is: > > #VC > Immediate NMI before IST gets shifted > #VC > > Kaboom. > > How are you dealing with this? Ultimately, I think that NMI will need > to turn off IST before engaging in any funny business. Let me ponder > this a bit. Right, I dealt with that by unconditionally shifting/unshifting the #VC IST entry in do_nmi() (thanks to Davin Kaplan for the idea). It might cause one of the IST stacks to be unused during nesting, but that is fine. The stack memory for #VC is only allocated when SEV-ES is active (in an SEV-ES VM). Regards, Joerg