Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3820686ybt; Tue, 23 Jun 2020 11:30:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6sKZncxY+WAvExjVoqNXgKYA3sN/skjjG2SrTvKT3/0q8v3HOzhImBZbHbxQ8MEbroWQX X-Received: by 2002:aa7:d8c2:: with SMTP id k2mr13017690eds.346.1592937037174; Tue, 23 Jun 2020 11:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592937037; cv=none; d=google.com; s=arc-20160816; b=ti+5+pKxW2ZkhDthFT92nYczfNzllgGQKTqzJz4eAsS1Lv3I2TRB7ngBZmSsBPK8Fc VA4tpvhuw3GCb9MCKDW0ZU32oI9ysjkSkF1hg3EKW/VWhgPqHpZnS4E832pkB+aA7Wgv dEF8CUGTeZa2IdeuKHhtU7cUgQc3eY+dMrS/NtrkylRkgqJKDrTlXup9YySVwC/fZQDb hq7qPHqkfT9YgNl60jqSMX8X5Ut2Uf+KuB5fMsSraPsoShxvRidQsyqyIG0Y9M7a3qlu QGg7FBTJkmCBCJHXpWxzMyCrr1Hd+ZaMUEpoJHYBZoDOiWYeX5XAfj5QYE0kqCcerQvx vyog== 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=szmDzWgdXDU97NBLGA5wzFSwTDglYafVmQKSIJ1QXFw=; b=YaF8IKM8fzzci2S0BjurJaHP+6nTN3CHbT8V+SeegKcZfaUlFF1IXS3cUaqEx6X6t1 ivWH11Saz+ghLRSvUccRuprygyhu3G4KbHsBplqPRS6Sgq0EDNhsM6pHVaXixG02cvG3 NHzP0lNONTGp/T0x6x1xmnjc/rmVEz3WoXYu5paeMXhEo5HYeGUAigM6nymt9+LfNLqE lo8qU7vYtudG3DTSxtyumD2xWAuOkImNKvPxgwrDtNzvTYNbWAtHcPq9R/zbE1/rM4SV JjMYWHI+sLAUEzTH5hLFZ2unWbAnE6/DbwjIJN2fdN33jBkGnyc1q6pkRX7phpMvkFKQ mj6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=df8cmTqu; 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 n16si5085864edb.399.2020.06.23.11.30.13; Tue, 23 Jun 2020 11:30:37 -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=df8cmTqu; 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 S1733199AbgFWS1H (ORCPT + 99 others); Tue, 23 Jun 2020 14:27:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:58732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733125AbgFWS1H (ORCPT ); Tue, 23 Jun 2020 14:27:07 -0400 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 3C41420842 for ; Tue, 23 Jun 2020 18:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592936826; bh=e3u7eLEEiVgkvLGksxftLW9CJqkzsq+PZNCEuWyaMmA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=df8cmTqu/u475ksvRlgGMGspPrUZ1p4YlTLJWRWJf2sLid0Jg+1PK1r6nHm17M0Nf Cs9pG/JyzOOIt6yP8CVgR6gkIFrQyirjD0ndbYEKmArDq+iSaao360C3EcX7/d1YSM VHRwBaOLwVvpAT9hUlJJVXqo8l0Og1MbMtH/xeJ0= Received: by mail-wr1-f52.google.com with SMTP id v3so14077854wrc.1 for ; Tue, 23 Jun 2020 11:27:06 -0700 (PDT) X-Gm-Message-State: AOAM532PP9vms/7fwtNQMHYv+Cc9Mtmeyk9P0+BRnQFL450O5jIQ6740 UDnNiHV9Q68LAjZwjFyu/StwqatJEU2BBLSHhcyiaw== X-Received: by 2002:adf:e482:: with SMTP id i2mr2759106wrm.75.1592936824477; Tue, 23 Jun 2020 11:27:04 -0700 (PDT) MIME-Version: 1.0 References: <20200425202316.GL21900@8bytes.org> <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> <9e3f9b2a-505e-dfd7-c936-461227b4033e@citrix.com> In-Reply-To: <9e3f9b2a-505e-dfd7-c936-461227b4033e@citrix.com> From: Andy Lutomirski Date: Tue, 23 Jun 2020 11:26:52 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Should SEV-ES #VC use IST? (Re: [PATCH] Allow RDTSC and RDTSCP from userspace) To: Andrew Cooper Cc: Peter Zijlstra , Joerg Roedel , 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 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 Tue, Jun 23, 2020 at 8:23 AM Andrew Cooper wrote: > > On 23/06/2020 14:03, Peter Zijlstra wrote: > > On Tue, Jun 23, 2020 at 02:12:37PM +0200, Joerg Roedel wrote: > >> On Tue, Jun 23, 2020 at 01:50:14PM +0200, Peter Zijlstra wrote: > >>> If SNP is the sole reason #VC needs to be IST, then I'd strongly urge > >>> you to only make it IST if/when you try and make SNP happen, not before. > >> It is not the only reason, when ES guests gain debug register support > >> then #VC also needs to be IST, because #DB can be promoted into #VC > >> then, and as #DB is IST for a reason, #VC needs to be too. > > Didn't I read somewhere that that is only so for Rome/Naples but not for > > the later chips (Milan) which have #DB pass-through? > > I don't know about hardware timelines, but some future part can now opt > in to having debug registers as part of the encrypted state, and swapped > by VMExit, which would make debug facilities generally usable, and > supposedly safe to the #DB infinite loop issues, at which point the > hypervisor need not intercept #DB for safety reasons. > > Its worth nothing that on current parts, the hypervisor can set up debug > facilities on behalf of the guest (or behind its back) as the DR state > is unencrypted, but that attempting to intercept #DB will redirect to > #VC inside the guest and cause fun. (Also spare a thought for 32bit > kernels which have to cope with userspace singlestepping the SYSENTER > path with every #DB turning into #VC.) What do you mean 32-bit? 64-bit kernels have exactly the same problem. At least the stack is okay, though. Anyway, since I'm way behind on this thread, here are some thoughts: First, I plan to implement actual precise recursion detection for the IST stacks. We'll be able to reliably panic when unallowed recursion happens. Second, I don't object *that* strongly to switching to a second #VC stack if an NMI or MCE happens, but we really need to make sure we cover *all* the bases. And #VC is distressingly close to "happens at all kinds of unfortunate times and the guest doesn't actually have much ability to predice it" right now. So we have #VC + #DB + #VC, #VC + NMI + #VC, #VC + MCE + #VC, and even worse options. So doing the shift in a reliable way is not necessarily possible in a clean way. Let me contemplate. And maybe produce some code soon.