From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sean Christopherson Subject: Re: [PATCH v3 47/75] x86/sev-es: Add Runtime #VC Exception Handler Date: Thu, 11 Jun 2020 10:38:48 -0700 Message-ID: <20200611173848.GK29918@linux.intel.com> References: <20200428151725.31091-1-joro@8bytes.org> <20200428151725.31091-48-joro@8bytes.org> <20200523075924.GB27431@zn.tnic> <20200611114831.GA11924@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20200611114831.GA11924@8bytes.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" To: Joerg Roedel Cc: Juergen Gross , Tom Lendacky , Thomas Hellstrom , x86@kernel.org, Mike Stunes , Kees Cook , kvm@vger.kernel.org, Peter Zijlstra , Cfir Cohen , Dave Hansen , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel , Borislav Petkov , Masami Hiramatsu , Andy Lutomirski , hpa@zytor.com, Erdem Aktas , David Rientjes , Dan Williams , Jiri Slaby List-Id: virtualization@lists.linuxfoundation.org On Thu, Jun 11, 2020 at 01:48:31PM +0200, Joerg Roedel wrote: > On Sat, May 23, 2020 at 09:59:24AM +0200, Borislav Petkov wrote: > > On Tue, Apr 28, 2020 at 05:16:57PM +0200, Joerg Roedel wrote: > > > + /* > > > + * Mark the per-cpu GHCBs as in-use to detect nested #VC exceptions. > > > + * There is no need for it to be atomic, because nothing is written to > > > + * the GHCB between the read and the write of ghcb_active. So it is safe > > > + * to use it when a nested #VC exception happens before the write. > > > + */ > > > > Looks liks that is that text... support for nested #VC exceptions. > > I'm sure this has come up already but why do we even want to support > > nested #VCs? IOW, can we do without them first or are they absolutely > > necessary? > > > > I'm guessing VC exceptions inside the VC handler but what are the > > sensible use cases? > > The most important use-case is #VC->NMI->#VC. When an NMI hits while the > #VC handler uses the GHCB and the NMI handler causes another #VC, then > the contents of the GHCB needs to be backed up, so that it doesn't > destroy the GHCB contents of the first #VC handling path. Isn't it possible for the #VC handler to hit a #PF, e.g. on copy_from_user() in insn_fetch_from_user()? If that happens, what prevents the #PF handler from hitting a #VC? AIUI, do_vmm_communication() panics if the backup GHCB is already in use, e.g. #VC->#PF->#VC->NMI->#VC would be fatal.