[PATCH 2/2] WIP: ASYNC_PF_INT

From: Vitaly Kuznetsov
Date: Fri Apr 24 2020 - 09:09:45 EST


Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
---
target/i386/cpu.c | 2 +-
target/i386/cpu.h | 1 +
target/i386/kvm.c | 10 ++++++++++
target/i386/machine.c | 19 +++++++++++++++++++
4 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 9c256ab15910..ea794f3f52b5 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -810,7 +810,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
"kvmclock", "kvm-nopiodelay", "kvm-mmu", "kvmclock",
"kvm-asyncpf", "kvm-steal-time", "kvm-pv-eoi", "kvm-pv-unhalt",
NULL, "kvm-pv-tlb-flush", NULL, "kvm-pv-ipi",
- "kvm-poll-control", "kvm-pv-sched-yield", NULL, NULL,
+ "kvm-poll-control", "kvm-pv-sched-yield", "kvm-asyncpf-int", NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
"kvmclock-stable-bit", NULL, NULL, NULL,
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index e818fc712aca..673e31e191cc 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1474,6 +1474,7 @@ typedef struct CPUX86State {
uint64_t wall_clock_msr;
uint64_t steal_time_msr;
uint64_t async_pf_en_msr;
+ uint64_t async_pf_int_msr;
uint64_t pv_eoi_en_msr;
uint64_t poll_control_msr;

diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 4901c6dd747d..d2b286f9dcb9 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -283,6 +283,7 @@ static const struct kvm_para_features {
{ KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
{ KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
{ KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
+ { KVM_CAP_ASYNC_PF_INT, KVM_FEATURE_ASYNC_PF_INT },
};

static int get_para_features(KVMState *s)
@@ -2798,6 +2799,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) {
kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, env->async_pf_en_msr);
}
+ if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF_INT)) {
+ kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, env->async_pf_int_msr);
+ }
if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) {
kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, env->pv_eoi_en_msr);
}
@@ -3183,6 +3187,9 @@ static int kvm_get_msrs(X86CPU *cpu)
if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) {
kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, 0);
}
+ if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF_INT)) {
+ kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_INT, 0);
+ }
if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) {
kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, 0);
}
@@ -3423,6 +3430,9 @@ static int kvm_get_msrs(X86CPU *cpu)
case MSR_KVM_ASYNC_PF_EN:
env->async_pf_en_msr = msrs[i].data;
break;
+ case MSR_KVM_ASYNC_PF_INT:
+ env->async_pf_int_msr = msrs[i].data;
+ break;
case MSR_KVM_PV_EOI_EN:
env->pv_eoi_en_msr = msrs[i].data;
break;
diff --git a/target/i386/machine.c b/target/i386/machine.c
index 0c96531a56f0..dc124cf57de7 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -394,6 +394,13 @@ static bool async_pf_msr_needed(void *opaque)
return cpu->env.async_pf_en_msr != 0;
}

+static bool async_pf_int_msr_needed(void *opaque)
+{
+ X86CPU *cpu = opaque;
+
+ return cpu->env.async_pf_int_msr != 0;
+}
+
static bool pv_eoi_msr_needed(void *opaque)
{
X86CPU *cpu = opaque;
@@ -467,6 +474,17 @@ static const VMStateDescription vmstate_async_pf_msr = {
}
};

+static const VMStateDescription vmstate_async_pf_int_msr = {
+ .name = "cpu/async_pf_int_msr",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = async_pf_int_msr_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT64(env.async_pf_int_msr, X86CPU),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static const VMStateDescription vmstate_pv_eoi_msr = {
.name = "cpu/async_pv_eoi_msr",
.version_id = 1,
@@ -1409,6 +1427,7 @@ VMStateDescription vmstate_x86_cpu = {
.subsections = (const VMStateDescription*[]) {
&vmstate_exception_info,
&vmstate_async_pf_msr,
+ &vmstate_async_pf_int_msr,
&vmstate_pv_eoi_msr,
&vmstate_steal_time_msr,
&vmstate_poll_control_msr,
--
2.25.4


--=-=-=--