Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1275499ybz; Sat, 25 Apr 2020 15:12:57 -0700 (PDT) X-Google-Smtp-Source: APiQypLWEoIHWVeyX3OfgfHcg9Kk2IABTieIi8Sg2lF1Jz0B7MjpbrPx9NXsMVI2/LeQKeHch6js X-Received: by 2002:a05:6402:19b0:: with SMTP id o16mr12920222edz.162.1587852777236; Sat, 25 Apr 2020 15:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587852777; cv=none; d=google.com; s=arc-20160816; b=RMV3ds8+N4kZfVyBI/VKJC/XfbHsq4Byw/o3hiKrzQGqlknqfayz2ubGoXhNTNbHy4 +dyJ++i6ZBTMYSSd+6QAP1qnLGd/ukUdCEl1og3kiBeK2JewXB/OqTxDV/WiOznuTLAg VWXhvqUc6SaXGwzrAyjLXcBm19FVrCJiFFrgMZM3mD9Xj2dSEdhtczH8QswHuRN28X7G 4V9eUh7Kp9ReIAjE7RtW9Hfvwsl4ba92+mcamOcg87QErGDgvmwCD7b+/VPvZ/Nl57nB +nXZdNwu3ry6+XX10eDZbntE5j1rgs6BHXciqGLE+2tetcnXdYfL/SIQIERdl0zO6SY9 vH1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hYi+9yBX2vUbQ5AMY9RcdlcgwEHMLg0KE/cUCgDeGw0=; b=CxcSocaRBBQOUXTjUX9WFtHJeomGiInvOOCdapyeQrv9tZ7bYHth7seHWbmxTNk7Py 0oMLGiXgQum/hLjS4kR45rKQf6cIhXBT5r2c/zqxgKsLG61468/CghhdGFo8K3eRKxQm M4ufRcJqjXRsWQyg00sfJXvSbO50tIkdQz58DT1jqgF7Vmxdixc0LGTEcGcEtrNgQhk5 GCrVLigYce8/VFhhEBgxtYfD9uBDpd1J8wLvuKQkutTKyg1f4gRlD5iqpJZ+xXxgXqDw nf7xprbssx17XhdTrIOunzwyNexU8udwTMfTs/ElbRDfFw/V6LWrDB1Qm/rvzoEOE+TR b5cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VQq6Mz7s; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si4879051edq.430.2020.04.25.15.12.34; Sat, 25 Apr 2020 15:12:57 -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=pass header.i=@kernel.org header.s=default header.b=VQq6Mz7s; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726348AbgDYWKn (ORCPT + 99 others); Sat, 25 Apr 2020 18:10:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:60998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbgDYWKn (ORCPT ); Sat, 25 Apr 2020 18:10:43 -0400 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A1FBE21707 for ; Sat, 25 Apr 2020 22:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587852642; bh=xuqmIzDpOCho8iZFxLKt+Gkxw+5vPYAZTLSjtItPycU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VQq6Mz7smcr3zNIcC9pKupyHyFvsFY8q4jW93o4Pvp61DKtny6S1PN1CVtESTMt1x 0YOy/VXa+OfZBvFpSU6eteA54tRtaoUDqUeg9gPjIMkG43XV6c3n6wN2gXYsQk4uLU CqnubEshLb3LjDTEOxBI+/8+ibDs0pY1ir/VgnPY= Received: by mail-wr1-f46.google.com with SMTP id f13so15920628wrm.13 for ; Sat, 25 Apr 2020 15:10:42 -0700 (PDT) X-Gm-Message-State: AGi0PuYcua7VEg9rcGXJ/C5ppVCICWLpMtU3chXTDhdzI9NqFGnqk/u2 A8uBFPi19ZFVzCe948vnStP/brnxlTwvP4BFEBlKPA== X-Received: by 2002:a5d:62cc:: with SMTP id o12mr18433808wrv.75.1587852641044; Sat, 25 Apr 2020 15:10:41 -0700 (PDT) MIME-Version: 1.0 References: <20200425191032.GK21900@8bytes.org> <910AE5B4-4522-4133-99F7-64850181FBF9@amacapital.net> <20200425202316.GL21900@8bytes.org> In-Reply-To: <20200425202316.GL21900@8bytes.org> From: Andy Lutomirski Date: Sat, 25 Apr 2020 15:10:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] Allow RDTSC and RDTSCP from userspace 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 , Peter Zijlstra , Thomas Hellstrom , Linux Virtualization , X86 ML , Sean Christopherson Content-Type: text/plain; charset="UTF-8" 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 1:23 PM Joerg Roedel wrote: > > 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). Blech. It probably works, but still, yuck. It's a bit sad that we seem to be growing more and more poorly designed happens-anywhere exception types at an alarming rate. We seem to have #NM, #MC, #VC, #HV, and #DB. This doesn't really scale. --Andy