- i386/cpuid: Move leaf 7 to correct group - i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F - i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs - i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available - target/i386: Change wrong XFRM value in SGX CPUID leaf - target/i386: Enable support for XSAVES based features - target/i386: Add kvm_get_one_msr helper - hw/block/hd-geometry: Do not override specified bios-chs-trans mainline inclusion commit fd8a68ad6823d33bedeba20a22857867a1c3890e category: bugfix - linux-user/riscv: Align signal frame to 16 bytes mainline inclusion commit 1eaa63429a9944265c92efdb94c02fabb231f564 category: bugfix - ipmi:smbus: Add a check around a memcpy mainline inclusion commit 3fde641e7286f9b968bdb3b4b922c6465f2a9abc category: bugfix - tests/tcg/linux-test: Fix random hangs in test_socket mainline inclusion commit b9e6074fc5b429b1e956e9c60db7e284a91e0f3d category: bugfix - qemu-options.hx: Don't claim "-serial" has limit of 4 serial ports Before v2.12, the implementation of serial ports was limited to a value of MAX_SERIAL_PORTS = 4. We now dynamically allocate the data structures for serial ports, so this limit is no longer present, but the documentation for the -serial options still reads: - target/ppc: Modify the uncorrect value irq to n_IRQ - block-migration: Ensure we don't crash during migration cleanup - target/s390x: fix handling of zeroes in vfmin/vfmax mainline inclusion commit 13c59eb09bd6d1fbc13f08b708226421f14a232b category: bugfix - hw/virtio/virtio-iommu: Enforce power-of-two notify for both MAP and UNMAP mainline inclusion commit 0522be9a0c0094088ccef7aab352c57f483ca250 category: bugfix - configure: Add missing POSIX-required space mainline inclusion commit 35a7a6fc5624b1df828d82f2dfa74d0e4188b3b2 category: bugfix - vga: fix incorrect line height in 640x200x2 mode mainline inclusion commit 37e7b86766244b62a406747bb78e049390d0b528 category: bugfix - hw/ide/core: set ERR_STAT in unsupported command completion - linux-user/flatload.c: Fix setting of image_info::end_code mainline inclusion commit 734a659ad264ac080457167e845ffabbaaa66d0e category: bugfix - load_elf: fix iterator's type for elf file processing - hw/misc/mps2-scc: Free MPS2SCC::oscclk[] array on finalize() - hw/nvram/xlnx-efuse: Free XlnxEFuse::ro_bits[] array on finalize() - hw/nvram/xlnx-efuse-ctrl: Free XlnxVersalEFuseCtrl[] "pg0-lock" array - chardev/char.c: fix "abstract device type" error message - block/rbd: fix handling of holes in .bdrv_co_block_status - qga: treat get-guest-fsinfo as "best effort" mainline inclusion commit bbb0151cf2e82489120a15df5e2eb9653312b0ec category: bugfix - usb/hcd-xhci: check slotid in xhci_wakeup_endpoint() mainline inclusion commit 84218892f05515d20347fde4506e1944eb11cb25 category: bugfix - hw/display/bcm2835_fb: Fix framebuffer allocation address mainline inclusion commit 5865d99fe88d8c8fa437c18c6b63fb2a8165634f category: bugfix - block/parallels: Fix buffer-based write call mainline inclusion commit eba088f91d21d9e42a81bef847173da30c5da961 category: bugfix - vl: Improve error message for conflicting -incoming and -loadvm - hw/smbios: Fix OEM strings table option validation Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com> (cherry picked from commit 5d1a5160936dce1757c09050d97d12f42642794b)
124 lines
3.7 KiB
Diff
124 lines
3.7 KiB
Diff
From 66d093c4b3fbb3dcb232b38852c47fe1d7d5e1c1 Mon Sep 17 00:00:00 2001
|
|
From: Yang Weijiang <weijiang.yang@intel.com>
|
|
Date: Tue, 15 Feb 2022 14:52:53 -0500
|
|
Subject: [PATCH] target/i386: Add kvm_get_one_msr helper
|
|
|
|
commit 5a778a5f820fdd907b95e93560637a61f6ea3c71 upstream.
|
|
|
|
When try to get one msr from KVM, I found there's no such kind of
|
|
existing interface while kvm_put_one_msr() is there. So here comes
|
|
the patch. It'll remove redundant preparation code before finally
|
|
call KVM_GET_MSRS IOCTL.
|
|
|
|
No functional change intended.
|
|
|
|
Intel-SIG: commit 5a778a5f820f target/i386: Add kvm_get_one_msr helper
|
|
Backport i386/cpu bugfixes
|
|
|
|
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
|
|
Message-Id: <20220215195258.29149-4-weijiang.yang@intel.com>
|
|
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Signed-off-by: Jason Zeng <jason.zeng@intel.com>
|
|
---
|
|
target/i386/kvm/kvm.c | 46 ++++++++++++++++++++++++-------------------
|
|
1 file changed, 26 insertions(+), 20 deletions(-)
|
|
|
|
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
|
|
index 54e48530ad..e1601422bc 100644
|
|
--- a/target/i386/kvm/kvm.c
|
|
+++ b/target/i386/kvm/kvm.c
|
|
@@ -138,6 +138,7 @@ static struct kvm_msr_list *kvm_feature_msrs;
|
|
|
|
#define BUS_LOCK_SLICE_TIME 1000000000ULL /* ns */
|
|
static RateLimit bus_lock_ratelimit_ctrl;
|
|
+static int kvm_get_one_msr(X86CPU *cpu, int index, uint64_t *value);
|
|
|
|
int kvm_has_pit_state2(void)
|
|
{
|
|
@@ -208,28 +209,21 @@ static int kvm_get_tsc(CPUState *cs)
|
|
{
|
|
X86CPU *cpu = X86_CPU(cs);
|
|
CPUX86State *env = &cpu->env;
|
|
- struct {
|
|
- struct kvm_msrs info;
|
|
- struct kvm_msr_entry entries[1];
|
|
- } msr_data = {};
|
|
+ uint64_t value;
|
|
int ret;
|
|
|
|
if (env->tsc_valid) {
|
|
return 0;
|
|
}
|
|
|
|
- memset(&msr_data, 0, sizeof(msr_data));
|
|
- msr_data.info.nmsrs = 1;
|
|
- msr_data.entries[0].index = MSR_IA32_TSC;
|
|
env->tsc_valid = !runstate_is_running();
|
|
|
|
- ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data);
|
|
+ ret = kvm_get_one_msr(cpu, MSR_IA32_TSC, &value);
|
|
if (ret < 0) {
|
|
return ret;
|
|
}
|
|
|
|
- assert(ret == 1);
|
|
- env->tsc = msr_data.entries[0].data;
|
|
+ env->tsc = value;
|
|
return 0;
|
|
}
|
|
|
|
@@ -1529,21 +1523,14 @@ static int hyperv_init_vcpu(X86CPU *cpu)
|
|
* the kernel doesn't support setting vp_index; assert that its value
|
|
* is in sync
|
|
*/
|
|
- struct {
|
|
- struct kvm_msrs info;
|
|
- struct kvm_msr_entry entries[1];
|
|
- } msr_data = {
|
|
- .info.nmsrs = 1,
|
|
- .entries[0].index = HV_X64_MSR_VP_INDEX,
|
|
- };
|
|
+ uint64_t value;
|
|
|
|
- ret = kvm_vcpu_ioctl(cs, KVM_GET_MSRS, &msr_data);
|
|
+ ret = kvm_get_one_msr(cpu, HV_X64_MSR_VP_INDEX, &value);
|
|
if (ret < 0) {
|
|
return ret;
|
|
}
|
|
- assert(ret == 1);
|
|
|
|
- if (msr_data.entries[0].data != hyperv_vp_index(CPU(cpu))) {
|
|
+ if (value != hyperv_vp_index(CPU(cpu))) {
|
|
error_report("kernel's vp_index != QEMU's vp_index");
|
|
return -ENXIO;
|
|
}
|
|
@@ -2766,6 +2753,25 @@ static int kvm_put_one_msr(X86CPU *cpu, int index, uint64_t value)
|
|
return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
|
|
}
|
|
|
|
+static int kvm_get_one_msr(X86CPU *cpu, int index, uint64_t *value)
|
|
+{
|
|
+ int ret;
|
|
+ struct {
|
|
+ struct kvm_msrs info;
|
|
+ struct kvm_msr_entry entries[1];
|
|
+ } msr_data = {
|
|
+ .info.nmsrs = 1,
|
|
+ .entries[0].index = index,
|
|
+ };
|
|
+
|
|
+ ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data);
|
|
+ if (ret < 0) {
|
|
+ return ret;
|
|
+ }
|
|
+ assert(ret == 1);
|
|
+ *value = msr_data.entries[0].data;
|
|
+ return ret;
|
|
+}
|
|
void kvm_put_apicbase(X86CPU *cpu, uint64_t value)
|
|
{
|
|
int ret;
|
|
--
|
|
2.27.0
|
|
|