From patchwork Thu Sep 5 14:46:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 19774 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f197.google.com (mail-ye0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5B37B24692 for ; Thu, 5 Sep 2013 14:46:51 +0000 (UTC) Received: by mail-ye0-f197.google.com with SMTP id q5sf1924807yen.8 for ; Thu, 05 Sep 2013 07:46:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Ydx2+eGtklr1jz9/mWw1koFA2Ohq8C770Xgixv7d0qo=; b=TAw7msDbZDl63itCwQ6unIY0wKr6yAM0u5aPz4TF3KGg/vg3qwfqP2W6nS0O5fzBrx eEe8S4ehKXGcRe3n/NqZOL78+WOF3drO2hN/4T3jl/mBF9Xbl+SavQzkl46EZD5d4QPW udnTCMJSEdvZiZrf/v9rwrBPZxlzA8nmItylyKzM0OUhb7h7wYALZwWTpXd+wfsPN0Kc QEp/oImLbhouNwcSdsBIsNQPyXQKSvcKb0IZ/zKiVBw1bWA6b9Z9107clxbS8IeyFuBd ywbmrx6Wxb0u5fder82LX7uk4POjmJOhZVvzKtOXeW1U+CVYXQWK+LCteGM+RDfR1G4m b/NA== X-Received: by 10.236.6.134 with SMTP id 6mr3326490yhn.7.1378392411183; Thu, 05 Sep 2013 07:46:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.59.14 with SMTP id v14ls456413qeq.87.gmail; Thu, 05 Sep 2013 07:46:51 -0700 (PDT) X-Received: by 10.58.217.167 with SMTP id oz7mr8187091vec.15.1378392411098; Thu, 05 Sep 2013 07:46:51 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id tj1si7313717vdc.66.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 07:46:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ib11so1246591vcb.0 for ; Thu, 05 Sep 2013 07:46:51 -0700 (PDT) X-Gm-Message-State: ALoCoQljNH/H8eK8LjY+Fwsp5M4eLzU1b11dWSklNjcnFmvwa2Lhe/9FLzfm7JlBDnAayJmkNATu X-Received: by 10.221.64.17 with SMTP id xg17mr2532900vcb.5.1378392411017; Thu, 05 Sep 2013 07:46:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp284241vcz; Thu, 5 Sep 2013 07:46:50 -0700 (PDT) X-Received: by 10.68.216.33 with SMTP id on1mr9678809pbc.107.1378392409868; Thu, 05 Sep 2013 07:46:49 -0700 (PDT) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id w4si9152933pax.150.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 07:46:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of anup.patel@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id rq2so1892862pbb.33 for ; Thu, 05 Sep 2013 07:46:49 -0700 (PDT) X-Received: by 10.68.254.5 with SMTP id ae5mr9822943pbd.40.1378392409447; Thu, 05 Sep 2013 07:46:49 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id xs1sm38485325pac.7.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 07:46:48 -0700 (PDT) From: Anup Patel To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, marc.zyngier@arm.com, christoffer.dall@linaro.org, pranavkumar@linaro.org, Anup Patel Subject: [RFC PATCH 1/3] ARM: KVM: Implement target CPU=Host Date: Thu, 5 Sep 2013 20:16:00 +0530 Message-Id: <1378392362-6773-2-git-send-email-anup.patel@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1378392362-6773-1-git-send-email-anup.patel@linaro.org> References: <1378392362-6773-1-git-send-email-anup.patel@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: anup.patel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch implements KVM_ARM_TARGET_HOST for KVM ARM. If user space provides KVM_ARM_TARGET_HOST as target type in KVM_ARM_VCPU_INIT ioctl then we find out appropriate target type based on underlying host and return that to user space via struct kvm_vcpu_init. Signed-off-by: Anup Patel Signed-off-by: Pranavkumar Sawargaonkar --- arch/arm/include/asm/kvm_host.h | 2 +- arch/arm/include/uapi/asm/kvm.h | 1 + arch/arm/kvm/arm.c | 9 ++++++++- arch/arm/kvm/guest.c | 11 +++++++++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 7d22517..3bb6c2b 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -153,7 +153,7 @@ struct kvm_vcpu_stat { struct kvm_vcpu_init; int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, - const struct kvm_vcpu_init *init); + struct kvm_vcpu_init *init); unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices); struct kvm_one_reg; diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h index c1ee007..644012e 100644 --- a/arch/arm/include/uapi/asm/kvm.h +++ b/arch/arm/include/uapi/asm/kvm.h @@ -63,6 +63,7 @@ struct kvm_regs { /* Supported Processor Types */ #define KVM_ARM_TARGET_CORTEX_A15 0 +#define KVM_ARM_TARGET_HOST 0x0FFFFFFF #define KVM_ARM_NUM_TARGETS 1 /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */ diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 741f66a..d8e494e 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -698,6 +698,7 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level, long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { + int err; struct kvm_vcpu *vcpu = filp->private_data; void __user *argp = (void __user *)arg; @@ -708,8 +709,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp, if (copy_from_user(&init, argp, sizeof(init))) return -EFAULT; - return kvm_vcpu_set_target(vcpu, &init); + err = kvm_vcpu_set_target(vcpu, &init); + if (err) + return err; + + if (copy_to_user(argp, &init, sizeof(init))) + return -EFAULT; + return 0; } case KVM_SET_ONE_REG: case KVM_GET_ONE_REG: { diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c index 152d036..050df63 100644 --- a/arch/arm/kvm/guest.c +++ b/arch/arm/kvm/guest.c @@ -198,12 +198,19 @@ int __attribute_const__ kvm_target_cpu(void) } int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, - const struct kvm_vcpu_init *init) + struct kvm_vcpu_init *init) { unsigned int i; + int phys_target = kvm_target_cpu(); + + if (phys_target < 0) { + return phys_target; + } /* We can only do a cortex A15 for now. */ - if (init->target != kvm_target_cpu()) + if (init->target == KVM_ARM_TARGET_HOST) + init->target = phys_target; + else if (init->target != phys_target) return -EINVAL; vcpu->arch.target = init->target;