From patchwork Mon Aug 10 13:26:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhichao Huang X-Patchwork-Id: 52258 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 0BEA522919 for ; Mon, 10 Aug 2015 13:33:22 +0000 (UTC) Received: by labth1 with SMTP id th1sf61767011lab.2 for ; Mon, 10 Aug 2015 06:33:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=RAicF32u/ElDkC+b8rqQi7e+lQ3mhSB4gfN/S9zrub8=; b=e2xUKyULojDyzRfNcFwJOoZqexmuesiYtnhoRNovvjQW82I8gLCtudiWyDKtCC9KBs Rt+0r/cLUGV/f/KdLCthFx+wTmXyNXdy8kLDTOu5WcwEogk12TJXkmzj8aCZmdqSZAMr lZKUeFdBs8yDOB1bJ9fFtK2MSyw+bfA/zwYKVpBIjBBidZphBKHQrXtG31lMib5Jjt4H r2j4Cm2p3ZbgEHXDK/5FAjNy5D7zYOGB+HzYhXnJemGtqf4+m9O38Ayf9dEDMszntDf9 H6LpOEw6Jq3+k8SSlzeaSPTz7eGly8OYh+qNcRAuIcbuvcTb03CnorSVQm1HUACZssnl nynw== X-Gm-Message-State: ALoCoQneE8vqTIZfIdlLWbCXX7dWGbG9QslNZj9ogmYR6iqwmW+vNOTo7fMNQISHRwvVlbQ8Ux82 X-Received: by 10.112.148.101 with SMTP id tr5mr6360511lbb.13.1439213601001; Mon, 10 Aug 2015 06:33:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.69 with SMTP id l5ls737362lae.73.gmail; Mon, 10 Aug 2015 06:33:20 -0700 (PDT) X-Received: by 10.152.21.71 with SMTP id t7mr19676195lae.118.1439213600728; Mon, 10 Aug 2015 06:33:20 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id vs3si9877222lac.153.2015.08.10.06.33.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:33:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbsx3 with SMTP id sx3so11452323lbb.0 for ; Mon, 10 Aug 2015 06:33:20 -0700 (PDT) X-Received: by 10.112.125.34 with SMTP id mn2mr18286253lbb.76.1439213600575; Mon, 10 Aug 2015 06:33:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1937705lba; Mon, 10 Aug 2015 06:33:19 -0700 (PDT) X-Received: by 10.68.117.11 with SMTP id ka11mr45074702pbb.77.1439213599510; Mon, 10 Aug 2015 06:33:19 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id hk2si3586953pbb.131.2015.08.10.06.33.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:33:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZOnBF-0003F2-Hu; Mon, 10 Aug 2015 13:31:57 +0000 Received: from mail-pd0-f182.google.com ([209.85.192.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZOn7j-00073g-Ou for linux-arm-kernel@lists.infradead.org; Mon, 10 Aug 2015 13:28:26 +0000 Received: by pdrh1 with SMTP id h1so53639217pdr.0 for ; Mon, 10 Aug 2015 06:27:58 -0700 (PDT) X-Received: by 10.70.49.73 with SMTP id s9mr44070899pdn.149.1439213278527; Mon, 10 Aug 2015 06:27:58 -0700 (PDT) Received: from localhost ([199.168.112.128]) by smtp.gmail.com with ESMTPSA id t2sm20026379pdo.81.2015.08.10.06.27.52 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 10 Aug 2015 06:27:57 -0700 (PDT) From: Zhichao Huang To: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, alex.bennee@linaro.org, will.deacon@arm.com Subject: [PATCH v4 09/15] KVM: arm: redefine kvm_cpu_context_t to save the host cp14 states Date: Mon, 10 Aug 2015 21:26:01 +0800 Message-Id: <1439213167-8988-10-git-send-email-zhichao.huang@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1439213167-8988-1-git-send-email-zhichao.huang@linaro.org> References: <1439213167-8988-1-git-send-email-zhichao.huang@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150810_062820_334184_615698A5 X-CRM114-Status: UNSURE ( 9.80 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.192.182 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.182 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: huangzhichao@huawei.com, Zhichao Huang MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhichao.huang@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Redefine kvm_cpu_context_t as a new struct that include the cp14 states, which we used to save the host cp14 states. Signed-off-by: Zhichao Huang --- arch/arm/include/asm/kvm_host.h | 6 +++++- arch/arm/kernel/asm-offsets.c | 4 +++- arch/arm/kvm/interrupts.S | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 63ac005..fc461ac 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -91,7 +91,11 @@ struct kvm_vcpu_fault_info { u32 hyp_pc; /* PC when exception was taken from Hyp mode */ }; -typedef struct vfp_hard_struct kvm_cpu_context_t; +struct kvm_cpu_context { + struct vfp_hard_struct vfp; + u32 cp14[NR_CP14_REGS]; +}; +typedef struct kvm_cpu_context kvm_cpu_context_t; struct kvm_vcpu_arch { struct kvm_regs regs; diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c index 9158de0..cee4254 100644 --- a/arch/arm/kernel/asm-offsets.c +++ b/arch/arm/kernel/asm-offsets.c @@ -175,7 +175,9 @@ int main(void) DEFINE(VCPU_CP14, offsetof(struct kvm_vcpu, arch.cp14)); DEFINE(VCPU_CP15, offsetof(struct kvm_vcpu, arch.cp15)); DEFINE(VCPU_VFP_GUEST, offsetof(struct kvm_vcpu, arch.vfp_guest)); - DEFINE(VCPU_VFP_HOST, offsetof(struct kvm_vcpu, arch.host_cpu_context)); + DEFINE(VCPU_HOST_CONTEXT, offsetof(struct kvm_vcpu, arch.host_cpu_context)); + DEFINE(VCPU_VFP_HOST, offsetof(struct kvm_cpu_context, vfp)); + DEFINE(VCPU_CP14_HOST, offsetof(struct kvm_cpu_context, cp14)); DEFINE(VCPU_REGS, offsetof(struct kvm_vcpu, arch.regs)); DEFINE(VCPU_USR_REGS, offsetof(struct kvm_vcpu, arch.regs.usr_regs)); DEFINE(VCPU_SVC_REGS, offsetof(struct kvm_vcpu, arch.regs.svc_regs)); diff --git a/arch/arm/kvm/interrupts.S b/arch/arm/kvm/interrupts.S index 48333ff..d4ff22e 100644 --- a/arch/arm/kvm/interrupts.S +++ b/arch/arm/kvm/interrupts.S @@ -176,8 +176,9 @@ __kvm_vcpu_return: @ Switch VFP/NEON hardware state to the host's add r7, vcpu, #VCPU_VFP_GUEST store_vfp_state r7 - add r7, vcpu, #VCPU_VFP_HOST + add r7, vcpu, #VCPU_HOST_CONTEXT ldr r7, [r7] + add r7, r7, #VCPU_VFP_HOST restore_vfp_state r7 after_vfp_restore: @@ -484,8 +485,9 @@ switch_to_guest_vfp: set_hcptr vmtrap, (HCPTR_TCP(10) | HCPTR_TCP(11)) @ Switch VFP/NEON hardware state to the guest's - add r7, r0, #VCPU_VFP_HOST + add r7, r0, #VCPU_HOST_CONTEXT ldr r7, [r7] + add r7, r7, #VCPU_VFP_HOST store_vfp_state r7 add r7, r0, #VCPU_VFP_GUEST restore_vfp_state r7