From patchwork Fri Sep 16 06:26:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 9335041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D89F76089F for ; Fri, 16 Sep 2016 06:27:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C904429ECB for ; Fri, 16 Sep 2016 06:27:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B61A229EC8; Fri, 16 Sep 2016 06:27:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33CB029EC8 for ; Fri, 16 Sep 2016 06:27:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752977AbcIPG10 (ORCPT ); Fri, 16 Sep 2016 02:27:26 -0400 Received: from mx2.suse.de ([195.135.220.15]:56105 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751861AbcIPG1X (ORCPT ); Fri, 16 Sep 2016 02:27:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E90A6AAC7; Fri, 16 Sep 2016 06:27:20 +0000 (UTC) From: Alexander Graf To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Subject: [PATCH v3 1/2] KVM: arm/arm64: Add vcpu ENABLE_CAP functionality Date: Fri, 16 Sep 2016 08:26:26 +0200 Message-Id: <1474007187-18673-2-git-send-email-agraf@suse.de> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1474007187-18673-1-git-send-email-agraf@suse.de> References: <1474007187-18673-1-git-send-email-agraf@suse.de> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In a follow-up patch we will need to enable capabilities on demand for backwards compatibility. This patch adds the generic framework to handle vcpu cap enablement to the arm code base. Signed-off-by: Alexander Graf --- Documentation/virtual/kvm/api.txt | 4 +++- arch/arm/kvm/arm.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index 739db9a..23937e0 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -997,7 +997,9 @@ documentation when it pops into existence). Capability: KVM_CAP_ENABLE_CAP, KVM_CAP_ENABLE_CAP_VM Architectures: x86 (only KVM_CAP_ENABLE_CAP_VM), - mips (only KVM_CAP_ENABLE_CAP), ppc, s390 + mips (only KVM_CAP_ENABLE_CAP), ppc, s390, + arm (only KVM_CAP_ENABLE_CAP), + arm64 (only KVM_CAP_ENABLE_CAP) Type: vcpu ioctl, vm ioctl (with KVM_CAP_ENABLE_CAP_VM) Parameters: struct kvm_enable_cap (in) Returns: 0 on success; -1 on error diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 75f130e..c84b6ad 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -878,6 +878,23 @@ static int kvm_arm_vcpu_has_attr(struct kvm_vcpu *vcpu, return ret; } +static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, + struct kvm_enable_cap *cap) +{ + int r; + + if (cap->flags) + return -EINVAL; + + switch (cap->cap) { + default: + r = -EINVAL; + break; + } + + return r; +} + long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { @@ -941,6 +958,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp, return -EFAULT; return kvm_arm_vcpu_has_attr(vcpu, &attr); } + case KVM_ENABLE_CAP: + { + struct kvm_enable_cap cap; + + if (copy_from_user(&cap, argp, sizeof(cap))) + return -EFAULT; + return kvm_vcpu_ioctl_enable_cap(vcpu, &cap); + } default: return -EINVAL; }