From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: [PATCH 18/70] x86/boot/compressed/64: Add stage1 #VC handler Date: Fri, 20 Mar 2020 23:19:23 +0100 Message-ID: <20200320221923.GL5122@8bytes.org> References: <20200319091407.1481-1-joro@8bytes.org> <20200319091407.1481-19-joro@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: David Rientjes Cc: erdemaktas@google.com, x86@kernel.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel List-Id: virtualization@lists.linuxfoundation.org On Fri, Mar 20, 2020 at 02:16:39PM -0700, David Rientjes wrote: > On Thu, 19 Mar 2020, Joerg Roedel wrote: > > +#define GHCB_SEV_GHCB_RESP_CODE(v) ((v) & 0xfff) > > +#define VMGEXIT() { asm volatile("rep; vmmcall\n\r"); } > > Since preemption and irqs should be disabled before updating the GHCB and > its MSR and until the contents have been accessed following VMGEXIT, > should there be checks in place to ensure that's always the case? Good point, some checking is certainly helpful. Currently it is the case, because the GHCB is accessed and used only: 1) At boot when only the boot CPU is running 2) In the #VC handler, which does not enable interrupts 3) In the NMI handler, which is also not preemptible I can also add code to sev_es_get/put_ghcb to make sure these conditions are met. All this does not prevent the preemption by NMIs, which could cause another nested #VC exception, but that is handled separatly. Regards, Joerg