* [patch 0/2] support RT_PRIO_HC hypercall
@ 2017-09-21 12:03 ` Marcelo Tosatti
0 siblings, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2017-09-21 12:03 UTC (permalink / raw)
To: kvm, qemu-devel
Add the following CPU options:
allow-rt-prio-hc: allow guest to execute hypercall to change vcpu
thread priority.
rt-prio: SCHED_FIFO priority to be used when that hypercall is invoked.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [patch 0/2] support RT_PRIO_HC hypercall
@ 2017-09-21 12:03 ` Marcelo Tosatti
0 siblings, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2017-09-21 12:03 UTC (permalink / raw)
To: kvm, qemu-devel
Add the following CPU options:
allow-rt-prio-hc: allow guest to execute hypercall to change vcpu
thread priority.
rt-prio: SCHED_FIFO priority to be used when that hypercall is invoked.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 1/2] qemu: sync linux-headers with KVM
2017-09-21 12:03 ` [Qemu-devel] " Marcelo Tosatti
@ 2017-09-21 12:03 ` Marcelo Tosatti
-1 siblings, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2017-09-21 12:03 UTC (permalink / raw)
To: kvm, qemu-devel; +Cc: Marcelo Tosatti
[-- Attachment #1: sync-linux-headers --]
[-- Type: text/plain, Size: 2000 bytes --]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: qemu-fifoprio/linux-headers/linux/kvm.h
===================================================================
--- qemu-fifoprio.orig/linux-headers/linux/kvm.h
+++ qemu-fifoprio/linux-headers/linux/kvm.h
@@ -929,6 +929,7 @@ struct kvm_ppc_resize_hpt {
#define KVM_CAP_PPC_SMT_POSSIBLE 147
#define KVM_CAP_HYPERV_SYNIC2 148
#define KVM_CAP_HYPERV_VP_INDEX 149
+#define KVM_CAP_VCPU_RT_PRIO_HC 150
#ifdef KVM_CAP_IRQ_ROUTING
@@ -1355,6 +1356,8 @@ struct kvm_s390_ucas_mapping {
/* Available with KVM_CAP_S390_CMMA_MIGRATION */
#define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log)
#define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log)
+/* Available with KVM_CAP_VCPU_RT_PRIO_HC */
+#define KVM_SET_VCPU_RT_PRIO_HC _IOW(KVMIO, 0xba, struct kvm_vcpu_rt_prio)
#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
#define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
Index: qemu-fifoprio/linux-headers/asm-x86/kvm.h
===================================================================
--- qemu-fifoprio.orig/linux-headers/asm-x86/kvm.h
+++ qemu-fifoprio/linux-headers/asm-x86/kvm.h
@@ -353,6 +353,11 @@ struct kvm_xcrs {
__u64 padding[16];
};
+struct kvm_vcpu_rt_prio {
+ __u32 enabled;
+ __u32 sched_priority;
+};
+
/* definition of registers in kvm_run */
struct kvm_sync_regs {
};
Index: qemu-fifoprio/linux-headers/linux/kvm_para.h
===================================================================
--- qemu-fifoprio.orig/linux-headers/linux/kvm_para.h
+++ qemu-fifoprio/linux-headers/linux/kvm_para.h
@@ -15,6 +15,7 @@
#define KVM_E2BIG E2BIG
#define KVM_EPERM EPERM
#define KVM_EOPNOTSUPP 95
+#define KVM_EINVAL EINVAL
#define KVM_HC_VAPIC_POLL_IRQ 1
#define KVM_HC_MMU_OP 2
@@ -25,6 +26,7 @@
#define KVM_HC_MIPS_EXIT_VM 7
#define KVM_HC_MIPS_CONSOLE_OUTPUT 8
#define KVM_HC_CLOCK_PAIRING 9
+#define KVM_HC_RT_PRIO 10
/*
* hypercalls use architecture specific
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [patch 1/2] qemu: sync linux-headers with KVM
@ 2017-09-21 12:03 ` Marcelo Tosatti
0 siblings, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2017-09-21 12:03 UTC (permalink / raw)
To: kvm, qemu-devel; +Cc: Marcelo Tosatti
[-- Attachment #1: sync-linux-headers --]
[-- Type: text/plain, Size: 2000 bytes --]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Index: qemu-fifoprio/linux-headers/linux/kvm.h
===================================================================
--- qemu-fifoprio.orig/linux-headers/linux/kvm.h
+++ qemu-fifoprio/linux-headers/linux/kvm.h
@@ -929,6 +929,7 @@ struct kvm_ppc_resize_hpt {
#define KVM_CAP_PPC_SMT_POSSIBLE 147
#define KVM_CAP_HYPERV_SYNIC2 148
#define KVM_CAP_HYPERV_VP_INDEX 149
+#define KVM_CAP_VCPU_RT_PRIO_HC 150
#ifdef KVM_CAP_IRQ_ROUTING
@@ -1355,6 +1356,8 @@ struct kvm_s390_ucas_mapping {
/* Available with KVM_CAP_S390_CMMA_MIGRATION */
#define KVM_S390_GET_CMMA_BITS _IOWR(KVMIO, 0xb8, struct kvm_s390_cmma_log)
#define KVM_S390_SET_CMMA_BITS _IOW(KVMIO, 0xb9, struct kvm_s390_cmma_log)
+/* Available with KVM_CAP_VCPU_RT_PRIO_HC */
+#define KVM_SET_VCPU_RT_PRIO_HC _IOW(KVMIO, 0xba, struct kvm_vcpu_rt_prio)
#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
#define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
Index: qemu-fifoprio/linux-headers/asm-x86/kvm.h
===================================================================
--- qemu-fifoprio.orig/linux-headers/asm-x86/kvm.h
+++ qemu-fifoprio/linux-headers/asm-x86/kvm.h
@@ -353,6 +353,11 @@ struct kvm_xcrs {
__u64 padding[16];
};
+struct kvm_vcpu_rt_prio {
+ __u32 enabled;
+ __u32 sched_priority;
+};
+
/* definition of registers in kvm_run */
struct kvm_sync_regs {
};
Index: qemu-fifoprio/linux-headers/linux/kvm_para.h
===================================================================
--- qemu-fifoprio.orig/linux-headers/linux/kvm_para.h
+++ qemu-fifoprio/linux-headers/linux/kvm_para.h
@@ -15,6 +15,7 @@
#define KVM_E2BIG E2BIG
#define KVM_EPERM EPERM
#define KVM_EOPNOTSUPP 95
+#define KVM_EINVAL EINVAL
#define KVM_HC_VAPIC_POLL_IRQ 1
#define KVM_HC_MMU_OP 2
@@ -25,6 +26,7 @@
#define KVM_HC_MIPS_EXIT_VM 7
#define KVM_HC_MIPS_CONSOLE_OUTPUT 8
#define KVM_HC_CLOCK_PAIRING 9
+#define KVM_HC_RT_PRIO 10
/*
* hypercalls use architecture specific
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch 2/2] qemu: kvm: support RT_PRIO_HC hypercall
2017-09-21 12:03 ` [Qemu-devel] " Marcelo Tosatti
@ 2017-09-21 12:03 ` Marcelo Tosatti
-1 siblings, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2017-09-21 12:03 UTC (permalink / raw)
To: kvm, qemu-devel; +Cc: Marcelo Tosatti
[-- Attachment #1: qemu-toggle-kvmrt-prio --]
[-- Type: text/plain, Size: 3062 bytes --]
Add the following CPU options:
allow-rt-prio-hc: allow guest to execute hypercall to change vcpu
thread priority.
rt-prio: SCHED_FIFO priority to be used when that hypercall is invoked.
See kernel patchset for details about this hypercall.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
target/i386/cpu.c | 2 ++
target/i386/cpu.h | 4 ++++
target/i386/kvm.c | 23 +++++++++++++++++++++++
3 files changed, 29 insertions(+)
Index: qemu-fifoprio/target/i386/cpu.c
===================================================================
--- qemu-fifoprio.orig/target/i386/cpu.c
+++ qemu-fifoprio/target/i386/cpu.c
@@ -4106,6 +4106,8 @@ static Property x86_cpu_properties[] = {
false),
DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true),
DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true),
+ DEFINE_PROP_BOOL("allow-rt-prio-hc", X86CPU, allow_rt_prio_hc, false),
+ DEFINE_PROP_UINT32("rt-prio", X86CPU, rt_prio_hc, 0),
DEFINE_PROP_END_OF_LIST()
};
Index: qemu-fifoprio/target/i386/cpu.h
===================================================================
--- qemu-fifoprio.orig/target/i386/cpu.h
+++ qemu-fifoprio/target/i386/cpu.h
@@ -1215,6 +1215,7 @@ struct X86CPU {
bool hyperv_runtime;
bool hyperv_synic;
bool hyperv_stimer;
+ bool allow_rt_prio_hc;
bool check_cpuid;
bool enforce_cpuid;
bool expose_kvm;
@@ -1270,6 +1271,9 @@ struct X86CPU {
/* Number of physical address bits supported */
uint32_t phys_bits;
+ /* RT priority of VCPU thread, when hypercall is invoked by guest */
+ uint32_t rt_prio_hc;
+
/* in order to simplify APIC support, we leave this pointer to the
user */
struct DeviceState *apic_state;
Index: qemu-fifoprio/target/i386/kvm.c
===================================================================
--- qemu-fifoprio.orig/target/i386/kvm.c
+++ qemu-fifoprio/target/i386/kvm.c
@@ -673,6 +673,28 @@ static int hyperv_handle_properties(CPUS
static Error *invtsc_mig_blocker;
+static int enable_allow_rt_prio_hc(CPUState *cs)
+{
+ int ret;
+ struct kvm_vcpu_rt_prio rt_prio;
+ X86CPU *cpu = X86_CPU(cs);
+
+ if (!kvm_check_extension(kvm_state, KVM_CAP_VCPU_RT_PRIO_HC)) {
+ fprintf(stderr, "RT prio hypercall not supported by kernel\n");
+ return -ENOSYS;
+ }
+
+ rt_prio.sched_priority = cpu->rt_prio_hc;
+ rt_prio.enabled = 1;
+
+ ret = kvm_vcpu_ioctl(cs, KVM_ENABLE_VCPU_RT_PRIO_HC, &rt_prio);
+ if (ret) {
+ fprintf(stderr, "RT prio hypercall failed, ret=%d\n", ret);
+ }
+
+ return ret;
+}
+
#define KVM_MAX_CPUID_ENTRIES 100
int kvm_arch_init_vcpu(CPUState *cs)
@@ -758,6 +780,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
has_msr_hv_hypercall = true;
}
+ if (cpu->allow_rt_prio_hc) {
+ if (enable_allow_rt_prio_hc(cs)) {
+ abort();
+ }
+ }
+
if (cpu->expose_kvm) {
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
c = &cpuid_data.entries[cpuid_i++];
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [patch 2/2] qemu: kvm: support RT_PRIO_HC hypercall
@ 2017-09-21 12:03 ` Marcelo Tosatti
0 siblings, 0 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2017-09-21 12:03 UTC (permalink / raw)
To: kvm, qemu-devel; +Cc: Marcelo Tosatti
[-- Attachment #1: qemu-toggle-kvmrt-prio --]
[-- Type: text/plain, Size: 3062 bytes --]
Add the following CPU options:
allow-rt-prio-hc: allow guest to execute hypercall to change vcpu
thread priority.
rt-prio: SCHED_FIFO priority to be used when that hypercall is invoked.
See kernel patchset for details about this hypercall.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
target/i386/cpu.c | 2 ++
target/i386/cpu.h | 4 ++++
target/i386/kvm.c | 23 +++++++++++++++++++++++
3 files changed, 29 insertions(+)
Index: qemu-fifoprio/target/i386/cpu.c
===================================================================
--- qemu-fifoprio.orig/target/i386/cpu.c
+++ qemu-fifoprio/target/i386/cpu.c
@@ -4106,6 +4106,8 @@ static Property x86_cpu_properties[] = {
false),
DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true),
DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true),
+ DEFINE_PROP_BOOL("allow-rt-prio-hc", X86CPU, allow_rt_prio_hc, false),
+ DEFINE_PROP_UINT32("rt-prio", X86CPU, rt_prio_hc, 0),
DEFINE_PROP_END_OF_LIST()
};
Index: qemu-fifoprio/target/i386/cpu.h
===================================================================
--- qemu-fifoprio.orig/target/i386/cpu.h
+++ qemu-fifoprio/target/i386/cpu.h
@@ -1215,6 +1215,7 @@ struct X86CPU {
bool hyperv_runtime;
bool hyperv_synic;
bool hyperv_stimer;
+ bool allow_rt_prio_hc;
bool check_cpuid;
bool enforce_cpuid;
bool expose_kvm;
@@ -1270,6 +1271,9 @@ struct X86CPU {
/* Number of physical address bits supported */
uint32_t phys_bits;
+ /* RT priority of VCPU thread, when hypercall is invoked by guest */
+ uint32_t rt_prio_hc;
+
/* in order to simplify APIC support, we leave this pointer to the
user */
struct DeviceState *apic_state;
Index: qemu-fifoprio/target/i386/kvm.c
===================================================================
--- qemu-fifoprio.orig/target/i386/kvm.c
+++ qemu-fifoprio/target/i386/kvm.c
@@ -673,6 +673,28 @@ static int hyperv_handle_properties(CPUS
static Error *invtsc_mig_blocker;
+static int enable_allow_rt_prio_hc(CPUState *cs)
+{
+ int ret;
+ struct kvm_vcpu_rt_prio rt_prio;
+ X86CPU *cpu = X86_CPU(cs);
+
+ if (!kvm_check_extension(kvm_state, KVM_CAP_VCPU_RT_PRIO_HC)) {
+ fprintf(stderr, "RT prio hypercall not supported by kernel\n");
+ return -ENOSYS;
+ }
+
+ rt_prio.sched_priority = cpu->rt_prio_hc;
+ rt_prio.enabled = 1;
+
+ ret = kvm_vcpu_ioctl(cs, KVM_ENABLE_VCPU_RT_PRIO_HC, &rt_prio);
+ if (ret) {
+ fprintf(stderr, "RT prio hypercall failed, ret=%d\n", ret);
+ }
+
+ return ret;
+}
+
#define KVM_MAX_CPUID_ENTRIES 100
int kvm_arch_init_vcpu(CPUState *cs)
@@ -758,6 +780,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
has_msr_hv_hypercall = true;
}
+ if (cpu->allow_rt_prio_hc) {
+ if (enable_allow_rt_prio_hc(cs)) {
+ abort();
+ }
+ }
+
if (cpu->expose_kvm) {
memcpy(signature, "KVMKVMKVM\0\0\0", 12);
c = &cpuid_data.entries[cpuid_i++];
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-21 12:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 12:03 [patch 0/2] support RT_PRIO_HC hypercall Marcelo Tosatti
2017-09-21 12:03 ` [Qemu-devel] " Marcelo Tosatti
2017-09-21 12:03 ` [patch 1/2] qemu: sync linux-headers with KVM Marcelo Tosatti
2017-09-21 12:03 ` [Qemu-devel] " Marcelo Tosatti
2017-09-21 12:03 ` [patch 2/2] qemu: kvm: support RT_PRIO_HC hypercall Marcelo Tosatti
2017-09-21 12:03 ` [Qemu-devel] " Marcelo Tosatti
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.