From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 01/28] target/i386: kvm: add support for TSC scaling
Date: Fri, 25 Jun 2021 16:17:55 +0200 [thread overview]
Message-ID: <20210625141822.1368639-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com>
Linux 5.14 will add support for nested TSC scaling. Add the
corresponding feature in QEMU; to keep support for existing kernels,
do not add it to any processor yet.
The handling of the VMCS enumeration MSR is ugly; once we have more than
one case, we may want to add a table to check VMX features against.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/cpu.c | 2 +-
target/i386/cpu.h | 1 +
target/i386/kvm/kvm.c | 12 ++++++++----
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index a9fe1662d3..d8f3ab3192 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1031,7 +1031,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
"vmx-invpcid-exit", "vmx-vmfunc", "vmx-shadow-vmcs", "vmx-encls-exit",
"vmx-rdseed-exit", "vmx-pml", NULL, NULL,
"vmx-xsaves", NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
+ NULL, "vmx-tsc-scaling", NULL, NULL,
NULL, NULL, NULL, NULL,
},
.msr = {
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 1e11071d81..f7fa5870b1 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -972,6 +972,7 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
#define VMX_SECONDARY_EXEC_RDSEED_EXITING 0x00010000
#define VMX_SECONDARY_EXEC_ENABLE_PML 0x00020000
#define VMX_SECONDARY_EXEC_XSAVES 0x00100000
+#define VMX_SECONDARY_EXEC_TSC_SCALING 0x02000000
#define VMX_PIN_BASED_EXT_INTR_MASK 0x00000001
#define VMX_PIN_BASED_NMI_EXITING 0x00000008
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index ad950c3c27..04e4ec063f 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2700,8 +2700,6 @@ static uint64_t make_vmx_msr_value(uint32_t index, uint32_t features)
return must_be_one | (((uint64_t)can_be_one) << 32);
}
-#define VMCS12_MAX_FIELD_INDEX (0x17)
-
static void kvm_msr_entry_add_vmx(X86CPU *cpu, FeatureWordArray f)
{
uint64_t kvm_vmx_basic =
@@ -2791,8 +2789,14 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, FeatureWordArray f)
CR0_PE_MASK | CR0_PG_MASK | CR0_NE_MASK);
kvm_msr_entry_add(cpu, MSR_IA32_VMX_CR4_FIXED0,
CR4_VMXE_MASK);
- kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM,
- VMCS12_MAX_FIELD_INDEX << 1);
+
+ if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) {
+ /* TSC multiplier (0x2032). */
+ kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x32);
+ } else {
+ /* Preemption timer (0x482E). */
+ kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x2E);
+ }
}
static void kvm_msr_entry_add_perf(X86CPU *cpu, FeatureWordArray f)
--
2.31.1
next prev parent reply other threads:[~2021-06-25 14:22 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 14:17 [PULL v2 00/28] Misc (including block file-posix) for 2021-06-23 Paolo Bonzini
2021-06-25 14:17 ` Paolo Bonzini [this message]
2021-06-25 14:17 ` [PULL 02/28] meson: drop unused CONFIG_GCRYPT_HMAC Paolo Bonzini
2021-06-25 14:17 ` [PULL 03/28] configure: drop unused variables for xts Paolo Bonzini
2021-06-25 14:17 ` [PULL 04/28] meson: remove preadv from summary Paolo Bonzini
2021-06-25 14:17 ` [PULL 05/28] tests: remove QCRYPTO_HAVE_TLS_TEST_SUPPORT Paolo Bonzini
2021-06-25 14:18 ` [PULL 06/28] configure, meson: convert crypto detection to meson Paolo Bonzini
2021-06-25 14:18 ` [PULL 07/28] configure, meson: convert libtasn1 " Paolo Bonzini
2021-06-25 14:18 ` [PULL 08/28] configure, meson: convert pam " Paolo Bonzini
2021-06-25 14:18 ` [PULL 09/28] configure, meson: convert libusb " Paolo Bonzini
2021-06-25 14:18 ` [PULL 10/28] configure, meson: convert libcacard " Paolo Bonzini
2021-06-25 14:18 ` [PULL 11/28] configure, meson: convert libusbredir " Paolo Bonzini
2021-06-25 14:18 ` [PULL 12/28] KVM: Fix dirty ring mmap incorrect size due to renaming accident Paolo Bonzini
2021-06-25 14:18 ` [PULL 13/28] file-posix: fix max_iov for /dev/sg devices Paolo Bonzini
2021-06-25 14:18 ` [PULL 14/28] scsi-generic: pass max_segments via max_iov field in BlockLimits Paolo Bonzini
2021-06-25 14:18 ` [PULL 15/28] osdep: provide ROUND_DOWN macro Paolo Bonzini
2021-06-29 4:12 ` Philippe Mathieu-Daudé
2021-06-25 14:18 ` [PULL 16/28] block-backend: align max_transfer to request alignment Paolo Bonzini
2021-06-25 14:18 ` [PULL 17/28] block: add max_hw_transfer to BlockLimits Paolo Bonzini
2021-06-25 14:18 ` [PULL 18/28] file-posix: try BLKSECTGET on block devices too, do not round to power of 2 Paolo Bonzini
2021-09-06 14:24 ` Halil Pasic
2021-09-22 19:51 ` Halil Pasic
2021-09-23 9:18 ` Recent qemu patch results in aio failures with host DASD disks resulting in guest I/O errors Christian Borntraeger
2021-09-23 10:57 ` [PULL 18/28] file-posix: try BLKSECTGET on block devices too, do not round to power of 2 Paolo Bonzini
2021-09-23 12:13 ` Halil Pasic
2021-09-23 13:02 ` Paolo Bonzini
2021-06-25 14:18 ` [PULL 19/28] block: feature detection for host block support Paolo Bonzini
2021-06-25 14:18 ` [PULL 20/28] block: check for sys/disk.h Paolo Bonzini
2021-06-25 14:18 ` [PULL 21/28] block: try BSD disk size ioctls one after another Paolo Bonzini
2021-06-25 14:18 ` [PULL 22/28] block: detect DKIOCGETBLOCKCOUNT/SIZE before use Paolo Bonzini
2021-06-25 14:18 ` [PULL 23/28] file-posix: handle EINTR during ioctl Paolo Bonzini
2021-06-25 14:18 ` [PULL 24/28] machine: move dies from X86MachineState to CpuTopology Paolo Bonzini
2021-06-25 14:18 ` [PULL 25/28] machine: move common smp_parse code to caller Paolo Bonzini
2021-06-25 14:18 ` [PULL 26/28] machine: add error propagation to mc->smp_parse Paolo Bonzini
2021-06-25 14:18 ` [PULL 27/28] machine: pass QAPI struct " Paolo Bonzini
2021-06-25 14:18 ` [PULL 28/28] machine: reject -smp dies!=1 for non-PC machines Paolo Bonzini
2021-06-29 8:37 ` [PULL v2 00/28] Misc (including block file-posix) for 2021-06-23 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210625141822.1368639-2-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).