Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx> --- x86/hyperv_synic.c | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/x86/hyperv_synic.c b/x86/hyperv_synic.c index a08e69f7da5f..fd74d1d79ee3 100644 --- a/x86/hyperv_synic.c +++ b/x86/hyperv_synic.c @@ -12,7 +12,7 @@ #define MAX_CPUS 4 static atomic_t isr_enter_count[MAX_CPUS]; -static atomic_t cpus_comp_count; +static ulong cr3; static void synic_sint_auto_eoi_isr(isr_regs_t *regs) { @@ -73,12 +73,12 @@ static void synic_sints_prepare(int vcpu) } } -static void synic_test_prepare(void *ctx) +static void synic_test_prepare(void) { u64 r; int i = 0; - write_cr3((ulong)ctx); + write_cr3(cr3); irq_enable(); rdmsr(HV_X64_MSR_SVERSION); @@ -91,7 +91,7 @@ static void synic_test_prepare(void *ctx) r = rdmsr(HV_X64_MSR_EOM); if (r != 0) { report("Hyper-V SynIC test, EOM read %#" PRIx64, false, r); - goto ret; + return; } wrmsr(HV_X64_MSR_SIMP, (u64)virt_to_phys(alloc_page()) | @@ -101,8 +101,6 @@ static void synic_test_prepare(void *ctx) wrmsr(HV_X64_MSR_SCONTROL, HV_SYNIC_CONTROL_ENABLE); synic_sints_prepare(smp_id()); -ret: - atomic_inc(&cpus_comp_count); } static void synic_sints_test(int dst_vcpu) @@ -125,10 +123,9 @@ static void synic_test(void *ctx) irq_enable(); synic_sints_test(dst_vcpu); - atomic_inc(&cpus_comp_count); } -static void synic_test_cleanup(void *ctx) +static void synic_test_cleanup(void) { int vcpu = smp_id(); int i; @@ -142,7 +139,6 @@ static void synic_test_cleanup(void *ctx) wrmsr(HV_X64_MSR_SCONTROL, 0); wrmsr(HV_X64_MSR_SIMP, 0); wrmsr(HV_X64_MSR_SIEFP, 0); - atomic_inc(&cpus_comp_count); } int main(int ac, char **av) @@ -156,40 +152,26 @@ int main(int ac, char **av) smp_init(); enable_apic(); - synic_prepare_sint_vecs(); - ncpus = cpu_count(); - if (ncpus > MAX_CPUS) { - ncpus = MAX_CPUS; - } + if (ncpus > MAX_CPUS) + report_abort("number cpus exceeds %d", MAX_CPUS); printf("ncpus = %d\n", ncpus); - atomic_set(&cpus_comp_count, 0); - for (i = 0; i < ncpus; i++) { - on_cpu_async(i, synic_test_prepare, (void *)read_cr3()); - } + synic_prepare_sint_vecs(); + printf("prepare\n"); - while (atomic_read(&cpus_comp_count) != ncpus) { - pause(); - } + cr3 = read_cr3(); + on_cpus(synic_test_prepare); - atomic_set(&cpus_comp_count, 0); for (i = 0; i < ncpus; i++) { printf("test %d -> %d\n", i, ncpus - 1 - i); on_cpu_async(i, synic_test, (void *)(ulong)(ncpus - 1 - i)); } - while (atomic_read(&cpus_comp_count) != ncpus) { + while (cpus_active()) pause(); - } - atomic_set(&cpus_comp_count, 0); - for (i = 0; i < ncpus; i++) { - on_cpu_async(i, synic_test_cleanup, NULL); - } printf("cleanup\n"); - while (atomic_read(&cpus_comp_count) != ncpus) { - pause(); - } + on_cpus(synic_test_cleanup); ok = true; for (i = 0; i < ncpus; ++i) { -- 2.9.4