From patchwork Mon Apr 14 16:48:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 339010 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8F866140082 for ; Tue, 15 Apr 2014 02:51:00 +1000 (EST) Received: from localhost ([::1]:44287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZk5y-00051v-9G for incoming@patchwork.ozlabs.org; Mon, 14 Apr 2014 12:50:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZk3z-0002Ct-F7 for qemu-devel@nongnu.org; Mon, 14 Apr 2014 12:49:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WZk3j-0004Gk-SP for qemu-devel@nongnu.org; Mon, 14 Apr 2014 12:48:55 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:49041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZk3j-0004Gc-JW for qemu-devel@nongnu.org; Mon, 14 Apr 2014 12:48:39 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 Apr 2014 17:48:38 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 14 Apr 2014 17:48:36 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id B4E7A17D8059 for ; Mon, 14 Apr 2014 17:49:30 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s3EGmZW945678782 for ; Mon, 14 Apr 2014 16:48:35 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s3EGmZN3009463 for ; Mon, 14 Apr 2014 10:48:35 -0600 Received: from gondolin.boeblingen.de.ibm.com (dyn-9-152-224-107.boeblingen.de.ibm.com [9.152.224.107]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s3EGmXlA009338; Mon, 14 Apr 2014 10:48:34 -0600 From: Cornelia Huck To: qemu-devel@nongnu.org Date: Mon, 14 Apr 2014 18:48:23 +0200 Message-Id: <1397494110-5756-3-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397494110-5756-1-git-send-email-cornelia.huck@de.ibm.com> References: <1397494110-5756-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14041416-3548-0000-0000-000008BD8530 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.112 Cc: Cornelia Huck , borntraeger@de.ibm.com, agraf@suse.de Subject: [Qemu-devel] [PATCH 2/9] kvm: add kvm_enable_cap_{vm,vcpu} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Provide helper functions for enabling capabilities (on a vcpu and on a vm). Reviewed-by: Thomas Huth Signed-off-by: Cornelia Huck --- include/sysemu/kvm.h | 4 ++++ kvm-all.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 0bee1e8..2ff5ad3 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -294,6 +294,10 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cpu); int kvm_check_extension(KVMState *s, unsigned int extension); +int kvm_enable_cap_vm(KVMState *s, unsigned int capability, ...); + +int kvm_enable_cap_vcpu(CPUState *cpu, unsigned int capability, ...); + uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, uint32_t index, int reg); diff --git a/kvm-all.c b/kvm-all.c index cd4111d..658e50c 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -501,7 +501,38 @@ int kvm_check_extension(KVMState *s, unsigned int extension) return ret; } -static int kvm_set_ioeventfd_mmio(int fd, hwaddr addr, uint32_t val, +int kvm_enable_cap_vm(KVMState *s, unsigned int capability, ...) +{ + struct kvm_enable_cap cap = {}; + va_list ap; + int i; + + cap.cap = capability; + va_start(ap, capability); + for (i = 0; i < 4; i++) { + cap.args[i] = va_arg(ap, uint64_t); + } + va_end(ap); + return kvm_vm_ioctl(s, KVM_ENABLE_CAP, &cap); +} + +int kvm_enable_cap_vcpu(CPUState *cpu, unsigned int capability, ...) +{ + struct kvm_enable_cap cap = {}; + va_list ap; + int i; + + cap.cap = capability; + va_start(ap, capability); + for (i = 0; i < 4; i++) { + cap.args[i] = va_arg(ap, uint64_t); + } + va_end(ap); + return kvm_vcpu_ioctl(cpu, KVM_ENABLE_CAP, &cap); +} + + +static int kvm_set_ioeventfd_mmio(int fd, uint32_t addr, uint32_t val, bool assign, uint32_t size, bool datamatch) { int ret;