Skip to contentSkip to conversation

x86 queue, 2018-03-12

GIT PULL Applied Eduardo Habkost 2 participants 5 messages Mar 12, 2018 – Mar 13, 2018

lore
Share & tools
lore
#0 lore raw

The following changes since commit b16a54da0696efc5d91b6c3597a37a317abb5de7:

Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180312-pull-request' into staging (2018-03-12 14:06:23 +0000)

are available in the Git repository at:

git://github.com/ehabkost/qemu.git tags/x86-next-pull-request

for you to fetch changes up to b77146e9a129bcdb60edc23639211679ae846a92:

i386: Add support to get/set/migrate Intel Processor Trace feature (2018-03-12 15:59:46 -0300)

----------------------------------------------------------------
x86 queue, 2018-03-12

* Intel Processor Trace support
* KVM_HINTS_DEDICATED

----------------------------------------------------------------

Chao Peng (2):
i386: Add Intel Processor Trace feature support
i386: Add support to get/set/migrate Intel Processor Trace feature

Wanpeng Li (1):
target-i386: add KVM_HINTS_DEDICATED performance hint

 target/i386/cpu.h     | 26 +++++++++++++++
 target/i386/cpu.c     | 92 +++++++++++++++++++++++++++++++++++++++++++++++++--
 target/i386/kvm.c     | 78 +++++++++++++++++++++++++++++++++++++++++++
 target/i386/machine.c | 38 +++++++++++++++++++++
 4 files changed, 232 insertions(+), 2 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

[Qemu-devel] [PULL 1/3] target-i386: add KVM_HINTS_DEDICATED performance hint

From: Wanpeng Li <[email protected]>

Add KVM_HINTS_DEDICATED performance hint, guest checks this feature bit to determine if they run on dedicated vCPUs, allowing optimizations such as usage of qspinlocks.

Cc Paolo Bonzini <[email protected]>
Cc Radim Krčmář <[email protected]>
Cc Eduardo Habkost <[email protected]>

Message-Id: <[email protected]>

[ehabkost: Renamed property to kvm-hint-dedicated]
---
 target/i386/cpu.h |  3 +++
 target/i386/cpu.c | 14 ++++++++++++++
 target/i386/kvm.c |  4 ++++
 3 files changed, 21 insertions(+)
target/i386/cpu.h +3 -0
index faf39ec1ce..8d977ec567 100644
@@ -471,6 +471,7 @@ typedef enum FeatureWord {
     FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */
     FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */
     FEAT_KVM,           /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */
+    FEAT_KVM_HINTS,     /* CPUID[4000_0001].EDX */
     FEAT_HYPERV_EAX,    /* CPUID[4000_0003].EAX */
     FEAT_HYPERV_EBX,    /* CPUID[4000_0003].EBX */
     FEAT_HYPERV_EDX,    /* CPUID[4000_0003].EDX */
@@ -666,6 +667,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
 #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */
 #define CPUID_7_0_EDX_SPEC_CTRL     (1U << 26) /* Speculation Control */
 
+#define KVM_HINTS_DEDICATED (1U << 0)
+
 #define CPUID_8000_0008_EBX_IBPB    (1U << 12) /* Indirect Branch Prediction Barrier */
 
 #define CPUID_XSAVE_XSAVEOPT   (1U << 0)
target/i386/cpu.c +14 -0
index 2c04645cea..5ea1931b7e 100644
@@ -359,6 +359,20 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
         .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX,
         .tcg_features = TCG_KVM_FEATURES,
     },
+    [FEAT_KVM_HINTS] = {
+        .feat_names = {
+            "kvm-hint-dedicated", NULL, NULL, NULL,
+            NULL, NULL, NULL, NULL,
+            NULL, NULL, NULL, NULL,
+            NULL, NULL, NULL, NULL,
+            NULL, NULL, NULL, NULL,
+            NULL, NULL, NULL, NULL,
+            NULL, NULL, NULL, NULL,
+            NULL, NULL, NULL, NULL,
+        },
+        .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EDX,
+        .tcg_features = TCG_KVM_FEATURES,
+    },
     [FEAT_HYPERV_EAX] = {
         .feat_names = {
             NULL /* hv_msr_vp_runtime_access */, NULL /* hv_msr_time_refcount_access */,
target/i386/kvm.c +4 -0
index ad4b159b28..44ee524188 100644
@@ -383,6 +383,9 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
         if (!kvm_irqchip_in_kernel()) {
             ret &= ~(1U << KVM_FEATURE_PV_UNHALT);
         }
+    } else if (function == KVM_CPUID_FEATURES && reg == R_EDX) {
+        ret |= KVM_HINTS_DEDICATED;
+        found = 1;
     }
 
     /* fallback for older kernels */
@@ -801,6 +804,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
         c = &cpuid_data.entries[cpuid_i++];
         c->function = KVM_CPUID_FEATURES | kvm_base;
         c->eax = env->features[FEAT_KVM];
+        c->edx = env->features[FEAT_KVM_HINTS];
     }
 
     cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
Signature · 1 line
2.14.3
#2 lore raw

[Qemu-devel] [PULL 2/3] i386: Add Intel Processor Trace feature support

In reply to Eduardo Habkost

From: Chao Peng <[email protected]>

Expose Intel Processor Trace feature to guest.

To make Intel PT live migration safe and get same CPUID information with same CPU model on diffrent host. CPUID[14] is constant in this patch. Intel PT use EPT is first supported in IceLake, the CPUID[14] get on this machine as default value. Intel PT would be disabled if any machine don't support this minial feature list.

Message-Id: <[email protected]>

---
 target/i386/cpu.h |  1 +
 target/i386/cpu.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 target/i386/kvm.c | 23 ++++++++++++++++
 3 files changed, 100 insertions(+), 2 deletions(-)
target/i386/cpu.h +1 -0
index 8d977ec567..ec2a771299 100644
@@ -641,6 +641,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
 #define CPUID_7_0_EBX_PCOMMIT  (1U << 22) /* Persistent Commit */
 #define CPUID_7_0_EBX_CLFLUSHOPT (1U << 23) /* Flush a Cache Line Optimized */
 #define CPUID_7_0_EBX_CLWB     (1U << 24) /* Cache Line Write Back */
+#define CPUID_7_0_EBX_INTEL_PT (1U << 25) /* Intel Processor Trace */
 #define CPUID_7_0_EBX_AVX512PF (1U << 26) /* AVX-512 Prefetch */
 #define CPUID_7_0_EBX_AVX512ER (1U << 27) /* AVX-512 Exponential and Reciprocal */
 #define CPUID_7_0_EBX_AVX512CD (1U << 28) /* AVX-512 Conflict Detection */
target/i386/cpu.c +76 -2

102 lines not on this page · raw message

target/i386/kvm.c +23 -0
index 44ee524188..f5d3d73ed6 100644
@@ -869,6 +869,29 @@ int kvm_arch_init_vcpu(CPUState *cs)
                 c = &cpuid_data.entries[cpuid_i++];
             }
             break;
+        case 0x14: {
+            uint32_t times;
+
+            c->function = i;
+            c->index = 0;
+            c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
+            cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+            times = c->eax;
+
+            for (j = 1; j <= times; ++j) {
+                if (cpuid_i == KVM_MAX_CPUID_ENTRIES) {
+                    fprintf(stderr, "cpuid_data is full, no space for "
+                                "cpuid(eax:0x14,ecx:0x%x)\n", j);
+                    abort();
+                }
+                c = &cpuid_data.entries[cpuid_i++];
+                c->function = i;
+                c->index = j;
+                c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
+                cpu_x86_cpuid(env, i, j, &c->eax, &c->ebx, &c->ecx, &c->edx);
+            }
+            break;
+        }
         default:
             c->function = i;
             c->flags = 0;
Signature · 1 line
2.14.3
#3 lore raw

[Qemu-devel] [PULL 3/3] i386: Add support to get/set/migrate Intel Processor Trace feature

In reply to Eduardo Habkost

From: Chao Peng <[email protected]>

Add Intel Processor Trace related definition. It also add corresponding part to kvm_get/set_msr and vmstate.

Message-Id: <[email protected]>

---
 target/i386/cpu.h     | 22 ++++++++++++++++++++++
 target/i386/kvm.c     | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 target/i386/machine.c | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
target/i386/cpu.h +22 -0
index ec2a771299..0c3f51445e 100644
@@ -415,6 +415,21 @@ typedef enum X86Seg {
 #define MSR_MC0_ADDR                    0x402
 #define MSR_MC0_MISC                    0x403
 
+#define MSR_IA32_RTIT_OUTPUT_BASE       0x560
+#define MSR_IA32_RTIT_OUTPUT_MASK       0x561
+#define MSR_IA32_RTIT_CTL               0x570
+#define MSR_IA32_RTIT_STATUS            0x571
+#define MSR_IA32_RTIT_CR3_MATCH         0x572
+#define MSR_IA32_RTIT_ADDR0_A           0x580
+#define MSR_IA32_RTIT_ADDR0_B           0x581
+#define MSR_IA32_RTIT_ADDR1_A           0x582
+#define MSR_IA32_RTIT_ADDR1_B           0x583
+#define MSR_IA32_RTIT_ADDR2_A           0x584
+#define MSR_IA32_RTIT_ADDR2_B           0x585
+#define MSR_IA32_RTIT_ADDR3_A           0x586
+#define MSR_IA32_RTIT_ADDR3_B           0x587
+#define MAX_RTIT_ADDRS                  8
+
 #define MSR_EFER                        0xc0000080
 
 #define MSR_EFER_SCE   (1 << 0)
@@ -1157,6 +1172,13 @@ typedef struct CPUX86State {
     uint64_t msr_hv_stimer_config[HV_STIMER_COUNT];
     uint64_t msr_hv_stimer_count[HV_STIMER_COUNT];
 
+    uint64_t msr_rtit_ctrl;
+    uint64_t msr_rtit_status;
+    uint64_t msr_rtit_output_base;
+    uint64_t msr_rtit_output_mask;
+    uint64_t msr_rtit_cr3_match;
+    uint64_t msr_rtit_addrs[MAX_RTIT_ADDRS];
+
     /* exception/interrupt handling */
     int error_code;
     int exception_is_int;
target/i386/kvm.c +51 -0

69 lines not on this page · raw message

target/i386/machine.c +38 -0
index 361c05aedf..c05fe6fb1a 100644
@@ -837,6 +837,43 @@ static const VMStateDescription vmstate_spec_ctrl = {
     }
 };
 
+static bool intel_pt_enable_needed(void *opaque)
+{
+    X86CPU *cpu = opaque;
+    CPUX86State *env = &cpu->env;
+    int i;
+
+    if (env->msr_rtit_ctrl || env->msr_rtit_status ||
+        env->msr_rtit_output_base || env->msr_rtit_output_mask ||
+        env->msr_rtit_cr3_match) {
+        return true;
+    }
+
+    for (i = 0; i < MAX_RTIT_ADDRS; i++) {
+        if (env->msr_rtit_addrs[i]) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
+static const VMStateDescription vmstate_msr_intel_pt = {
+    .name = "cpu/intel_pt",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = intel_pt_enable_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(env.msr_rtit_ctrl, X86CPU),
+        VMSTATE_UINT64(env.msr_rtit_status, X86CPU),
+        VMSTATE_UINT64(env.msr_rtit_output_base, X86CPU),
+        VMSTATE_UINT64(env.msr_rtit_output_mask, X86CPU),
+        VMSTATE_UINT64(env.msr_rtit_cr3_match, X86CPU),
+        VMSTATE_UINT64_ARRAY(env.msr_rtit_addrs, X86CPU, MAX_RTIT_ADDRS),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 VMStateDescription vmstate_x86_cpu = {
     .name = "cpu",
     .version_id = 12,
@@ -957,6 +994,7 @@ VMStateDescription vmstate_x86_cpu = {
 #endif
         &vmstate_spec_ctrl,
         &vmstate_mcg_ext_ctl,
+        &vmstate_msr_intel_pt,
         NULL
     }
 };
Signature · 1 line
2.14.3
#4 lore raw
In reply to Eduardo Habkost
Quoted 12 lines · Eduardo Habkost

The following changes since commit b16a54da0696efc5d91b6c3597a37a317abb5de7:

Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180312-pull-request' into staging (2018-03-12 14:06:23 +0000)

are available in the Git repository at:

git://github.com/ehabkost/qemu.git tags/x86-next-pull-request

for you to fetch changes up to b77146e9a129bcdb60edc23639211679ae846a92:

i386: Add support to get/set/migrate Intel Processor Trace feature (2018-03-12 15:59:46 -0300)

Quoted 7 lines

----------------------------------------------------------------
x86 queue, 2018-03-12

* Intel Processor Trace support
* KVM_HINTS_DEDICATED

----------------------------------------------------------------

Applied, thanks.

-- PMM