[patch 30/71] KVM: SVM: force new asid on vcpu migration

From: Greg KH
Date: Fri Sep 04 2009 - 20:25:56 EST


2.6.30-stable review patch. If anyone has any objections, please let us know.

------------------
From: Marcelo Tosatti <mtosatti@xxxxxxxxxx>

(cherry picked from commit 4b656b1202498184a0ecef86b3b89ff613b9c6ab)

If a migrated vcpu matches the asid_generation value of the target pcpu,
there will be no TLB flush via TLB_CONTROL_FLUSH_ALL_ASID.

The check for vcpu.cpu in pre_svm_run is meaningless since svm_vcpu_load
already updated it on schedule in.

Such vcpu will VMRUN with stale TLB entries.

Based on original patch from Joerg Roedel (http://patchwork.kernel.org/patch/10021/)

Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
Acked-by: Joerg Roedel <joerg.roedel@xxxxxxx>
Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
arch/x86/kvm/svm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -736,6 +736,7 @@ static void svm_vcpu_load(struct kvm_vcp
svm->vmcb->control.tsc_offset += delta;
vcpu->cpu = cpu;
kvm_migrate_timers(vcpu);
+ svm->asid_generation = 0;
}

for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)
@@ -1046,7 +1047,6 @@ static void new_asid(struct vcpu_svm *sv
svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID;
}

- svm->vcpu.cpu = svm_data->cpu;
svm->asid_generation = svm_data->asid_generation;
svm->vmcb->control.asid = svm_data->next_asid++;
}
@@ -2258,8 +2258,8 @@ static void pre_svm_run(struct vcpu_svm
struct svm_cpu_data *svm_data = per_cpu(svm_data, cpu);

svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING;
- if (svm->vcpu.cpu != cpu ||
- svm->asid_generation != svm_data->asid_generation)
+ /* FIXME: handle wraparound of asid_generation */
+ if (svm->asid_generation != svm_data->asid_generation)
new_asid(svm, svm_data);
}



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/