Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp491663rwb; Fri, 2 Sep 2022 18:45:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mTeGyaDfMK+vW/wko50hj9BJM+7d2ZWdjWTeS+cUmY7kfB802DEKxJpSe7mvUzm51vfGt X-Received: by 2002:a17:902:e751:b0:174:89f8:cef2 with SMTP id p17-20020a170902e75100b0017489f8cef2mr30252007plf.156.1662169506013; Fri, 02 Sep 2022 18:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662169506; cv=none; d=google.com; s=arc-20160816; b=cF+hpoded+sUy24ERKMDcv3ssQVTt4npFzMVb2hVh/VemucsGidMwEnYpUzZwBPK0G zDZpkif/9tv205ggxV91sQADhp5A7ty7/1rO9JrRd4nJIZztPVJl7V3pAGNag76fuZIF BpYwX4PTN7PPoNyWliL6L7sufEhfhyLAFGluKAXZ8bO64nPP0K2DnZWr7CBVodhHkOoc bvqGIV19sFKPE2HgRZUBERo/0gt7kh1K+bkOwDW+Suti3xKkIhgkpSi84F/l8J+sUeft X7vrdiiubJkVcB29QH88P5tBRkA4kysB94hbwoyaar2z53IMtxOK/ago6on5x+vEObQm ErxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=zLFYPEVszfNpW6dCutbkzHT/LYTZJZBJHTuaDoaj/cE=; b=rLmAqv6O2DUkqDPJ8CG4ZZI1CnotE9I1wLIBny23/fkf0iBgK9cQHFKoUU8gfO1YR0 lwpyKxPshffcg4NNNyZkS0zG8L4rJRvoMI9S8HuUK/XHrcMF6ItclaWbfBi1lXVGt5LT SoKPWP4srAbrVFrtTBRe27qK1+jKS3JMNQrwAusOKInGMVL1p/n+EaHnv6zyoqcdbeT5 Ck66dQD9w9ly6ukdCWGvLyQOY/KUJTR6VSwVGH9kvtSPKz3syZuRIEWyBGNiV5QHNxdZ wg9vwzHArkQuofSdjU8HhGoFOeA6ozxoh+vhc9UxpaiXUAh6QTrTg8xcivWTEKFtft9q QPdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jduT6xdj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a056a0024d300b0053a8225dc47si3912952pfv.55.2022.09.02.18.44.54; Fri, 02 Sep 2022 18:45:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jduT6xdj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230325AbiICB3K (ORCPT + 99 others); Fri, 2 Sep 2022 21:29:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230459AbiICB3I (ORCPT ); Fri, 2 Sep 2022 21:29:08 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07EADEEF13 for ; Fri, 2 Sep 2022 18:29:07 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id m5-20020a170902f64500b0016d313f3ce7so2186664plg.23 for ; Fri, 02 Sep 2022 18:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date; bh=zLFYPEVszfNpW6dCutbkzHT/LYTZJZBJHTuaDoaj/cE=; b=jduT6xdjGBEpUaZZI4/ZP9lwMs8afG7T8AbeScf86NEDtTl3FPIPdc5ZefkA3jIrDj Bwb3/DP5hlGZY0WU3YZpC5AglW3nbor5Zb/S961uBOb3PUmk7Udw1GQ54mX1dNwk2jPI noQNbXLcB4uoecphVEXOx8qyF64OLSPdkp5kRKQ40qZtBN9TNL8jJOLNR5Qj1qWQf22C VZf2Oer2GQYEIYNZQgsTsx8MKpiIT0bwQfRO4eB4SchDYHhXAng2I65osVf2BG7qAN7I PaEOhkYpuXWewR8O1cB7p9EM3Jjvlow8cWj5mMfdLwCu8QGWMEC+jR2eMfeJ2zXg6bmN VquQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date; bh=zLFYPEVszfNpW6dCutbkzHT/LYTZJZBJHTuaDoaj/cE=; b=qnzKvL3zrzQY5jJ2l0NC7I7imZQ9YrIVDqRSkc0APdIsguc3TIvnaRjF1TgeXdzXlW BEmqTqlHby/Pzmoah1Gv0vWZEeb+JAnSWXjVYocIjvdggMUJ/qhvckLZgR6PgyLobpK7 dH7EXDObYHZ359lca6BTkPBnLhYhMi2o85cVYkIk7FJ0+cP9WAPXeb5cvNGo5E3pmIX7 nLenSJN1kG55nI5KD+MKGCEo3dA7JZ/zKfXfYF85HTV6Q7l2LWvCZnuEstPa/XV9tTX0 /mN9c5ftvQh93nzk4cILm36R+gX5Qci+Dk66hrdaWvdiGPemCUhNKTNgJaxeC4beCqYH Kgeg== X-Gm-Message-State: ACgBeo13A9YP8edipziAe9RI/iXt4fVoiKXiO8pYwdxOAt/wqYgoo7pu J+g6vhiNBQaRSuDtSPxCgE2psfzbpavC/IW7 X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a62:27c1:0:b0:536:32d2:d098 with SMTP id n184-20020a6227c1000000b0053632d2d098mr39234197pfn.63.1662168546414; Fri, 02 Sep 2022 18:29:06 -0700 (PDT) Date: Sat, 3 Sep 2022 01:28:44 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220903012849.938069-1-vannapurve@google.com> Subject: [V1 PATCH 0/5] Execute hypercalls from guests according to cpu type From: Vishal Annapurve To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: pbonzini@redhat.com, shuah@kernel.org, bgardon@google.com, seanjc@google.com, oupton@google.com, peterx@redhat.com, vkuznets@redhat.com, drjones@redhat.com, dmatlack@google.com, Vishal Annapurve Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series is posted in context of the discussion at: https://lore.kernel.org/lkml/Ywa9T+jKUpaHLu%2Fl@google.com/ Major changes: 1) Move common startup logic to a single common main function in kvm_util.c 2) Introduce following APIs: kvm_arch_main: to perform arch specific common startup. kvm_post_vm_load: to update the guest memory state to convey common information to guests. 3) For x86, capture cpu type at startup and pass on the cpu type to guest after guest elf is loaded. 4) Execute hypercall instruction from within guest VMs according to the cpu type. This will help prevent an extra kvm exit during hypercall execution. Vishal Annapurve (5): selftests: kvm: move common startup logic to kvm_util.c selftests: kvm: Introduce kvm_arch_main and helpers selftests: kvm: x86: Execute vmcall/vmmcall according to CPU type selftests: kvm: delete svm_vmcall_test selftests: kvm: Execute vmcall/vmmcall as per cpu type tools/testing/selftests/kvm/.gitignore | 1 - .../selftests/kvm/aarch64/arch_timer.c | 5 +- .../selftests/kvm/aarch64/debug-exceptions.c | 2 +- .../selftests/kvm/aarch64/get-reg-list.c | 2 +- .../selftests/kvm/aarch64/hypercalls.c | 4 +- .../testing/selftests/kvm/aarch64/psci_test.c | 2 +- .../selftests/kvm/aarch64/vcpu_width_config.c | 2 +- .../testing/selftests/kvm/aarch64/vgic_init.c | 2 +- .../testing/selftests/kvm/aarch64/vgic_irq.c | 5 +- .../selftests/kvm/access_tracking_perf_test.c | 4 +- .../selftests/kvm/demand_paging_test.c | 7 +- .../selftests/kvm/dirty_log_perf_test.c | 4 +- tools/testing/selftests/kvm/dirty_log_test.c | 4 +- .../selftests/kvm/hardware_disable_test.c | 2 +- .../selftests/kvm/include/kvm_util_base.h | 15 ++++ .../selftests/kvm/include/x86_64/processor.h | 10 +++ .../selftests/kvm/include/x86_64/vmx.h | 9 --- .../selftests/kvm/kvm_binary_stats_test.c | 3 +- .../selftests/kvm/kvm_create_max_vcpus.c | 4 +- .../selftests/kvm/kvm_page_table_test.c | 4 +- .../selftests/kvm/lib/aarch64/processor.c | 8 ++ tools/testing/selftests/kvm/lib/elf.c | 2 + tools/testing/selftests/kvm/lib/kvm_util.c | 12 +++ .../selftests/kvm/lib/riscv/processor.c | 8 ++ .../selftests/kvm/lib/s390x/processor.c | 8 ++ tools/testing/selftests/kvm/lib/sparsebit.c | 2 +- .../selftests/kvm/lib/x86_64/perf_test_util.c | 2 +- .../selftests/kvm/lib/x86_64/processor.c | 38 +++++++++- .../selftests/kvm/max_guest_memory_test.c | 2 +- .../kvm/memslot_modification_stress_test.c | 4 +- .../testing/selftests/kvm/memslot_perf_test.c | 9 +-- tools/testing/selftests/kvm/rseq_test.c | 7 +- tools/testing/selftests/kvm/s390x/memop.c | 4 +- tools/testing/selftests/kvm/s390x/resets.c | 4 +- .../selftests/kvm/s390x/sync_regs_test.c | 5 +- tools/testing/selftests/kvm/s390x/tprot.c | 2 +- .../selftests/kvm/set_memory_region_test.c | 7 +- tools/testing/selftests/kvm/steal_time.c | 4 +- .../kvm/system_counter_offset_test.c | 2 +- tools/testing/selftests/kvm/x86_64/amx_test.c | 2 +- .../testing/selftests/kvm/x86_64/cpuid_test.c | 2 +- .../kvm/x86_64/cr4_cpuid_sync_test.c | 6 +- .../testing/selftests/kvm/x86_64/debug_regs.c | 4 +- .../kvm/x86_64/emulator_error_test.c | 7 +- .../testing/selftests/kvm/x86_64/evmcs_test.c | 2 +- .../selftests/kvm/x86_64/fix_hypercall_test.c | 2 +- .../kvm/x86_64/get_msr_index_features.c | 2 +- .../selftests/kvm/x86_64/hyperv_clock.c | 2 +- .../selftests/kvm/x86_64/hyperv_cpuid.c | 7 +- .../selftests/kvm/x86_64/hyperv_features.c | 2 +- .../selftests/kvm/x86_64/hyperv_svm_test.c | 2 +- .../selftests/kvm/x86_64/kvm_clock_test.c | 2 +- .../selftests/kvm/x86_64/kvm_pv_test.c | 2 +- .../kvm/x86_64/max_vcpuid_cap_test.c | 3 +- .../selftests/kvm/x86_64/mmio_warning_test.c | 4 +- .../selftests/kvm/x86_64/monitor_mwait_test.c | 3 +- .../selftests/kvm/x86_64/nx_huge_pages_test.c | 4 +- .../selftests/kvm/x86_64/platform_info_test.c | 7 +- .../kvm/x86_64/pmu_event_filter_test.c | 7 +- .../selftests/kvm/x86_64/set_boot_cpu_id.c | 2 +- .../selftests/kvm/x86_64/set_sregs_test.c | 7 +- .../selftests/kvm/x86_64/sev_migrate_tests.c | 3 +- tools/testing/selftests/kvm/x86_64/smm_test.c | 4 +- .../testing/selftests/kvm/x86_64/state_test.c | 10 +-- .../selftests/kvm/x86_64/svm_int_ctl_test.c | 3 +- .../kvm/x86_64/svm_nested_soft_inject_test.c | 7 +- .../selftests/kvm/x86_64/svm_vmcall_test.c | 74 ------------------- .../selftests/kvm/x86_64/sync_regs_test.c | 7 +- .../kvm/x86_64/triple_fault_event_test.c | 2 +- .../selftests/kvm/x86_64/tsc_msrs_test.c | 4 +- .../selftests/kvm/x86_64/tsc_scaling_sync.c | 3 +- .../kvm/x86_64/ucna_injection_test.c | 2 +- .../selftests/kvm/x86_64/userspace_io_test.c | 6 +- .../kvm/x86_64/userspace_msr_exit_test.c | 7 +- .../kvm/x86_64/vmx_apic_access_test.c | 5 +- .../kvm/x86_64/vmx_close_while_nested_test.c | 2 +- .../selftests/kvm/x86_64/vmx_dirty_log_test.c | 4 +- .../vmx_exception_with_invalid_guest_state.c | 2 +- .../x86_64/vmx_invalid_nested_guest_state.c | 2 +- .../selftests/kvm/x86_64/vmx_msrs_test.c | 2 +- .../kvm/x86_64/vmx_nested_tsc_scaling_test.c | 5 +- .../selftests/kvm/x86_64/vmx_pmu_caps_test.c | 2 +- .../kvm/x86_64/vmx_preemption_timer_test.c | 4 +- .../kvm/x86_64/vmx_set_nested_state_test.c | 3 +- .../kvm/x86_64/vmx_tsc_adjust_test.c | 5 +- .../selftests/kvm/x86_64/xapic_ipi_test.c | 4 +- .../selftests/kvm/x86_64/xapic_state_test.c | 2 +- .../selftests/kvm/x86_64/xen_shinfo_test.c | 67 +++++++---------- .../selftests/kvm/x86_64/xen_vmcall_test.c | 17 +++-- .../selftests/kvm/x86_64/xss_msr_test.c | 2 +- 90 files changed, 223 insertions(+), 339 deletions(-) delete mode 100644 tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c -- 2.37.2.789.g6183377224-goog