From patchwork Fri Jun 4 15:51:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 454080 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp565054jae; Fri, 4 Jun 2021 09:28:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxhX39lv2Vj60NVmxd90Hk1AayMS2Zr9k5IjnFLPiWHkv92t0eXayKuK5KeZ7PFT9rT/Eo X-Received: by 2002:a1f:eac6:: with SMTP id i189mr3151805vkh.3.1622824108306; Fri, 04 Jun 2021 09:28:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622824108; cv=none; d=google.com; s=arc-20160816; b=KL8VVzkmZgtgGR4MygfoUbHBCjqCqqLcWQc+ufCGRBYM6PW9biNGqk6gq1IF993NWJ thEr0IHkKypAyWlcY8hc5kF70JyXhjS+n0+t8+ZB5R5CCInVRcKOymN6hUkhXjZK954t fHGoBNH+05VWio5txyvX4QA9hXez1cS/mwnAPPFojhkvt80CAm2J1td8I1Q8Eg5DkS9I iqEBwrrCTdV7NDt3P+vV7hU0v/1x370q7LNcB149cDaXXPqA19JyuO1c9LeABojYSKjb EfnvcCdQgw3fJHtSxn+LviP68VEu4cNITDTeewZBMhqUuz5JmH7Zn4uS0AuMEsNDDXRN 1QWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GCSulBcboNnhY3ZaOpOOMESbDYWsZSCOIUDwjeQhgs4=; b=fojJlKQcY+6esmtBPegjrhgd9KAIhvjXP4ScjwZdy6Z6iZUXQQnvU4VWvjkcZJngDU hDQUw/Mgb8qtwJHXe0D10294CaH2T+JOf69+yOxFAJzMG8+0KdfQ8liRd7Dw9xjCKwZC V5fpXPHsAnlAUF5WaSGTxQDQKODaZzEAA/kSjhszNilLe9xR90n5m09HkRBfO5/7NjlR t+ZXSkUBHziHN472OtvOxJOmPEwOUoNrAv5dc2u4SqWwiE6hmWUgICFTYwqMhILWxqOP scm8CTKGK3w/gkqKrdqxBF5DBBCGBqzIT0DTK01Z3CYHstTd8/mcUcrpE/zGuW31ly/R tsmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K+VlibPV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t7si3171323vsh.173.2021.06.04.09.28.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Jun 2021 09:28:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K+VlibPV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCgN-0003uA-It for patch@linaro.org; Fri, 04 Jun 2021 12:28:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCRI-0002x6-4v for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:12:52 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:46009) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpCRC-0003pF-QP for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:12:51 -0400 Received: by mail-wr1-x436.google.com with SMTP id z8so9831954wrp.12 for ; Fri, 04 Jun 2021 09:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GCSulBcboNnhY3ZaOpOOMESbDYWsZSCOIUDwjeQhgs4=; b=K+VlibPVepMujXzNtGQBh8v6ArVzXuqim/LVzd/SGYDgZ3mc7+iMaFoQDQXX3M4gGL aWVwCUi3SkYIRe1Z9lWGra7axoT6/IU6M2sADR8uUOPXeINsSaSvuXx32flCfe5Jsfjx FVF4tX662du1+bT1+ya8eb0NUpvTrqWlVdnIYz5LkLGs5HF9pmkegoV8gq4PwJWZ2QJv UDlvk66hlV5iDUzeCxAk79SNiRU8BUh0WlEsAlAEBdDiKCEQZ2N8kmDYrRaAeOF/SW/H PPJBb0dQH+xIeQ4LbRPz9fhyVdjHIqyDuFrC/VE/VoBtscSUXfJFjBVhUW788lYIhh+W fauw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GCSulBcboNnhY3ZaOpOOMESbDYWsZSCOIUDwjeQhgs4=; b=KxKJaoK6xJM4xWIDSR3Ou4GwQfrPqwM2heNqW057pOp0lfKPrupk8r4Exc+0awIGXX 9xwb01qeJX3rND/W/dlhqxdIX0F9YzjOde3dPs3BNqx65Ea33UzFSPifrtnC9x9f9Zw+ 5ttA4y0lqZiOvR+MrVDI8LQ43f4/HiZxIUN5w248D2oQ6PYKX2qCdr42dFP3pbtekfVt MPxCxVBc8k5kT/o7ylxLSbaKdjkQUpGaouLNGVkKpsAoxuegehSSqbxrPc8i7Q5rp8GS WjcTse+QoCNpAYRh3MYfNC+cHXzntCQ11gXKRWaaWIDopzPyVofSP+NRCrHu4b5RHhpp jHlA== X-Gm-Message-State: AOAM531obpmzttaupgYFs8knokcRfppXnlkzAjET9Jv0Kqd9qMMv7Ias K86xryKP6WF40wTmkWVDzjjDzA== X-Received: by 2002:adf:df02:: with SMTP id y2mr4641178wrl.120.1622823165406; Fri, 04 Jun 2021 09:12:45 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id l8sm9299316wrf.0.2021.06.04.09.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 09:12:42 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1BDFF1FFAE; Fri, 4 Jun 2021 16:53:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v16 24/99] target/arm: split off cpu-sysemu.c Date: Fri, 4 Jun 2021 16:51:57 +0100 Message-Id: <20210604155312.15902-25-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210604155312.15902-1-alex.bennee@linaro.org> References: <20210604155312.15902-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Richard Henderson , qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Claudio Fontana , Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Claudio Fontana move work is needed later on to split things into tcg-specific portions and kvm-specific portions of this Signed-off-by: Claudio Fontana Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/arm/internals.h | 8 ++- target/arm/cpu-sysemu.c | 105 ++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 83 ------------------------------- target/arm/meson.build | 1 + 4 files changed, 113 insertions(+), 84 deletions(-) create mode 100644 target/arm/cpu-sysemu.c -- 2.20.1 diff --git a/target/arm/internals.h b/target/arm/internals.h index 886db56b58..8809334228 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1202,4 +1202,10 @@ static inline uint64_t useronly_maybe_clean_ptr(uint32_t desc, uint64_t ptr) return ptr; } -#endif +#ifndef CONFIG_USER_ONLY +void arm_cpu_set_irq(void *opaque, int irq, int level); +void arm_cpu_kvm_set_irq(void *opaque, int irq, int level); +bool arm_cpu_virtio_is_big_endian(CPUState *cs); +#endif /* !CONFIG_USER_ONLY */ + +#endif /* TARGET_ARM_INTERNALS_H */ diff --git a/target/arm/cpu-sysemu.c b/target/arm/cpu-sysemu.c new file mode 100644 index 0000000000..db1c8cb245 --- /dev/null +++ b/target/arm/cpu-sysemu.c @@ -0,0 +1,105 @@ +/* + * QEMU ARM CPU + * + * Copyright (c) 2012 SUSE LINUX Products GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see + * + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "internals.h" +#include "sysemu/hw_accel.h" +#include "kvm_arm.h" + +void arm_cpu_set_irq(void *opaque, int irq, int level) +{ + ARMCPU *cpu = opaque; + CPUARMState *env = &cpu->env; + CPUState *cs = CPU(cpu); + static const int mask[] = { + [ARM_CPU_IRQ] = CPU_INTERRUPT_HARD, + [ARM_CPU_FIQ] = CPU_INTERRUPT_FIQ, + [ARM_CPU_VIRQ] = CPU_INTERRUPT_VIRQ, + [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ + }; + + if (level) { + env->irq_line_state |= mask[irq]; + } else { + env->irq_line_state &= ~mask[irq]; + } + + switch (irq) { + case ARM_CPU_VIRQ: + assert(arm_feature(env, ARM_FEATURE_EL2)); + arm_cpu_update_virq(cpu); + break; + case ARM_CPU_VFIQ: + assert(arm_feature(env, ARM_FEATURE_EL2)); + arm_cpu_update_vfiq(cpu); + break; + case ARM_CPU_IRQ: + case ARM_CPU_FIQ: + if (level) { + cpu_interrupt(cs, mask[irq]); + } else { + cpu_reset_interrupt(cs, mask[irq]); + } + break; + default: + g_assert_not_reached(); + } +} + +void arm_cpu_kvm_set_irq(void *opaque, int irq, int level) +{ +#ifdef CONFIG_KVM + ARMCPU *cpu = opaque; + CPUARMState *env = &cpu->env; + CPUState *cs = CPU(cpu); + uint32_t linestate_bit; + int irq_id; + + switch (irq) { + case ARM_CPU_IRQ: + irq_id = KVM_ARM_IRQ_CPU_IRQ; + linestate_bit = CPU_INTERRUPT_HARD; + break; + case ARM_CPU_FIQ: + irq_id = KVM_ARM_IRQ_CPU_FIQ; + linestate_bit = CPU_INTERRUPT_FIQ; + break; + default: + g_assert_not_reached(); + } + + if (level) { + env->irq_line_state |= linestate_bit; + } else { + env->irq_line_state &= ~linestate_bit; + } + kvm_arm_set_irq(cs->cpu_index, KVM_ARM_IRQ_TYPE_CPU, irq_id, !!level); +#endif +} + +bool arm_cpu_virtio_is_big_endian(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + + cpu_synchronize_state(cs); + return arm_cpu_data_is_big_endian(env); +} diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ad65b60b04..bd8413c161 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -649,89 +649,6 @@ void arm_cpu_update_vfiq(ARMCPU *cpu) } } -#ifndef CONFIG_USER_ONLY -static void arm_cpu_set_irq(void *opaque, int irq, int level) -{ - ARMCPU *cpu = opaque; - CPUARMState *env = &cpu->env; - CPUState *cs = CPU(cpu); - static const int mask[] = { - [ARM_CPU_IRQ] = CPU_INTERRUPT_HARD, - [ARM_CPU_FIQ] = CPU_INTERRUPT_FIQ, - [ARM_CPU_VIRQ] = CPU_INTERRUPT_VIRQ, - [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ - }; - - if (level) { - env->irq_line_state |= mask[irq]; - } else { - env->irq_line_state &= ~mask[irq]; - } - - switch (irq) { - case ARM_CPU_VIRQ: - assert(arm_feature(env, ARM_FEATURE_EL2)); - arm_cpu_update_virq(cpu); - break; - case ARM_CPU_VFIQ: - assert(arm_feature(env, ARM_FEATURE_EL2)); - arm_cpu_update_vfiq(cpu); - break; - case ARM_CPU_IRQ: - case ARM_CPU_FIQ: - if (level) { - cpu_interrupt(cs, mask[irq]); - } else { - cpu_reset_interrupt(cs, mask[irq]); - } - break; - default: - g_assert_not_reached(); - } -} - -static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level) -{ -#ifdef CONFIG_KVM - ARMCPU *cpu = opaque; - CPUARMState *env = &cpu->env; - CPUState *cs = CPU(cpu); - uint32_t linestate_bit; - int irq_id; - - switch (irq) { - case ARM_CPU_IRQ: - irq_id = KVM_ARM_IRQ_CPU_IRQ; - linestate_bit = CPU_INTERRUPT_HARD; - break; - case ARM_CPU_FIQ: - irq_id = KVM_ARM_IRQ_CPU_FIQ; - linestate_bit = CPU_INTERRUPT_FIQ; - break; - default: - g_assert_not_reached(); - } - - if (level) { - env->irq_line_state |= linestate_bit; - } else { - env->irq_line_state &= ~linestate_bit; - } - kvm_arm_set_irq(cs->cpu_index, KVM_ARM_IRQ_TYPE_CPU, irq_id, !!level); -#endif -} - -static bool arm_cpu_virtio_is_big_endian(CPUState *cs) -{ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - - cpu_synchronize_state(cs); - return arm_cpu_data_is_big_endian(env); -} - -#endif - static int print_insn_thumb1(bfd_vma pc, disassemble_info *info) { diff --git a/target/arm/meson.build b/target/arm/meson.build index a9fdada0cc..b75392e3e9 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -17,6 +17,7 @@ arm_softmmu_ss = ss.source_set() arm_softmmu_ss.add(files( 'arch_dump.c', 'arm-powerctl.c', + 'cpu-sysemu.c', 'machine.c', 'monitor.c', ))