lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8912020e-bf85-67b0-f401-538893c4ca5e@redhat.com>
Date:	Thu, 18 Aug 2016 19:06:20 +0200
From:	Paolo Bonzini <pbonzini@...hat.com>
To:	Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
	linux-kernel@...r.kernel.org
Cc:	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>, rt@...utronix.de,
	Gleb Natapov <gleb@...nel.org>, kvm@...r.kernel.org
Subject: Re: [PATCH 14/16] x86: kvm: Convert to hotplug state machine



On 18/08/2016 14:57, Sebastian Andrzej Siewior wrote:
> Install the callbacks via the state machine. The online & down callbacks are
> invoke on the target CPU so we can avoid using smp_call_function_single().
> local_irq_disable() is used because smp_call_function_single() used to invoke
> the function with interrupts disabled.
> 
> Cc: Gleb Natapov <gleb@...nel.org>
> Cc: Paolo Bonzini <pbonzini@...hat.com>
> Cc: kvm@...r.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
>  arch/x86/kernel/kvm.c | 42 +++++++++++++++---------------------------
>  1 file changed, 15 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 1726c4c12336..d1fcb2d3c976 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -423,12 +423,7 @@ static void __init kvm_smp_prepare_boot_cpu(void)
>  	kvm_spinlock_init();
>  }
>  
> -static void kvm_guest_cpu_online(void *dummy)
> -{
> -	kvm_guest_cpu_init();
> -}
> -
> -static void kvm_guest_cpu_offline(void *dummy)
> +static void kvm_guest_cpu_offline(void)
>  {
>  	kvm_disable_steal_time();
>  	if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
> @@ -437,29 +432,21 @@ static void kvm_guest_cpu_offline(void *dummy)
>  	apf_task_wake_all();
>  }
>  
> -static int kvm_cpu_notify(struct notifier_block *self, unsigned long action,
> -			  void *hcpu)
> +static int kvm_cpu_online(unsigned int cpu)
>  {
> -	int cpu = (unsigned long)hcpu;
> -	switch (action) {
> -	case CPU_ONLINE:
> -	case CPU_DOWN_FAILED:
> -	case CPU_ONLINE_FROZEN:
> -		smp_call_function_single(cpu, kvm_guest_cpu_online, NULL, 0);
> -		break;
> -	case CPU_DOWN_PREPARE:
> -	case CPU_DOWN_PREPARE_FROZEN:
> -		smp_call_function_single(cpu, kvm_guest_cpu_offline, NULL, 1);
> -		break;
> -	default:
> -		break;
> -	}
> -	return NOTIFY_OK;
> +	local_irq_disable();
> +	kvm_guest_cpu_init();
> +	local_irq_enable();
> +	return 0;
>  }
>  
> -static struct notifier_block kvm_cpu_notifier = {
> -        .notifier_call  = kvm_cpu_notify,
> -};
> +static int kvm_cpu_down_prepare(unsigned int cpu)
> +{
> +	local_irq_disable();
> +	kvm_guest_cpu_offline();
> +	local_irq_enable();
> +	return 0;
> +}
>  #endif
>  
>  static void __init kvm_apf_trap_init(void)
> @@ -494,7 +481,8 @@ void __init kvm_guest_init(void)
>  
>  #ifdef CONFIG_SMP
>  	smp_ops.smp_prepare_boot_cpu = kvm_smp_prepare_boot_cpu;
> -	register_cpu_notifier(&kvm_cpu_notifier);
> +	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "X86_KVM_ONLINE",
> +				  kvm_cpu_online, kvm_cpu_down_prepare);
>  #else
>  	kvm_guest_cpu_init();
>  #endif
> 

Reviewed-by: Paolo Bonzini <pbonzini@...hat.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ