From patchwork Thu Sep 5 14:46:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 19775 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2936424692 for ; Thu, 5 Sep 2013 14:46:57 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf2027453vbg.3 for ; Thu, 05 Sep 2013 07:46:57 -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=SiYb4HuhamIZpWL9twu6T/O3bcf5p5nLDt2UpduA0Vk=; b=Oy7XfPnJmQaumFLoO2mXKcE4ta5TJB7jDnZOxdN3gGeYDf+evMF1HhzrPgsOL++1Fa jZTa20FAN2iG9XyGgcXNnBOmWYfVDQBIfmqbPvamUpKgPCUEpj85XtpWbvwbAg9k+2/k czykggLyzMWFC6diL5ktQa7uWILdyHnSXSC/5vjbGLyIFhb9K+fAQ7sn5163OumNgx9M ZkAjmI7S7jDWMEch8j0M28tOFECudUanUeUHWr1Q4fCYhc3Lf6QJYPATE1sLi7nqIVoD ZqtziYktc3+CeIQLsJDRoM8P2mpSfPwonVIz1c66eVlH3Gxtc+N4aXNsOWJbxuAbZK1b D7dg== X-Received: by 10.236.156.138 with SMTP id m10mr3142125yhk.26.1378392416986; Thu, 05 Sep 2013 07:46:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.81.210 with SMTP id c18ls225811qey.37.gmail; Thu, 05 Sep 2013 07:46:56 -0700 (PDT) X-Received: by 10.220.173.134 with SMTP id p6mr357918vcz.36.1378392416856; Thu, 05 Sep 2013 07:46:56 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id f8si7305752vec.47.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 07:46:56 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 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.179; Received: by mail-vc0-f179.google.com with SMTP id ht10so1190279vcb.38 for ; Thu, 05 Sep 2013 07:46:56 -0700 (PDT) X-Gm-Message-State: ALoCoQmlAlG7OwgTAmS8R9vKozMOz1lqE3y9zfiEBADzFPok8Ips4d1Q8tFwZrZ5A7vutMMgomxg X-Received: by 10.52.249.102 with SMTP id yt6mr6459500vdc.21.1378392416759; Thu, 05 Sep 2013 07:46:56 -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 u4csp284245vcz; Thu, 5 Sep 2013 07:46:56 -0700 (PDT) X-Received: by 10.68.134.133 with SMTP id pk5mr9679339pbb.89.1378392415863; Thu, 05 Sep 2013 07:46:55 -0700 (PDT) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by mx.google.com with ESMTPS id xx2si24037512pac.140.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 07:46:55 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.48 is neither permitted nor denied by best guess record for domain of anup.patel@linaro.org) client-ip=209.85.220.48; Received: by mail-pa0-f48.google.com with SMTP id kp13so1986243pab.7 for ; Thu, 05 Sep 2013 07:46:55 -0700 (PDT) X-Received: by 10.68.202.201 with SMTP id kk9mr9679632pbc.166.1378392415462; Thu, 05 Sep 2013 07:46:55 -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:54 -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 2/3] ARM64: KVM: Implement target CPU=Host Date: Thu, 5 Sep 2013 20:16:01 +0530 Message-Id: <1378392362-6773-3-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.179 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 ARM64. 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/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/include/uapi/asm/kvm.h | 2 +- arch/arm64/kvm/guest.c | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 0859a4d..9ee431c 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -150,7 +150,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/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h index d9f026b..eeb5726 100644 --- a/arch/arm64/include/uapi/asm/kvm.h +++ b/arch/arm64/include/uapi/asm/kvm.h @@ -56,7 +56,7 @@ struct kvm_regs { #define KVM_ARM_TARGET_FOUNDATION_V8 1 #define KVM_ARM_TARGET_CORTEX_A57 2 #define KVM_ARM_TARGET_XGENE_POTENZA 3 - +#define KVM_ARM_TARGET_HOST 0x0FFFFFFF #define KVM_ARM_NUM_TARGETS 4 /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */ diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index d7bf7d6..261e836 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -230,12 +230,18 @@ 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 (init->target != phys_target) + if (phys_target < 0) { + return phys_target; + } + + if (init->target == KVM_ARM_TARGET_HOST) + init->target = phys_target; + else if (init->target != phys_target) return -EINVAL; vcpu->arch.target = phys_target;