From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751909AbdKHJx6 (ORCPT ); Wed, 8 Nov 2017 04:53:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34520 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751658AbdKHJxz (ORCPT ); Wed, 8 Nov 2017 04:53:55 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EEF9F7E383 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH 2/3] x86: add guest_late_init hook to hypervisor_x86 structure To: Juergen Gross , linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, boris.ostrovsky@oracle.com, rkrcmar@redhat.com, rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz References: <20171108090739.26491-1-jgross@suse.com> <20171108090739.26491-3-jgross@suse.com> From: Paolo Bonzini Message-ID: Date: Wed, 8 Nov 2017 10:53:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171108090739.26491-3-jgross@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 08 Nov 2017 09:53:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/11/2017 10:07, Juergen Gross wrote: > Add a new guest_late_init hook to the hypervisor_x86 structure. It > will replace the current kvm_guest_init() call which is changed to > make use of the new hook. > > Signed-off-by: Juergen Gross The trivial KVM changes are of course Acked-by: Paolo Bonzini Paolo > --- > arch/x86/include/asm/hypervisor.h | 11 +++++++++++ > arch/x86/include/asm/kvm_para.h | 2 -- > arch/x86/kernel/kvm.c | 3 ++- > arch/x86/kernel/setup.c | 2 +- > 4 files changed, 14 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h > index 0ead9dbb9130..37320687b8cb 100644 > --- a/arch/x86/include/asm/hypervisor.h > +++ b/arch/x86/include/asm/hypervisor.h > @@ -38,6 +38,9 @@ struct hypervisor_x86 { > /* Platform setup (run once per boot) */ > void (*init_platform)(void); > > + /* Guest late init */ > + void (*guest_late_init)(void); > + > /* X2APIC detection (run once per boot) */ > bool (*x2apic_available)(void); > > @@ -66,9 +69,17 @@ static inline void hypervisor_init_mem_mapping(void) > if (x86_hyper && x86_hyper->init_mem_mapping) > x86_hyper->init_mem_mapping(); > } > + > +static inline void hypervisor_guest_late_init(void) > +{ > + if (x86_hyper && x86_hyper->guest_late_init) > + x86_hyper->guest_late_init(); > +} > + > #else > static inline void init_hypervisor_platform(void) { } > static inline bool hypervisor_x2apic_available(void) { return false; } > static inline void hypervisor_init_mem_mapping(void) { } > +static inline void hypervisor_guest_late_init(void) { } > #endif /* CONFIG_HYPERVISOR_GUEST */ > #endif /* _ASM_X86_HYPERVISOR_H */ > diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h > index c373e44049b1..7b407dda2bd7 100644 > --- a/arch/x86/include/asm/kvm_para.h > +++ b/arch/x86/include/asm/kvm_para.h > @@ -88,7 +88,6 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1, > #ifdef CONFIG_KVM_GUEST > bool kvm_para_available(void); > unsigned int kvm_arch_para_features(void); > -void __init kvm_guest_init(void); > void kvm_async_pf_task_wait(u32 token, int interrupt_kernel); > void kvm_async_pf_task_wake(u32 token); > u32 kvm_read_and_reset_pf_reason(void); > @@ -103,7 +102,6 @@ static inline void kvm_spinlock_init(void) > #endif /* CONFIG_PARAVIRT_SPINLOCKS */ > > #else /* CONFIG_KVM_GUEST */ > -#define kvm_guest_init() do {} while (0) > #define kvm_async_pf_task_wait(T, I) do {} while(0) > #define kvm_async_pf_task_wake(T) do {} while(0) > > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 8bb9594d0761..d331b5060aa9 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -465,7 +465,7 @@ static void __init kvm_apf_trap_init(void) > update_intr_gate(X86_TRAP_PF, async_page_fault); > } > > -void __init kvm_guest_init(void) > +static void __init kvm_guest_init(void) > { > int i; > > @@ -548,6 +548,7 @@ const struct hypervisor_x86 x86_hyper_kvm __refconst = { > .name = "KVM", > .detect = kvm_detect, > .x2apic_available = kvm_para_available, > + .guest_late_init = kvm_guest_init, > }; > EXPORT_SYMBOL_GPL(x86_hyper_kvm); > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index 0957dd73d127..578569481d87 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -1294,7 +1294,7 @@ void __init setup_arch(char **cmdline_p) > > io_apic_init_mappings(); > > - kvm_guest_init(); > + hypervisor_guest_late_init(); > > e820__reserve_resources(); > e820__register_nosave_regions(max_low_pfn); >