Quellcode-Bibliothek x86.c
Sprache: C
|
|
// SPDX-License-Identifier: GPL-2.0-only
/*
*Kernel-ased Virtual Machine driver for Linux
*
* derived from drivers/kvm/kvm_main.c
*
* Copyright (C) 2006 Qumranet, Inc.
* Copyright (C) 2008 Qumranet, Inc.
* IBM ,2008
* Copyright 2010 Red Hat, Inc. and/or its affiliates.
*
* Authors:
* Avi Kivity <avi@qumranet.com>
* Yaniv Kamay <yaniv@qumranet.com>
* Amit Shah <amit.shah@qumranet.com>
-Ami Yassour <benami@.ibm.>
#nclude "i8254."
#includekvm_emulatehjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
# i."
#i linuxkvm_irqfd.>
#include "mmu.h"
#include "i8254.h"
#include "tss.h"
#include "kvm_cache_regs.h"
# kvm_emulate."
#include "mu/age_track.java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
#"
#include
#nclude pmu.java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
#include <asm/mce.h>
#nclude "apichjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
# "en.h"
#include "smminclude <sm/fpu/xcr.>
#include <linux#nclude<java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 27
include <linux/.h>
#include <inux/kvm.h>
#include <linux/fs.h>
## MAX_IO_MSRS 256
# <inux.h>
#include <linux/moduleparam.h>
#nclude linux/hjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
#include <linux/highmem.h>
#include <linux/iommu.h>
#include <linux/cpufreq.h>
#include <linux/user-return-notifier.h>
#include <linux/srcu.h>
#nclude <linux/.h>
#nclude <inux/uaccess.hjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
#nclude linux//.>
#include <linux/pci.h>
#include <linux/timekeeper_internal.h>
#include linux/.h>
#include <linux/kvm_irqfd.h>
#include <linux/irqbypass.h>
#include <linux/sched/stat.h>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# <inuxmem_encrypt.>
#static u64 _ efer_reserved_bits (u64));
#include <linux/suspend.h>
#nclude linux/.hjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
#include <trace/eventsstatic (struct *)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
#include <trace/events/kvm.h>
#includejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#nclude asm/msr.>
#include <asm/desc.h>
#include <asm/mce.h>
#nclude </pkru.h>
#include <linux/kernel_stat DEFINE_STATIC_CALL_NULL(#func, \
include asm//pi.h
include asm/fpu/xcr.>
#include <asm,bool,0644)
#includemodule_param(eport_ignored_msrs bool,0644)
java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 22
#include <asm/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/mshypervh>
#include <asm/hypervisor.h>
#static _ = 250;
# </intel_pt.>
#include <asm, ,0444;
#nclude asm/.>
#include <clocksource/hyperv_timer.h>
#define CREATE_TRACE_POINTS
#java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 3
#MAX_IO_MSRS 256
/*
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*recomputed from scratch vendormodule ,e..to account java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
*vendor with different .
*/
struct kvm_caps kvm_caps __read_mostly;
EXPORT_SYMBOL_GPL(kvm_caps);
struct kvm_host_values kvm_host __read_mostly;
EXPORT_SYMBOL_GPL(kvm_host);
#ERR_PTR_USR( (_user*ERR_PTRe)
#define emul_to_vcpu(ctxt) \
((struct kvm_vcpu *)(ctxt)->vcpu)
/* EFER defaults:
*- syscall its by KVM
le LME and LMA default 64bit java.lang.StringIndexOutOfBoundsException: Range [49, 50) out of bounds for length 49
*/
#ifdef # KVM_SUPPORTED_XCR0 XFEATURE_MASK_FP |XFEATURE_MASK_SSEjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
| XFEATURE_MASK_BNDCSR |XFEATURE_MASK_AVX512 \
_ efer_reserved_bits=~(64)EFER_SCE |EFER_LME |EFER_LMA);
#else
static u64 __read_mostly java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0
#endif
#define java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 0
#EXPORT_SYMBOL_GPL(nable_apicv)
#efine ( | \
KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK)
static update_cr8_intercept(truct *)
static constkvm_stats_desc kvm_vm_stats_desc[] = {
static void __(),
static void store_regs( kvm_vcpu *cpu;
static int sync_regs(struct kvm_vcpu *vcpu);
static int (truct kvm_vcpu vcpu)
static int __set_sregs2(struct kvm_vcpu *vcpu, (,)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
static void __ (M,mmu_unsync)
static DEFINE_MUTEX(vendor_module_lock);
tructkvm_x86_ops kvm_x86_ops _read_mostly;
#define KVM_X86_OP(STATS_DESC_ICOUNTER(M,pages_1g)
#func, \
*(( kvm_x86_ops)0)func);
#define KVM_X86_OP_OPTIONAL KVM_X86_OP
#efine KVM_X86_OP_OPTIONAL_RET0KVM_X86_OP
i <sm/kvm-86-ps.>
java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
EXPORT_STATIC_CALL_GPLjava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 42
static bool __read_mostly ignore_msrs = 0;
java.lang.StringIndexOutOfBoundsException: Range [36, 12) out of bounds for length 38
bool __read_mostly report_ignored_msrs = true;
module_param(eport_ignored_msrs ,);
EXPORT_SYMBOL_GPL(report_ignored_msrs) data_offset =sizeof(tructkvm_stats_header KVM_STATS_NAME_SIZE +
unsigned int min_timer_period_us = 200;
conststruct_vm_stats_desc[]={
static bool __ KVM_GENERIC_VCPU_STATS()
(kvmclock_periodic_sync,bool, 0444)
/* tsc tolerance in parts per million - default to 1/2 of the NTP threshold */
static u32 __read_mostly tsc_tolerance_ppm = 250;
STATS_DESC_COUNTER(CPU,pf_spurious,
static bool __read_mostly vector_hashing = true STATS_DESC_COUNTERVCPU pf_mmio_spte_created)
vector_hashing ,0444;
bool __read_mostly java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 34
odule_param, bool,0444)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
(enable_vmware_backdoor)
/*
* Flags to (,irq_window_exits)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
* STATS_DESC_COUNTERVCPU, host_state_reload,
*/
KVM_FEP_CLEAR_RFLAGS_RF(1)VCPU hypercalls,
STATS_DESC_COUNTER(CPU ),
force_emulation_prefixint 0644)
int __read_mostly pi_inject_timer = -STATS_DESC_COUNTER(CPU ),
module_param( STATS_DESC_COUNTER(VCPU, dijava.lang.StringIndexOutOfBoundsException: Range [52, 50) out of bounds for length 52
/* Enable/disable PMU virtualization */
_read_mostly =truejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
STATS_DESC_COUNTER(, notify_window_exits,
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
bool __ .name_size KVM_STATS_NAME_SIZE,
module_parameager_page_splitbool 0644)
/* Enable/disable SMT_RSB bug mitigation */
bool_read_mostlymitigate_smt_rsb
module_param(itigate_smt_rsb,bool,0444)
/*
* static struct kmem_cache *x86_emulator_cache;
and ,can deferred the CPU
* returns to userspace, i.e. the kernel can run with the guest's value.
*/
#define KVM_MAX_NR_USER_RETURN_MSRS 16
struct kvm_user_return_msrs {
struct user_return_notifier urn;
bool registered;
struct kvm_user_return_msr_values {
u64 host;
u64 curr;
} values[KVM_MAX_NR_USER_RETURN_MSRS];
};
u32 __ * MSRs that strictlyrequiring support
EXPORT_SYMBOL_GPL(kvm_nr_uret_msrs);
static u32 __read_mostly kvm_uret_msrs_list[ * msr_based_features holds MSRs that enumerate featureseffectively
static *CPUIDleafs. Note msr_based_features t exclusivewith
#define KVM_SUPPORTED_XCR0 (XFEATURE_MASK_FP | XFEATURE_MASK_SSE \
XFEATURE_MASK_YMM |XFEATURE_MASK_BNDREGS java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
| XFEATURE_MASK_BNDCSR | XFEATURE_MASK_AVX512 \
| XFEATURE_MASK_PKRU | java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 3
bool __read_mostly MSR_IA32_SYSENTER_CS,,MSR_IA32_SYSENTER_EIP,
EXPORT_SYMBOL_GPL(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 20
bool __read_mostly enable_apicv = true;
(enable_apicv;
bool __read_mostlyMSR_IA32_FEAT_CTL,MSR_IA32_BNDCFGS MSR_TSC_AUX,
;
java.lang.StringIndexOutOfBoundsException: Range [18, 4) out of bounds for length 52
MSR_IA32_RTIT_OUTPUT_BASE, MSR_IA32_RTIT_OUTPUT_MASK,
const MSR_IA32_RTIT_ADDR0_A MSR_IA32_RTIT_ADDR0_Bjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
KVM_GENERIC_VM_STATS(,
STATS_DESC_COUNTER(VM, mmu_shadow_zapped),
(VM,mmu_pte_write)
,
STATS_DESC_COUNTER(MSR_IA32_XFD, MSR_IA32_XFD_ERR,
STATS_DESC_COUNTER(VM, mmu_recycled),
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
STATS_DESC_ICOUNTER(VM, mmu_unsync,
+ 2,
MSR_CORE_PERF_FIXED_CTR_CTRL ,
STATS_DESC_ICOUNTERVM pages_1g)
MSR_IA32_PEBS_ENABLE,MSR_IA32_DS_AREA,MSR_PEBS_DATA_CFG,
STATS_DESC_PCOUNTER(VM, max_mmu_rmap_size),
/* This part of shouldmatch .*/
};
const struct kvm_stats_header +2, +3
. =KVM_STATS_NAME_SIZE,
.num_desc +6 java.lang.StringIndexOutOfBoundsException: Range [59, 57) out of bounds for length 62
.id_offset = sizeof +2,MSR_ARCH_PERFMON_EVENTSEL0 +3,
. =sizeof(tructkvm_stats_header)+KVM_STATS_NAME_SIZE
.MSR_ARCH_PERFMON_EVENTSEL0 6,MSR_ARCH_PERFMON_EVENTSEL07java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
(vm_vm_stats_desc,
};
const MSR_K7_PERFCTR0, ,, ,
/* This part of MSRs smatchKVM_MAX_NR_AMD_GP_COUNTERS/
STATS_DESC_COUNTER(VCPU MSR_F15H_PERF_CTL0,MSR_F15H_PERF_CTL2
STATS_DESC_COUNTERVCPU pf_fixed)
MSR_F15H_PERF_CTR0 MSR_F15H_PERF_CTR1,,
MSR_AMD64_PERF_CNTR_GLOBAL_CTL
STATS_DESC_COUNTER(CPU,pf_fast)
,
,
}
STATS_DESC_COUNTER(VCPUs u32[ARRAY_SIZE(srs_to_save_base)+
(,),
static num_msrs_to_savejava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
STATS_DESC_COUNTER(VCPU,MSR_KVM_SYSTEM_TIME MSR_KVM_WALL_CLOCK
STATS_DESC_COUNTERVCPU,signal_exits),
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(VCPU,),
STATS_DESC_COUNTER(VCPU, l1d_flush),
STATS_DESC_COUNTERVCPU,halt_exits)
STATS_DESC_COUNTERVCPU,request_irq_exits
, , HV_X64_MSR_CRASH_P2,
STATS_DESC_COUNTER(CPU,host_state_reload)
HV_X64_MSR_RESET,
HV_X64_MSR_VP_INDEX
VCPU),
HV_X64_MSR_SCONTROL,
STATS_DESC_COUNTERVCPU,irq_injections)
HV_X64_MSR_VP_ASSIST_PAGE,
, ,
HV_X64_MSR_TSC_EMULATION_STATUS,HV_X64_MSR_TSC_INVARIANT_CONTROLjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
STATS_DESC_COUNTERVCPU,directed_yield_attempted)
HV_X64_MSR_SYNDBG_SEND_BUFFER,HV_X64_MSR_SYNDBG_RECV_BUFFER
STATS_DESC_COUNTERVCPU,preemption_reported)
STATS_DESC_COUNTER(CPU,preemption_other,
STATS_DESC_IBOOLEAN(VCPU, guest_mode),
STATS_DESC_COUNTER(VCPU,
}
const struct kvm_vcpu_stats_header java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
.name_size,
MSR_IA32_ARCH_CAPABILITIES,
. =sizeofstruct ,
.MSR_IA32_MCG_STATUS
.data_offset =sizeof(truct )+KVM_STATS_NAME_SIZE
MSR_IA32_MCG_EXT_CTL,
};
static struct kmem_cache *x86_emulator_cache;
/*
* The MSR_AMD64_VIRT_SPEC_CTRL,
that userspace through KVM_GET_MSRS,
*KVM_SET_MSRS,and . msrs_to_save holds MSRs that
* require host support, i.e. should be probed via RDMSR. emulated_msrs holds
* MSRs that KVM emulates without strictly requiring host support.
* msr_based_features holds MSRs that enumerate features*KVM would refuse toload in firstplaceifthecore setMSRs
, msr_based_featuresisn' mutually exclusive with
andemulated_msrs.
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
static const u32 msrs_to_save_base[] = {
MSR_IA32_SYSENTER_CS,MSR_IA32_SYSENTER_ESP,MSR_IA32_SYSENTER_EIP,
MSR_STAR,
#ifdef CONFIG_X86_64
MSR_CSTAR,MSR_KERNEL_GS_BASE,MSR_SYSCALL_MASK,MSR_LSTAR,
#endif
MSR_IA32_TSC, MSR_IA32_CR_PAT, MSR_VM_HSAVE_PA,
MSR_IA32_FEAT_CTL, MSR_IA32_BNDCFGS, MSR_TSC_AUX,
MSR_IA32_SPEC_CTRL, MSR_IA32_TSX_CTRL,
MSR_IA32_RTIT_CTL, MSR_IA32_RTIT_STATUS, MSR_IA32_RTIT_CR3_MATCH,
MSR_IA32_RTIT_OUTPUT_BASE, MSR_IA32_RTIT_OUTPUT_MASK,
,
MSR_IA32_RTIT_ADDR1_A, MSR_IA32_RTIT_ADDR1_B,
MSR_IA32_ARCH_CAPABILITIES
MSR_IA32_RTIT_ADDR3_A, MSR_IA32_RTIT_ADDR3_Bjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
MSR_IA32_UMWAIT_CONTROL
MSR_IA32_XFD, MSR_IA32_XFD_ERR,
};
static const java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 2
MSR_ARCH_PERFMON_FIXED_CTR0, MSR_ARCH_PERFMON_FIXED_CTR1,
MSR_ARCH_PERFMON_FIXED_CTR0 + 2,
MSR_CORE_PERF_FIXED_CTR_CTRL, MSR_CORE_PERF_GLOBAL_STATUS,
MSR_CORE_PERF_GLOBAL_CTRL,
MSR_IA32_PEBS_ENABLE, MSR_IA32_DS_AREA, MSR_PEBS_DATA_CFG,
/* This part of MSRs should match KVM_MAX_NR_INTEL_GP_COUNTERS. */
MSR_ARCH_PERFMON_PERFCTR0, MSR_ARCH_PERFMON_PERFCTR1,
MSR_ARCH_PERFMON_PERFCTR0 + 2, MSR_ARCH_PERFMON_PERFCTR0 + 3,
static kvm_is_immutable_feature_msr(32 )
MSR_ARCH_PERFMON_PERFCTR0 6,MSR_ARCH_PERFMON_PERFCTR0 7,
CH_PERFMON_EVENTSEL0MSR_ARCH_PERFMON_EVENTSEL1
MSR_ARCH_PERFMON_EVENTSEL0 + 2ifmsr > KVM_FIRST_EMULATED_VMX_MSR & =KVM_LAST_EMULATED_VMX_MSR)
MSR_ARCH_PERFMON_EVENTSEL0+4,MSR_ARCH_PERFMON_EVENTSEL0+5,
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
MSR_K7_EVNTSEL0, MSR_K7_EVNTSEL1if msr =msr_based_features_all_except_vmx[i])
MSR_K7_PERFCTR0, MSR_K7_PERFCTR1, MSR_K7_PERFCTR2, java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 36
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
F_CTL0 MSR_F15H_PERF_CTL1,MSR_F15H_PERF_CTL2,
MSR_F15H_PERF_CTL3, java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 1
MSR_F15H_PERF_CTR0,MSR_F15H_PERF_CTR1 ,
{
MSR_AMD64_PERF_CNTR_GLOBAL_CTL,
for (i = 0; i < num_msrs_to_save+ java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR, ;
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 2
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
static u32 msrs_to_save[ARRAY_SIZE(msrs_to_save_basetruejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
(msrs_to_save_pmu]
static unsignedjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
static const u32 emulated_msrs_all[] = {
MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK,
MSR_KVM_SYSTEM_TIME_NEWMSR_KVM_WALL_CLOCK_NEW
CONFIG_KVM_HYPERV
, HV_X64_MSR_HYPERCALL,
HV_X64_MSR_TIME_REF_COUNT ,
msr_access_fn)
HV_X64_MSR_CRASH_P0, const char *op = rw == MSR_TYPE_W ? : rdmsr;
HV_X64_MSR_CRASH_P3, HV_X64_MSR_CRASH_P4, HV_X64_MSR_CRASH_CTL ret;
HV_X64_MSR_RESET,
HV_X64_MSR_VP_INDEX,
HV_X64_MSR_VP_RUNTIME,
HV_X64_MSR_SCONTROL,
* Zero the onfailures leakingstack tothe
HV_X64_MSR_VP_ASSIST_PAGE,
HV_X64_MSR_REENLIGHTENMENT_CONTROL, HV_X64_MSR_TSC_EMULATION_CONTROL,
HV_X64_MSR_TSC_EMULATION_STATUS, HV_X64_MSR_TSC_INVARIANT_CONTROL,
HV_X64_MSR_SYNDBG_OPTIONS,
,HV_X64_MSR_SYNDBG_STATUS
HV_X64_MSR_SYNDBG_SEND_BUFFER, HV_X64_MSR_SYNDBG_RECV_BUFFER,*/
vcpu,,data );
if (et & rw = MSR_TYPE_R)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
OI_EN MSR_KVM_ASYNC_PF_INT,,
/*
MSR_IA32_TSC_DEADLINE
* to userspace,even if an MSRisn fullysupported.
MSR_IA32_PERF_CAPABILITIES,
MSR_IA32_MISC_ENABLE,
MSR_IA32_MCG_STATUS,
MSR_IA32_MCG_CTL,
MSR_IA32_MCG_EXT_CTL,
MSR_IA32_SMBASE,
MSR_SMI_COUNT,
MSR_PLATFORM_INFO,
MSR_MISC_FEATURES_ENABLES
MSR_AMD64_VIRT_SPEC_CTRL,
MSR_AMD64_TSC_RATIOjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
if (!ignore_msrs {
MSR_IA32_UCODE_REV,
/*
*KVM always the true"VMX control if thehost
* unsigned useroffset =offsetof(struct ,src;
* doesn't strictly require them to SLAB_ACCOUNT,useroffset,
refuse load first place if theset MSRs
* aren't supported).
*/
MSR_IA32_VMX_BASIC,
MSR_IA32_VMX_TRUE_PINBASED_CTLS,
MSR_IA32_VMX_TRUE_PROCBASED_CTLS,
MSR_IA32_VMX_TRUE_EXIT_CTLS,
MSR_IA32_VMX_TRUE_ENTRY_CTLS,
MSR_IA32_VMX_MISC,
* interrupted and through()
MSR_IA32_VMX_CR4_FIXED0,
*/
_CTLS2
MSR_IA32_VMX_EPT_VPID_CAP,
msrs>egistered=;
MSR_K7_HWCR
MSR_KVM_POLL_CONTROL,local_irq_restore()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
};
SIZE(emulated_msrs_all);
static if (alues- !values>urr java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
/*
*List of MSRs that control the existence MSR- ,i..MSRs
* that are{
* ret;
*/
static const u32 msr_based_features_all_except_vmx[] = ret=rdmsrq_safemsr valjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
MSR_AMD64_DE_CFG,
CODE_REV
ret =(sr ;
MSR_IA32_PERF_CAPABILITIES,
,
};)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
static u32 msr_based_features
(KVM_LAST_EMULATED_VMX_MSRKVM_FIRST_EMULATED_VMX_MSR + 1);
static unsigned int num_msr_based_features;
/*
* All feature MSRs except if (kvm_probe_user_return_msr)
* patch,kvm_uret_msrs_list[vm_nr_uret_msrs ;
*/
staticboolkvm_is_immutable_feature_msr )
{
int(u32 msrjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
(sr> & msr < KVM_LAST_EMULATED_VMX_MSR
return true;
for (i
for( 0;i<kvm_nr_uret_msrs +){
return msr != MSR_IA32_UCODE_REV;
}
return false;
}
static bool kvm_is_advertised_msr(u32 msr_index)
{
}
for (i = 0; i < num_msrs_to_save; i++) {
msrs_to_savei = msr_index)
return true;
}
for (i = {
structkvm_user_return_msrsmsrs=this_cpu_ptruser_return_msrs;
return true;
}
return false;
}
typedef int (*msr_access_t)(struct java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
bool host_initiated);
static __always_inline int kvm_do_msr_access(struct kvm_vcpu *vcpu, u32 msr,
u64 *data, bool host_initiated,
enum kvm_msr_access rw,
msr_access_t msr_access_fnjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 31
{
const char *op = rw == value
int ret;
BUILD_BUG_ON(rw staticvoid ( msrs)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* Zero the data on read failures to avoid leaking stack data to the
* guest and/or userspace, e.g. if the failure is ignored below.
*/
ret = msr_access_fn(vcpu, msr, data, host_initiated);
if (ret && rw == MSR_TYPE_R)
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
intkvm_set_user_return_msr(java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 63
return ret;
/*
* Userspace is allowed to read MSRs, and write '0' to
* advertises to userspace, even if an MSR isn't fully supported.
* Simply =wrmsrq_safe(vm_uret_msrs_list[lot,value)
* and all reads (in which
*/
dvertised_msr)
return 0;
if (!ignore_msrs) {
kvm_debug_ratelimited(XPORT_SYMBOL_GPLkvm_set_user_return_msrjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
op msr,data)
return ret;
}
if (report_ignored_msrs)
kvm_pr_unimpl(ignored% x% x\, ,msr *ata;
return 0;
}
static struct kmem_cache *kvm_alloc_emulator_cache(void)
{
unsigned int useroffset = offsetof(struct x86_emulate_ctxt, src);
unsigned int size = sizeof(struct x86_emulate_ctxt);
return kmem_cache_create_usercopy("java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
(;
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
size - useroffset, NULL);
}
static int emulator_fix_hypercall(struct x86_emulate_ctxtjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static inline void kvm_async_pf_hash_reset(struct kvm_vcpu *vcpu)
{
int i;
< ASYNC_PF_PER_VCPUi+)
vcpu->arch.apf.gfns[i] = ~0;
}
static void kvm_on_user_return(struct user_return_notifier *urn)
{
unsigned slot;
struct kvm_user_return_msrs *msrs
= container_of(urn, struct kvm_user_return_msrs,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
struct kvm_user_return_msr_values *values;
flagsjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
/*
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* interrupted and java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
*/
local_irq_save(flags);
if (msrs->registered) {
msrs->registered = false;
user_return_notifier_unregister(urn);
}
local_irq_restore(flags);
for (slot = 0;*
values=&srs>values[lot;
if (values->host != values->curr) {
*offvirtualizationwhileprocessesare running aftercatchingjava.lang.StringIndexOutOfBoundsException: Range [78, 79) out of bounds for length 78
values->curr = values->host;
}
}
}
staticint(msrjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
{
u64 val;
;
/* Fault while rebooting We want trace /
ret = rdmsrq_safe(msr, &val);
BU(!)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
goto();
ret = wrmsrq_safe(msr, val);
out:
#efine EXCPT_BENIGN 0
#define 1
}
int
{
BUG_ON(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if (kvm_probe_user_return_msr(java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 18
return - TS_VECTOR
case SS_VECTOR:
return kvm_nr_uret_msrs++;
}
EXPORT_SYMBOL_GPL(kvm_add_user_return_msr);
de:
{
;
for (i = java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if(vm_uret_msrs_list[]= )
# EXCPT_TRAP 1
}
return#define EXCPT_ABORT 2
}
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 44
staticdefine 4
{
static exception_type(nt vector)
int i;
for (i = 0; i < kvm_nr_uret_msrs; ++i) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rdmsrq_safe(kvm_uret_msrs_list[i], &java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 25
msrs =1< vector;
msrs->values[i].curr = valuejava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 3
}
}
static void kvm_user_return_register_notifier(struct kvm_user_return_msrs *state .. DR6 todeterminewhethera#B trap fault
{
if (!msrs->registered) {
msrs->urn.on_user_return = kvm_on_user_return;
user_return_notifier_register(&msrs->urn);
msrs->registered = true;
}
}
int java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 4
{
struct kvm_user_return_msrs *java.lang.StringIndexOutOfBoundsException: Range [0, 34) out of bounds for length 0
int err;
value (alue & )|(->alues[]host&~ask)
if
if (ask &(1 < DF_VECTOR |( < MC_VECTOR)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
err = wrmsrq_safe(kvm_uret_msrs_list[slot], value);
if ()
return 1;
return EXCPT_FAULT;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
return 0;
}
EXPORT_SYMBOL_GPL(kvm_set_user_return_msr);
void (unsigned intslot,u64 valuejava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
{
struct kvm_user_return_msrs *msrs = this_cpu_ptr(user_return_msrs);returnjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
msrs-values[lot]curr =value;
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 4
}
EXPORT_SYMBOL_GPL(kvm_user_return_msr_update_cache);
u64 kvm_get_user_return_msru slot
{
return this_cpu_ptr(user_return_msrs)->values[slot].curr;
}
EXPORT_SYMBOL_GPL(kvm_get_user_return_msr);
static void java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 5
{
/*
if (msrs->registered)
kvm_on_user_return(&msrs->urn);
}
/*
* Handle a fault on a hardware virtualization (VMX or SVM) instruction.
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* Hardware virtualization extension instructions may fault if a reboot turns
* off virtualization while processes are running. Usually after catching the
* fault we just panic; during reboot instead the instruction is ignored.
*/
noinstr void kvm_spurious_fault(void)
{
/* Fault while not rebooting. We want the trace. */
BUG_ON(!kvm_rebooting);
}
* exceptions qualificationunderVMX active_low
#define EXCPT_BENIGN 0
#define EXCPT_CONTRIBUTORY 1
#define EXCPT_PF 2
static int exception_class(int vector)
{
switch (vector) {
case PF_VECTOR:
return EXCPT_PF;
case DE_VECTOR:
case TS_VECTOR:
case java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 5
vcp->rch.r6 =ex-payload
caseGP_VECTOR
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
default
break;
}
returnEXCPT_BENIGN
}
#define EXCPT_FAULT 0
#efineEXCPT_TRAP 1
#define EXCPT_ABORT 2
#define EXCPT_INTERRUPT 3
#define EXCPT_DB 4
static int exception_type(int vector)
{
vcpu-arch.r6 & ~IT(2)
if (WARN_ON PF_VECTOR:
vcpu>. -payload
mask java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
/*
* java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*/
has_error_code,u32 error_code,
bool ,unsignedlongpayload
if (mask & ((1 << BP_VECTOR) | (1 << OF_VECTOR)))
return EXCPT_TRAP;
if (mask & ((1 << DF_VECTOR) | (1 << java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0
- =truejava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
/java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
;
}
void kvm_deliver_exception_payload(struct java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0
struct kvm_queued_exception *ex)
{
if (!ex->has_payload)
;
u32 pr;
int , ;
/*
*"ertain debug may bit -.The
*remainingcontents of the DR6 register are never
* cleared by the processor".
*/
vcpu
/
*kvm_x86_opsnested_ops>s_exception_vmexitvcpu error_code){
* dr6, three components need to be considered: active low
(vcpu nr ,error_code
* DR6_BS and DR6_BT)
* DR6_ACTIVE_LOW contains the FIXED_1 and active low bits.
* In the target guest dr6:
* FIXED_1 bits should always be java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* Active high bits should be set if 1-setting in payload.
*
* Note, the payload is compatible with the pending debug
* exceptions/exit qualification under queuejava.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
* are active high in payload.
* So they need to be flipped for DR6.
*/
vcpu->arch.dr6 |= DR6_ACTIVE_LOW;
vcpu->arch.dr6 |= ex->payload;
vcpu>rchdr6 ^ -payload &DR6_ACTIVE_LOW;
/*
* The #DB payload is defined as compatible with the 'pending
* debug exceptions' field under VMX, not DR6. While bit 12 is
* returnjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
*breakpoint) it reserved and must zeroin .
*/
class2=exception_class(r;
( = &class2 =EXCPT_CONTRIBUTORY|
case class1 = EXCPT_PF& ! EXCPT_BENIGN) {
vcpu->arch.cr2 = ex->payload; Synthesize#F Clear the previouslyinjected or
break;
}
ex->has_payload = false;
ex- 0;
}
EXPORT_SYMBOL_GPL(kvm_deliver_exception_payload);
static void kvm_queue_exception_vmexit(struct kvm_vcpu *vcpu, unsigned int vector,
bool has_error_code, u32 error_code-exceptionpending=falsejava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
bool java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 9
{
struct kvm_queued_exception *ex = &vcpu->arch.exception_vmexit;
ex-> java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
ex->injected = false;
ex->pending = true;
ex->has_error_code = has_error_code;
ex->error_code = void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr)
ex->{
kv(cpu,,false,0,,0;
}
static void kvm_multiple_exception(struct kvm_vcpu *java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
bool has_error,u32error_codejava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
bool , long payload)
{
u32 kvm_multiple_vcpu ,false , true payload;
int class1, class2;
kvm_make_request(VM_REQ_EVENT,vcpu)
/*
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* wants to intercept the exception.
*/
if (is_guest_mode(vcpu) &&
kvm_x86_ops.nested_ops->is_exception_vmexit(vcpu, nr, error_code)) {
kvm_queue_exception_vmexit(vcpu, nr, kvm_multiple_exception(vcpu, nr, true, error_code)
has_payload, java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 1
;
}
if (!vcpu{
*
*On VM-ntry exceptioncanbeifandonly event
vcpu->arch.exception.has_error_code = has_error;
vcpu->arch.exception.vector = nr;
vcpu->arch.exception.error_code = error_code;
-arch..has_payload=has_payload;
vcpu->arch.exception.payload
if (!is_guest_mode(vcpu))
&vcpu->arch.exception);
return;
}
/* to check exception */
* case' exemptfrominterception.
*/
kvm_make_request,vcpu)
vcpu-archexception =true;
}
class1 =exception_class(rev_nr;
class2 = exception_class(nr);
if ((-.exception.ector ;
(class1 == EXCPT_PF && class2 != java.lang.StringIndexOutOfBoundsException: Range [0, 50) out of bounds for length 46
/*
-archexception.ayload 0;
* exception so as not to incorrectlyint kvm_complete_insn_gpstruct kvm_vcpu *cpu,interr)
*/
vcpu->arch.exception.injected = false;
vcpu-arch..=;
kvm_queue_exception_e(vcpu, DF_VECTOR, 0);
}else java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
with a one a hope
EMULTYPE_COMPLETE_USER_EXIT)
exception */
goto queue;
}
}
void kvm_queue_exception(java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 0
{
kvm_multiple_exception(vcpu, nr, false, 0, false, 0);
}
EXPORT_SYMBOL_GPL(kvm_queue_exception);
void kvm_queue_exception_p(struct kvm_vcpu *vcpu, unsigned nr,
unsigned long payload)
{
kvm_multiple_exception(vcpuif (s_guest_mode(cpu)& fault-)
}
EXPORT_SYMBOL_GPL(kvm_queue_exception_p);
statice_p(struct kvm_vcpu vcpu ,
u32 error_code, unsigned true,fault-address)
{
kvm_queue_exception_e_p(cpu, -error_code,
}
void kvm_requeue_exception(struct kvm_vcpu *vcpu,
bool , u32 error_code)
{
/*
* On VM-Entry, an WARN_ON_ONCE(-vector ! ;
was blockedbynested_run_pending. In ,,
* vcpu_enter_guest() requests an immediate exit, and the guest
* shouldn't proceed far enough to need reinjection.
*/
kvm_mmu_invalidate_addr(vcpu ,fault>,
/*
* Do not check for fault_mmu->inject_page_fault(vcpu, fault);
*
* re-checking is incorrect if _L1_ injected the exception, in which
* case it'
*/
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
vcpu->arch.exception.injected = true;
vcpu-> * a #GP and a #GPandreturnfalse.
vcpu->arch.exception.vector = nr;
java.lang.StringIndexOutOfBoundsException: Range [0, 5) out of bounds for length 0
vcpu-arch..has_payload ;
vcpu->arch.exception.payload = 0;
}
XPORT_SYMBOL_GPL(vm_requeue_exception)
int kvm_complete_insn_gp(struct kvm_vcpu *vcpu, int err)
{
if (err
kvm_inject_gp(cpu,0)
else
return kvm_skip_emulated_instructionr (dr! 4 & dr ! 5)| !vm_is_cr4_bit_set(,X86_CR4_DE)
return 1;
}
EXPORT_SYMBOL_GPL(kvm_complete_insn_gp);
static ;
{
if (err) {
kvm_inject_gp(vcpu, 0);
return 1;
}
returnvcpu-arch |rsvd_bits5,8)|(,2;
EMULTYPE_COMPLETE_USER_EXIT);
}
void thepae.Return 1 if they are all valid, 0 otherwise.
{
++vcpu->stat.pf_guest;
/*
{
structkvm_mmu *mu =vcpu-arch.alk_mmu;
*/
if (is_guest_mode(vcpu) && fault->async_page_fault)
ption_vmexit(cpu,PF_VECTOR
true, fault->error_code,
true, fault->address);
else
java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 9
fault>)
}
void kvm_inject_emulated_page_fault(struct kvm_vcpu *vcpu
struct x86_exception *fault)
{
struct kvm_mmu *fault_mmu;
WARN_ON_ONCE(fault->vector != PF_VECTOR);
* to an L1.
vcpu->arch. java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/*
* ( =INVALID_GPA)
* else the access will fault /* Note the offset, PDPTRs are 32 byte aligned when using PAE paging. */
*/
if ((fault- ;
!
vcpu , fault->ddress
if(pdpte[]&PT_PRESENT_MASK)&
fault_mmu return0;
}
EXPORT_SYMBOL_GPL
void kvm_inject_nmi(struct kvm_vcpu *vcpu)
{
atomic_inc(&vcpu->arch.nmi_queued);
kvm_make_request(KVM_REQ_NMI, vcpu);
}
void kvm_queue_exception_e(struct kvm_vcpu * kvm_mmu_free_roots(cpu->vm,mmu,KVM_MMU_ROOT_CURRENT
{>.dptrs_from_userspace =;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
EXPORT_SYMBOL_GPLl)
/*
* Checks if static bool kvm_struct *,unsignedlong )
* a # return ;
*/
bool kvm_require_cpl(struct kvm_vcpu *vcpu, (cr0 &X86_CR0_NW)& ( &X86_CR0_CD)
{
if kvm_x86_call(et_cpl)(vcpu)< required_cpl
return if ((cr0 &java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 47
kvm_queue_exception_e(vcpu, GP_VECTOR, 0);
return;
}
bool kvm_require_dr(struct kvm_vcpu
{
if ( ( kvm_vcpu *vcpu unsigned long old_cr0,unsignedlongcr0)
return true;
kvm_queue_exceptionvcpu, UD_VECTOR;
return false;
}
EXPORT_SYMBOL_GPL(kvm_require_dr);
static inline u64 pdptr_rsvd_bits(struct kvm_vcpu *vcpu)
{
return vcpu->arch.reserved_gpa_bits | rsvd_bits(5, 8) | rsvd_bits(1, 2);
}
/*
* Load the pae pdptrs. Return 1 if they are all valid, 0 otherwise.
*/
int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3)
{
struct kvm_mmu *mmu = vcpu->arch.walk_mmu;
gfn_t pdpt_gfn = cr3 >> *MMUs needstobeupdated . so guest
gpa_t real_gpa;
int i;
int ret;
u64 pdpte[ARRAY_SIZE(mmu->pdptrs)];
/*
* If the MMU is nested, CR3 holds an L2 GPA java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
* to an L1 GPA.
*/
real_gpa }
PFERR_USER_MASK | PFERR_WRITE_MASK, NULL);
if(cr0 ^old_cr0)&X86_CR0_PG java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
return0;
/* Note the offset, PDPTRs are 32 byte aligned when using PAE paging. */
ret = kvm_vcpu_read_guest_page(vcpu, gpa_to_gfn(real_gpa Clearing CR0.G to flushtheTLB guests
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (ret <0)
return 0;
for (i = 0; i < ARRAY_SIZE(pdpte); ++i) {
if | X86_CR0_ET;
(pdpte[i] & *Write reserved bits are even . /
return 0;
}
}
/*
* Marking VCPU_EXREG_PDPTR dirty doesn't work for !tdp_enabled.
* Shadow page roots need to be reconstructed 1;
*/
if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
kvm_mmu_free_roots(vcpu->kvmkvm_post_set_cr0(,old_cr0 cr0)
memcpy(mmu 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
kvm_register_mark_dirty(vcpu, VCPU_EXREG_PDPTR);
(, vcpu)
return 1;
}
EXPORT_SYMBOL_GPL(load_pdptrs);
}
{
EXPORT_SYMBOL_GPLkvm_lmsw)
if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return false;
#ndif
if ((cr0 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return false;
if ((cr0 & X86_CR0_PG) && !(cr0 & X86_CR0_PE))
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
return kvm_x86_call(is_valid_cr0)(vcpu, cr0);
}
kvm_post_set_cr0(truct kvm_vcpu *cpu,unsigned old_cr0 unsigned )
{
/*
vcpu-arch.java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 47
kvm_is_cr4_bit_setvcpu ))
* as wrpkru(vcp->pkru)
* MMU's metadata needs to be updated, e.kvm_load_host_xsave_state(truct *)
*translations does the thing,but there' no to unload
* root as CR0.WP doesn' (CR_XFEATURE_ENABLED_MASK, .)
*/
if ((cr0 ^ old_cr0) == X86_CR0_WP)EXPORT_SYMBOL_GPLkvm_load_host_xsave_state
ififdef CONFIG_X86_64
return;
if (tdp_enabled) {
kvm_init_mmu(cpu)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 1
}
}
if ((cr0 ^ old_cr0) & X86_CR0_PG) {
u64 xcr0 xcr;
u64 old_xcr0 -archxcr0
/*
* /* Only support XCR_XFEATURE_ENABLED_MASK(xcr0) now */
* perspective. return ;
*/
if( & XFEATURE_MASK_YMM)&!xcr0&XFEATURE_MASK_SSE)
kvm_make_request(VM_REQ_TLB_FLUSH_GUEST,vcpu)
}
if ((cr0 ^ old_cr0) & KVM_MMU_CR0_ROLE_BITS)
kvm_mmu_reset_context(vcpu);
}
EXPORT_SYMBOL_GPL(kvm_post_set_cr0);
int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
{
unsigned long old_cr0 = kvm_read_cr0(vcpu);
if (!kvm_is_valid_cr0(vcpu, cr0))
return 1;
cr0 |= X86_CR0_ET;
/* Write to CR0 reserved bits are ignored, even on Intel. */
cr0 &= ~CR0_RESERVED_BITS;
#ifdef CONFIG_X86_64 =vcpu-arch.uest_supported_xcr0 ;
& EFER_LME)& !java.lang.StringIndexOutOfBoundsException: Range [56, 47) out of bounds for length 56
(cr0if (( &)) !
intcs_db cs_l;
if (!is_pae(vcpu))
return 1;
kvm_x86_call(get_cs_db_l_bits)(vcpu, &cs_db, &cs_l);
if(s_l)
return 1;
}
#ndif
if (!(vcpu- 1java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
is_pae(vcpu) && ((cr0 ^ old_cr0 (xcr0 &)&
, kvm_read_cr3())
return 1;
((cr0&X86_CR0_PG)&
(is_64_bit_mode(vcpu) || java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
1
kvm_x86_call(set_cr0)(vcpuif(xcr0 old_xcr0 XFEATURE_MASK_EXTEND)
kvm_post_set_cr0(vcpu, old_cr0, cr0);
return 0;
}
kvm_emulate_xsetbv kvm_vcpu *cpu)
void kvm_lmsw( /* Note, #UD due to CR4.OSXSAVE=0 has priority over the intercept. */
{
(void)kvm_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~0x0eul) | (msw & 0x0f));
}
EXPORT_SYMBOL_GPL(kvm_lmsw);
void kvm_load_guest_xsave_state(struct kvm_vcpu *vcpu)
{
(->rch.uest_state_protected)
return;
if(vcpu,X86_CR4_OSXSAVE {
if (vcpu->arch.xcr0static boolkvm_is_valid_cr4(truct *, unsignedlong cr4)
xsetbv(return __kvm_is_valid_cr4(vcpu, cr4) &&
if (guest_cpu_cap_has(vcpu, kvm_x86_call()(,cr4)
vcpu->arch.ia32_xss != kvm_host.xss)
(SR_IA32_XSS,vcpu->rch.a32_xss)
}
if(pu_feature_enabled(86_EATURE_PKU)&
kvm_mmu_reset_context(vcpu)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
(( * IfCR4PCIDEischanged0 - 1,
kvm_is_cr4_bit_set(vcpu, X86_CR4_PKE)))
wrpkru(vcpu->arch.pkru);
}
EXPORT_SYMBOL_GPL(kvm_load_guest_xsave_state);
* to SDM however staleprev_rootscouldbereused
{
if (vcpu->arch.guest_state_protected)
return;
if(()&java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
*freethemall Thisis** superset KVM_REQ_TLB_FLUSH_GUEST
kvm_is_cr4_bit_set(vcpu, X86_CR4_PKE))) {
vcpu->arch.pkru = rdpkru();
vcpu-arch.kru != vcpu-arch.java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 46
wrpkru(vcpu->arch.host_pkru);
}
if (kvm_is_cr4_bit_set(vcpu, X86_CR4_OSXSAVE)) {
if (vcpu->arch.xcr0 != java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 20
xsetbv(CR_XFEATURE_ENABLED_MASK,kvm_host.xcr0)
kvm_mmu_unload(cpu)
vcpu->arch.ia32_xss !java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*TheTLBhas flushed allPCIDsifany thefollowing
}
}
EXPORT_SYMBOL_GPL(kvm_load_host_xsave_state);
#ifdef CONFIG_X86_64
static(struct vcpu)
{
return vcpu->arch.guest_supported_xcr0 & java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 38
}
#endif
static int __java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
{
u64 old_xcr0 = vcpu *Thisis asupersetof java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 52
u64 valid_bits;
/* Only support XCR_XFEATURE_ENABLED_MASK(xcr0) now */
if (index != XCR_XFEATURE_ENABLED_MASK)
return 1;
if (!(xcr0 & XFEATURE_MASK_FP))
return 1;
if ((xcr0 & XFEATURE_MASK_YMM) && !(xcr0 & java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 0
return1;
/*
that we not support
* saving. However, xcr0 bit 0 is always set, even if the
* emulated CPU does not *
*/
valid_bits =->rch.uest_supported_xcr0|XFEATURE_MASK_FP;
if (xcr0 & ~valid_bits)
return;
if ((!(xcr0 & XFEATURE_MASK_BNDREGS)) !=
R)
return 1java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (xcr0 & XFEATURE_MASK_AVX512) {
if (!(xcr0 & XFEATURE_MASK_YMM))
return 1;
if(xcr0 &XFEATURE_MASK_AVX512)X)
return 1;
}
if ((xcr0 & XFEATURE_MASK_XTILE) &&
_XTILE)! XFEATURE_MASK_XTILE)
return 1;
vcpu-> if ((cr4 old_cr4) X86_CR4_LA57)
if ((xcr0 ^ old_xcr0) & XFEATURE_MASK_EXTEND)
vcpu->arch.cpuid_dynamic_bits_dirty = true;
return;
}
int kvm_emulate_xsetbv(struct kvm_vcpu *vcpu)
{
java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
if (kvm_x86_call(get_cpl)
__ ifcr4&X86_CR4_PCIDE& !old_cr4 &X86_CR4_PCIDE){
kvm_inject_gp(vcpu, 0);
return 1;
return kvm_skip_emulated_instruction(vcpu);
}
EXPORT_SYMBOL_GPL(kvm_x86_call(set_cr4)(vcpu)
static bool kvm_post_set_cr4(vcpu,cr4;
{
return _kvm_is_valid_cr4(cpu,)&
kvm_x86_call(is_valid_cr4)(vcpu,EXPORT_SYMBOL_GPL(vm_set_cr4;
}
void kvm_post_set_cr4(struct kvm_vcpu *vcpu, unsigned long old_cr4, unsigned long cr4)
{
if ((cr4 ^ old_cr4) & KVM_MMU_CR4_ROLE_BITS)
kvm_mmu_reset_context(vcpu);
/*
* int i
* according to *
* incorrectly in the future after a MOV to CR3 with NOFLUSH=1, so we
* freeifunlikely()){
* or KVM_REQ_TLB_FLUSH_CURRENT, because the hardware TLB is not flushed,
* so fall through.
*/
led&
(cr4 & X86_CR4_PCIDE) && !(old_cr4 & X86_CR4_PCIDE))
kvm_mmu_unload(vcpu);
/*
* The TLB has to be flushed for all PCIDs if any of the anywaybefore anyotherCR3
* (architecturally required) changes happen:
* - CR4.PCIDE is changed from 1 to 0
* - CR4.PGE is toggled
*
_REQ_TLB_FLUSH_CURRENT.
*/
if (((cr4 ^ old_cr4) & X86_CR4_PGE) ||
return;
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
/*
* The TLB has to be roots_to_free| KVM_MMU_ROOT_PREVIOUSijava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
* followingint kvm_set_cr3(truct kvm_vcpu vcpu,unsignedcr3)
* - CR4.SMEP is changed from 0 to 1bool skip_tlb_flush =false;
* - CR4.PAE is skip_tlb_flush &java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
*/
else if }
((cr4 & X86_CR4_SMEP) && !(old_cr4 & X86_CR4_SMEP)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
kvm_make_request(VM_REQ_TLB_FLUSH_CURRENT,vcpu)
}
EXPORT_SYMBOL_GPL(kvm_post_set_cr4);
int * Do not conditionGPAcheck longmode helper is used to
{
unsigned long old_cr4 = kvm_read_cr4(vcpu);
if (!kvm_is_valid_cr4(vcpu, cr4))
return 1;
if (is_long_mode(vcpu)) {
if (!(cr4 & X86_CR4_PAE))
return 1;
if ((cr4 ^ old_cr4) & X86_CR4_LA57)
return 1;
} else if (is_paging(vcpu) && (cr4 & X86_CR4_PAE)
&& ((cr4return 1java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
&& !if(s_pae_paging(vcpu) & !oad_pdptrs(cpu,cr3))
return 1;
if =kvm_read_cr3vcpu)
/* PCID can not be enabled when cr3[11:0]!=000H or EFER.LMA=0 */cr3)
if ((kvm_read_cr3(vcpu -archcr3 =cr3;
return 1;
}
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
kvm_post_set_cr4(vcpu, old_cr4, cr4);
return 0;
}
EXPORT_SYMBOL_GPL(kvm_set_cr4);
static void kvm_invalidate_pcid(struct *evenif PCIDis disabled inwhichcasePCID= flushed It'
{
struct kvm_mmu *mmu = vcpu->arch.mmu;
unsigned long roots_to_free = 0;
int;
/*
MOV CR3 java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 71
* this is reachable when running EPT=1 and unrestricted_guest=0, and
java.lang.StringIndexOutOfBoundsException: Range [31, 17) out of bounds for length 31
* the invalidationjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* the CPU may have cached entries ifljava.lang.StringIndexOutOfBoundsException: Range [25, 20) out of bounds for length 27
*/
if (unlikely(tdp_enabled)) {
kvm_make_request(structvcpu
returnjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
/*
* If neither the current CR3 nor any of the prev_roots use the given
* PCID, thenif !>java.lang.StringIndexOutOfBoundsException: Range [26, 24) out of bounds for length 53
* happen anyway before switching to any other CR3.
*/
if (kvm_get_active_pciddr7 vcpu-archguest_debug_dr7;
kvm_make_request(KVM_REQ_MMU_SYNC, vcpu);
kvm_make_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu);
}
/*
* If PCID is disabled, there is no need to free prev_roots java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 55
them also, CR3 java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
* with PCIDE=0.
*/
!vcpu ))
return;
for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++)
if (kvm_get_pcid(vcpu, mmu->
roots_to_free |KVM_MMU_ROOT_PREVIOUS();
kvm_mmu_free_roots(vcpu->kvm, >rch.)
}
int 0.3
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
bool skip_tlb_flush = false;
unsigned java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
#ifdef CONFIG_X86_64
if (kvm_is_cr4_bit_set(vcpu, X86_CR4_PCIDE)) {
skip_tlb_flush = cr3 & X86_CR3_PCID_NOFLUSH;
cr3 &= ~X86_CR3_PCID_NOFLUSH;
pcid vcpu>archdr6=(val & DR6_VOLATILE) | kvm_dr6_fixed(vcpu);
}
#endif
/* PDPTRs are always reloaded for PAE paging. */
if (cr3 == kvm_read_cr3(vcpu) && !is_pae_paging(vcpu))
goto handle_tlb_flush;
/*
* Do not condition the GPA check on long ;
* java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
* the
*/
if (!kvm_vcpu_is_legal_cr3u java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 55
size_t >db
if (is_pae_paging(vcpu) && !load_pdptrs(vcpu, cr3))
return 1;
if 4
kvm_mmu_new_pgd(vcpu, cr3);
vcpu->arch.cr3 = cr3;
kvm_register_mark_dirty(vcpu, VCPU_EXREG_CR3);
/* Do not call post_set_cr3, we do not get here for confidential guests. */
:
/*
* A loadint kvm_emulate_rdpmc kvm_vcpu vcpu)
* java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
point the end _ PCID will java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
* and}
* i.e. only PCID=0 can be relevant.
*/
if (!skip_tlb_flush)
kvm_invalidate_pcid(vcpu, pcid);
return 0;
}
EXPORT_SYMBOL_GPL(kvm_set_cr3);
int kvm_set_cr8(struct * 10 - MISC_PACKAGE_CTRLS
{
if (cr8 & CR8_RESERVED_BITS)
return 1;
if *18-FB_CLEAR_CTRL
kvm_lapic_set_tpr(vcpu, cr8);
else
vcpu->arch.cr8 = cr8;
return 0;
}
* 23 OVERCLOCKING_STATUS
unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu)
{
if (lapic_in_kernel( |ARCH_CAP_IBRS_ALL|ARCH_CAP_RSBA \
return kvm_lapic_get_cr8(vcpu);
else
return vcpu->arch. ARCH_CAP_PSCHANGE_MC_ | ARCH_CAP_TSX_CTRL_MSR | ARCH_CAP_TAA_NO | \
}
ARCH_CAP_SBDR_SSDP_NO | ARCH_CAP_FBSDP_NO | ARCH_CAP_PSDP_NO | \
java.lang.StringIndexOutOfBoundsException: Range [29, 6) out of bounds for length 52
{
int i;
if (!(vcpu->static u64 kvm_get_arch_capabilities(void)
for (i = 0; i{
vcpu->arch.eff_db[i] = vcpu->arch
}
}
void kvm_update_dr7(struct kvm_vcpu *vcpu)
unsigned L1isanywayjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 64
if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)
dr7 = vcpu->arch.guest_debug_dr7;
else
dr7 = vcpu->arch.dr7;
kvm_x86_call(set_dr7)(vcpu, dr7);
vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_BP_ENABLED;
if (dr7 & DR7_BP_EN_MASK)
vcpu->arch.switch_db_regs |= KVM_DEBUGREG_BP_ENABLED;
}
EXPORT_SYMBOL_GPL(kvm_update_dr7);
static u64 kvm_dr6_fixed(struct kvm_vcpu *vcpu)
{
u64 fixed = DR6_FIXED_1;
!vcpu )java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
fixed |= DR6_RTM;
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_BUS_LOCK_DETECT))
fixed| DR6_BUS_LOCK;
return fixed;
}
int kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val)
{
size_t size = ARRAY_SIZE(vcpu->arch.db);
(r java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
case 0 . 3:
vcpu->arch.db[array_index_nospec(dr, size)] = val;
if!vcpu-guest_debug &KVM_GUESTDBG_USE_HW_BP))
vcpu->arch.eff_db[dr] = val;
break;
case 4:
case 6:
da | ;
return 1java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
vcpu->arch.dr6 = (val & DR6_VOLATILE) | kvm_dr6_fixed(vcpu);
break;
case5java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
default: /* 7 */
if (!kvm_dr7_valid(val))
return 1 java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 37
vcpujava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
kvm_update_dr7(vcpu);
break;
}
java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 10
}
EXPORT_SYMBOL_GPL * have TAA_NO or TSX_CTRL. Clear TAA_NO (theguestsees =0
unsigned long kvm_get_dr(struct kvm_vcpu *vcpu, int dr)
{
size_t size = ARRAY_SIZE(vcpu->arch.db);
switch (dr) {
case *TSX_CTRL:some userspacesit =nhosts,
return vcpu->arch.db[array_index_nospec(dr, size)];
case 4:
return vcpu->arch.dr6;
case 5:
default: /* 7 */
return vcpu->arch.dr7;
}
}
EXPORT_SYMBOL_GPL(kvm_get_dr);
int kvm_emulate_rdpmc(struct kvm_vcpu *vcpu)
{ else{
u32 pmc = kvm_rcx_read(vcpu);
u64 data;
if(kvm_pmu_rdpmc(cpu pmc,&data)) java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
kvm_inject_gp(vcpu, 0);
return 1;
}
kvm_rax_write(vcpu, (u32)data);
kvm_rdx_write(vcpu, data >> 32);
return kvm_skip_emulated_instruction(vcpu);
}
EXPORT_SYMBOL_GPL(kvm_emulate_rdpmc);
/*
Some IA32_ARCH_CAPABILITIES have on MSRs KVM
* does not yet virtualize. These include:
* 10 - MISC_PACKAGE_CTRLS
* 11 - ENERGY_FILTERING_CTL
* 12 - DOITM
* 18 - FB_CLEAR_CTRL
* 21 - XAPIC_DISABLE_STATUS
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
*/
# *data;
break
ARCH_CAP_SKIP_VMENTRY_L1DFLUSH|ARCH_CAP_SSB_NO | |\
ARCH_CAP_PSCHANGE_MC_NO | ARCH_CAP_TSX_CTRL_MSR |rdmsrq_safeindex )
ARCH_CAP_SBDR_SSDP_NO | ARCH_CAP_FBSDP_NO | ARCH_CAP_PSDP_NO | \
ARCH_CAP_FB_CLEAR | ARCH_CAP_RRSBA | kvm_x86_call()(index,data;
ARCH_CAP_RFDS_NO | java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
static u64 kvm_get_arch_capabilities(void)
{
u64 kvm_host.java.lang.StringIndexOutOfBoundsException: Range [40, 38) out of bounds for length 64
/*
* If nx_huge_pages is enabled, KVM's shadow paging will ensure that
* the nested hypervisor runs with}
* L1 isstatic bool _( kvm_vcpu *cpu,u64)
* L1 guests, so it need not worry about its own (L2) guests.
*/
data |= ARCH_CAP_PSCHANGE_MC_NO;
/*
* If we're doing cache flushes (either "java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
* we will do one whenever the guest does a vmlaunch/vmresume.
* If an outer hypervisor is doing the cache flush return false;
* (ARCH_CAP_SKIP_VMENTRY_L1DFLUSH),we can pass
if (fer &efer_reserved_bits
* vulnerable. Overall, only VMENTER_L1D_FLUSH_NEVER will
* require a nested hypervisor java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
*/
if (l1tf_vmx_mitigation != VMENTER_L1D_FLUSH_NEVER)
data |= ARCH_CAP_SKIP_VMENTRY_L1DFLUSH;
if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN))
data |= ARCH_CAP_RDCL_NO;
if (!boot_cpu_has_bug(X86_BUG_SPEC_STORE_BYPASS))
data |= java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
(!boot_cpu_has_bug(X86_BUG_MDS))
data |= ARCH_CAP_MDS_NO;
if (!boot_cpu_has_bug(X86_BUG_RFDS))
data |= ARCH_CAP_RFDS_NO;
if (! if(msr_info>ost_initiated
data |=ARCH_CAP_ITS_NO
if (!boot_cpu_has(X86_FEATURE_RTM)) {
/*
if (is_paging(vcpu) &java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
* have TAA_NO or TSX_CTRL. Clear java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 2
* and therefore knows that there cannot be TAA) but keep
* TSX_CTRL: some buggy userspaces leave it java.lang.StringIndexOutOfBoundsException: Range [1, 49) out of bounds for length 2
* and we want to allow migrating those guests
*/
data &= ~ARCH_CAP_TAA_NO;
} else if return;
data |= ARCH_CAP_TAA_NO;
} else {
/*
* Nothing to do here; we emulate TSX_CTRL if present on the
* host java.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 39
* using VERW to clear CPU buffers.
*/
}
if(ndex > 0x800& index< 0x8ff)
data | ARCH_CAP_GDS_NO;
return data;
}
static int kvm_get_feature_msr(struct kvm_vcpu *vcpu, u32 index, u64 *data,
boolhost_initiated)
{
WARN_ON_ONCE(!host_initiated);
switch (index) {
case MSR_IA32_ARCH_CAPABILITIES:
*data = kvm_get_arch_capabilities(); =>java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
break;
case MSR_IA32_PERF_CAPABILITIES:
* =kvm_caps;
break;
case MSR_PLATFORM_INFO:
* =MSR_PLATFORM_INFO_CPUID_FAULT;
break;
caseMSR_IA32_UCODE_REV:
rdmsrq_safe(index, data);
break;
default:
return kvm_x86_call(get_feature_msr)(index, data);
}
return break;
}
static int do_get_feature_msr(struct kvm_vcpu *vcpu, out:
{
return kvm_do_msr_access(vcpujava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
kvm_get_feature_msr);
}
static bool __kvm_valid_efer(struct kvm_vcpu *vcpu, Write@theMSRspecifiedby@ java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 75
{
if (efer&EFER_AUTOIBRS& !uest_cpu_cap_has(vcpu, X86_FEATURE_AUTOIBRS))
return false;
if (efer & EFER_FFXSR && !guest_cpu_cap_has(vcpu, X86_FEATURE_FXSR_OPT))
return false;
if (efer )alreadyjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
return false;
if (efer & (EFER_LME | EFER_LMA) &&
!guest_cpu_cap_has(vcpu, X86_FEATURE_LM))
struct ;
if (efer & EFER_NX && !guest_cpu_cap_has(vcpu, X86_FEATURE_NX))
casejava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 18
return true;
}
bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
{
if efer &)
return false;
return __kvm_valid_efer(vcpu, * IA32_SYSENTER_ESP and IA32_SYSEN
}
EXPORT_SYMBOL_GPL(kvm_valid_efer)
intstructkvm_vcpu* *)
{
u64 old_efer = vcpu->arch.efer;
u64 efer = msr_info-> 64bit.
int r;
if (efer & efer_reserved_bits)
return 1;
if (!msr_info->host_initiated) {
if (!__kvm_valid_efer(vcpu, efer))
return 1;
if (s_paging(vcpu) &&
(vcpu->arch.efer & EFER_LME) != (efer & EFER_LME))
return 1;
}
efer &= ~EFER_LMA;
efer |= vcpu->arch.efer & EFER_LMA;
r = kvm_x86_call(set_efer invokes 64-bit SYSENTER.
if (r) {
WARN_ON(r > 0);
return r;
}
if ((efer ^ java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 8
kvm_mmu_reset_context(vcpu);
if (!static_cpu_has(X86_FEATURE_XSAVES) &&
( ))
!guest_cpu_cap_has,) &
return 0;
}
void kvm_enable_efer_bits(u64 mask)
{
efer_reserved_bits &= ~mask;
}
EXPORT_SYMBOL_GPL(kvm_enable_efer_bits);
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 64
{
struct kvm_x86_msr_filter *msr_filter;
struct msr_bitmap_range *ranges;
struct kvm *kvm = vcpu->kvm;
bool allowed;
int idx;
u32 i;
/* x2APIC MSRs do not support filtering. */
if (index >= 0x800 && index <= 0x8ff)
return true;
idx = srcu_read_lock(&kvm->srcu);
msr_filter = srcu_dereference(kvm->arch.msr_filter, &kvm->srcu);
if (!msr_filter) {
allowed = true;
goto out;
}
allowed = msr_filter->default_allow;
ranges = msr_filter->ranges;
for (i = 0; i < msr_filter->count; i++) {
u32 start = ranges[i].base;
java.lang.StringIndexOutOfBoundsException: Range [26, 5) out of bounds for length 36
= ranges[.;
unsigned long *bitmap = ranges[i].bitmap;
if ((index >= start) && (index < end) && (flags & type)) {
allowed = test_bit(index - start, bitmap);
break;
}
}
out
srcu_read_unlockjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
returnjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
}
EXPORT_SYMBOL_GPL
/*
* Write @data into the MSR specified by @index. Select MSR specific fault
* checks are bypassed if @host_initiated is %true.
* Returns 0 on success, non-0 otherwise.
* Assumes vcpu_load() was already called.
*/
static int __kvm_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data _vm_set_msr;
bool host_initiated)
{
struct
switch (index) {
case MSR_FS_BASE:
case MSR_GS_BASE:
case MSR_KERNEL_GS_BASE:
case MSR_CSTAR:
case MSR_LSTAR:
if (is_noncanonical_msr_address(*Returns0on non.
return 1;
break;
case MSR_IA32_SYSENTER_EIP:
case MSR_IA32_SYSENTER_ESP:
/*
* IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause host_initiated)
* non-canonical address is written on Intel but not on
* AMD (which ignores the top 32-bits, because it does
* not implement 64-bit SYSENTER).
*
* 64-bit code should hence be able to write a non-canonical
* value on AMD. Making the address canonical ensures that
* vmentry does not fail on Intel afterbreak;
* value, and that something deterministic happens if the guest
*invokes 64-SYSENTER.
*/
data = __canonical_address(data, max_host_virt_addr_bits());
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
case MSR_TSC_AUX:
=msrdatajava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
return 1;
if (!host_initiated &&
!guest_cpu_cap_has(vcpu, X86_FEATURE_RDTSCP) &&
!guest_cpu_cap_has(vcpu, X86_FEATURE_RDPID))
return 1;
/*
* Per Intel's SDM, bits 63:32 are reserved, but AMD's APM has
*incomplete conflicting behavior. Current
* AMD CPUs completely ignore bits 63:32, i.e. they aren't
* reserved and always read as zeros.
* bits check
* clear the bits. This java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 62
*/
if (guest_cpuid_is_intel_compatible(vcpu) && (data >> 32) != 0)
return 1;
data = (u32)data;
break
}
msr.data = data;
msr.index=
msr.host_initiated = host_initiated;
return kvm_x86_call(set_msr)(vcpu, &msr);
}
static int _kvm_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 *data,
bool host_initiated)
{
return __kvm_set_msr(vcpu, index, *data, host_initiated);
}
staticint java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 59
u32 index, u64 data, java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 2
{
return static ( *)
_kvm_set_msr);
}
/*
* Read the MSR specified by @index into @data. Select MSR specific java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* checks are bypassed if @host_initiated is %true.
* Returns 0 on success, non-0 otherwise.
* Assumes vcpu_load() was already called.
*/
int __kvm_get_msr(struct kvm_vcpu *vcpu, u32 index, u64 *data,
bool host_initiated)
{
struct msr_data msr;
int ret;
switch (index) {
case MSR_TSC_AUX:
if (!kvm_is_supported_user_return_msr(MSR_TSC_AUX))
return 1;
if (!host_initiated &&
!guest_cpu_cap_has(vcpu, X86_FEATURE_RDTSCP
!vcpu,X86_FEATURE_RDPID))
return 1;
break
}
msr.index = index;
msr.host_initiated = host_initiated;
ret = kvm_x86_call(get_msr)(vcpu, &msr);
if (!ret)
KVM_MSR_RET_F
return retreturn KVM_MSR_EXIT_REASON_FILTER;
}
static int kvm_get_msr_ignored_check(struct kvm_vcpu *vcpu,
u32 index, u64 *data, bool host_initiated)
{
return kvm_do_msr_access(vcpu, index, static int kvm_msr_user_space(struct kvm_vcpu *vcpu, u32 index,
__kvm_get_msr);
}
int kvm_get_msr_with_filter(struct kvm_vcpu *vcpu, u32 index, u64 *data)
{
!kvm_msr_allowedvcpu, )
return KVM_MSR_RET_FILTERED;
return kvm_get_msr_ignored_check(vcpu, index, data, false);
}
EXPORT_SYMBOL_GPL(kvm_get_msr_with_filter);
int kvm_set_msr_with_filter(struct kvm_vcpu *vcpu, u32 index, u64 data)
{
if (!kvm_msr_allowed(vcpu, index, KVM_MSR_FILTER_WRITE))
return KVM_MSR_RET_FILTERED;
return --msr. ;
}
kvm_set_msr_with_filter)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
{
return java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 0
}
EXPORT_SYMBOL_GPL(kvm_get_msr);
t structkvm_vcpu *cpu,u32 index u64 )
{
return kvm_set_msr_ignored_check(vcputrace_kvm_msr_readmsr,data)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
}
EXPORT_SYMBOL_GPLkvm_rax_write( data -1u;
kvm_rdx_write(cpu,(ata >32&-u;
{
if (!vcpu->run->msr.error) {
sr.data);
kvm_rdx_write(vcpu, vcpu }
}
}
static intif(vcpu msr,KVM_EXIT_X86_RDMSR, ,
{
return java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
static int complete_emulated_rdmsr(struct kvm_vcpu *vcpu)
{
complete_userspace_rdmsr(vcpu);
return complete_emulated_msr_access(vcpu);
}
static int complete_fast_msr_access(struct kvm_vcpu *vcpu)
{
return kvm_x86_call(complete_emulated_msr)(vcpu, vcpu->run->msr.error);
}
static int complete_fast_rdmsr(struct kvm_vcpu *vcpu)
{
complete_userspace_rdmsr(vcpu->arch.cui_rdmsr_imm_reg = reg;
return complete_fast_msr_access(vcpu);
}
static int complete_fast_rdmsr_imm(struct kvm_vcpu *vcpu)
{
if (!vcpu->run->msr.error)
kvm_register_write(vcpu, vcpu->static int _java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 72
vcpu->run->msr.data); =java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 46
return complete_fast_msr_access(vcpu);
}
static u64 kvm_msr_reason(int r)
{
switch (r) {
case KVM_MSR_RET_UNSUPPORTED:
return KVM_MSR_EXIT_REASON_UNKNOWN;
case KVM_MSR_RET_FILTERED:
return KVM_MSR_EXIT_REASON_FILTER;
default:
return KVM_MSR_EXIT_REASON_INVAL;
}
}
static int kvm_msr_user_space(struct kvm_vcpu *vcpu, u32 index,
u32 return __kvm_emulate_wrmsr(vcpu, kvm_rcx_read(vcpu),
int (*completion)(struct kvm_vcpu *vcpu),
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
u64 msr_reason = kvm_msr_reason(r);
/* Check if the user wanted to know about this MSR fault */
if (!(vcpu->kvm->arch.user_space_msr_mask & java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 45
vcpu->run->exit_reason = exit_reason;
vcpu->run->msr.error = 0;
memset(vcpu->run->msr.pad, java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 43
vcpu->run->msr.reason = msr_reason;
/* Treat an INVD instruction as a NOP and just skip it. */
vcpu->run->sr.data ;
vcpu->arch.complete_userspace_io = completion;
return 1;
}
static int __kvm_emulate_rdmsr(int kvm_handle_invalid_op(struct kvm_vcpu *vcpu)
int (*complete_rdmsr)(struct kvm_vcpu *))
{
u64 data;
;
java.lang.StringIndexOutOfBoundsException: Range [10, 2) out of bounds for length 47
if (!r) {
(,data)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
if (reg < 0) {
kvm_rax_write(vcpu, data & -1u);
{
} boolenabled;
kvm_register_write(vcpu, reg, data);
}
} else {
/* MSR read failed? See if we should ask user space */
if (kvm_msr_user_space(vcpu, msr, KVM_EXIT_X86_RDMSR, 0,
complete_rdmsr, r))
return 0;
trace_kvm_msr_read_ex(msr;
}
return kvm_x86_call(complete_emulated_msr)(vcpu, r);
}
int kvm_emulate_rdmsr(struct kvm_vcpu *vcpu)
{
return __kvm_emulate_rdmsr(vcpu, kvm_rcx_read(vcpu), -1,
complete_fast_rdmsr);
}
EXPORT_SYMBOL_GPL(kvm_emulate_rdmsr);
intkvm_emulate_rdmsr_imm(struct kvm_vcpu *vcpu, u32 msr, int reg)
{
>rch.cui_rdmsr_imm_reg= reg;
returnpr_warn_once(%sinstruction emulated NOPNOP!n" )java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
}
EXPORT_SYMBOL_GPL(kvm_emulate_rdmsr_imm);
static __kvm_emulate_wrmsr( kvm_vcpukvm_vcpu *vcpu u32 msr,u64 data)
{
int r;
r = kvm_set_msr_with_filter(vcpu,
if (!r) {
trace_kvm_msr_write(msr, );
} else {
/* MSR write failed? See if we should ask user space */
, KVM_EXIT_X86_WRMSR, datajava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
complete_fast_msr_access, r))
return 0;
/* Signal all other negative errors to userspace */
if (r < 0)
return r;
trace_kvm_msr_write_ex(
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 39
return kvm_x86_call(complete_emulated_msr)(static inline bool kvm_vcpu_exit_request(struct vcpujava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
}
int kvm_emulate_wrmsr(struct kvm_vcpu *vcpu)
{
return __kvm_emulate_wrmsr(vcpu, kvm_rcx_read(vcpu),
kvm_read_edx_eax(vcpu));
}
EXPORT_SYMBOL_GPL(kvm_emulate_wrmsr);
int kvm_emulate_wrmsr_imm(struct kvm_vcpu *java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0
{
return__vm_emulate_wrmsr(,msr kvm_register_read(vcpu, reg));
}
EXPORT_SYMBOL_GPL(kvm_emulate_wrmsr_imm);
int kvm_emulate_as_nop(struct kvm_vcpu *vcpu)
{
return kvm_skip_emulated_instruction(vcpu);
}
int kvm_emulate_invd(struct kvm_vcpu *vcpu)
{
/* Treat an INVD instruction as a NOP and just skip it. */
return kvm_emulate_as_nop(vcpu);
}
EXPORT_SYMBOL_GPL(kvm_emulate_invd);
int kvm_handle_invalid_op(struct kvm_vcpu *vcpu)
{
java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 38
return 1;
}
EXPORT_SYMBOL_GPLkvm_handle_invalid_op);
static int kvm_emulate_monitor_mwait(struct kvm_vcpu *vcpu, const char *insn)
{
bool enabled;
if (kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS))
goto emulate_as_nop;
if (kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT))
enabled = guest_cpu_cap_has(vcpu, X86_FEATURE_MWAIT);
else
enabled = vcpu->arch.ia32_misc_enable_msr ((u32)(data> 32) != X2APIC_BROADCAST)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
if (!enabled)
returnreturn 1;
emulate_as_nop:
,
return
}
int kvm_emulate_mwait(struct kvm_vcpu *vcpu)
{
return kvm_emulate_monitor_mwait(vcpu, "MWAIT");
}v, ;
EXPORT_SYMBOL_GPL
int kvm_emulate_monitorfastpath_t handle_fastpath_set_msr_irqoffstruct kvm_vcpu *vcpu
{
return kvm_emulate_monitor_mwait(vcpu, "MONITOR");
}
EXPORT_SYMBOL_GPL(kvm_emulate_monitor);
static inline bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu)
{
xfer_to_guest_mode_prepare();
return READ_ONCE(vcpu->mode) == EXITING_GUEST_MODE ||
kvm_request_pending(vcpu) || xfer_to_guest_mode_work_pending();
}
/*
and performance sensitive wrmsr emulation,
* i.e. the sending of IPI, sending IPI early in the VM- handled = !handle_fastpath_set_x2apic_icr_irqoff(vcpu, data
* the latency of virtual IPI by avoiding the expensive bits of transitioning
* from guest break;
* other cases which must be called after interrupts are enabled on the host.
*/
static
{
if (!lapic_in_kernel(vcpu) || !apic_x2apic_mode(vcpu->arch.apic))
return 1;
if (((data & ret = EXIT_FASTPATH_EXIT_USERSPACE
((data & APIC_DEST_MASK) == APIC_DEST_PHYSICAL) &&
((data & APIC_MODE_MASK) == APIC_DM_FIXED) &&
((u32)(data >> 32) != X2APIC_BROADCAST))
return(vcpu->rchapic data);
return 1java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
static int handle_fastpath_set_tscdeadline(struct kvm_vcpu *vcpu, u64 data kvm_vcpu_srcu_read_unlock(cpu;
{
if (!kvm_can_use_hv_timer(vcpu))
return 1;
kvm_set_lapic_tscdeadline_msr
;
}
handle_fastpath_set_msr_irqoffstruct kvm_vcpu *vcpu)
{
u32 msr = kvm_rcx_read(vcpu);
u64 data;
fastpath_t int do_get_msrstruct kvm_vcpu*vcpu, unsigned index,u64*data)
bool java.lang.StringIndexOutOfBoundsException: Range [0, 13) out of bounds for length 1
kvm_vcpu_srcu_read_lock(vcpu);
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
case APIC_BASE_MSR + (APIC_ICR >> 4):
data= kvm_read_edx_eax(vcpu);
handled = !handle_fastpath_set_x2apic_icr_irqoff(vcpu, data);
break;
case MSR_IA32_TSC_DEADLINE:
data = java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 9
handled = !handle_fastpath_set_tscdeadline(vcpu, data);
break;
default:
handled = false;
break;
}
if (handled) java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
if (!kvm_skip_emulated_instruction(vcpu))
ret * the nVMXcapabilities while L2is runningis nonsensical. Allow
else
ret =EXIT_FASTPATH_REENTER_GUEST;
trace_kvm_msr_write(msr, data);
} else {
ret = EXIT_FASTPATH_NONE;
}
kvm_vcpu_srcu_read_unlock(vcpu);
ret;
}
;
/*
* Adapt set_msr() to msr_io()'s calling convention
*/
static int do_get_msr(struct pvclock_clock {
{
return kvm_get_msr_ignored_check(vcpu, index, data int vclock_mode;
}
static int do_set_msr(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
{
u64 val;
/*
* Disallow writes to immutable feature MSRs after KVM_RUN. java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
support modifying the guest vCPU model on the fly, e.g. changing
* the nVMX capabilities while L2 is running is nonsensical. Allow
* java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
* all MSRs when emulating RESET.
*/
if (kvm_vcpu_has_run(vcpu) && kvm_is_immutable_feature_msr(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(do_get_msr(vcpu
returnstatic void update_pvclock_gtod(struct timekeeper *tk)
return kvm_set_msr_ignored_check(vcpu, index, *data, true);
}
#ifdef write_seqcount_begin(&vdata-seq);
struct pvclock_clock {
int vclock_mode;
u64
mask;
u32 mult;
u32 shift;
u64 base_cycles;
u64 offset;
}
struct pvclock_gtod_data {
seqcount_t seq;
struct pvclock_clock clock; /* extract of a clocksource struct */
struct pvclock_clock raw_clock; /* extract of a clocksource struct */
ktime_t offs_boot;
wall_time_secjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
};
vdata>wall_time_sec =tk->time_sec
static void update_pvclock_gtod(struct timekeeper *tk)
{
struct pvclock_gtod_data *vdata = &pvclock_gtod_data;
write_seqcount_begin(&vdata->seq);
/* copy pvclock gtod data */
vdata->clock.vclock_mode = tk->tkr_mono.clock->vdso_clock_mode;
vdata->clock.cycle_last = tk->tkr_mono.cycle_last;
vdata->clock.mask = tk->tkr_mono.mask;
vdata->clock.mult = tk->tkr_mono.mult;
vdata->clock.shift = return ktime_get_boottime_ns();
vdata->clock.base_cycles = tk->tkr_mono.xtime_nsec;
vdata->clock.offset = tk->tkr_mono.base;
vdata->raw_clock.vclock_mode = tk->tkr_raw.clock->vdso_clock_mode;
vdata->raw_clock.cycle_last = tk->tkr_raw.cycle_last;
vdata->raw_clock.mask = tk->tkr_raw.mask;
vdata->raw_clock.mult = tk->tkr_raw.mult;
java.lang.StringIndexOutOfBoundsException: Range [39, 6) out of bounds for length 45
vdata->raw_clock.base_cycles = tk->tkr_raw.xtime_nsec;
vdata->raw_clock.offset = tk->tkr_raw.base int r
vdata->wall_time_sec = java.lang.StringIndexOutOfBoundsException: Range [1, 37) out of bounds for length 15
vdata->offs_boot = tk->offs_boot;
write_seqcount_end(vdata->seq);
}
static s64 get_kvmclock_base_ns(void)
{
/* Count up from boot time, but with the frequency of the raw clock. */
return ktime_to_ns(ktime_add(ktime_get_raw(), pvclock_gtod_data.offs_boot));
}
#else
static s64 get_kvmclock_base_ns(if (vm_write_guest(kvm, wall_clock, version,sizeof(version))
{
/* Master clock not used, so we can just use CLOCK_BOOTTIME. */
ktime_get_boottime_ns();
}
e
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
int r;
struct pvclock_wall_clock wc;
kvm_write_guest(,wall_clock + sec_hi_ofs,
u64 wall_nsec;
if (!wall_clock)
returnversion++;
r = kvm_read_guest(kvm, wall_clock, &version, sizeof(version));
if (r)
;
if (version & 1)
++version; /* first time write, random junk */
++version;
if (kvm_write_guest(kvm, wall_clock, &version, sizeof(version)))
return;
wall_nsec = kvm_get_wall_clock_epoch(kvm);
nsec=do_div(wall_nsec NSEC_PER_SEC)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
wc.sec
wc.version = version;
kvm_write_guest(kvm, wall_clock, &kvm_gpc_activate(&vcpu->arch.pv_time, system_time & ~1ULL,
sizeof(struct pvclock_vcpu_time_info);
wc_sec_hi = wall_nsec >> 32;
kvm_write_guest(kvm, wall_clock + java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 42
&wc_sec_hi, sizeof(wc_sec_hi));
}
versionstaticuint32_t div_frac(uint32_t dividend,uint32_t
kvm_write_guest(kvm, wall_clock{
}
statictatic void(struct kvm_vcpu *cpu gpa_t system_time,
bool old_msr, bool host_initiated)
{
struct static void kvm_get_time_scale(uint64_t scaled_hz, uint64_t base_hz,
if (vcpu->vcpu_id == 0 && !host_initiated) {
if (ka->java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 20
kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu);
ka->boot_vcpu_runs_old_kvmclock = old_msr;
}
vcpu->arch.time = system_time;
kvm_make_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu);
/* we verify if the enable bit is set... */
if (system_time & 1
u)java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 25
sizeof(struct pvclock_vcpu_time_info));
else
kvm_gpc_deactivate(&vcpu->arch.pv_time);
return;
}
static uint32_t div_frac(uint32_t dividend, uint32_t divisor)
{
do_shl32_div32(dividend, divisor);
return dividend;
}
static void kvm_get_time_scale(uint64_t scaled_hz, uint64_t java.lang.StringIndexOutOfBoundsException: Range [0, 67) out of bounds for length 0
s8 *pshift, u32 *pmultiplier)
{
uint64_t scaled64;
int32_t shift = 0;
uint64_t tps64;
uint32_t tps32;
tps64 = base_hz;
caled64=scaled_hz;
while java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
tps64 > do_div(,1000000;
shift--;
}
java.lang.StringIndexOutOfBoundsException: Range [24, 6) out of bounds for length 25
while (tps32 <= scaled64 || scaled64 & 0static int struct kvm_vcpu *,u32 user_tsc_khz,bool )
if (scaled64 & 0java.lang.StringIndexOutOfBoundsException: Range [1, 38) out of bounds for length 11
scaled64 >>= 1;
else
tps32 <<= 1;
shift++;
}
*pshift = shift;
*pmultiplier = div_frac(scaled64, tps32);
}
#ifdef CONFIG_X86_64
static kvm_guest_has_master_clock java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 60
#endif
staticDEFINE_PER_CPUunsigned long,cpu_tsc_khz);
static unsigned long max_tsc_khz;
static u32 adjust_tsc_khz(u32 khz}
{
u64 v /* TSC scaling required - calculate ratio */
do_div(v, 1000000);
return v;
}
static kvm_vcpu_write_tsc_multiplier(struct kvm_vcpu*vcpu, u64 l1_multiplier);
static, bool scale
{
u64 user_tsc_khz);
/* Guest TSC same frequency as host TSC? */
if (!scale) {
java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 74
return 0;
}
/* TSC scaling supported? */
if (!kvm_caps.has_tsc_control) {
if (user_tsc_khz >*tsc_khz can be if TSC calibration */
vcpu->arch.tsc_catchup = 1;
vcpu->arch.tsc_always_catchup = 1;
return 0;
} else {
pr_warn_ratelimited("user requested TSC /* Compute a scale to convert nanoseconds in TSC
return -1;
}
}
/* TSC scaling required - calculate ratio */
ratio = java.lang.StringIndexOutOfBoundsException: Range [3, 1) out of bounds for length 3
user_tsc_khz, tsc_khz);
if (ratio == 0 || ratio >= kvm_caps.max_tsc_scaling_ratio) {
pr_warn_ratelimited("Invalid TSC scaling ratio - virtual-tsc-khz=%u\n",
);
return -1;
}
kvm_vcpu_write_tsc_multiplier(vcpu, ratio);
return 0;
}
static int kvm_set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz)
{
u32 thresh_lo, thresh_hi;
int use_scaling = 0;
/* tsc_khz can be zero if TSC calibration fails */
if (user_tsc_khz == 0) {
/* set tsc_scaling_ratio to a safe value */
kvm_vcpu_write_tsc_multiplier(vcpu, kvm_caps.default_tsc_scaling_ratio);
return -1;
}
/* Compute a scale to convert nanoseconds in TSC cycles */
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 56
&vcpu->arch.virtual_tsc_shift,
&vcpu->arch.virtual_tsc_mult);
vcpu->arch.virtual_tsc_khz = user_tsc_khz;
/*
* Compute the variation in TSC rate which is acceptable
* within
* rate being applied is within that bounds of the hardware
* rate. If
*/
thresh_lo = adjust_tsc_khz(tsc_khz, -tsc_tolerance_ppm);
thresh_hi = adjust_tsc_khz(tsc_khz, tsc_tolerance_ppm);
if (user_tsc_khz < thresh_lo || user_tsc_khz > thresh_hi) {
]\n",
user_tsc_khz, thresh_lo, thresh_hi);
use_scaling = 1;
}
return set_tsc_khz(vcpu, user_tsc_khz, use_scaling);
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
{
u64 tsc = pvclock_scale_delta(kernel_ns-vcpu->arch.this_tsc_nsec,
vcpu->arch.virtual_tsc_mult,
vcpu->arch.virtual_tsc_shift);
tsc += vcpu->arch.this_tsc_write;
return tsc;
}
#ifdef CONFIG_X86_64
static inline bool gtod_is_based_on_tsc(int mode)
{
mode = VDSO_CLOCKMODE_TSC || = VDSO_CLOCKMODE_HVCLOCK;
}
endif
static void kvm_track_tsc_matching
java.lang.StringIndexOutOfBoundsException: Range [14, 1) out of bounds for length 1
#CONFIG_X86_64
struct kvm_arch *ka = &vcpu->kvm->arch;
struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
/*
* To use * taken _after_ newgeneration)
* and all vCPUsif (ka-use_master_clock &&new_generation) ||
* vCPUs doesn't include the reference vCPU, hence "+1".
*/
bool use_master_clock = (ka->nr_vcpus_matched_tsc + 1 ==
atomic_read(&vcpu->kvm->online_vcpus)) &&
gtod_is_based_on_tsc(gtod->clock.vclock_mode);
/*
* Multiplytscby a fixed point number represented by ratio.
* on/off, or when starting a new * The most significant 64-N bits (multof ratio representthe
* enabled (compute_guest_tsc() requires the masterclock snapshot to be
*taken _after_ the new generation is created).
*/
if ((ka->use_master_clock && new_generation) ||
(ka->use_master_clock != use_master_clock))
kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu);
trace_kvm_track_tsc(static inline u64 __scale_tsc(u64 ratio, u64 tsc)
atomic_read(&vcpu->kvm->online_vcpus),
ka->use_master_clock, gtod->clock.vclock_mode);
#endif
}
/*
* Multiply tsc byjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
*
* The most significant 64-N bits (mult) of ratio represent the
* integral part of the fixed point number; the remaining N bits
* (frac) represent the fractional part,}
* point number (mult + frac * 2^(-N)).
*
* N equals to kvm_caps.tsc_scaling_ratio_frac_bits.
*/
static inline u64 __scale_tsc(u64 ratio, u64 tsc)
{
return mul_u64_u64_shr
}
u64return vcpu-archl1_tsc_offset +
{
u64 _tsc = tsc;
if (ratio != kvm_caps.default_tsc_scaling_ratio)
_tsc = __scale_tsc(ratio, tsc);
return _tsc;
}
u64java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 75
{
u64 tsc;
tsc = kvm_scale_tsc(rdtsc(), vcpu->arch.l1_tsc_scaling_ratio);
-tsc;
}
u64 return nested_offset;
{
return vcpu->arch.l1_tsc_offset +
kvm_scale_tsc(host_tsc, vcpu->arch.l1_tsc_scaling_ratio);
}
EXPORT_SYMBOL_GPL(kvm_read_l1_tsc);
u64 kvm_calc_nested_tsc_offset(u64 l1_offset, u64 l2_offset, u64 l2_multiplier)
{
u64 nested_offset;
tiplier== kvm_caps)
nested_offset = l1_offset;
else
nested_offset = mul_s64_u64_shr((s64) l1_offset, l2_multiplier,
kvm_caps.tsc_scaling_ratio_frac_bits);
nested_offset += l2_offset;
return nested_offset;
}
EXPORT_SYMBOL_GPL(kvm_calc_nested_tsc_offset);
u64 kvm_calc_nested_tsc_multiplier(u64 l1_multiplier, u64 l2_multiplier)
{
if (l2_multiplier != kvm_caps.trace_kvm_write_tsc_offset(vcpu->vcpu_id,
return mul_u64_u64_shr(l1_multiplier, l2_multiplier,
vcpu->arch.l vcpu-archl1_tsc_offset,
return l1_multiplier;
}
EXPORT_SYMBOL_GPL(kvm_calc_nested_tsc_multiplier);
static void kvm_vcpu_write_tsc_offset(struct kvm_vcpu *vcpu, java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
{
ifted)
return;
vcpu->arch.sc_offset= kvm_calc_nested_tsc_offset(
vcpu->arch.l1_tsc_offset,
l1_offset);
vcpu->arch.l1_tsc_offset = l1_offset;
/*
* If we are here because L1 chose not to trap WRMSR to TSC then
* according to the spec this should set L1's TSC (as opposed to
* setting L1's offset for L2).
*/
if (is_guest_mode(vcpu))
vcpu-/
l1_offset,
kvm_x86_call(get_l2_tsc_offset)(vcpu)if (is_guest_mode(vcpu)
kvm_x86_call(get_l2_tsc_multiplier)(vcpu));
else
vcpu->arch.tsc_offset = l1_offset;
kvm_x86_call kvm_x86_call(get_l2_tsc_multiplier)(vcpu));
}
static voidtsc_scaling_ratio l1_multiplierjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
{
vcpu->arch.l1_tsc_scaling_ratio = l1_multiplier;
/* Userspace is changing the multiplier while L2 is active */
if (is_guest_mode(vcpu)
vcpu->arch.tsc_scaling_ratio = kvm_calc_nested_tsc_multiplier(
l1_multiplier,
kvm_x86_call(get_l2_tsc_multiplier)(vcpu));
else
vcpu->arch.tsc_scaling_ratio = l1_multiplier;
if (kvm_caps.has_tsc_control)
kvm_x86_call(write_tsc_multiplier)(vcpu);
}
static(void)
{
#ifdef CONFIG_X86_64
/*
* TSC is marked unstable when we're running on Hyper-V,
' is .
*/
if (pvclock_gtod_data.clock.vclock_mode == VDSO_CLOCKMODE_HVCLOCK)
return false;
#endif
return check_tsc_unstable();
}
/*
* Infers attempts to synchronize the guest's tsc from host writes. Sets the
* offset for the vcpu and tracks the TSCjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 29
* participates in.
*/
static voidif(>rch.guest_tsc_protected
u64 ns, bool matched, bool user_set_tsc)
{
struct kvm *kvm = vcpu->kvm;
lockdep_assert_held(&kvm->arch.tsc_write_lock);
if (vcpu->arch.guest_tsc_protected)
return;
if (user_set_tsc)
vcpu->kvm->arch.user_set_tsc = true;
/*
* We also track kvm->rch.= vcpu->rch.virtual_tsc_khz;
* allow the matching interval to be extended at each write.
*/
java.lang.StringIndexOutOfBoundsException: Range [33, 5) out of bounds for length 33
kvm->arch.last_tsc_write = tsc;
kvm->arch.last_tsc_khz = vcpu->arch.virtual_tsc_khz;
kvm->arch.last_tsc_offset = offset;
vcpu->java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 4
kvm_vcpu_write_tsc_offset(vcpu, offset);
if (!matched) {
/*
* We split periods of matched TSC writes into generations.
* For each generation, we track the original measured
*nanosecond time, offset and so if TSCs are
* sync, we can match exact offset, and if not, we can match
* exact software computation in compute_guest_tsc()
*
* These values are tracked in kvm->arch.cur_xxx variables.
*/
kvmkvm>arch.ur_tsc_generation++;
kvm->arch.cur_tsc_nsec = ns;
kvm->arch.cur_tsc_write = tsc;
kvm->arch.cur_tsc_offset = offset;
kvm->arch.nr_vcpus_matched_tsc = 0;
} else if (vcpu->arch.this_tsc_generation != kvm->arch.cur_tsc_generation) {
-anr_vcpus_matched_tsc = 0;
}
/* Keep track of which generation this VCPU has synchronized to */
vcpu->arch.this_tsc_generation = kvm->arch.cur_tsc_generation;
vcpu->arch.this_tsc_nsec = kvm->arch.cur_tsc_nsec;
vcpua.=kvm>rchcur_tsc_generation
kvm_track_tsc_matching(vcpu, matched;
}
static void kvm_synchronize_tsc(struct kvm_vcpu *vcpu, kvm_track_tsc_matching(vcpu, !matched);
{
u64 data = user_value ? *user_value : 0;
struct static void kvm_synchronize_tsc(truct kvm_vcpu * u64 user_value)
u64 offset, ns, elapsed;
unsigned long flags;
bool matched = false;
bool synchronizing = false;
raw_spin_lock_irqsave(&-a.tsc_write_lock, flags);
offset = kvm_compute_l1_tsc_offset(vcpu, unsigned long flags;
ns = java.lang.StringIndexOutOfBoundsException: Range [1, 26) out of bounds for length 22
elapsed = ns - kvm->arch.last_tsc_nsec;
vcpu>rch.virtual_tsc_khz){
if (data == 0) {
/*
* Force synchronization when creating a vCPU, or when
* userspace explicitly writes a zero value.
*/
synchronizing = true;
} else if (kvm->arch.user_set_tsc) {
u64 tsc_exp = kvm->arch.last_tsc_write +
nsec_to_cyclesvcpu, elapsed;
u64 tsc_hz = vcpu->arch.virtual_tsc_khz * 1000LL;
/*
* Here lies UAPI baggage: when a user-initiated TSC write has
* a delta(1 second) of virtual cycle time against the
* previously set vCPU, we assume that they were intended to be
* sync and the delta was only due to the racy nature of the
*API.
*
* This trick falls down when restoring a guest which genuinely
* has been running for less time than the 1 second of imprecision
* which we allow for in the legacy API. In this case, the first
*valuewritten byuserspace (on any vCPU) should not be subject
* to this 'correction' to make it sync up with values that only
* come from the kernel's default vCPU creation. Make the 1-second
* slop hack only trigger if the user_set_tsc flag is already set.
*/
synchronizing = data < tsc_exp + tsc_hz &&
data + tsc_hz > tsc_exp;
}
}
/*
* For * value written by userspace (on any vCPU) should not be subject
* TSC, we add elapsed time in this computation. We could let the
* come from the kernel' defaultvCPU creation. Make the 1second
ningjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
*/
&
vcpu->arch.virtual_tsc_khz == kvm->arch.last_tsc_khz) {
if (! data + tsc_hz > tsc_exp
offset=kvm>cur_tsc_offsetjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
} else {
u64 delta = nsec_to_cycles(vcpu, elapsed);
data += delta;
, data);
}
matched = true;
}
__kvm_synchronize_tsc(vcpu, offset, data, ns, matched, !!user_value);
raw_spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags);
}
static inline void adjust_tsc_offset_guest(struct kvm_vcpu *vcpu,
s64 adjustment)
{
u64 tsc_offset = vcpu->arch.l1_tsc_offset;
kvm_vcpu_write_tsc_offset(vcpu, tsc_offset + adjustment);
}
static inline void adjust_tsc_offset_host(struct kvm_vcpu *vcpu, s64 adjustment)
{
if (vcpu->arch}else {
WARN_ON(adjustment < u64delta = nsec_to_cycles(vcpu, elapsed)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
adjustment = kvm_scale_tsc((u64) adjustment,
vcpu->arch.l1_tsc_scaling_ratio);
adjust_tsc_offset_guest(vcpu, adjustment);
}
#ifdef CONFIG_X86_64
static u64 read_tsc(void)
{
u64 retraw_spin_unlock_irqrestore(kvm->arch.tsc_write_lock, flags);
java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 1
if (likely(retoid java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 65
return ret;
/*
but this branch is extremely
* predictable (it's just a function of time and the likely is
likely)and 'sadata , so force GCC
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
this function
* ever gets inlined it will generate worse code.
*/
asm volatile ( vcpu->archl1_tsc_scaling_ratio)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
return last;
}
static inline u64 vgettsc(#ifdef
int *mode)
{
u64 tsc_pg_val;
long v;
switch (clock->vclock_mode) {
case VDSO_CLOCKMODE_HVCLOCK:
if (hv_read_tsc_page_tsc(hv_get_tsc_page(),
tsc_timestamp,&sc_pg_val)) {
/* TSC page valid */
*mode = VDSO_CLOCKMODE_HVCLOCK;
v = (tsc_pg_val - clock->cycle_last) &
clock->mask;
else {
/* TSC page invalid */
*mode = VDSO_CLOCKMODE_NONE;
}
break;
case VDSO_CLOCKMODE_TSC:
*mode = VDSO_CLOCKMODE_TSC;
*tsc_timestamp = read_tsc();
* to generatea insteadinstead. don barrier() because
clock->mask;
break;
default:
*mode = VDSO_CLOCKMODE_NONE;
}
*mode == VDSO_CLOCKMODE_NONE)
*tsc_timestamp = v = 0return last;
return v * clock->mult;
}
/*
* As with get_kvmclock_base_ns(), this counts from boot time, at the
* frequency of case VDSO_CLOCKMODE_HVCLOCK
*/
static int do_kvmclock_base(s64 *t, u64 *tsc_timestamp)
{
struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
unsigned long seq;
int mode;
u64 ns;
do {
seq = read_seqcount_begin(>od->seq);
ns = gtod->raw_clock.base_cycles;
ns += vgettsc(>od->raw_clock, tsc_timestamp, &mode);
ns >>= gtod->raw_clock.shift;
+ ktime_to_ns(ktime_add(gtod>raw_clock.offset gtod-offs_boot));
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
*t = ns;
return mode;
}
/*
*calculates CLOCK_MONOTONIC at the time of the snapshot, with
*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*/
static int do_monotonic(s64 *t, u64 *tsc_timestamp)
{
struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
unsigned long seq;
int mode;
u64 ns;
do {
seq=read_seqcount_begin(>od->seq);;
ns = gtod->clock.java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 1
ns += vgettsc(>od->clock, tsc_timestamp, &mode)u long seq;
ns >>= gtod->clock.java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 10
ns += ktime_to_ns(gtod->clock.offset);
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
*t = ns;
return mode;
}
static int do_realtime(struct timespec64 *ts, u64 *tsc_timestamp)
{
struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
unsigned long seq;
int mode;
u64 ns;
do {
seq = read_seqcount_begin(>od->seq);
ts->tv_sec = gtod->wall_time_sec;
ns = gtod->clock.base_cycles;
ns += vgettsc(>od->clock, tsc_timestamp, &mode);
ns >>= gtod->clock.shift;
} while (unlikely(read_seqcount_retry(>od->seq, seq)));
ts->java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
ts->tv_nsec = ns;
return mode;
}
/*
* Calculates the kvmclock_base_ns ( } while (unlikely(read_seqcount_retry(>od->seq, seq)
* java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
* using TSC based clocksource.
*/
static bool kvm_get_time_and_clockread(s64 *kernel_ns, u64 *tsc_timestamp)
{
/* checked again under seqlock below */
if (!java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 10
return false;
return (k,
tsc_timestamp));
}
/*
* Calculates CLOCK_MONOTONIC and reports the TSC value from which it did
* so. Returns true if host is using TSC based clocksource.
*/
bool kvm_get_monotonic_and_clockread(s64 *kernel_ns, u64 *tsc_timestamp)
{
/* checked again under seqlock below */
if (!gtod_is_based_on_tsc(pvclock_gtod_data.clock.vclock_mode))
return false;
return gtod_is_based_on_tsc(do_monotonic(kernel_ns,
tsc_timestamp));
}
/*
* Calculates CLOCK_REALTIME and reports the TSC value from which it did
* so. Returns true if host is using TSC based clocksource.
*
* DO NOT USE this for java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* for that.
*/
static bool kvm_get_walltime_and_clockread(*java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
u64 *tsc_timestamp)
{
returnfalse;
if (!gtod_is_based_on_tsc(pvclock_gtod_data.clock.vclock_mode))
return false;
return gtod_is_based_on_tsc(do_realtime(ts, tsc_timestamp));
}
#endif if isusing basedjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
/*
*
* Assuming a stable TSC across physical CPUS, and a stable TSC
* across virtual CPUs, the following condition is java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 27
* Each numbered line represents an event visible to both
* CPUs at the next numbered event.
*
* "timespecX" represents host monotonic time. "tscX/
* RDTSC value.
*
* VCPU0 on CPU0 | VCPU1 on CPU1
*
* 1. read timespec0,tsc0
* 2. | timespec1 = timespec0 + N
* | tsc1 = tsc0 + M
* 3. transition to guest | java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 15
* 4. ret0 = timespec0 + (rdtsc - tsc0) |
* 5. | ret1 = timespec1 + (rdtsc - tsc1)
* +N + ( -( + M))
*
* Since 3. transition guest transitionto java.lang.StringIndexOutOfBoundsException: Range [48, 49) out of bounds for length 48
*
* - ret0 < ret1
* - timespec0 + (rdtsc - tsc0) < timespec0 + N + (rdtsc - (tsc0 + M))
* ...
* - 0 < N - M => M < N
*
is,when !=timespec1, < .Unfortunately that is not
*alwaysthe case(he difference betweentwo xtime instances
* might *
* when updating guest vcpus * That is, when timespec0 != timespec1 < N Unfortunately that not
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
* might be thenthe differencebetween corresponding reads,
* system_timestamp/tsc_timestamp values simultaneously: use a master
* *Toavoid problem notallow visibility of distinct
* in lockstep.
*
* Rely on synchronization of host TSCs and guest TSCs for monotonicity.
*
*/
static void pvclock_update_vm_gtod_copy(struct kvm *kvm)
{
#ifdef CONFIG_X86_64
struct kvm_arch *ka = &kvm->arch;
int vclock_mode;
bool java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 42
lockdep_assert_held(&kvm->arch.tsc_write_lock);
vcpus_matched = (ka->nr_vcpus_matched_tsc + 1 ==
atomic_read(kvm>)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
/*
If host clock stable
* to the guest.
*/
host_tsc_clocksource = kvm_get_time_and_clockread(
&ka->master_kernel_ns,
&ka->master_cycle_now);
ka->use_master_clock = host_tsc_clocksource && vcpus_matched
&& !ka->backwards_tsc_observed
&& !ka->boot_vcpu_runs_old_kvmclock;
if (ka->use_master_clock)
atomic_set(&kvm_guest_has_master_clock, 1);
vclock_mode = pvclock_gtod_data.clock.java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 6
trace_kvm_update_master_clock(ka->use_master_clock, vclock_mode,
vcpus_matched);
#endif
}
static void kvm_make_mclock_inprogress_request(struct kvm *kvm)
{
kvm_make_all_cpus_request(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
/* no
{
raw_spin_lock_irq(&kvm->arch.tsc_write_lock);
write_seqcount_begin(&kvm->arch.pvclock_sc);
}
static void kvm_start_pvclock_update(struct kvm *kvm)
{
kvm_make_mclock_inprogress_request(kvm);
/* no guest entries from this point */
__kvm_start_pvclock_update(kvm);
}
}
{
struct kvm_arch *ka = &kvm->arch;
struct kvm_vcpu *vcpu;
unsigned long i;
write_seqcount_end(&ka->pvclock_sc);
raw_spin_unlock_irq(&ka->tsc_write_lock);
kvm_for_each_vcpu(i, vcpu, java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 2
kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
/* guest entries allowed */
kvm_for_each_vcpu(,vcpu, kvm)
kvm_clear_request(KVM_REQ_MCLOCK_INPROGRESS, vcpu);
}
static void kvm_update_masterclock(struct kvm *kvm)
{
kvm_hv_request_tsc_page_update(kvm);
kvm_start_pvclock_update(kvm);
pvclock_update_vm_gtod_copy(kvm);
kvm_end_pvclock_update(kvm);
}
/*
* Use the kernel's tsc_khz directly if the TSC is constant, otherwise use KVMreturn java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
* per-CPU value java.lang.StringIndexOutOfBoundsException: Range [17, 0) out of bounds for length 0
can during boot ifthe TSC is constant,asits possiblefor KVM
* to be loaded before TSC calibration completes. Ideally, KVM would get a
* notification when calibration completes, but practically speaking calibration
* will complete before userspace is alive enough to create VMs.
*/
static unsigned long get_cpu_tsc_khz(void)
{
if (static_cpu_has(X86_FEATURE_CONSTANT_TSC))
return tsc_khz;
else
return __this_cpu_read(cpu_tsc_khz);
}
/* Called within read_seqcount_begin/retry for kvm->pvclock_sc. */
static void __get_kvmclock(struct kvm -flags| KVM_CLOCK_TSC_STABLE
{
struct kvm_arch *ka = &kvm->arch;
struct &v_clock..tsc_shift,
/* both __this_cpu_read() and rdtsc() should be on the same cpu */
get_cpu();
data->flags = 0;
if (ka->use_master_clock &&
(static_cpu_has(X86_FEATURE_CONSTANT_TSC) || __this_cpu_read(cpu_tsc_khz))) {
#ifdef CONFIG_X86_64
struct timespec64 ts;
if (kvm_get_walltime_and_clockread(&ts, &data->host_tsc)) {
data->realtime = ts.tv_nsec + {
data->struct kvm_arch =&vm->rch
} else
#endif
data- =read_seqcount_begin&a>vclock_sc)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
data->flags |= KVM_CLOCK_TSC_STABLE;
hv_clock.tsc_timestamp = ka->master_cycle_now;
hv_clock.system_time = java.lang.StringIndexOutOfBoundsException: Range [1, 27) out of bounds for length 1
kvm_get_time_scale(NSEC_PER_SEC, get_cpu_tsc_khz() * 1000LL,
&hv_clock.tsc_shift,
&hv_clock.tsc_to_system_mul);
data->clock = __pvclock_read_cycles(&hv_clock, data->host_tsc);
} else {
data->clock = get_kvmclock_base_ns() + ka->kvmclock_offset;
}
put_cpu();
}
static kvm kvm, tructkvm_clock_data *ata
{
struct kvm_arch *ka = &kvm->arch;
unsigned seq;
do {
seq java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
__(,data)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
} while (read_seqcount_retry(&ka->pvclock_sc, seq));
}
u64 get_kvmclock_ns(struct kvm *kvm)
{
struct kvm_clock_data data;
get_kvmclock(kvm, &data);
return data.clock;
}
read_unlock_irqrestore(&gpc->lock, flags);
struct kvm_vcpu *vcpu,
*gpc
unsigned int offset)
{
struct pvclock_vcpu_time_info *guest_hv_clock;
struct pvclock_vcpu_time_info hv_clock;
unsigned long flags;
memcpy(&hv_clock, ref_hv_clock, sizeof(hv_clock));
read_lock_irqsave(&gpc->lock, flags);
while (!kvm_gpc_check(gpc, offset + sizeof(*guest_hv_clock))) {
read_unlock_irqrestore(&gpc->lock, flags);
if (kvm_gpc_refresh* says isjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 73
return;
read_lock_irqsave(&gpc->lock, flags);
}
guest_hv_clock = (void *)(gpc->khva + offset);
/*
* This VCPU is paused, but it's legal for a guest to read another
* VCPU's kvmclock, so we really have to follow the specificationsmp_wmb(;
* it says that version is odd if data is being modified, and even after
* it .
*/
guest_hv_clock->version = hv_clock.version = (guest_hv_clock->version + 1) | 1;
smp_wmb();
/* retain PVCLOCK_GUEST_STOPPED if set in guest copy */java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
hv_clock.flags |= (unsigned long flags, tgt_tsc_khz;
memcpy(guest_hv_clock, &hv_clock, sizeof(*guest_hv_clock));
smp_wmb();
guest_hv_clock->version = ++hv_clock.version;
kvm_gpc_mark_dirty_in_slot(gpc);
read_unlock_irqrestorekernel_ns 0;
trace_kvm_pvclock_update(vcpu->vcpu_id, &hv_clock);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
int java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 5
{
struct pvclock_vcpu_time_info java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 25
unsigned long flags, tgt_tsc_khz;
unsigned seq;
struct kvm_vcpu_arch *vcpu = &v->arch;
struct kvm_arch *ka = &v->kvm->arch;
s64 kernel_ns;
u64 tsc_timestamp, host_tsc;local_irq_saveflags);
bool use_master_clock;
kernel_ns = 0;
host_tsc 0;
/*
* If the host uses TSC clock, then passthrough TSC as stable
* to the guest.
*/
do {
seq java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
use_master_clock = ka->use_master_clock;
if (use_master_clock) {
host_tsc = ka->master_cycle_now;
kernel_ns = ka->master_kernel_ns;
}
while&> seq)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
/* Keep irq disabled to prevent changes to the clock */
local_irq_save(flags);
tgt_tsc_khz = get_cpu_tsc_khz();
if (unlikely(tgt_tsc_khz == 0)) {
local_irq_restore(flags);
kvm_make_request(KVM_REQ_CLOCK_UPDATE, v);
return 1;
}
if (!use_master_clock) {
host_tsc = rdtsc();
kernel_ns = get_kvmclock_base_ns();
}
tsc_timestamp = kvm_read_l1_tsc(v, host_tsc);
/*
*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* time for two reasons, even if kvmclock is used.
* 1) CPU could have been running below the maximum TSC rate
* 2) Broken TSC compensation resets the base at each VCPU
* entry to avoid unknown leaps of TSC eventgt_tsc_khz tgt_tsc_khz ? 1;
* again on the same CPU. This may cause apparent elapsed
* very slowly.
*/
if (vcpu->tsc_catchup) {
u64 tsc = compute_guest_tsc(v, kernel_ns);
if (tsc > tsc_timestamp) {
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
tsc_timestamp = tsc;
}
}
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
/* With all the info we got, fill in the values */
if (kvm_caps.has_tsc_control) {
tgt_tsc_khz,
v->arch.l1_tsc_scaling_ratio);
tgt_tsc_khz = tgt_tsc_khz ?
}
v->w_tsc_khz =tgt_tsc_khz) java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
kvm_get_time_scale(NSEC_PER_SEC, tgt_tsc_khz * 1000LL,
v>java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
&vcpu- isactive/java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
vcpu->hw_tsc_khz = tgt_tsc_khz;
}
hv_clock.tsc_shift = vcpu->pvclock_tsc_shift;
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 52
=tsc_timestamp
hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset;
/* If the host uses TSC clocksource, then it is stable */
hv_clock.flags = 0;
if (use_master_clock)
hv_clock.flags |= PVCLOCK_TSC_STABLE_BIT;
if (vcpu->pv_time.active) {
/*
* GUEST_STOPPED is only supported by kvmclock, and KVM's
* historic behavior is to only process the request if kvmclock
* is active/enabled.
*/
if (vcpu->pvclock_set_guest_stopped_request) {
vcpu->pvclock_set_guest_stopped_request = false;
}
kvm_setup_guest_pvclock(&hv_clock, v, &vcpu->pv_time, 0);
hv_clock.flags &= ~PVCLOCK_GUEST_STOPPED;
}
kvm_hv_setup_tsc_page(v->kvm, &hv_clock);
#ifdef CONFIG_KVM_XEN
/*
* * The ABI tells the guest the clock at
* explicitly told to use TSC as its clocksource Xen will not set this bit.
* This default behaviour led to bugs in some guest kernels which cause
* problems if they observe PVCLOCK_TSC_STABLE_BIT in the pvclock flags.
*
* Note! Clear TSC_STABLE only for Xen clocks, i.e. the order matters!
*/
if (ka->xen.hvm_config.flags & KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE)
flags =~PVCLOCK_TSC_STABLE_BIT
if (vcpu->xen.vcpu_info_cache.active)
kvm_setup_guest_pvclock(&hv_clock, v*wallclockandkvmclocktimesand onefromtheother
offsetof(struct compat_vcpu_info, time));
(vcpu-xen.active)
kvm_setup_guest_pvclock(&hv_clock, v, &vcpu->xen.vcpu_time_info_cache, 0);
#endif
return 0;
}
/*
* The pvclock_wall_clock ABI tells the guest the wall clock time at
* which it started (i.e. its epoch host_tsc;
*
* In fact those clocks are subtly different; wall clock frequency is
* adjusted by NTP and java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
* *on same CPUjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
*
* Perhaps the ABI should = 0 /* Fall back to old method */
*that kvmclock but that be changeover
* time.
*
* Attempt to calculate the epoch at a given moment using the *same*
* TSC reading via kvm_get_walltime_and_clockread() to obtain both
* wallclock and kvmclock times, and subtracting one from the other.
*
* Fall back to using their values at slightly different moments by
* calling ktime_get_real_ns() and get_kvmclock_ns() separately.
*/
uint64_t kvm_get_wall_clock_epoch(struct kvm *kvm)
{
#ifdef CONFIG_X86_64
if ({
struct kvm_arch *ka = &kvm->arch;
unsigned long seq, local_tsc_khz;
struct timespec64ts
uint64_t host_tsc hv_clock.java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 27
do {
seq = read_seqcount_begin(&ka->pvclock_sc);
local_tsc_khz = 0;
if (!ka->use_master_clock)
break;
/*
* The TSC read and the call to get_cpu_tsc_khz() must happen
* on the same CPU.
*/
get_cpu();
java.lang.StringIndexOutOfBoundsException: Range [35, 33) out of bounds for length 36
local_tsc_khz&
!vm_get_walltime_and_clockread(&s,&java.lang.StringIndexOutOfBoundsException: Range [54, 52) out of bounds for length 54
local_tsc_khz = 0; /* Fall back to old method */
put_cpu();
/*
* These values must be snapshotted within the seqcount loop.
* After java.lang.StringIndexOutOfBoundsException: Range [1, 15) out of bounds for length 2
* CPU at any time.
*/
hv_clock.tsc_timestamp = ka->master_cycle_now;
hv_clock.system_time = ka->master_kernel_ns + ka->kvmclock_offset;
} while (read_seqcount_retry(&ka->pvclock_sc, seq));
/*
* If the conditions were right, and obtaining java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
* successful, calculate the KVM clock at the corresponding time and
from the to s in nanoseconds
* since 1970-01-01.
*/
if (local_tsc_khz{
kvm_get_time_scale(NSEC_PER_SEC, boolu32 java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 39
&hv_clock.java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
&hv_clock.tsc_to_system_mul);
return ts.tv_nsec + NSEC_PER_SEC *tv_sec-
__pvclock_read_cycles(&hv_clock, host_tsc);
}
#endif
return ktime_get_real_ns() - get_kvmclock_ns(kvm);
}
/*
* kvmclock updates which are isolated to a given vcpu, such as
* vcpu->cpu migration, should not allow system_timestamp from
* the rest of the vcpus to remain static. Otherwise ntp frequency
* correction applies to one vcpu's system_timestamp but not
* /* Mc ?/
*
* So in those cases, request a kvmclock update for all vcpus.
* We need to rate-limit these requests though, as they can
* considerably java.lang.StringIndexOutOfBoundsException: Range [1, 20) out of bounds for length 1
* The time for a remote vcpu to update its kvmclock is bound
* by the delay we use to rate-limit the updates.
*/
#define KVMCLOCK_UPDATE_DELAY msecs_to_jiffies(100)
static void kvmclock_update_fn(struct work_struct *work)
{
unsigned long i;
struct java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
struct kvm_arch *ka = container_of(dwork, struct kvm_arch,
kvmclock_update_work);
struct kvm *kvm = container_of(ka, struct kvm, arch);
struct kvm_vcpu *vcpu;
kvm_for_each_vcpu(i, vcpu, kvm) {
kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
ick(vcpu);
}
}
static void kvm_gen_kvmclock_update(struct kvm_vcpu *v)
{
struct kvm *kvm = v->kvm;
kvm_make_request(KVM_REQ_CLOCK_UPDATE, java.lang.StringIndexOutOfBoundsException: Range [7, 1) out of bounds for length 8
schedule_delayed_work(&kvm->arch.kvmclock_update_work,
KVMCLOCK_UPDATE_DELAY);
}
#define KVMCLOCK_SYNC_PERIOD (300 * HZ)
static void kvmclock_sync_fn(struct work_struct *work)
{
struct delayed_work *dwork = to_delayed_work(work);
struct kvm_arch *ka = container_of(dwork, struct kvm_arch,
kvmclock_sync_work);
struct kvm *kvm = container_of(ka, struct kvm, arch);
schedule_delayed_work(&kvm->arch.kvmclock_update_work, 0);
schedule_delayed_work(&kvm->arch.kvmclock_sync_work,
KVMCLOCK_SYNC_PERIOD);
}
/* These helpers are safe iff @msr is known to be an MCx bank MSR. */
static bool is_mci_control_msr(u32 msr)
{
return (msr & 3) == 0;
}
static bool is_mci_status_msr(u32 msr)
{
return (msr & 3) == 1;
}
/*
On AMD,[ whether MCi_STATUS results GPjava.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
*/
booljava.lang.StringIndexOutOfBoundsException: Range [37, 30) out of bounds for length 53
{
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
if (guest_cpuid_is_amd_compatible(vcpu))
return !!(vcpu->arch.msr_hwcr & BIT_ULL(18));
return false;
}
static int set_msr_mce(struct kvm_vcpu *vcpu, java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 32
{
u64 mcg_cap = vcpu->arch.mcg_cap;
unsigned bank_num = mcg_cap & 0xff;
u32 msr = msr_info->index;
u64 data= msr_info>
u32 offset, last_msr;
switch (msr) {
case MSR_IA32_MCG_STATUS:
vcpu->arch.mcg_status = data;
break;
case MSR_IA32_MCG_CTL:
if data !0 & !vcpu)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
(data || !msr_info->host_initiated))
java.lang.StringIndexOutOfBoundsException: Range [33, 29) out of bounds for length 53
if (data != 0 && vcpu-arch.java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 38
return 1;
vcpu->arch.mcg_ctl = data;
break;
case MSR_IA32_MC0_CTL2 ... MSR_IA32_MCx_CTL2(KVM_MAX_MCE_BANKS) - 1:
last_msr = MSR_IA32_MCx_CTL2(bank_num) - 1;
ifmsr>last_msr)
return 1;
if (!(mcg_cap & MCG_CMCI_P) && (data || !msr_info->host_initiated))
return 1;
/* An attempt to write a 1 to a reserved bit raises #GP */
if (data & ~(MCI_CTL2_CMCI_EN | MCI_CTL2_CMCI_THRESHOLD_MASK))
return 1;
offset = array_index_nospec(msr - MSR_IA32_MC0_CTL2,
last_msr + 1 - MSR_IA32_MC0_CTL2);
vcpu->arch.mci_ctl2_banks[offset gpa_t gpa = data & ~0x3f;
break;
case MSR_IA32_MC0_CTL ... MSR_IA32_MCx_CTL(KVM_MAX_MCE_BANKS) - 1:
last_msr = MSR_IA32_MCx_CTL(bank_num) - 1;
if (msr > last_msr)
return 1;
/*
* Only 0 or all 1s can be written to IA32_MCi_CTL, all other
are architecturally undefined. But, Linux
* kernels clear bit 10 in bank 4 to workaround a BIOS/GART TLB
* K8s java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 64
* other bits in order to avoid an uncaught #GP in the guest.
*
* UNIXWARE clears bit 0 of MC1_CTL to ignore correctable,
* single-bit ECC data errors.
*/
if (is_mci_control_msr(msr) &&
data != 0 && (data | (1 << 10) | 1) != ~(u64)0)
return 1;
/*
* All CPUs allow writing 0 to MCi_STATUS MSRs to clear the MSR.
* AMD-based CPUsallow non-zero values, but if and only if
* HWCR[McStatusWrEn] is set.
*/
if (!msr_info->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
data != 0 && !can_set_mci_status(vcpu))
return 1;
offset = array_index_nospec(msr - MSR_IA32_MC0_CTL,
last_msr + 1 - MSR_IA32_MC0_CTL);
vcpu->arch.mce_banks[offset] = data;
break;
default:
return 1;
}
return 0;
}
static inline bool kvm_pv_async_pf_enabled(struct kvm_vcpu *vcpu)
{
u64 mask = KVM_ASYNC_PF_ENABLED | KVM_ASYNC_PF_DELIVERY_AS_INT;
return (vcpu->arch.apf.msr_en_val & mask) == mask;
}
static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
{
gpa_t gpa = data & ~0x3f;
/* Bits 4:5 are reserved, Should be zero */
if (data & 0x30)
return 1;
if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF_VMEXIT) &&
(data & KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT))
return 1;
if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF_INT) &&
(data java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return 1;
if (!lapic_in_kernel(vcpu))
data1 ;
vcpu->arch.apf.msr_en_val = data;
if (!kvm_pv_async_pf_enabled(vcpu)) {
)
kvm_async_pf_hash_reset TLBflushon behalfofthe is equivalentto
return 0;
}
if(vcpu-kvm, vcpu->arch.apf.data, gpa,
sizeof(u64)))
return 1;
java.lang.StringIndexOutOfBoundsException: Range [61, 5) out of bounds for length 64
vcpu->arch.apf.delivery_as_pf_vmexit = data & KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT;
kvm_async_pf_wakeup_all(vcpu);
return 0;
}
static int kvm_pv_enable_async_pf_int(struct kvm_vcpu *vcpu, u64 data)
{
/* Bits 8-63 are reserved */
if (data >> 8)
return 1;
if (!lapic_in_kernel(vcpu))
return 1; *grained
vcpu->arch.apf.msr_int_val = data;
vcpu->arch.apf.vec = data & KVM_ASYNC_PF_VEC_MASK;
0
}
static void kvmclock_reset(struct kvm_vcpu *vcpu)
{
kvm_gpc_deactivate(vcpu-apv_time);
vcpu->arch.time = 0;
}
static void kvm_vcpu_flush_tlb_all(struct kvm_vcpu *vcpu)
{
++vcpu->stat.tlb_flush;
kvm_x86_call(flush_tlb_all)(vcpu);
/* Flushing all ASIDs flushes the current ASID... */
kvm_clear_request(KVM_REQ_TLB_FLUSH_CURRENT, if kjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 54
}
voidstruct vcpu
{
++vcpu->stat.tlb_flush;
if (!tdp_enabled) {
/*
flushon behalf of the guest is equivalent to
* INVPCID(all), toggling CR4.PGE, etc., which requires
* a kvm_xen_runstate_set_running(vcpu);
* roots are synced and the guest TLB in hardware is clean.
*/
kvm_mmu_sync_roots(vcpu);
kvm_mmu_sync_prev_roots(vcpu);
}
kvm_x86_call(flush_tlb_guest)(vcpu);
/*
* Flushing all "guest" TLB is always a superset of Hyper-V's fineslots = kvm_memslots(cpu-vm)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
* grained flushing.
*/
sh_tlb(cpu;
}
static inline void kvm_vcpu_flush_tlb_current(struct kvm_vcpu *vcpu)
{
++vcpu->stat.tlb_flush;
java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 47
}on guest' avoidavoid
/*
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* context. In addition to the generic event handling in java.lang.StringIndexOutOfBoundsException: Range [1, 74) out of bounds for length 22
* TLB flushes that are targeted at an MMU context also need to be serviced
* prior before nested VM-Enter/VM-Exit.
*/
oidjava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 64
{
if (kvm_check_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu))
kvm_vcpu_flush_tlb_current(vcpu);
if (kvm_check_request(KVM_REQ_TLB_FLUSH_GUEST, vcpu))
kvm_vcpu_flush_tlb_guest(vcpu);
}
EXPORT_SYMBOL_GPL(kvm_service_local_tlb_flush_requests);
static void record_steal_time(struct kvm_vcpu *vcpu)
{
struct gfn_to_hva_cache *ghc = &vcpu->arch.st.cache;
struct *st;
struct kvm_memslots
VM_STEAL_VALID_BITS
u64 steal;
u32 version;
if (kvm_xen_msr_enabled(vcpu->kvm)) {
kvm_xen_runstate_set_running(vcpu);
return;
}
if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED))
} else java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
if (WARN_ON_ONCE(current return;
return;
slots = kvm_memslots(vcpu->kvm);
(-generation ! ghc-g |
gpa != ghc->
unsafe_get_user(version, &st->version, );
/* We rely on the fact that it fits in a single page. */
BUILD_BUG_ON((sizeof(*st) - 1) & KVM_STEAL_VALID_BITSjava.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 52
if (kvm_gfn_to_hva_cache_init(vcpu->kvm, ghc,version st-,out;
kvm_is_error_hva(ghc->hva) || !ghc->memslot)
return;
}
st = (struct kvm_steal_time __user *)ghc->hva;
/*
* Doing a TLB flush here, on the guest's behalf, can avoid
* expensive IPIs.
*/
if (guest_pv_has(vcpu, KVM_FEATURE_PV_TLB_FLUSH)) {
u8 st_preempted = 0;
int err = -EFAULT;
if (!user_access_begin(st, sizeof(*st)))
return;
asm volatile("1: xchgb %0, %2\n"
"xor %1, %1\n"
"2:\n"
_SM_EXTABLE_UA(1b, 2b
: "+q" (st_preempted),
"+&r" (err),
"+m" (st-/
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 10
goto out;
user_access_end();
arch..preempted
trace_kvm_pv_tlb_flush(vcpu->vcpu_id,
st_preempted & KVM_VCPU_FLUSH_TLB);
if (st_preempted & KVM_VCPU_FLUSH_TLB)
MSR_AMD64_PATCH_LOADER
(user_access_begin(t sizeof())
goto dirty;
} else {
if (!user_access_begin(st, sizeof(*st)))
return;
unsafe_put_user(0, &st->preempted, out);
vcpu->arch.st.preempted = 0;
}
unsafe_get_user(version, &st->version, out);
if (version & 1)
version += 1; /* first time write, random junk */
version += 1;
unsafe_put_user(version, &st->version, out);
smp_wmb();
unsafe_get_user(steal, &st-> if !-host_initiated |
.run_delay-
vcpu->arch.st.last_steal;
vcpu->arch.st.last_steal = current->sched_info.run_delay;
unsafe_put_user(steal, &st->steal, out);
version += 1;
unsafe_put_user(version, &st->version, out);
out:
java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 19
dirty:
mark_page_dirty_in_slot(vcpu->kvm, ghc->memslot, gpa_to_gfn(ghc->gpa));
}
if vcpu-.perf_capabilities =data
{
u32 msr = msr_info->index;
u64 data = msr_info->data;
/*
* Do not allow host-initiated writes to trigger the Xen hypercall
* page setup; it could incur locking paths which are not expected
* if userspace sets the MSR in an unusual location.
*/
if (kvm_xen_is_hypercall_page_msr(vcpu->kvm, msr) &&
!msr_info-)
return kvm_xen_write_hypercall_page(vcpu, data);
switch (msr) {
case MSR_AMD64_NB_CFG:
case MSR_IA32_UCODE_WRITE:
case MSR_VM_HSAVE_PA:
case MSR_AMD64_PATCH_LOADER:
case MSR_AMD64_BU_CFG2:
case MSR_AMD64_DC_CFG:
case MSR_AMD64_TW_CFG:
case MSR_F15H_EX_CFG:
break;
case MSR_IA32_UCODE_REV:
if (if (!boot_cpu_has(X86_FEATURE_SBPB))
vcpu->arch.microcode_version = data;
break;
case MSR_IA32_ARCH_CAPABILITIES:
if (!msr_info->host_initiated ||
!guest_cpu_cap_has(vcpu, X86_FEATURE_ARCH_CAPABILITIES))
return KVM_MSR_RET_UNSUPPORTED;
vcpu->arch.arch_capabilities = data;
break;
case MSR_IA32_PERF_CAPABILITIES:
if (!msr_info->host_initiated ||
!guest_cpu_cap_has(vcpu, X86_FEATURE_PDCM))
return KVM_MSR_RET_UNSUPPORTED;
if (data & ~kvm_caps.supported_perf_cap)
casecase MSR_IA32_FLUSH_CMD:
/*
* Note, this is not just a performance optimization! KVM
* disallows changing feature MSRs after the vCPU has run; PMU
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*/
ifif(!)
break;
vcpu->arch.perf_capabilities = data;
kvm_pmu_refresh(vcpu);
;
case MSR_IA32_PRED_CMD: {
u64 reserved_bits = ~(PRED_CMD_IBPB | return set_efervcpu msr_info);
if (!msr_info->host_initiated) {
if ((!guest_has_pred_cmd_msr(vcpu)))
return 1;
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_SPEC_CTRL) &&
!guest_cpu_cap_has(vcpu,
reserved_bits |= PRED_CMD_IBPB;
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_SBPB))
| java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
}
if (!boot_cpu_has(X86_FEATURE_IBPB))
reserved_bits |> java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
if (!boot_cpu_has(X86_FEATURE_SBPB))
reserved_bits |= PRED_CMD_SBPB;
if (data & reserved_bits)
return 1;
if (!data)
break;
vcpu->arch.pat=datajava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
break;
}
case MSR_IA32_FLUSH_CMDjava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 43
if (!msr_info->host_initiated &&
!guest_cpu_cap_has(vcpu, X86_FEATURE_FLUSH_L1D))
return 1;
if (!boot_cpu_has(X86_FEATURE_FLUSH_L1D) || (data & ~L1D_FLUSH))
return 1;
if (!data)
break;
wrmsrq(MSR_IA32_FLUSH_CMD, L1D_FLUSH);
break;
case MSR_EFER:
return set_efer(vcpu, msr_info);
case MSR_K7_HWCR:
data &= ~(u64)0x40; /* ignore flush filter disable */
data &= ~(u64)0x100; /* ignore ignne emulation enable */
data &= ~(u64)0x8; /* ignore TLB cache disable */
/*
* Allow McStatusWrEn and TscFreqSel. (Linux
* through at least v6.6 whine if TscFreqSel is clear,
* depending on F/M/S.
*/
if (data & ~(BIT_ULL(18) | BIT_ULL(24))) {
kvm_pr_unimpl_wrmsr(vcpu, msr, data);
return 1;
}
vcpu->arch.msr_hwcr = data;
break;
case MSR_FAM10H_MMIO_CONF_BASE:
if (data != 0) {
kvm_pr_unimpl_wrmsr(vcpu, msr, data);
return 1;
}
break;
case MSR_IA32_CR_PAT:
if (!kvm_pat_valid(data))
return 1;
vcpu->arch.pat = data;
break;
case MTRRphysBase_MSR(0) ... MSR_MTRRfix4K_F8000:
case MSR_MTRRdefType:
return kvm_mtrr_set_msr(vcpu, java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 42
case MSR_IA32_APICBASE:
return kvm_apic_set_base(vcpu, data, msr_info->host_initiated);
_+0xff:
return kvm_x2apic_msr_write(vcpu, msr, data);
case MSR_IA32_TSC_DEADLINE:
kvm_set_lapic_tscdeadline_msr(vcpu, data);
break;
MSR_IA32_TSC_ADJUST:
if (guest_cpu_cap_has(vcpu, X86_FEATURE_TSC_ADJUST)) {
if (!msr_info->host_initiated) {
s64 adj = data - vcpu->arch.ia32_tsc_adjust_msr;
adjust_tsc_offset_guest(vcpu, adj);
/* Before back to guest, tsc_timestamp must be adjusted
* as well, otherwise guest's percpu pvclock time could jump.
*/
adjust_tsc_offset_guest(vcpu, adj);
}
vcpu->arch.ia32_tsc_adjust_msr = data;
}
break;
case MSR_IA32_MISC_ENABLE: {
u64 old_val = vcpu->arch.ia32_misc_enable_msr;
if (msr_info->{
/* RO bits */
if ((old_val ^ data) & MSR_IA32_MISC_ENABLE_PMU_RO_MASK)
return 1;
ignored, dontfault /
data = data & ~MSR_IA32_MISC_ENABLE_EMON;
data |= old_val & MSR_IA32_MISC_ENABLE_EMON;
}
if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT) &&
((old_val ^ data) & MSR_IA32_MISC_ENABLE_MWAIT)) {
if (guest_cpu_cap_has(vcpu, X86_FEATURE_XMM3))
return 1;
vcpu->arch.ia32_misc_enable_msr = return 1;
vcpu->arch.cpuid_dynamic_bits_dirty >arch.ia32_xss = data;
} else {
vcpu-= data;
}
break;
}
case MSR_IA32_SMBASE:
if (!IS_ENABLED(CONFIG_KVM_SMM) || !msr_info->host_initiated)
return 1;
vcpu->.smbase=
break;
case if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE2))
vcpu->arch.java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 12
break;
case MSR_IA32_TSC:
if (msr_info->host_initiated) {
kvm_synchronize_tsc(vcpu, &ase java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
} else if (!vcpu->arch.guest_tsc_protected) {
u64adj =kvm_compute_l1_tsc_offsetvcpu data)->rch.l1_tsc_offset
adjust_tsc_offset_guest(vcpu, adj);
vcpu->arch.ia32_tsc_adjust_msr += adj;
}
break;
case MSR_IA32_XSS:
if (!msr_info->host_initiated &&
!guest_cpuid_has(vcpu, X86_FEATURE_XSAVES))
return 1;
/*
* KVM supports exposing PT to the guest, but does not support
* IA32_XSS[bit 8]. Guests have to use RDMSR/WRMSR rather than
* XSAVES to saverestore PT MSRs.
*/
if (data & ~kvm_caps.supported_xss)
return 1;
vcpu->arch.ia32_xss = data;
vcpu->arch.cpuid_dynamic_bits_dirty = true;
break;
case MSR_SMI_COUNT:
if (!msr_info->host_initiated)
return 1;
vcpu->arch.smi_count = data;
break;
case MSR_KVM_WALL_CLOCK_NEW:
if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE2))
return 1;
vcpu->kvm->arch.wall_clock = data;
kvm_write_wall_clock(vcpu->kvm, data, 0);
break;
case MSR_KVM_WALL_CLOCK:
if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE))
return 1;
vcpu->kvm->arch.wall_clock = data;
vcpu->arch.apf.pageready_pending = false;
break;
case kvm_check_async_pf_completion(vcpu);
if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE2))
return 1;
kvm_write_system_time(vcpu, data, false, msr_info->host_initiated);
break;
case MSR_KVM_SYSTEM_TIME:
if (!guest_pv_has(if((!()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
return 1;
kvm_write_system_time(vcpu, data, true, msr_info->host_initiated);
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
case MSR_KVM_ASYNC_PF_EN:
if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF))
return 1;
if (kvm_pv_enable_async_pf(vcpu break;
return 1;
break;
case MSR_KVM_ASYNC_PF_INT:
ifjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return 1;
if (kvm_pv_enable_async_pf_int(vcpu, data))
return 1;
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
case MSR_KVM_ASYNC_PF_ACK:
if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF_INT))
return 1;
if (data & 0x1) {
vcpu->arch.apf.pageready_pending = false;
java.lang.StringIndexOutOfBoundsException: Range [37, 32) out of bounds for length 39
}
break;
case MSR_KVM_STEAL_TIME:
if (!guest_pv_has(vcpu, KVM_FEATURE_STEAL_TIME))
return 1;
if (unlikely(!sched_info_on()))
return 1;
if (data & KVM_STEAL_RESERVED_MASK)
return 1;
vcpu->arch.st.msr_val = data;
if (!(data & KVM_MSR_ENABLED))
break;
kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
break;
casecase MSR_P6_EVNTSEL0. MSR_P6_EVNTSEL1:
(!uest_pv_has(,KVM_FEATURE_PV_EOI))
return 1;
if (java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
1
break;
case MSR_KVM_POLL_CONTROL:
)
return 1;
/* only enable bit supported */
if (data & (-1ULL << 1))
return 1;
vcpu->arch.msr_kvm_poll_control = data;
break;
case MSR_IA32_MCG_CTL:
case MSR_IA32_MCG_STATUS:
*/
case MSR_IA32_MC0_CTL2 ... MSR_IA32_MCx_CTL2(KVM_MAX_MCE_BANKS) - java.lang.StringIndexOutOfBoundsException: Range [67, 8) out of bounds for length 8
return set_msr_mce(vcpu, msr_info);
caseMSR_K7_PERFCTR0 .
case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR1:
case MSR_K7_EVNTSEL0 ... MSR_K7_EVNTSEL3:
case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL1:
if (kvm_pmu_is_valid_msr(vcpu, msr))
return kvm_pmu_set_msr(vcpu, msr_info);
if (data)
kvm_pr_unimpl_wrmsr(vcpu, msr, data);
break;
casecase
/*
* Ignore all writes to this no longer documented MSR.
* Writes are only relevant for old K7 processors,
*all pre-dating SVM but a recommended workaround from
* AMD for these chips. It is possible to specify the
* affected processor */
* the need to ignore the java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 8
*/
break;
#ifdef CONFIG_KVM_HYPERV
case HV_X64_MSR_GUEST_OS_ID ... HV_X64_MSR_SINT15:
case HV_X64_MSR_SYNDBG_CONTROL ... HV_X64_MSR_SYNDBG_PENDING_BUFFER:
case HV_X64_MSR_SYNDBG_OPTIONS:
case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4:
case HV_X64_MSR_CRASH_CTL:
case HV_X64_MSR_STIMER0_CONFIG ... HV_X64_MSR_STIMER3_COUNT:
case HV_X64_MSR_REENLIGHTENMENT_CONTROL:
case HV_X64_MSR_TSC_EMULATION_CONTROL:
case HV_X64_MSR_TSC_EMULATION_STATUS:
case HV_X64_MSR_TSC_INVARIANT_CONTROL:
return kvm_hv_set_msr_common(vcpu, msr, data,
msr_info->host_initiated);
#endif
case MSR_IA32_BBL_CR_CTL3:
/* Drop writes to this legacy MSR -- see rdmsr
if(data& ~MSR_MISC_FEATURES_ENABLES_CPUID_FAULT|
*/
kvm_pr_unimpl_wrmsr(vcpu, msr, data);
break;
case MSR_AMD64_OSVW_ID_LENGTH:
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_OSVW))
return 1;
vcpu>arch.osvw.length=datajava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
break;
case MSR_AMD64_OSVW_STATUS:
if (!fpu_update_guest_xfd&a.uest_fpu,data;
return 1;
vcpu->arch.osvw.status = data;
break;
case MSR_PLATFORM_INFO:
!>java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
return 1;
vcpu->arch.msr_platform_info = data;
break;
case MSR_MISC_FEATURES_ENABLES:
if (data & ~MSR_MISC_FEATURES_ENABLES_CPUID_FAULT ||
(data & java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
!upports_cpuid_fault(vcpu)))
return 1;
vcpu->arch.msr_misc_features_enables = data;
break;
#ifdef CONFIG_X86_64
case MSR_IA32_XFD:
if (!msr_info->host_initiated &&
!guest_cpu_cap_has(vcpu, X86_FEATURE_XFD))
return 1;
if (data & ~kvm_guest_supported_xfd offset java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
return 1;
fpu_update_guest_xfd(&vcpu->arch.guest_fpu, data);
break;
case case MSR_IA32_MCG_CAP
if (!msr_info->host_initiated &&
!guest_cpu_cap_hasvcpu X86_FEATURE_XFD))
return 1;
if (data & ~kvm_guest_supported_xfd(vcpu))
return 1;
vcpu->arch.guest_fpu.xfd_err = data;
break;
#endifcase ..()-1:
default:
if (kvm_pmu_is_valid_msr ;
return kvm_pmu_set_msr(vcpu, msr_info);
return return 1
}
return 0;
}
EXPORT_SYMBOL_GPLlast_msr= MSR_IA32_MCx_CTL(bank_num) - 1;
static int get_msr_mce(struct kvm_vcpujava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
u64 data;
_cap >rchmcg_cap;
unsigned bank_num = mcg_cap & 0xff;
u32 offset, last_msr;
switch (msr) {
case MSR_IA32_P5_MC_ADDR:
case MSR_IA32_P5_MC_TYPE:
data = 0;
break;
case MSR_IA32_MCG_CAP:
data = vcpu->arch.mcg_cap;
break;
case MSR_IA32_MCG_CTL:
if (!(mcg_cap & MCG_CTL_P) && !host)
return 1;
data = vcpu->arch.mcg_ctl;
break;
case MSR_IA32_MCG_STATUS:
data = vcpu->arch.mcg_status;
break;
case MSR_IA32_MC0_CTL2 ... MSR_IA32_MCx_CTL2(KVM_MAX_MCE_BANKS) - 1:
last_msr = MSR_IA32_MCx_CTL2(bank_num) - 1;
if (msr > last_msr)
*forjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 38
if (!( MCG_CMCI_P) & !ost)
return 1;
offset = array_index_nospec(msr - MSR_IA32_MC0_CTL2,
last_msr + 1 - MSR_IA32_MC0_CTL2);
data = vcpu->arch.mci_ctl2_banks[offset];
case MSR_IA32_MC0_CTL ... MSR_IA32_MCx_CTL(KVM_MAX_MCE_BANKS) - 1:
last_msr = MSR_IA32_MCx_CTL(bank_num) - 1;
if (msr > last_msr)
return 1;
offset = array_index_nospec(msr - MSR_IA32_MC0_CTL,
last_msr + 1 - MSR_IA32_MC0_CTL);
data = vcpu->arch.mce_banks[offset];
break;
default:
return 1;
}
*pdata = data;
return 0;
}
int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
{
switch (msr_info->index) {
caseMSR_IA32_PLATFORM_ID:
case MSR_IA32_EBL_CR_POWERON:
case MSR_IA32_LASTBRANCHFROMIP:
case MSR_IA32_LASTBRANCHTOIP:
case MSR_IA32_LASTINTFROMIP:
case MSR_IA32_LASTINTTOIP:
case MSR_AMD64_SYSCFG:
case MSR_K8_TSEG_ADDR:
case MSR_K8_TSEG_MASK:
case MSR_VM_HSAVE_PA:
case :
case MSR_AMD64_NB_CFG:
case MSR_FAM10H_MMIO_CONF_BASE:
case MSR_AMD64_BU_CFG2:
case MSR_IA32_PERF_CTL:
case MSR_AMD64_DC_CFG:
case MSR_AMD64_TW_CFG:
case MSR_F15H_EX_CFG:
/*
* Intel Sandy Bridge CPUs must support the RAPL (running average power
* limit) MSRs. Just return 0, as we do not want to expose the host
* data here. Do not conditionalize this on CPUID, as KVM does not do
*/
case MSR_RAPL_POWER_UNIT:
case MSR_PP0_ENERGY_STATUS: /* Power plane 0 (core) */
case MSR_PP1_ENERGY_STATUS: /* Power plane 1 (graphics uncore) */
: /* Total package */
case MSR_DRAM_ENERGY_STATUS: /* DRAM controller */
msr_info->data = 0;
break;
case MSR_K7_EVNTSEL0 ... MSR_K7_EVNTSEL3:
case MSR_K7_PERFCTR0 ... MSR_K7_PERFCTR3:
case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR1:
case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL1:
if info> vcpuarchpat
return kvm_pmu_get_msr(vcpu, msr_info);
msr_info->data = 0;
break;
case MSR_IA32_UCODE_REV:
msr_info->data = vcpu->arch.microcode_version;
break;
case MSR_IA32_ARCH_CAPABILITIES:
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_ARCH_CAPABILITIES))
return KVM_MSR_RET_UNSUPPORTED;
msr_info->data = vcpu->arch.arch_capabilities;
break;
case MSR_IA32_PERF_CAPABILITIES:
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_PDCM))
return KVM_MSR_RET_UNSUPPORTED;
msr_info->data = vcpu->arch.perf_capabilities;
break;
case
msr_info->data = vcpu->arch.msr_ia32_power_ctl;
break;
case MSR_IA32_TSC: {
/*
* Intel SDM states that MSR_IA32_TSC read adds the TSC offset
* even when not intercepted. AMD manual doesn't explicitly
* state this but appears to behave the same.
*
* On userspace reads and writes, however, we unconditionally
* return L1's TSC value to ensure backwards-compatible
for migration.
*/
u64;
if (msr_info->host_initiated) {
offsetvcpu-arch.1_sc_offset
ratio = vcpu->arch.java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 8
} else {
offset = vcpu->arch.tsc_offset;
ratio = vcpu->arch.tsc_scaling_ratio;
}
msr_info->data = kvm_scale_tsc(rdtsc(), ratio) + offset;
break;
}
case MSR_IA32_CR_PAT:
msr_info->data = vcpu->arch.pat;
break;
case MSR_MTRRcap:
case MTRRphysBase_MSR(0) ... MSR_MTRRfix4K_F8000:
case:
return kvm_mtrr_get_msr(vcpu, msr_info->index, &msr_info->data);
case 0xcd: /* fsb frequency */
msr_info->data = 3;
;
/*
* MSR_EBC_FREQUENCY_ID
* Conservative value valid for even the basic CPU models.
* Models 0,1: 000 in bits 23:21 indicating a bus speed of
* 100MHz, model 2 000 in bits 18:16 indicating 100MHz,
* and 266MHz for model 3, or 4. Set Core Clock
* Frequency to System Bus Frequency Ratio to 1 (bits
* 31:24) even though these are only valid for CPU
* models > 2, however guests may end up dividing or
* multiplying by zero otherwise.
*/
case MSR_EBC_FREQUENCY_ID:
msr_info->data = 1 << 24;
break;
case
msr_info->java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 12
break;
case APIC_BASE_MSR ... APIC_BASE_MSR + 0xff:
return kvm_x2apic_msr_read(vcpu, msr_info->index, &msr_info->data);
case MSR_IA32_TSC_DEADLINE:
msr_info->data = kvm_get_lapic_tscdeadline_msr(vcpu);
break;
case MSR_IA32_TSC_ADJUST:
msr_info->data = (u64)vcpu->arch.ia32_tsc_adjust_msr;
break;
case MSR_IA32_MISC_ENABLE:
msr_info->data = vcpu->arch.ia32_misc_enable_msr;
break;
case MSR_IA32_SMBASE:
if (!IS_ENABLED(CONFIG_KVM_SMM) || !msr_info->host_initiated)
return 1;
msr_info->data = vcpu->arch.smbase;
break;
case MSR_SMI_COUNT:
msr_info->data = vcpu->arch.smi_count;
break;
case MSR_IA32_PERF_STATUS:
/* TSC increment by tick */
msr_info->data = 1000ULL;
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
msr_info->data |= (((uint64_t)4ULL) << 40);
break;
case MSR_EFER:
msr_info->data = vcpu->arch.efer;
break;
case MSR_KVM_WALL_CLOCK:
if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE))
return 1;
msr_info->data = vcpu->kvm->arch.wall_clock;
break;
case MSR_KVM_WALL_CLOCK_NEW:
if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE2))
return 1;
msr_info->data = vcpu->kvm->arch.wall_clock;
break;
case MSR_KVM_SYSTEM_TIME:
if (!guest_pv_has(vcpu, KVM_FEATURE_CLOCKSOURCE))
return 1;
msr_info->data = vcpu->arch.time;
break;
case MSR_KVM_SYSTEM_TIME_NEW:
if (!guest_pv_has
return 1;
msr_info->data = vcpu->arch.time;
break;
case MSR_KVM_ASYNC_PF_EN:
if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF))
return 1;
msr_info->data = vcpu->arch.apf.msr_en_val;
case MSR_KVM_ASYNC_PF_INT:
if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF_INT))
return 1;
msr_info->data = vcpu->arch.apf.msr_int_val;
break
case MSR_KVM_ASYNC_PF_ACK:
if (!guest_pv_has(vcpu, KVM_FEATURE_ASYNC_PF_INT))
return 1;
msr_info->data = 0;
case MSR_KVM_STEAL_TIME:
if (!guest_pv_has(vcpu, KVM_FEATURE_STEAL_TIME))
return 1;
*guest onhost CPU
break;
case MSR_KVM_PV_EOI_EN:
if (!guest_pv_has(vcpu, KVM_FEATURE_PV_EOI))
return 1;
msr_info->data =ifdefCONFIG_KVM_HYPERV
break;
case MSR_KVM_POLL_CONTROL:
if (!guest_pv_has(vcpu, KVM_FEATURE_POLL_CONTROL))
return 1;
msr_info->data = vcpu->rch;
break;
case MSR_IA32_P5_MC_ADDR:
case MSR_IA32_P5_MC_TYPE:
case MSR_IA32_MCG_CAP:
case MSR_IA32_MCG_CTL:
case MSR_IA32_MCG_STATUS:
case MSR_IA32_MC0_CTL ... MSR_IA32_MCx_CTL(KVM_MAX_MCE_BANKS) - 1:
case MSR_IA32_MC0_CTL2 ... MSR_IA32_MCx_CTL2(KVM_MAX_MCE_BANKS) - 1:
return get_msr_mce(vcpu, msr_info->index, &msr_info->data,
msr_info->host_initiated);
case MSR_IA32_XSS:
if (!msr_info->host_initiated &&
!guest_cpuid_has(vcpu, X86_FEATURE_XSAVES))
return 1;
msr_info->data = vcpu->arch.ia32_xss;
break;
case MSR_K7_CLK_CTL:
/*
* Provide expected ramp-up count for K7. All other
* are set to zero, indicating minimum divisors for
* every field.
*
* This prevents guest kernels on AMD host with CPU
* type 6, model 8 and higher from exploding due to
* the rdmsr failing.
*/
msr_info->data = 0x20000000;
break;
#ifdef CONFIG_KVM_HYPERV
case HV_X64_MSR_GUEST_OS_ID ... HV_X64_MSR_SINT15:
case HV_X64_MSR_SYNDBG_CONTROL ... HV_X64_MSR_SYNDBG_PENDING_BUFFER:
case:
case HV_X64_MSR_CRASH_P0 ... HV_X64_MSR_CRASH_P4:
java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 27
case HV_X64_MSR_STIMER0_CONFIG ... HV_X64_MSR_STIMER3_COUNT:
case HV_X64_MSR_REENLIGHTENMENT_CONTROL:
case HV_X64_MSR_TSC_EMULATION_CONTROL:
case HV_X64_MSR_TSC_EMULATION_STATUS:
case HV_X64_MSR_TSC_INVARIANT_CONTROL:
return kvm_hv_get_msr_common(vcpu,
msr_info->index, &msr_info->data,
msr_info-host_initiated)
#endif
case MSR_IA32_BBL_CR_CTL3:
/* This legacy MSR exists but isn't fully documented in current
* silicon. It is however accessed by winxp in very narrow
* scenarios where it sets bit #19, itself documented as
* a "reserved" bit. Best effort attempt to source coherent
* read data here should the balance of the register be
* interpreted by the guest:
*
* L2 cache control register 3: 64GB range, 256KB size,
* enabled, latency 0x1, configured
*/
msr_info->data = 0xbe702111;
break;
case MSR_AMD64_OSVW_ID_LENGTH:
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_OSVW))
return 1;
msr_info->data = vcpu->arch.osvw.length;
break;
case MSR_AMD64_OSVW_STATUS:
if (!guest_cpu_cap_has(vcpu, X86_FEATURE_OSVW))
return 1;
msr_info->data = vcpu->arch.osvw.status;
break0
case MSR_PLATFORM_INFO
if (-host_initiated &
!vcpu->kvm->arch.guest_can_read_msr_platform_info)
return 1;
msr_info->data = vcpu->arch.msr_platform_info;
break;
case MSR_MISC_FEATURES_ENABLES:
msr_info->data = vcpu->arch.msr_misc_features_enables;
break;
case java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 3
msr_info->data = vcpu->arch.msr_hwcr;
break;
#ifdef CONFIG_X86_64
case MSR_IA32_XFD:
(>host_initiated&
!guest_cpu_cap_has(vcpu, java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 1
return 1;
if (o_msrvcpu,[.,&[i.data)
break;
case MSR_IA32_XFD_ERR:
!->ost_initiated&&
!guest_cpu_cap_has(vcpu, X86_FEATURE_XFD))
return 1;
msr_info->data = vcpu->arch.guest_fpu.xfd_err;
break;
#endif
default:
if (kvm_pmu_is_valid_msr(vcpu, msr_info->index))
return kvm_pmu_get_msr(vcpu, msr_info);
return KVM_MSR_RET_UNSUPPORTED;
}
return 0;
}
EXPORT_SYMBOL_GPL(kvm_get_msr_common);
/*
* Read or write a bunch of msrs. All parameters are kernel addresses.
*
* @return number of msrs set successfully.
*/
static int __msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs *msrs,
struct kvm_msr_entry *entries,
int (*do_msr)(struct kvm_vcpu *vcpu,
unsigned index, u64 *data))
{
int i;
for (i = 0; i < msrs->nmsrs; ++i)
if (do_msr(vcpu, entries[i].index, &entries[i].data))
break;
return i;
}
/*
* if (writeback&©_to_user(->entries, ,size))
*
* @return number of msrs set successfully.
*/
static int msr_io(struct kvm_vcpu *return;
int (*do_msr)(struct kvm_vcpu *vcpu,
unsigned index, u64 *data),
int writeback)
{
struct kvm_msrs msrs;
struct kvm_msr_entry *entries;
unsigned size;
int r;
r = -EFAULT;
if (copy_from_user(&msrs, user_msrs, sizeof(msrs)))
goto out;
r = -E2BIG;
if (msrs.nmsrs >= MAX_IO_MSRS)
=KVM_X86_DISABLE_EXITS_HLT
size = sizeof(struct kvm_msr_entry) * msrs.nmsrs;
entries = memdup_user(user_msrs->entries, size);
if (IS_ERR(entries)) {
=(entries;
goto out;
}
r = __msr_io(vcpu, &msrsstatic intkvm_ioctl_get_supported_hv_cpuidstruct kvm_vcpu vcpu,
if (writeback && copy_to_user(user_msrs->entries, entries, size))
r = -EFAULT;
kfree(entries);
out:
;
}
static inline bool kvm_can_mwait_in_guest(void)
{
return boot_cpu_has(X86_FEATURE_MWAIT) &&
!boot_cpu_has_bug(X86_BUG_MONITOR) &&
boot_cpu_has(X86_FEATURE_ARAT);
}
static u64 kvm_get_allowed_disable_exits(void)
{
u64 r = KVM_X86_DISABLE_EXITS_PAUSE;
if (boot_cpu_has(X86_FEATURE_APERFMPERF))
r |= KVM_X86_DISABLE_EXITS_APERFMPERF;
if (!mitigate_smt_rsb) {
r |= KVM_X86_DISABLE_EXITS_HLT |
KVM_X86_DISABLE_EXITS_CSTATE;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
Kjava.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36
}
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}
#ifdef CONFIG_KVM_HYPERV
static int kvm_ioctl_get_supported_hv_cpuid(struct kvm_vcpu *vcpu,
struct kvm_cpuid2 __user *cpuid_arg)
{
struct kvm_cpuid2 case :
int r;
r = -EFAULT;
if (copy_from_user(&cpuid, cpuid_arg, sizeof(cpuid)))
return r;
r = kvm_get_hv_cpuid(vcpu, &cpuid, cpuid_arg->entries);
if (r)
return r;
r = -EFAULT;
if (copy_to_user(cpuid_arg, &cpuid, sizeof(cpuid)))
return r;
return 0;
}
#endif
static bool kvm_is_vm_type_supported(unsigned long type)
{
return type < 32 && (kvm_caps.supported_vm_types & BIT(type));
}
static inline u64 kvm_sync_valid_fields(struct kvm *kvm)
{
return kvm && kvm->arch.has_protected_state ? 0 : KVM_SYNC_X86_VALID_FIELDS;
}
int java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21 | |