From patchwork Wed May 12 14:08:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bruno Larsen (billionai)" X-Patchwork-Id: 12253865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4704C433B4 for ; Wed, 12 May 2021 14:26:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9069613E9 for ; Wed, 12 May 2021 14:26:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9069613E9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=eldorado.org.br Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgpok-00010K-QI for qemu-devel@archiver.kernel.org; Wed, 12 May 2021 10:26:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgpZ9-00064F-1Z; Wed, 12 May 2021 10:10:23 -0400 Received: from [201.28.113.2] (port=32758 helo=outlook.eldorado.org.br) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgpZ5-0000Pm-3d; Wed, 12 May 2021 10:10:22 -0400 Received: from power9a ([10.10.71.235]) by outlook.eldorado.org.br with Microsoft SMTPSVC(8.5.9600.16384); Wed, 12 May 2021 11:08:39 -0300 Received: from eldorado.org.br (unknown [10.10.71.235]) by power9a (Postfix) with ESMTP id 3CA828000C2; Wed, 12 May 2021 11:08:39 -0300 (-03) From: "Bruno Larsen (billionai)" To: qemu-devel@nongnu.org Subject: [PATCH 07/11] target/ppc: added KVM fallback to fpscr manipulation Date: Wed, 12 May 2021 11:08:09 -0300 Message-Id: <20210512140813.112884-8-bruno.larsen@eldorado.org.br> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210512140813.112884-1-bruno.larsen@eldorado.org.br> References: <20210512140813.112884-1-bruno.larsen@eldorado.org.br> X-OriginalArrivalTime: 12 May 2021 14:08:39.0384 (UTC) FILETIME=[4EA42580:01D74738] X-Host-Lookup-Failed: Reverse DNS lookup failed for 201.28.113.2 (failed) Received-SPF: pass client-ip=201.28.113.2; envelope-from=bruno.larsen@eldorado.org.br; helo=outlook.eldorado.org.br X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: farosas@linux.ibm.com, richard.henderson@linaro.org, luis.pires@eldorado.org.br, lucas.araujo@eldorado.org.br, fernando.valle@eldorado.org.br, qemu-ppc@nongnu.org, "Bruno Larsen \(billionai\)" , matheus.ferst@eldorado.org.br, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" some common code needs to store information in fpscr, but this function relies on TCG cde to work. This patch adds a kvm way to do it, and a transparent way to call it when TCG is not compiled Signed-off-by: Bruno Larsen (billionai) --- target/ppc/gdbstub.c | 1 + target/ppc/kvm.c | 14 ++++++++++++++ target/ppc/kvm_ppc.h | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 17e41fc113..65759e0c1c 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -23,6 +23,7 @@ #include "exec/helper-proto.h" #include "internal.h" #include "helper_regs.h" +#include "kvm_ppc.h" static int ppc_gdb_register_len_apple(int n) { diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 104a308abb..a8a720eb48 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2947,3 +2947,17 @@ bool kvm_arch_cpu_check_are_resettable(void) { return true; } + +void kvmppc_store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask) +{ + CPUState *cs = env_cpu(env); + struct kvm_one_reg reg; + int ret; + reg.id = KVM_REG_PPC_FPSCR; + reg.addr = (uintptr_t) &env->fpscr; + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret < 0) + { + fprintf(stderr, "Unable to set FPSCR to KVM: %s", strerror(errno)); + } +} diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 989f61ace0..ff365e57a6 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -86,6 +86,12 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_t tb_offset); int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run); +#ifndef CONFIG_TCG +# define store_fpscr kvmppc_store_fpscr +#endif +void kvmppc_store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask); + + #else static inline uint32_t kvmppc_get_tbfreq(void)