- migration/xbzrle: fix out-of-bounds write with axv512 - migration/xbzrle: use ctz64 to avoid undefined result - Update bench-code for addressing CI problem - AVX512 support for xbzrle_encode_buffer - configure, meson: move AVX tests to meson - target/i386: KVM: allow fast string operations if host supports them - target/i386: add FSRM to TCG - hw/nvme: fix memory leak in nvme_dsm - aio-posix: fix race between epoll upgrade and aio_set_fd_handler() - target/i386: Add SGX aex-notify and EDECCSSA support - hw/usb/imx: Fix out of bounds access in imx_usbphy_read() - target/i386: Set maximum APIC ID to KVM prior to vCPU creation - target/i386: Fix sanity check on max APIC ID / X2APIC enablement Signed-off-by: Fei Xu <xufei30@huawei.com>
96 lines
3.3 KiB
Diff
96 lines
3.3 KiB
Diff
From db3e0a8dd430a11e8dde6aee4e1f9cca4af0e015 Mon Sep 17 00:00:00 2001
|
|
From: Zeng Guang <guang.zeng@intel.com>
|
|
Date: Thu, 25 Aug 2022 10:52:46 +0800
|
|
Subject: [PATCH] target/i386: Set maximum APIC ID to KVM prior to vCPU
|
|
creation
|
|
|
|
from mainline-v7.2.0-rc0
|
|
commit 19e2a9fb9da067acba95b3be83588bda5a3f6a99
|
|
category: feature
|
|
feature: Optimization of IPI virtualization
|
|
bugzilla: https://gitee.com/openeuler/intel-qemu/issues/I6Y34T
|
|
|
|
Intel-SIG: commit 19e2a9fb9da0 ("target/i386: Set maximum APIC ID to KVM prior to vCPU creation")
|
|
|
|
------------------------------------------------
|
|
|
|
Specify maximum possible APIC ID assigned for current VM session to KVM
|
|
prior to the creation of vCPUs. By this setting, KVM can set up VM-scoped
|
|
data structure indexed by the APIC ID, e.g. Posted-Interrupt Descriptor
|
|
pointer table to support Intel IPI virtualization, with the most optimal
|
|
memory footprint.
|
|
|
|
It can be achieved by calling KVM_ENABLE_CAP for KVM_CAP_MAX_VCPU_ID
|
|
capability once KVM has enabled it. Ignoring the return error if KVM
|
|
doesn't support this capability yet.
|
|
|
|
Signed-off-by: Zeng Guang <guang.zeng@intel.com>
|
|
Acked-by: Peter Xu <peterx@redhat.com>
|
|
Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
Message-Id: <20220825025246.26618-1-guang.zeng@intel.com>
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
[ jason: amend commit log ]
|
|
Signed-off-by: Jason Zeng <jason.zeng@intel.com>
|
|
---
|
|
hw/i386/x86.c | 4 ++++
|
|
target/i386/kvm/kvm-stub.c | 5 +++++
|
|
target/i386/kvm/kvm.c | 5 +++++
|
|
target/i386/kvm/kvm_i386.h | 2 ++
|
|
4 files changed, 16 insertions(+)
|
|
|
|
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
|
|
index f64639b873..a3258d78fa 100644
|
|
--- a/hw/i386/x86.c
|
|
+++ b/hw/i386/x86.c
|
|
@@ -152,6 +152,10 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version)
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
+ if (kvm_enabled()) {
|
|
+ kvm_set_max_apic_id(x86ms->apic_id_limit);
|
|
+ }
|
|
+
|
|
possible_cpus = mc->possible_cpu_arch_ids(ms);
|
|
for (i = 0; i < ms->smp.cpus; i++) {
|
|
x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, &error_fatal);
|
|
diff --git a/target/i386/kvm/kvm-stub.c b/target/i386/kvm/kvm-stub.c
|
|
index f6e7e4466e..e052f1c7b0 100644
|
|
--- a/target/i386/kvm/kvm-stub.c
|
|
+++ b/target/i386/kvm/kvm-stub.c
|
|
@@ -44,3 +44,8 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp)
|
|
{
|
|
abort();
|
|
}
|
|
+
|
|
+void kvm_set_max_apic_id(uint32_t max_apic_id)
|
|
+{
|
|
+ return;
|
|
+}
|
|
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
|
index b8257e7e5f..7212ed98a9 100644
|
|
--- a/target/i386/kvm/kvm.c
|
|
+++ b/target/i386/kvm/kvm.c
|
|
@@ -5270,3 +5270,8 @@ void kvm_arch_accel_class_init(ObjectClass *oc)
|
|
"Clock cycles without an event window "
|
|
"after which a notification VM exit occurs");
|
|
}
|
|
+
|
|
+void kvm_set_max_apic_id(uint32_t max_apic_id)
|
|
+{
|
|
+ kvm_vm_enable_cap(kvm_state, KVM_CAP_MAX_VCPU_ID, 0, max_apic_id);
|
|
+}
|
|
diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h
|
|
index 4124912c20..58590138e5 100644
|
|
--- a/target/i386/kvm/kvm_i386.h
|
|
+++ b/target/i386/kvm/kvm_i386.h
|
|
@@ -54,4 +54,6 @@ uint64_t kvm_swizzle_msi_ext_dest_id(uint64_t address);
|
|
bool kvm_enable_sgx_provisioning(KVMState *s);
|
|
void kvm_request_xsave_components(X86CPU *cpu, uint64_t mask);
|
|
|
|
+void kvm_set_max_apic_id(uint32_t max_apic_id);
|
|
+
|
|
#endif
|
|
--
|
|
2.27.0
|
|
|