diff mbox

kvm/vmx: Use local vmx variable in vmx_get_msr()

Message ID 20171220115028.3009-1-bp@alien8.de (mailing list archive)
State New, archived
Headers show

Commit Message

Borislav Petkov Dec. 20, 2017, 11:50 a.m. UTC
From: Borislav Petkov <bp@suse.de>

... just like in vmx_set_msr().

No functionality change.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
---
 arch/x86/kvm/vmx.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Paolo Bonzini Dec. 20, 2017, 2:41 p.m. UTC | #1
On 20/12/2017 12:50, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> ... just like in vmx_set_msr().
> 
> No functionality change.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Radim Krčmář" <rkrcmar@redhat.com>
> ---
>  arch/x86/kvm/vmx.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 023afa0c8887..58be7915da81 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3249,6 +3249,7 @@ static inline bool vmx_feature_control_msr_valid(struct kvm_vcpu *vcpu,
>   */
>  static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  {
> +	struct vcpu_vmx *vmx = to_vmx(vcpu);
>  	struct shared_msr_entry *msr;
>  
>  	switch (msr_info->index) {
> @@ -3260,8 +3261,8 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  		msr_info->data = vmcs_readl(GUEST_GS_BASE);
>  		break;
>  	case MSR_KERNEL_GS_BASE:
> -		vmx_load_host_state(to_vmx(vcpu));
> -		msr_info->data = to_vmx(vcpu)->msr_guest_kernel_gs_base;
> +		vmx_load_host_state(vmx);
> +		msr_info->data = vmx->msr_guest_kernel_gs_base;
>  		break;
>  #endif
>  	case MSR_EFER:
> @@ -3287,13 +3288,13 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  		break;
>  	case MSR_IA32_MCG_EXT_CTL:
>  		if (!msr_info->host_initiated &&
> -		    !(to_vmx(vcpu)->msr_ia32_feature_control &
> +		    !(vmx->msr_ia32_feature_control &
>  		      FEATURE_CONTROL_LMCE))
>  			return 1;
>  		msr_info->data = vcpu->arch.mcg_ext_ctl;
>  		break;
>  	case MSR_IA32_FEATURE_CONTROL:
> -		msr_info->data = to_vmx(vcpu)->msr_ia32_feature_control;
> +		msr_info->data = vmx->msr_ia32_feature_control;
>  		break;
>  	case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC:
>  		if (!nested_vmx_allowed(vcpu))
> @@ -3310,7 +3311,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  			return 1;
>  		/* Otherwise falls through */
>  	default:
> -		msr = find_msr_entry(to_vmx(vcpu), msr_info->index);
> +		msr = find_msr_entry(vmx, msr_info->index);
>  		if (msr) {
>  			msr_info->data = msr->data;
>  			break;
> 

Queued, thanks.

Paolo
David Hildenbrand Jan. 8, 2018, 10:57 a.m. UTC | #2
On 20.12.2017 12:50, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> 
> ... just like in vmx_set_msr().
> 
> No functionality change.
> 
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Radim Krčmář" <rkrcmar@redhat.com>
> ---
>  arch/x86/kvm/vmx.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 023afa0c8887..58be7915da81 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3249,6 +3249,7 @@ static inline bool vmx_feature_control_msr_valid(struct kvm_vcpu *vcpu,
>   */
>  static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  {
> +	struct vcpu_vmx *vmx = to_vmx(vcpu);
>  	struct shared_msr_entry *msr;
>  
>  	switch (msr_info->index) {
> @@ -3260,8 +3261,8 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  		msr_info->data = vmcs_readl(GUEST_GS_BASE);
>  		break;
>  	case MSR_KERNEL_GS_BASE:
> -		vmx_load_host_state(to_vmx(vcpu));
> -		msr_info->data = to_vmx(vcpu)->msr_guest_kernel_gs_base;
> +		vmx_load_host_state(vmx);
> +		msr_info->data = vmx->msr_guest_kernel_gs_base;
>  		break;
>  #endif
>  	case MSR_EFER:
> @@ -3287,13 +3288,13 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  		break;
>  	case MSR_IA32_MCG_EXT_CTL:
>  		if (!msr_info->host_initiated &&
> -		    !(to_vmx(vcpu)->msr_ia32_feature_control &
> +		    !(vmx->msr_ia32_feature_control &
>  		      FEATURE_CONTROL_LMCE))
>  			return 1;
>  		msr_info->data = vcpu->arch.mcg_ext_ctl;
>  		break;
>  	case MSR_IA32_FEATURE_CONTROL:
> -		msr_info->data = to_vmx(vcpu)->msr_ia32_feature_control;
> +		msr_info->data = vmx->msr_ia32_feature_control;
>  		break;
>  	case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC:
>  		if (!nested_vmx_allowed(vcpu))
> @@ -3310,7 +3311,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  			return 1;
>  		/* Otherwise falls through */
>  	default:
> -		msr = find_msr_entry(to_vmx(vcpu), msr_info->index);
> +		msr = find_msr_entry(vmx, msr_info->index);
>  		if (msr) {
>  			msr_info->data = msr->data;
>  			break;
> 

Why not, definitely easier to read.

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

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 023afa0c8887..58be7915da81 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3249,6 +3249,7 @@  static inline bool vmx_feature_control_msr_valid(struct kvm_vcpu *vcpu,
  */
 static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 {
+	struct vcpu_vmx *vmx = to_vmx(vcpu);
 	struct shared_msr_entry *msr;
 
 	switch (msr_info->index) {
@@ -3260,8 +3261,8 @@  static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 		msr_info->data = vmcs_readl(GUEST_GS_BASE);
 		break;
 	case MSR_KERNEL_GS_BASE:
-		vmx_load_host_state(to_vmx(vcpu));
-		msr_info->data = to_vmx(vcpu)->msr_guest_kernel_gs_base;
+		vmx_load_host_state(vmx);
+		msr_info->data = vmx->msr_guest_kernel_gs_base;
 		break;
 #endif
 	case MSR_EFER:
@@ -3287,13 +3288,13 @@  static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 		break;
 	case MSR_IA32_MCG_EXT_CTL:
 		if (!msr_info->host_initiated &&
-		    !(to_vmx(vcpu)->msr_ia32_feature_control &
+		    !(vmx->msr_ia32_feature_control &
 		      FEATURE_CONTROL_LMCE))
 			return 1;
 		msr_info->data = vcpu->arch.mcg_ext_ctl;
 		break;
 	case MSR_IA32_FEATURE_CONTROL:
-		msr_info->data = to_vmx(vcpu)->msr_ia32_feature_control;
+		msr_info->data = vmx->msr_ia32_feature_control;
 		break;
 	case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC:
 		if (!nested_vmx_allowed(vcpu))
@@ -3310,7 +3311,7 @@  static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 			return 1;
 		/* Otherwise falls through */
 	default:
-		msr = find_msr_entry(to_vmx(vcpu), msr_info->index);
+		msr = find_msr_entry(vmx, msr_info->index);
 		if (msr) {
 			msr_info->data = msr->data;
 			break;