mirror of
https://github.com/torvalds/linux.git
synced 2026-09-29 04:22:03 +02:00
KVM: VMX: Use cached vcpu_vmx pointer in MSR and segment helpers
vmx_get_msr() and vmx_set_msr() already cache to_vmx(vcpu) in a local 'vmx' pointer, but a few cases still open-code to_vmx(vcpu). Use the cached pointer for consistency. Likewise, cache to_vmx(vcpu) in vmx_get_segment_base() instead of open-coding it in both the real-mode check and the VMCS read path. No functional change intended. Signed-off-by: Hao Zhang <zhanghao1@kylinos.cn> Link: https://patch.msgid.link/tencent_A78DC401911634111A3391650CB00FCD0409@qq.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
a204badd84
commit
6978adcc3e
|
|
@ -2159,7 +2159,7 @@ int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
|
|||
!guest_has_spec_ctrl_msr(vcpu))
|
||||
return 1;
|
||||
|
||||
msr_info->data = to_vmx(vcpu)->spec_ctrl;
|
||||
msr_info->data = vmx->spec_ctrl;
|
||||
break;
|
||||
case MSR_IA32_SYSENTER_CS:
|
||||
msr_info->data = vmcs_read32(GUEST_SYSENTER_CS);
|
||||
|
|
@ -2191,7 +2191,7 @@ int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
|
|||
if (!msr_info->host_initiated &&
|
||||
!guest_cpu_cap_has(vcpu, X86_FEATURE_SGX_LC))
|
||||
return 1;
|
||||
msr_info->data = to_vmx(vcpu)->msr_ia32_sgxlepubkeyhash
|
||||
msr_info->data = vmx->msr_ia32_sgxlepubkeyhash
|
||||
[msr_info->index - MSR_IA32_SGXLEPUBKEYHASH0];
|
||||
break;
|
||||
case KVM_FIRST_EMULATED_VMX_MSR ... KVM_LAST_EMULATED_VMX_MSR:
|
||||
|
|
@ -2404,7 +2404,7 @@ int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
|
|||
|
||||
vmx_guest_debugctl_write(vcpu, data);
|
||||
|
||||
if (intel_pmu_lbr_is_enabled(vcpu) && !to_vmx(vcpu)->lbr_desc.event &&
|
||||
if (intel_pmu_lbr_is_enabled(vcpu) && !vmx->lbr_desc.event &&
|
||||
(data & DEBUGCTLMSR_LBR))
|
||||
intel_pmu_create_guest_lbr_event(vcpu);
|
||||
return 0;
|
||||
|
|
@ -2483,7 +2483,7 @@ int vmx_set_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 &
|
||||
FEAT_CTL_LMCE_ENABLED)) ||
|
||||
(data & ~MCG_EXT_CTL_LMCE_EN))
|
||||
return 1;
|
||||
|
|
@ -3678,13 +3678,14 @@ void vmx_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg)
|
|||
|
||||
u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg)
|
||||
{
|
||||
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
||||
struct kvm_segment s;
|
||||
|
||||
if (to_vmx(vcpu)->rmode.vm86_active) {
|
||||
if (vmx->rmode.vm86_active) {
|
||||
vmx_get_segment(vcpu, &s, seg);
|
||||
return s.base;
|
||||
}
|
||||
return vmx_read_guest_seg_base(to_vmx(vcpu), seg);
|
||||
return vmx_read_guest_seg_base(vmx, seg);
|
||||
}
|
||||
|
||||
static int __vmx_get_cpl(struct kvm_vcpu *vcpu, bool no_cache)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user