From mboxrd@z Thu Jan 1 00:00:00 1970 From: Borislav Petkov Subject: Re: [PATCH v3 43/75] x86/sev-es: Setup per-cpu GHCBs for the runtime handler Date: Fri, 22 May 2020 10:33:21 +0200 Message-ID: <20200522083321.GA28750@zn.tnic> References: <20200428151725.31091-1-joro@8bytes.org> <20200428151725.31091-44-joro@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: <20200428151725.31091-44-joro@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 , Dave Hansen , Mike Stunes , Kees Cook , kvm@vger.kernel.org, Peter Zijlstra , Cfir Cohen , x86@kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel , Masami Hiramatsu , Andy Lutomirski , hpa@zytor.com, Erdem Aktas , David Rientjes , Dan Williams , Jiri Slaby List-Id: virtualization@lists.linuxfoundation.org On Tue, Apr 28, 2020 at 05:16:53PM +0200, Joerg Roedel wrote: > @@ -198,6 +210,48 @@ static bool __init sev_es_setup_ghcb(void) > return true; > } > > +static void __init sev_es_alloc_runtime_data(int cpu) > +{ > + struct sev_es_runtime_data *data; > + > + data = memblock_alloc(sizeof(*data), PAGE_SIZE); > + if (!data) > + panic("Can't allocate SEV-ES runtime data"); > + > + per_cpu(runtime_data, cpu) = data; > +} > + > +static void __init sev_es_init_ghcb(int cpu) Since those are static functions, I'd drop the "sev_es_" prefix from the name for better readability. Because otherwise the whole file is a sea of "sev_es_"-prefixed identifiers which you need to read until the end to know what they are. > +{ > + struct sev_es_runtime_data *data; > + int err; > + > + data = per_cpu(runtime_data, cpu); > + > + err = early_set_memory_decrypted((unsigned long)&data->ghcb_page, > + sizeof(data->ghcb_page)); > + if (err) > + panic("Can not map GHCBs unencrypted"); "Error mapping ..." > + > + memset(&data->ghcb_page, 0, sizeof(data->ghcb_page)); > +} -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette