From patchwork Mon Mar 20 10:10:27 2023 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: 665187 Delivered-To: patch@linaro.org Received: by 2002:a5d:5602:0:0:0:0:0 with SMTP id l2csp1036895wrv; Mon, 20 Mar 2023 03:12:10 -0700 (PDT) X-Google-Smtp-Source: AK7set/3ym6Al9sIb7meFJQjEUS7ZLczyS6AhO82UCvAm8sdYvcYwDeNGdAkJoA0pYYo06a3vRjm X-Received: by 2002:ac8:5793:0:b0:3e3:5ac8:c17f with SMTP id v19-20020ac85793000000b003e35ac8c17fmr842360qta.4.1679307130588; Mon, 20 Mar 2023 03:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679307130; cv=none; d=google.com; s=arc-20160816; b=tX66gzb0W/suSbe0uwplo5XCZMEK4NmtP0EbcaDQtPQN8CGQPtySDvYBTQZkaExKh6 oEF2DIrcSredzHdXV6QvPKlKzk/yxTS0IU37NeQSh3jK0Hw/Dse0x8jLCKAvxuWQbeu0 gYP6elzQc5SLcl6+iPfbNy0Wg8+qHMktDElJCtOH2Af5svIz4aTc+7dyJeiKILi1KIsx vcANHN28fBjI31lw+xsI3r+NB9udjy5Vdf00b6EUzM2jkQLJsRh1e/6eWeI+wLt1ONDy guXReMS7o1vDf5QDD+VNq9rmcefgCYhyCE/XJhBMqJLXT01eMSnTnBYp3OE3ml8R5UJT HITw== 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=lkGhHF/Bbg/xrVEDUpY4Rq5VsWgFg/qhGJTCVRi4OCI=; b=bmg9tE1dlR+TLqxUnX3D5kfxr1RYWHbVPh2ndfu4FJxam6d779a+m5HNvScv+WbIAs svABMM0JNLed0Pr0V3CWiThtvuyjB2HBGY3f8ZAAVHVyYzE5ta1MQfWYnxVOLbMaqmyK musgmgi7XeMcTE4lWI2iQ1YC79KNnb9fElDM/2jZE6GzN9R1Rut+x//YBQMSfohn3EHq smtuz40uH7fswTDSIXiW+Wpy/2PXEmxwzvw6ZNs1P6W3Aq4IhdTUYGYhBMxV9pjEbzjF Xrj9634iV1C4aft3jamH/2XHx+OH8RdahbBo/VXmgM05yLWaXAvBFeVuzjIfvc8H/bDv sRuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B/qIpmA+"; 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 br32-20020a05620a462000b007460166a3f7si1660789qkb.380.2023.03.20.03.12.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Mar 2023 03:12:10 -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="B/qIpmA+"; 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 1peCTb-0003mT-GB; Mon, 20 Mar 2023 06:10:51 -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 1peCTR-0003ke-94 for qemu-devel@nongnu.org; Mon, 20 Mar 2023 06:10:42 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1peCTP-0000CO-94 for qemu-devel@nongnu.org; Mon, 20 Mar 2023 06:10:41 -0400 Received: by mail-wr1-x42d.google.com with SMTP id y14so9756927wrq.4 for ; Mon, 20 Mar 2023 03:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679307037; 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=lkGhHF/Bbg/xrVEDUpY4Rq5VsWgFg/qhGJTCVRi4OCI=; b=B/qIpmA+PwpepOvsnR7yA/h9x7ITqpE2H8ciuXD6XjIoWk2PHhlZU/72Y7cr/UzN43 Xtg9SRiKnMZ38REdxOd181X9Yx1ehkiHqoqzzaba9ZRZsjyijzvslwd7wJQkqMeYJAom D2UX/h8V5/Nss/MZFL6dLD8uIYaG+hS9ZPGPwrfxd7Ikqibasn5df/h0SXlFlKe14/Xa ETLDlY1UGxRbE3D8EHtjlkPivfV/FJbFX9vZ8qsvw0Y1lgqQGXdAUwBfDkQXAVN092pz GkBHPdKaIiEJJXuQOT96VHFf0xHbrldejHdcYSuX9qlNnbomkRLqSYV+rrmxDuGnvsIg qwhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679307037; 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=lkGhHF/Bbg/xrVEDUpY4Rq5VsWgFg/qhGJTCVRi4OCI=; b=5c3b8hmp1F1rXPe7+pO89gkDVj2KpVMlLuQevPVooBcF8odmPlfAF+vuQXneMJMFuF 9/Fyv81PdKOickIBrcgbV3qoCRYmHUa0OPOGTlQhbMST7kiKY7uayCADEW8JJuf5lZOF tOTMgEx4bKhh9vNylir6NgPh2q+Ba8z8PKFIRf2G12fq0wnqI+aKkcGD/a7hfXWfbpgC 7PZ42+X2PCDRfJPu+YgecsR2b0gvBjMNYeSIORADZmHt2wwWbDjcY6mmVrhnpfwcv1p/ d9Aa7uId9dqlaZlr6fL/+UUYj1/oyOnpAddGgAx7LhGYr8DsibRdGUfL6Ok/VEVAMUQU C3HQ== X-Gm-Message-State: AO0yUKWd7nd2c34C/LT2xBaJI+MRq7X2AaW2SP4+INvxp0Datnr9cxF2 PZJVMfKe1Pwttkje1eSq1gjCIbODmya5MTsF/iA= X-Received: by 2002:a5d:4090:0:b0:2cf:aa6e:3ade with SMTP id o16-20020a5d4090000000b002cfaa6e3ademr13175365wrp.15.1679307037009; Mon, 20 Mar 2023 03:10:37 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id b9-20020a05600010c900b002c7163660a9sm8495893wrx.105.2023.03.20.03.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 03:10:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0BB361FFBA; Mon, 20 Mar 2023 10:10:36 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: Alessandro Di Federico , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-devel@nongnu.org Cc: Richard Henderson , Paolo Bonzini , Eduardo Habkost , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 02/10] accel/tcg: move cpu_reloading_memory_map into cpu-exec-softmmu Date: Mon, 20 Mar 2023 10:10:27 +0000 Message-Id: <20230320101035.2214196-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230320101035.2214196-1-alex.bennee@linaro.org> References: <20230320101035.2214196-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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.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 This doesn't save much as cpu-exec-common still needs to be built per-target for its knowledge of CPUState but this helps with keeping things organised. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Alessandro Di Federico --- accel/tcg/cpu-exec-common.c | 30 ---------------------- accel/tcg/cpu-exec-softmmu.c | 50 ++++++++++++++++++++++++++++++++++++ accel/tcg/meson.build | 10 ++++++++ 3 files changed, 60 insertions(+), 30 deletions(-) create mode 100644 accel/tcg/cpu-exec-softmmu.c diff --git a/accel/tcg/cpu-exec-common.c b/accel/tcg/cpu-exec-common.c index e7962c9348..c6b0ad303e 100644 --- a/accel/tcg/cpu-exec-common.c +++ b/accel/tcg/cpu-exec-common.c @@ -32,36 +32,6 @@ void cpu_loop_exit_noexc(CPUState *cpu) cpu_loop_exit(cpu); } -#if defined(CONFIG_SOFTMMU) -void cpu_reloading_memory_map(void) -{ - if (qemu_in_vcpu_thread() && current_cpu->running) { - /* The guest can in theory prolong the RCU critical section as long - * as it feels like. The major problem with this is that because it - * can do multiple reconfigurations of the memory map within the - * critical section, we could potentially accumulate an unbounded - * collection of memory data structures awaiting reclamation. - * - * Because the only thing we're currently protecting with RCU is the - * memory data structures, it's sufficient to break the critical section - * in this callback, which we know will get called every time the - * memory map is rearranged. - * - * (If we add anything else in the system that uses RCU to protect - * its data structures, we will need to implement some other mechanism - * to force TCG CPUs to exit the critical section, at which point this - * part of this callback might become unnecessary.) - * - * This pair matches cpu_exec's rcu_read_lock()/rcu_read_unlock(), which - * only protects cpu->as->dispatch. Since we know our caller is about - * to reload it, it's safe to split the critical section. - */ - rcu_read_unlock(); - rcu_read_lock(); - } -} -#endif - void cpu_loop_exit(CPUState *cpu) { /* Undo the setting in cpu_tb_exec. */ diff --git a/accel/tcg/cpu-exec-softmmu.c b/accel/tcg/cpu-exec-softmmu.c new file mode 100644 index 0000000000..2318dd8c7d --- /dev/null +++ b/accel/tcg/cpu-exec-softmmu.c @@ -0,0 +1,50 @@ +/* + * Emulator main CPU execution loop, softmmu bits + * + * Copyright (c) 2003-2005 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "hw/core/cpu.h" +#include "sysemu/cpus.h" + +void cpu_reloading_memory_map(void) +{ + if (qemu_in_vcpu_thread() && current_cpu->running) { + /* The guest can in theory prolong the RCU critical section as long + * as it feels like. The major problem with this is that because it + * can do multiple reconfigurations of the memory map within the + * critical section, we could potentially accumulate an unbounded + * collection of memory data structures awaiting reclamation. + * + * Because the only thing we're currently protecting with RCU is the + * memory data structures, it's sufficient to break the critical section + * in this callback, which we know will get called every time the + * memory map is rearranged. + * + * (If we add anything else in the system that uses RCU to protect + * its data structures, we will need to implement some other mechanism + * to force TCG CPUs to exit the critical section, at which point this + * part of this callback might become unnecessary.) + * + * This pair matches cpu_exec's rcu_read_lock()/rcu_read_unlock(), which + * only protects cpu->as->dispatch. Since we know our caller is about + * to reload it, it's safe to split the critical section. + */ + rcu_read_unlock(); + rcu_read_lock(); + } +} diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build index aeb20a6ef0..bdc086b90d 100644 --- a/accel/tcg/meson.build +++ b/accel/tcg/meson.build @@ -1,3 +1,9 @@ +# +# Currently most things here end up in specific_ss eventually because +# they need knowledge of CPUState. Stuff that that doesn't can live in +# common user, softmmu or overall code +# + tcg_ss = ss.source_set() tcg_ss.add(files( 'tcg-all.c', @@ -9,6 +15,7 @@ tcg_ss.add(files( 'translate-all.c', 'translator.c', )) + tcg_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-exec.c')) tcg_ss.add(when: 'CONFIG_SOFTMMU', if_false: files('user-exec-stub.c')) tcg_ss.add(when: 'CONFIG_PLUGIN', if_true: [files('plugin-gen.c')]) @@ -27,3 +34,6 @@ tcg_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files( 'tcg-accel-ops-icount.c', 'tcg-accel-ops-rr.c', )) + +# Common softmmu code +softmmu_ss.add(files('cpu-exec-softmmu.c'))