From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936821AbdJQQXO (ORCPT ); Tue, 17 Oct 2017 12:23:14 -0400 Received: from mail.skyhub.de ([5.9.137.197]:51760 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933143AbdJQQXM (ORCPT ); Tue, 17 Oct 2017 12:23:12 -0400 Date: Tue, 17 Oct 2017 18:23:04 +0200 From: Borislav Petkov To: Brijesh Singh , Paolo Bonzini Cc: x86@kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Radim =?utf-8?B?S3LEjW3DocWZ?= , Tom Lendacky , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [Part1 PATCH v6 16/17] X86/KVM: Decrypt shared per-cpu variables when SEV is active Message-ID: <20171017162303.4vekeemfz7ix2cjg@pd.tnic> References: <20171016153423.2980-1-brijesh.singh@amd.com> <20171016153423.2980-17-brijesh.singh@amd.com> <20171016222416.x26tp222x2ox3tkz@pd.tnic> <20171017082020.ctgjuo4xcvsaitdf@pd.tnic> <57ef6c36-1708-56f2-b0ac-ea2267f6aa9d@amd.com> <20171017133555.de4omyuoveaijkk6@pd.tnic> <35973f2a-664e-97e8-3dba-00db5f8d9719@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <35973f2a-664e-97e8-3dba-00db5f8d9719@amd.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 17, 2017 at 10:42:45AM -0500, Brijesh Singh wrote: > OK, this goes back to your initial feedback during RFC v3 where I tried > to do similar thing. But since sev_map_percpu_data() uses __init > functions hence we need to mark the kvm_guest_cpu_init() as __ref but > you didn't like the idea and asked me to call the sev_map_percpu_data > from kvm_smp_prepare_boot_cpu() which is already __init. So looking at this more, I'm wondering how did I miss this: this whole SEV code doesn't belong in kvm.c but in svm.c! This is AMD-only and should be there. Now, for that you need those three percpu variables to not be static but I think we can do this by adding their declarations to a kvm-internal.h header which is in arch/x86/kernel/kvm-internal.h, i.e., not in the include path and only kvm-related units can include it. @Paolo: thoughts? Then, you can call sev_map_percpu_data() during module init, i.e., svm_init(). Or in one of the init functions you're adding later, sev_hardware_setup() for example, or so. I.e., one of those init paths. Because, AFAICT, you want to clear the physical C-bit only once in the percpu pages. I think this is much better than the "grafted" situation now. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.