Commit 491a6038 authored by Liran Alon's avatar Liran Alon Committed by Paolo Bonzini

KVM: VMX: Mark vmcs header as shadow in case alloc_vmcs_cpu() allocate shadow vmcs

No functionality change.
Signed-off-by: default avatarLiran Alon <liran.alon@oracle.com>
Signed-off-by: default avatarJim Mattson <jmattson@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 32c7acf0
...@@ -4418,7 +4418,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) ...@@ -4418,7 +4418,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
return 0; return 0;
} }
static struct vmcs *alloc_vmcs_cpu(int cpu) static struct vmcs *alloc_vmcs_cpu(bool shadow, int cpu)
{ {
int node = cpu_to_node(cpu); int node = cpu_to_node(cpu);
struct page *pages; struct page *pages;
...@@ -4436,6 +4436,8 @@ static struct vmcs *alloc_vmcs_cpu(int cpu) ...@@ -4436,6 +4436,8 @@ static struct vmcs *alloc_vmcs_cpu(int cpu)
else else
vmcs->hdr.revision_id = vmcs_config.revision_id; vmcs->hdr.revision_id = vmcs_config.revision_id;
if (shadow)
vmcs->hdr.shadow_vmcs = 1;
return vmcs; return vmcs;
} }
...@@ -4459,14 +4461,14 @@ static void free_loaded_vmcs(struct loaded_vmcs *loaded_vmcs) ...@@ -4459,14 +4461,14 @@ static void free_loaded_vmcs(struct loaded_vmcs *loaded_vmcs)
WARN_ON(loaded_vmcs->shadow_vmcs != NULL); WARN_ON(loaded_vmcs->shadow_vmcs != NULL);
} }
static struct vmcs *alloc_vmcs(void) static struct vmcs *alloc_vmcs(bool shadow)
{ {
return alloc_vmcs_cpu(raw_smp_processor_id()); return alloc_vmcs_cpu(shadow, raw_smp_processor_id());
} }
static int alloc_loaded_vmcs(struct loaded_vmcs *loaded_vmcs) static int alloc_loaded_vmcs(struct loaded_vmcs *loaded_vmcs)
{ {
loaded_vmcs->vmcs = alloc_vmcs(); loaded_vmcs->vmcs = alloc_vmcs(false);
if (!loaded_vmcs->vmcs) if (!loaded_vmcs->vmcs)
return -ENOMEM; return -ENOMEM;
...@@ -4597,7 +4599,7 @@ static __init int alloc_kvm_area(void) ...@@ -4597,7 +4599,7 @@ static __init int alloc_kvm_area(void)
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
struct vmcs *vmcs; struct vmcs *vmcs;
vmcs = alloc_vmcs_cpu(cpu); vmcs = alloc_vmcs_cpu(false, cpu);
if (!vmcs) { if (!vmcs) {
free_kvm_area(); free_kvm_area();
return -ENOMEM; return -ENOMEM;
...@@ -7922,11 +7924,9 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu) ...@@ -7922,11 +7924,9 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)
goto out_cached_shadow_vmcs12; goto out_cached_shadow_vmcs12;
if (enable_shadow_vmcs) { if (enable_shadow_vmcs) {
shadow_vmcs = alloc_vmcs(); shadow_vmcs = alloc_vmcs(true);
if (!shadow_vmcs) if (!shadow_vmcs)
goto out_shadow_vmcs; goto out_shadow_vmcs;
/* mark vmcs as shadow */
shadow_vmcs->hdr.shadow_vmcs = 1;
/* init shadow vmcs */ /* init shadow vmcs */
vmcs_clear(shadow_vmcs); vmcs_clear(shadow_vmcs);
vmx->vmcs01.shadow_vmcs = shadow_vmcs; vmx->vmcs01.shadow_vmcs = shadow_vmcs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment