[PATCH 2/2] kvm/x86/vmx: sprinkle __read_mostly/__init/__ro_after_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>

Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
---
 arch/x86/kvm/vmx.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index e30da9a2430c..c66e75347a2e 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -887,18 +887,18 @@ static struct pi_desc *vcpu_to_pi_desc(struct kvm_vcpu *vcpu)
 	[ROL16(number##_HIGH, 6)] = VMCS12_OFFSET(name) + sizeof(u32)
 
 
-static u16 shadow_read_only_fields[] = {
+static u16 shadow_read_only_fields[] __ro_after_init = {
 #define SHADOW_FIELD_RO(x) x,
 #include "vmx_shadow_fields.h"
 };
-static int max_shadow_read_only_fields =
+static int max_shadow_read_only_fields __ro_after_init =
 	ARRAY_SIZE(shadow_read_only_fields);
 
-static u16 shadow_read_write_fields[] = {
+static u16 shadow_read_write_fields[] __ro_after_init = {
 #define SHADOW_FIELD_RW(x) x,
 #include "vmx_shadow_fields.h"
 };
-static int max_shadow_read_write_fields =
+static int max_shadow_read_write_fields __ro_after_init =
 	ARRAY_SIZE(shadow_read_write_fields);
 
 static const unsigned short vmcs_field_to_offset_table[] = {
@@ -1117,8 +1117,8 @@ static unsigned long *vmx_bitmap[VMX_BITMAP_NR];
 #define vmx_vmread_bitmap                    (vmx_bitmap[VMX_VMREAD_BITMAP])
 #define vmx_vmwrite_bitmap                   (vmx_bitmap[VMX_VMWRITE_BITMAP])
 
-static bool cpu_has_load_ia32_efer;
-static bool cpu_has_load_perf_global_ctrl;
+static __ro_after_init bool cpu_has_load_ia32_efer;
+static __ro_after_init bool cpu_has_load_perf_global_ctrl;
 
 static DECLARE_BITMAP(vmx_vpid_bitmap, VMX_NR_VPIDS);
 static DEFINE_SPINLOCK(vmx_vpid_lock);
@@ -1134,12 +1134,12 @@ static struct vmcs_config {
 	u32 vmexit_ctrl;
 	u32 vmentry_ctrl;
 	struct nested_vmx_msrs nested;
-} vmcs_config;
+} vmcs_config __ro_after_init;
 
 static struct vmx_capability {
 	u32 ept;
 	u32 vpid;
-} vmx_capability;
+} vmx_capability __ro_after_init;
 
 #define VMX_SEGMENT_FIELD(seg)					\
 	[VCPU_SREG_##seg] = {                                   \
@@ -1165,7 +1165,7 @@ static const struct kvm_vmx_segment_field {
 	VMX_SEGMENT_FIELD(LDTR),
 };
 
-static u64 host_efer;
+static u64 __read_mostly host_efer;
 
 static void ept_save_pdptrs(struct kvm_vcpu *vcpu);
 
@@ -1187,7 +1187,7 @@ DEFINE_STATIC_KEY_FALSE(enable_evmcs);
 #define KVM_EVMCS_VERSION 1
 
 #if IS_ENABLED(CONFIG_HYPERV)
-static bool __read_mostly enlightened_vmcs = true;
+static bool __ro_after_init enlightened_vmcs = true;
 module_param(enlightened_vmcs, bool, 0444);
 
 static inline void evmcs_write64(unsigned long field, u64 value)
@@ -1276,7 +1276,7 @@ static void evmcs_load(u64 phys_addr)
 	vp_ap->enlighten_vmentry = 1;
 }
 
-static void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf)
+static __init void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf)
 {
 	/*
 	 * Enlightened VMCSv1 doesn't support these:
@@ -1461,7 +1461,7 @@ static inline bool cpu_has_vmx_virtual_intr_delivery(void)
  * Refer from
  * https://www.virtualbox.org/svn/vbox/trunk/src/VBox/VMM/VMMR0/HMR0.cpp
  */
-static u32 vmx_preemption_cpu_tfms[] = {
+static const u32 vmx_preemption_cpu_tfms[] __initconst = {
 /* 323344.pdf - BA86   - D0 - Xeon 7500 Series */
 0x000206E6,
 /* 323056.pdf - AAX65  - C2 - Xeon L3406 */
@@ -4496,7 +4496,7 @@ static inline int vmcs_field_readonly(unsigned long field)
 	return (((field >> 10) & 0x3) == 1);
 }
 
-static void init_vmcs_shadow_fields(void)
+static __init void init_vmcs_shadow_fields(void)
 {
 	int i, j;
 
@@ -7487,7 +7487,7 @@ static void wakeup_handler(void)
 	spin_unlock(&per_cpu(blocked_vcpu_on_cpu_lock, cpu));
 }
 
-static void vmx_enable_tdp(void)
+static __init void vmx_enable_tdp(void)
 {
 	kvm_mmu_set_mask_ptes(VMX_EPT_READABLE_MASK,
 		enable_ept_ad_bits ? VMX_EPT_ACCESS_BIT : 0ull,
-- 
2.17.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux