Introduce some pv check helpers for consistency.
Unified · Split
| @@ -425,7 +425,27 @@ static void __init sev_map_percpu_data(void) · 424 unmodified lines | ||
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | +static bool pv_tlb_flush_supported(void) | |
| 429 | +{ | |
| 430 | + return (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && | |
| 431 | + !kvm_para_has_hint(KVM_HINTS_REALTIME) && | |
| 432 | + kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)); | |
| 433 | +} | |
| 434 | + | |
| 428 | 435 | #ifdef CONFIG_SMP |
| 436 | + | |
| 437 | +static bool pv_ipi_supported(void) | |
| 438 | +{ | |
| 439 | + return kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI); | |
| 440 | +} | |
| 441 | + | |
| 442 | +static bool pv_sched_yield_supported(void) | |
| 443 | +{ | |
| 444 | + return (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) && | |
| 445 | + !kvm_para_has_hint(KVM_HINTS_REALTIME) && | |
| 446 | + kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)); | |
| 447 | +} | |
| 448 | + | |
| 429 | 449 | #define KVM_IPI_CLUSTER_SIZE (2 * BITS_PER_LONG) |
| 430 | 450 | |
| 431 | 451 | static void __send_ipi_mask(const struct cpumask *mask, int vector) |
| @@ -619,9 +639,7 @@ static void __init kvm_guest_init(void) · 187 unmodified lines | ||
| 619 | 639 | pv_ops.time.steal_clock = kvm_steal_clock; |
| 620 | 640 | } |
| 621 | 641 | |
| 622 | − if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && | |
| 623 | − !kvm_para_has_hint(KVM_HINTS_REALTIME) && | |
| 624 | − kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) { | |
| 642 | + if (pv_tlb_flush_supported()) { | |
| 625 | 643 | pv_ops.mmu.flush_tlb_others = kvm_flush_tlb_others; |
| 626 | 644 | pv_ops.mmu.tlb_remove_table = tlb_remove_table; |
| 627 | 645 | } |
| @@ -632,9 +650,7 @@ static void __init kvm_guest_init(void) · 4 unmodified lines | ||
| 632 | 650 | #ifdef CONFIG_SMP |
| 633 | 651 | smp_ops.smp_prepare_cpus = kvm_smp_prepare_cpus; |
| 634 | 652 | smp_ops.smp_prepare_boot_cpu = kvm_smp_prepare_boot_cpu; |
| 635 | − if (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) && | |
| 636 | − !kvm_para_has_hint(KVM_HINTS_REALTIME) && | |
| 637 | − kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) { | |
| 653 | + if (pv_sched_yield_supported()) { | |
| 638 | 654 | smp_ops.send_call_func_ipi = kvm_smp_send_call_func_ipi; |
| 639 | 655 | pr_info("KVM setup pv sched yield\n"); |
| 640 | 656 | } |
| @@ -700,7 +716,7 @@ static uint32_t __init kvm_detect(void) · 59 unmodified lines | ||
| 700 | 716 | static void __init kvm_apic_init(void) |
| 701 | 717 | { |
| 702 | 718 | #if defined(CONFIG_SMP) |
| 703 | − if (kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI)) | |
| 719 | + if (pv_ipi_supported()) | |
| 704 | 720 | kvm_setup_pv_ipi(); |
| 705 | 721 | #endif |
| 706 | 722 | } |
| @@ -739,9 +755,7 @@ static __init int kvm_setup_pv_tlb_flush(void) · 32 unmodified lines | ||
| 739 | 755 | if (!kvm_para_available() || nopv) |
| 740 | 756 | return 0; |
| 741 | 757 | |
| 742 | − if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && | |
| 743 | − !kvm_para_has_hint(KVM_HINTS_REALTIME) && | |
| 744 | − kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) { | |
| 758 | + if (pv_tlb_flush_supported()) { | |
| 745 | 759 | for_each_possible_cpu(cpu) { |
| 746 | 760 | zalloc_cpumask_var_node(per_cpu_ptr(&__pv_tlb_mask, cpu), |
| 747 | 761 | GFP_KERNEL, cpu_to_node(cpu)); |