linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: vmx: unify adjacent #ifdefs
@ 2018-04-04 16:59 Paolo Bonzini
  2018-04-05 19:43 ` Krish Sadhukhan
  2018-04-09 11:00 ` David Hildenbrand
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2018-04-04 16:59 UTC (permalink / raw)
  To: linux-kernel, kvm

vmx_save_host_state has multiple ifdefs for CONFIG_X86_64 that have
no other code between them.  Simplify by reducing them to a single
conditional.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/vmx.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 939c8724feb4..a1572461786e 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2392,20 +2392,16 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
 #ifdef CONFIG_X86_64
 	savesegment(ds, vmx->host_state.ds_sel);
 	savesegment(es, vmx->host_state.es_sel);
-#endif
 
-#ifdef CONFIG_X86_64
 	vmcs_writel(HOST_FS_BASE, current->thread.fsbase);
 	vmcs_writel(HOST_GS_BASE, cpu_kernelmode_gs_base(cpu));
-#else
-	vmcs_writel(HOST_FS_BASE, segment_base(vmx->host_state.fs_sel));
-	vmcs_writel(HOST_GS_BASE, segment_base(vmx->host_state.gs_sel));
-#endif
 
-#ifdef CONFIG_X86_64
 	vmx->msr_host_kernel_gs_base = current->thread.gsbase;
 	if (is_long_mode(&vmx->vcpu))
 		wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base);
+#else
+	vmcs_writel(HOST_FS_BASE, segment_base(vmx->host_state.fs_sel));
+	vmcs_writel(HOST_GS_BASE, segment_base(vmx->host_state.gs_sel));
 #endif
 	if (boot_cpu_has(X86_FEATURE_MPX))
 		rdmsrl(MSR_IA32_BNDCFGS, vmx->host_state.msr_host_bndcfgs);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: vmx: unify adjacent #ifdefs
  2018-04-04 16:59 [PATCH] KVM: vmx: unify adjacent #ifdefs Paolo Bonzini
@ 2018-04-05 19:43 ` Krish Sadhukhan
  2018-04-09 11:00 ` David Hildenbrand
  1 sibling, 0 replies; 3+ messages in thread
From: Krish Sadhukhan @ 2018-04-05 19:43 UTC (permalink / raw)
  To: Paolo Bonzini, linux-kernel, kvm



On 04/04/2018 09:59 AM, Paolo Bonzini wrote:
> vmx_save_host_state has multiple ifdefs for CONFIG_X86_64 that have
> no other code between them.  Simplify by reducing them to a single
> conditional.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   arch/x86/kvm/vmx.c | 10 +++-------
>   1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 939c8724feb4..a1572461786e 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2392,20 +2392,16 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
>   #ifdef CONFIG_X86_64
>   	savesegment(ds, vmx->host_state.ds_sel);
>   	savesegment(es, vmx->host_state.es_sel);
> -#endif
>   
> -#ifdef CONFIG_X86_64
>   	vmcs_writel(HOST_FS_BASE, current->thread.fsbase);
>   	vmcs_writel(HOST_GS_BASE, cpu_kernelmode_gs_base(cpu));
> -#else
> -	vmcs_writel(HOST_FS_BASE, segment_base(vmx->host_state.fs_sel));
> -	vmcs_writel(HOST_GS_BASE, segment_base(vmx->host_state.gs_sel));
> -#endif
>   
> -#ifdef CONFIG_X86_64
>   	vmx->msr_host_kernel_gs_base = current->thread.gsbase;
>   	if (is_long_mode(&vmx->vcpu))
>   		wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base);
> +#else
> +	vmcs_writel(HOST_FS_BASE, segment_base(vmx->host_state.fs_sel));
> +	vmcs_writel(HOST_GS_BASE, segment_base(vmx->host_state.gs_sel));
>   #endif
>   	if (boot_cpu_has(X86_FEATURE_MPX))
>   		rdmsrl(MSR_IA32_BNDCFGS, vmx->host_state.msr_host_bndcfgs);
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: vmx: unify adjacent #ifdefs
  2018-04-04 16:59 [PATCH] KVM: vmx: unify adjacent #ifdefs Paolo Bonzini
  2018-04-05 19:43 ` Krish Sadhukhan
@ 2018-04-09 11:00 ` David Hildenbrand
  1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2018-04-09 11:00 UTC (permalink / raw)
  To: Paolo Bonzini, linux-kernel, kvm

On 04.04.2018 18:59, Paolo Bonzini wrote:
> vmx_save_host_state has multiple ifdefs for CONFIG_X86_64 that have
> no other code between them.  Simplify by reducing them to a single
> conditional.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/x86/kvm/vmx.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 939c8724feb4..a1572461786e 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2392,20 +2392,16 @@ static void vmx_save_host_state(struct kvm_vcpu *vcpu)
>  #ifdef CONFIG_X86_64
>  	savesegment(ds, vmx->host_state.ds_sel);
>  	savesegment(es, vmx->host_state.es_sel);
> -#endif
>  
> -#ifdef CONFIG_X86_64
>  	vmcs_writel(HOST_FS_BASE, current->thread.fsbase);
>  	vmcs_writel(HOST_GS_BASE, cpu_kernelmode_gs_base(cpu));
> -#else
> -	vmcs_writel(HOST_FS_BASE, segment_base(vmx->host_state.fs_sel));
> -	vmcs_writel(HOST_GS_BASE, segment_base(vmx->host_state.gs_sel));
> -#endif
>  
> -#ifdef CONFIG_X86_64
>  	vmx->msr_host_kernel_gs_base = current->thread.gsbase;
>  	if (is_long_mode(&vmx->vcpu))
>  		wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base);
> +#else
> +	vmcs_writel(HOST_FS_BASE, segment_base(vmx->host_state.fs_sel));
> +	vmcs_writel(HOST_GS_BASE, segment_base(vmx->host_state.gs_sel));
>  #endif
>  	if (boot_cpu_has(X86_FEATURE_MPX))
>  		rdmsrl(MSR_IA32_BNDCFGS, vmx->host_state.msr_host_bndcfgs);
> 

Much better indeed :)

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 

Thanks,

David / dhildenb

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-04-09 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04 16:59 [PATCH] KVM: vmx: unify adjacent #ifdefs Paolo Bonzini
2018-04-05 19:43 ` Krish Sadhukhan
2018-04-09 11:00 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).