From patchwork Fri Oct 20 16:36:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 736257 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp400265wrl; Fri, 20 Oct 2023 09:38:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVWnSu1IjJQE2f6DmMe5Wun35j6MOPMKciQKQw/DnIranfsWe+BYofgDEZfwr7drYBchFP X-Received: by 2002:a0d:ea8b:0:b0:5a7:aad1:6567 with SMTP id t133-20020a0dea8b000000b005a7aad16567mr2728444ywe.7.1697819932002; Fri, 20 Oct 2023 09:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697819931; cv=none; d=google.com; s=arc-20160816; b=Y9xdr2dh8Hlhn2gV17o1d0BDmbBV/LEGQV+0/SVDfJroJLryEFieWDiBQdYzVKgXFm M9e0b6j8k1ceZx6haITqPi4jLlhWMRaeQT35CO9bhSVaQb0+PWXuzWVfpn20iIqYElb7 Xss4QCgcxt1WrCB7ThkHqG0opQxnvslKYf+dA1TxJ8roz8XcKWEJNmR5TMsgBEVW8VgB G2DP4BpckEbJRN+LRANIf2zNC+dtjSIz+dbjU/MmDT9hsxB8gz0QpXb6zTN6giJhHIWI 1isB4RB2uLBg0cZeDLjQcepkq+ISsUImsb6iGYOMDMUFE1sDTV0K2uDOwEtImwZ0u0NQ foRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=0QpJSioSzBNTf91irQMN8BpZyzwJ1kd2+nNN3fujF2w=; fh=G7el6kS6mgIkmN4TGMLCfgJ3jrtLeyv2+mgbrNuwVGE=; b=pv6X7uRltXQaQAXNqojN0lPfbhoc9kZFT/XIP4aJCl3Vw3c2x40Ryc3aoUe0iflg4r r9Cc5BF6P4hZUy3oT/WYTTF3Yaqm5FrJk6KLdkFOrmDY+bVq/lm5l7hraCNil62tMCkm 8/AVrEY+xaVIuGVf2Sc08NHb3JzogflNkHg3edl58XOXPnDOcAh/pkN+i+LpGigGAZNV XQQxG5psSU1L9lr9I4ecvBya+YEPtH3BGS2xqaCqRu1Ij3g8CYgO6MLLRWlOZtWT/jGl Dh4bTnf2voR4RYMRXRw3r1k7lVydq1XSKQ0Qo/V9Q/67AfixvgYmO05yvQr+OZWxz2tJ cPKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jD507VLv; 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=pass (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 v21-20020a05622a145500b00417f87ff854si1591626qtx.46.2023.10.20.09.38.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2023 09:38:51 -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=pass header.i=@linaro.org header.s=google header.b=jD507VLv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtsVh-0003mw-0g; Fri, 20 Oct 2023 12:38:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtsVe-0003f3-OH for qemu-devel@nongnu.org; Fri, 20 Oct 2023 12:38:02 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtsVb-0002aJ-Ec for qemu-devel@nongnu.org; Fri, 20 Oct 2023 12:38:02 -0400 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-9ba081173a3so170513466b.1 for ; Fri, 20 Oct 2023 09:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697819877; x=1698424677; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0QpJSioSzBNTf91irQMN8BpZyzwJ1kd2+nNN3fujF2w=; b=jD507VLv1Q3DXpYYv4XOY/iKw6lLXZelPaf6QslcZil7D12UZCuiVO8B5iBcKmcPXA uUgR1ATUBPeS64AbMhWzUvMVfp/PjwlDbY//xeEMixhQmzYJ5ZtNtKnq5e/fkmU3NB0r RWA5F7R7LlBzooUvEPScCz7b87wTNVnYId5aWb3zsuNhpi6GBkn70H4ilk7s0MYVeTBb NgyluahTH9RUMpuC81gJ2pD7XRfQazMl8QV6/nj0bifO/CmodxTa35x9421PvtZK/A65 Y9+O/m90cvcq8tT8r5enqHD3s/4oS8G8VGN13ZJ6sWQ86PJupGKC7nUQGS6XwvS47jrF QVwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697819877; x=1698424677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0QpJSioSzBNTf91irQMN8BpZyzwJ1kd2+nNN3fujF2w=; b=g/s3/WOaTChRaQTjkIyOccNJMqjwqF37KQ00DfjsMZfpZmT8SrR8Kx5WunSnuTvhBg E7+UoD9Ps4/Knp8VQ/AhDO7YnXru7p6148++bpc9k7lZKY7EnBwLjKGRgtLXZ0WGcffo +TMCn00Tnp9+vd1R8H9GGR3WFtTc7c1QMQdkr4Y45xTFiF/xHOso9RGI4JZljf3vms3E KnNsWSNVo8W2a0MHbWe+zjTKgkL9+idBjKl3IlTCoV0j8akga+gyoPHET8EZj59eRjfP bPIuVuRK8DVeqRuwv6FbblDN28lkFOKXxZBnoaf4EwEFaMkMJiGQKQHeTHiSJvIj1Dbp 1OZg== X-Gm-Message-State: AOJu0YwmQywj0lm4dXQLsEI3wRPVHVDoz553geW+4i3w41i/qqyvsAYp AGCi0pUy5wAxq6jeoVqSTEa8sVlerZZSZGTDBS0= X-Received: by 2002:a17:907:988:b0:9c5:2806:72e2 with SMTP id bf8-20020a170907098800b009c5280672e2mr1733573ejc.34.1697819877055; Fri, 20 Oct 2023 09:37:57 -0700 (PDT) Received: from m1x-phil.lan (tbo33-h01-176-171-212-97.dsl.sta.abo.bbox.fr. [176.171.212.97]) by smtp.gmail.com with ESMTPSA id pw17-20020a17090720b100b009bd9ac83a9fsm1771713ejb.152.2023.10.20.09.37.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Oct 2023 09:37:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Richard Henderson , Paolo Bonzini , Alistair Francis , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, "Edgar E. Iglesias" , qemu-ppc@nongnu.org, Eduardo Habkost , "Michael S. Tsirkin" , qemu-s390x@nongnu.org, Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , Zhao Liu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , David Woodhouse , Paul Durrant , Marcel Apfelbaum , Marcelo Tosatti , kvm@vger.kernel.org Subject: [PATCH 09/19] cpus: Filter for target specific CPU (x86) Date: Fri, 20 Oct 2023 18:36:31 +0200 Message-ID: <20231020163643.86105-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231020163643.86105-1-philmd@linaro.org> References: <20231020163643.86105-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=philmd@linaro.org; helo=mail-ej1-x62e.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Enforce qemu_get_cpu() to return X86 CPUs in X86 specific files. Mechanical change using the following coccinelle script: @@ expression index; @@ - qemu_get_cpu(index, NULL) + qemu_get_cpu(index, TYPE_X86_CPU) Signed-off-by: Philippe Mathieu-Daudé --- hw/hyperv/hyperv.c | 2 +- hw/i386/kvm/xen_evtchn.c | 8 ++++---- target/i386/kvm/xen-emu.c | 14 +++++++------- target/i386/monitor.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index a43f29ad8d..cdda93e14d 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -226,7 +226,7 @@ struct HvSintRoute { static CPUState *hyperv_find_vcpu(uint32_t vp_index) { - CPUState *cs = qemu_get_cpu(vp_index, NULL); + CPUState *cs = qemu_get_cpu(vp_index, TYPE_X86_CPU); assert(hyperv_vp_index(cs) == vp_index); return cs; } diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c index de3650ba3b..d75b53934d 100644 --- a/hw/i386/kvm/xen_evtchn.c +++ b/hw/i386/kvm/xen_evtchn.c @@ -542,7 +542,7 @@ static void deassign_kernel_port(evtchn_port_t port) static int assign_kernel_port(uint16_t type, evtchn_port_t port, uint32_t vcpu_id) { - CPUState *cpu = qemu_get_cpu(vcpu_id, NULL); + CPUState *cpu = qemu_get_cpu(vcpu_id, TYPE_X86_CPU); struct kvm_xen_hvm_attr ha; if (!cpu) { @@ -589,7 +589,7 @@ static bool valid_port(evtchn_port_t port) static bool valid_vcpu(uint32_t vcpu) { - return !!qemu_get_cpu(vcpu, NULL); + return !!qemu_get_cpu(vcpu, TYPE_X86_CPU); } static void unbind_backend_ports(XenEvtchnState *s) @@ -917,7 +917,7 @@ static int set_port_pending(XenEvtchnState *s, evtchn_port_t port) if (s->evtchn_in_kernel) { XenEvtchnPort *p = &s->port_table[port]; - CPUState *cpu = qemu_get_cpu(p->vcpu, NULL); + CPUState *cpu = qemu_get_cpu(p->vcpu, TYPE_X86_CPU); struct kvm_irq_routing_xen_evtchn evt; if (!cpu) { @@ -1779,7 +1779,7 @@ int xen_evtchn_translate_pirq_msi(struct kvm_irq_routing_entry *route, return -EINVAL; } - cpu = qemu_get_cpu(s->port_table[port].vcpu, NULL); + cpu = qemu_get_cpu(s->port_table[port].vcpu, TYPE_X86_CPU); if (!cpu) { return -EINVAL; } diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index f289af906c..0a973c0259 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -384,7 +384,7 @@ static void do_set_vcpu_info_gpa(CPUState *cs, run_on_cpu_data data) void *kvm_xen_get_vcpu_info_hva(uint32_t vcpu_id) { - CPUState *cs = qemu_get_cpu(vcpu_id, NULL); + CPUState *cs = qemu_get_cpu(vcpu_id, TYPE_X86_CPU); if (!cs) { return NULL; } @@ -418,7 +418,7 @@ void kvm_xen_maybe_deassert_callback(CPUState *cs) void kvm_xen_set_callback_asserted(void) { - CPUState *cs = qemu_get_cpu(0, NULL); + CPUState *cs = qemu_get_cpu(0, TYPE_X86_CPU); if (cs) { X86_CPU(cs)->env.xen_callback_asserted = true; @@ -427,7 +427,7 @@ void kvm_xen_set_callback_asserted(void) void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id, int type) { - CPUState *cs = qemu_get_cpu(vcpu_id, NULL); + CPUState *cs = qemu_get_cpu(vcpu_id, TYPE_X86_CPU); uint8_t vector; if (!cs) { @@ -491,7 +491,7 @@ static void do_set_vcpu_timer_virq(CPUState *cs, run_on_cpu_data data) int kvm_xen_set_vcpu_virq(uint32_t vcpu_id, uint16_t virq, uint16_t port) { - CPUState *cs = qemu_get_cpu(vcpu_id, NULL); + CPUState *cs = qemu_get_cpu(vcpu_id, TYPE_X86_CPU); if (!cs) { return -ENOENT; @@ -588,7 +588,7 @@ static int xen_set_shared_info(uint64_t gfn) trace_kvm_xen_set_shared_info(gfn); for (i = 0; i < XEN_LEGACY_MAX_VCPUS; i++) { - CPUState *cpu = qemu_get_cpu(i, NULL); + CPUState *cpu = qemu_get_cpu(i, TYPE_X86_CPU); if (cpu) { async_run_on_cpu(cpu, do_set_vcpu_info_default_gpa, RUN_ON_CPU_HOST_ULONG(gpa)); @@ -834,7 +834,7 @@ static int kvm_xen_hcall_evtchn_upcall_vector(struct kvm_xen_exit *exit, return -EINVAL; } - target_cs = qemu_get_cpu(up.vcpu, NULL); + target_cs = qemu_get_cpu(up.vcpu, TYPE_X86_CPU); if (!target_cs) { return -EINVAL; } @@ -1161,7 +1161,7 @@ static bool kvm_xen_hcall_vcpu_op(struct kvm_xen_exit *exit, X86CPU *cpu, { CPUState *cs = CPU(cpu); CPUState *dest = cs->cpu_index == vcpu_id ? cs : qemu_get_cpu(vcpu_id, - NULL); + TYPE_X86_CPU); int err; if (!dest) { diff --git a/target/i386/monitor.c b/target/i386/monitor.c index aca7be61dd..01bfb4e3f1 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -592,7 +592,7 @@ void hmp_mce(Monitor *mon, const QDict *qdict) if (qdict_get_try_bool(qdict, "broadcast", false)) { flags |= MCE_INJECT_BROADCAST; } - cs = qemu_get_cpu(cpu_index, NULL); + cs = qemu_get_cpu(cpu_index, TYPE_X86_CPU); if (cs != NULL) { cpu = X86_CPU(cs); cpu_x86_inject_mce(mon, cpu, bank, status, mcg_status, addr, misc,