From patchwork Tue Apr 11 23:27:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Mackerras X-Patchwork-Id: 9676213 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 73F7F60234 for ; Tue, 11 Apr 2017 23:27:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58F642522B for ; Tue, 11 Apr 2017 23:27:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A37426E91; Tue, 11 Apr 2017 23:27:17 +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 967032522B for ; Tue, 11 Apr 2017 23:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752528AbdDKX1O (ORCPT ); Tue, 11 Apr 2017 19:27:14 -0400 Received: from ozlabs.org ([103.22.144.67]:40333 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbdDKX1N (ORCPT ); Tue, 11 Apr 2017 19:27:13 -0400 Received: by ozlabs.org (Postfix, from userid 1003) id 3w2jrH3ykyz9sNv; Wed, 12 Apr 2017 09:27:11 +1000 (AEST) Date: Wed, 12 Apr 2017 09:27:04 +1000 From: Paul Mackerras To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Subject: [PATCH] KVM: PPC: Book3S PR: Fix build when PR KVM is built in Message-ID: <20170411232704.GB3055@fergus.ozlabs.ibm.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit f8513214ac9d("KVM: PPC: Book3S: Add MMIO emulation for FP and VSX instructions", 2017-02-21) added uses of kvm_cvt_fd() and kvm_cvt_df() in arch/powerpc/kvm/powerpc.c, and therefore added arch/powerpc/kvm/fpu.S to the list of sources to be included in the main KVM module. However, the PR KVM module also uses fpu.S and has it in the list of sources for the PR KVM module. When PR KVM is built in (rather than being compiled as a module), this means we get two copies of fpu.o, leading to errors like this: arch/powerpc/kvm/fpu.o:(.opd+0x0): multiple definition of `fps_fres' arch/powerpc/kvm/fpu.o:(.opd+0x0): first defined here arch/powerpc/kvm/fpu.o: In function `fps_fres': (.text+0x0): multiple definition of `.fps_fres' arch/powerpc/kvm/fpu.o:(.text+0x0): first defined here arch/powerpc/kvm/fpu.o:(.opd+0x18): multiple definition of `fps_frsqrte' arch/powerpc/kvm/fpu.o:(.opd+0x18): first defined here arch/powerpc/kvm/fpu.o: In function `fps_frsqrte': (.text+0x20): multiple definition of `.fps_frsqrte' arch/powerpc/kvm/fpu.o:(.text+0x20): first defined here ... and so on ... To fix the problem, this replaces the calls to kvm_cvt_fd() and kvm_cvt_df() in powerpc.c with inline asm, meaning that we no longer need to include fpu.S in the list of sources for the main KVM module. Signed-off-by: Paul Mackerras --- Note: this commit is against my kvm-ppc-next branch and the referenced commit is only in that branch as of now. arch/powerpc/kvm/Makefile | 1 - arch/powerpc/kvm/powerpc.c | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile index 23dcb18..60115ff 100644 --- a/arch/powerpc/kvm/Makefile +++ b/arch/powerpc/kvm/Makefile @@ -17,7 +17,6 @@ CFLAGS_emulate.o := -I. CFLAGS_emulate_loadstore.o := -I. common-objs-y += powerpc.o emulate_loadstore.o -common-objs-$(CONFIG_PPC_FPU) += fpu.o obj-$(CONFIG_KVM_EXIT_TIMING) += timing.o obj-$(CONFIG_KVM_BOOK3S_HANDLER) += book3s_exports.o diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index ea7d0b7..9f8ef98 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include "timing.h" #include "irq.h" @@ -910,7 +909,8 @@ static inline u64 sp_to_dp(u32 fprs) preempt_disable(); enable_kernel_fp(); - kvm_cvt_fd(&fprs, &fprd); + asm ("lfs%U1%X1 0,%1; stfd%U0%X0 0,%0" : "=m" (fprd) : "m" (fprs) + : "fr0"); preempt_enable(); return fprd; } @@ -921,7 +921,8 @@ static inline u32 dp_to_sp(u64 fprd) preempt_disable(); enable_kernel_fp(); - kvm_cvt_df(&fprd, &fprs); + asm ("lfd%U1%X1 0,%1; stfs%U0%X0 0,%0" : "=m" (fprs) : "m" (fprd) + : "fr0"); preempt_enable(); return fprs; }