From patchwork Sat Dec 26 21:54:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Smarduch X-Patchwork-Id: 7922531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9975CBEEED for ; Sat, 26 Dec 2015 21:57:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE78920212 for ; Sat, 26 Dec 2015 21:57:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2F43202DD for ; Sat, 26 Dec 2015 21:57:25 +0000 (UTC) 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 1aCwog-00013B-P6; Sat, 26 Dec 2015 21:55:58 +0000 Received: from mailout4.w2.samsung.com ([211.189.100.14] helo=usmailout4.samsung.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aCwoR-0000py-0a for linux-arm-kernel@lists.infradead.org; Sat, 26 Dec 2015 21:55:44 +0000 Received: from uscpsbgm1.samsung.com (u114.gpu85.samsung.co.kr [203.254.195.114]) by usmailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NZZ00CQUJK91T20@usmailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Sat, 26 Dec 2015 16:55:21 -0500 (EST) X-AuditID: cbfec372-f79bc6d000005d24-a5-567f0cc91c0a Received: from ussync4.samsung.com ( [203.254.195.84]) by uscpsbgm1.samsung.com (USCPMTA) with SMTP id 9C.25.23844.9CC0F765; Sat, 26 Dec 2015 16:55:21 -0500 (EST) Received: from sisasmtp.sisa.samsung.com ([105.144.21.116]) by ussync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NZZ00F9TJK9JC50@ussync4.samsung.com>; Sat, 26 Dec 2015 16:55:21 -0500 (EST) Received: from localhost.localdomain (105.160.5.6) by SISAEX02SJ.sisa.samsung.com (105.144.21.116) with Microsoft SMTP Server (TLS) id 14.3.224.2; Sat, 26 Dec 2015 13:55:19 -0800 From: Mario Smarduch To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com Subject: [PATCH v6 1/6] arm/arm64: KVM: Introduce armv7 fp/simd vcpu fields and helpers Date: Sat, 26 Dec 2015 13:54:55 -0800 Message-id: <1451166900-3711-2-git-send-email-m.smarduch@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1451166900-3711-1-git-send-email-m.smarduch@samsung.com> References: <1451166900-3711-1-git-send-email-m.smarduch@samsung.com> MIME-version: 1.0 X-Originating-IP: [105.160.5.6] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFLMWRmVeSWpSXmKPExsVy+t/hEN2TPPVhBqeeyVi8eP2P0WLO1EKL j6eOs1tsenyN1eLvnX9sDqwea+atYfS4c20Pm8f5TWuYPTYvqff4vEkugDWKyyYlNSezLLVI 3y6BK6Nh5X3Wgp1SFScvL2BqYOwT62Lk4JAQMJHo+xbSxcgJZIpJXLi3nq2LkYtDSGAJo8TK lQsZIZwWJonV8z8zQzjbGCW+zfvLBNLCJqArsf/eRnYQW0QgVGLK8tdgcWaBDInZT/+BxYUF IiU+TdrNCmKzCKhKnJi5DCzOK+AqsWrKHyaI1XISJ49NBqvhFHCTuL3kCTOILQRUs3baEWaI ekGJH5PvsYBczSwgIfH8sxJEiarEtpvPGSHGyEts2d7GPoFRaBaSjlkIHQsYmVYxipYWJxcU J6XnGuoVJ+YWl+al6yXn525ihIR40Q7GZxusDjEKcDAq8fC+eFEbJsSaWFZcmXuIUYKDWUmE t/JqXZgQb0piZVVqUX58UWlOavEhRmkOFiVx3lRWn1AhgfTEktTs1NSC1CKYLBMHp1QD497A tO66azvTrpje7jXJvm7mc0X4RmNDxuvtCrX/vBbkqm+UUzyobij1qrbc2+lQaeVPsYdNWpUX /Cb9mdAsdemIrEFCiNIxw83mXI/ZSm6437a73eitMb+v3Nn/VvWfCdy3Lz/Pf73bpcVR8du/ WYVftptN6IycaC+z3EU3Nqa7I8vjs89eJZbijERDLeai4kQACJr8iG0CAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151226_135543_304616_C5C7E5BF X-CRM114-Status: GOOD ( 12.55 ) X-Spam-Score: -6.9 (------) 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: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Mario Smarduch Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add helper functions to enable access to fp/smid on guest entry and save host fpexc on vcpu put, check if fp/simd registers are dirty and add new vcpu fields. Signed-off-by: Mario Smarduch --- arch/arm/include/asm/kvm_emulate.h | 42 ++++++++++++++++++++++++++++++++++++ arch/arm/include/asm/kvm_host.h | 6 ++++++ arch/arm64/include/asm/kvm_emulate.h | 8 +++++++ 3 files changed, 56 insertions(+) diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h index 3095df0..d4d9da1 100644 --- a/arch/arm/include/asm/kvm_emulate.h +++ b/arch/arm/include/asm/kvm_emulate.h @@ -24,6 +24,8 @@ #include #include #include +#include +#include "../vfp/vfpinstr.h" unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num); unsigned long *vcpu_spsr(struct kvm_vcpu *vcpu); @@ -255,4 +257,44 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, } } +#ifdef CONFIG_VFPv3 +/* Called from vcpu_load - save fpexc and enable guest access to fp/simd unit */ +static inline void vcpu_trap_vfp_enable(struct kvm_vcpu *vcpu) +{ + u32 fpexc; + + /* Save host fpexc, and enable guest access to fp unit */ + fpexc = fmrx(FPEXC); + vcpu->arch.host_fpexc = fpexc; + fpexc |= FPEXC_EN; + fmxr(FPEXC, fpexc); + + /* Configure HCPTR to trap on tracing and fp/simd access */ + vcpu->arch.hcptr = HCPTR_TTA | HCPTR_TCP(10) | HCPTR_TCP(11); +} + +/* Called from vcpu_put - restore host fpexc */ +static inline void vcpu_restore_host_fpexc(struct kvm_vcpu *vcpu) +{ + fmxr(FPEXC, vcpu->arch.host_fpexc); +} + +/* If trap bits are reset then fp/simd registers are dirty */ +static inline bool vcpu_vfp_isdirty(struct kvm_vcpu *vcpu) +{ + return !(vcpu->arch.hcptr & (HCPTR_TCP(10) | HCPTR_TCP(11))); +} +#else +static inline void vcpu_trap_vfp_enable(struct kvm_vcpu *vcpu) +{ + vcpu->arch.hcptr = HCPTR_TTA; +} + +static inline void vcpu_restore_host_fpexc(struct kvm_vcpu *vcpu) {} +static inline bool vcpu_vfp_isdirty(struct kvm_vcpu *vcpu) +{ + return false; +} +#endif + #endif /* __ARM_KVM_EMULATE_H__ */ diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index f9f2779..d3ef58a 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -105,6 +105,12 @@ struct kvm_vcpu_arch { /* HYP trapping configuration */ u32 hcr; + /* HYP Co-processor fp/simd and trace trapping configuration */ + u32 hcptr; + + /* Save host FPEXC register to later restore on vcpu put */ + u32 host_fpexc; + /* Interrupt related fields */ u32 irq_lines; /* IRQ and FIQ levels */ diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index 3066328..ffe8ccf 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -299,4 +299,12 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, return data; /* Leave LE untouched */ } +static inline void vcpu_trap_vfp_enable(struct kvm_vcpu *vcpu) {} +static inline void vcpu_restore_host_fpexc(struct kvm_vcpu *vcpu) {} + +static inline bool vcpu_vfp_isdirty(struct kvm_vcpu *vcpu) +{ + return false; +} + #endif /* __ARM64_KVM_EMULATE_H__ */