From patchwork Mon Sep 18 16:02:33 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: 724153 Delivered-To: patch@linaro.org Received: by 2002:adf:f0d1:0:b0:31d:da82:a3b4 with SMTP id x17csp1772314wro; Mon, 18 Sep 2023 09:03:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa2xbOOCnCZ0j00+8G29Sm0YKOFZU9ITfPKQxkJtUxqLxm9o8fRLzk2C6zIyS1Am9YmRa4 X-Received: by 2002:a05:6808:a02:b0:3a7:44a1:512c with SMTP id n2-20020a0568080a0200b003a744a1512cmr10944802oij.5.1695053031724; Mon, 18 Sep 2023 09:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695053031; cv=none; d=google.com; s=arc-20160816; b=PH7tRuvpA3o146733/A5TouO/ahxfwtH+0Bxks1lDvQl3cuHgPWVk/Nz0t8DfKpK1m qKXwLet/0Xcy0DeE9a6t1lawDsfq09a5P2G9g0LINSs3R1wtBxm7/yWEWx2Ob99iAVOp Ds4Z63hlP3NbydN3RcVbCnwGoUF0sapqg09n1gsuzD8gOxGUvpvKMRrkHDP/GJilnTPu qVSXuURN2bDswG+wKiDZ4qY1r5qhfCh4GP8QIclsnlz8Dnxca4N2gVP75CInafURgrRE 5GvDIaL+R8ec9O5bcQ1OfnaADGNjLxAm4MhHm5fpsgLaYTH6U0j43FFy1EGOcWmiuGNS qhqw== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=R37K2a/Smepsc2iyIaDJqnazCMcEJOOAaYAXmsK0XT0=; fh=AIYNAcrfQPdTp+tiOBYg2bCy2NfWRbXD73JV9SLWbpM=; b=mT6yQvjuNDc3oMNNL5EIAo4zcEH3ZOWqE3XcoeioBHk++J3RfEZooFPv5OES5sAEm1 sCjw5e4vHwTU4cyu7+40jsY32WRR0J/+3cwZCUWHi1OIl8qlo25W7/LfyWXAA/gEUCbg 6Im3MzzZJxXsOY3QyYGMrMh+T9BypAulsNmhs10TxM5yLVNCkCIXVeDyvsmpZ6TUiirY lWL2wHaQuHTgMMPbQR1X4zUvy+xvbba0fE6/hHeJNzZoA9wI4wT5iaURJ+ChOnO9jzuu LLutR5Ynjd8T7CifZdJN4fQ9qr8kgg9fjFsgH+y/fNeLbiEUr5pkZ+FvNGylIaxlw78N gkfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=INxTo8Ew; 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 o3-20020ac85a43000000b00417b94b364csi1055891qta.571.2023.09.18.09.03.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Sep 2023 09:03: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=INxTo8Ew; 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 1qiGiH-00060W-Hr; Mon, 18 Sep 2023 12:03: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 1qiGiG-0005yx-2H for qemu-devel@nongnu.org; Mon, 18 Sep 2023 12:03:04 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiGiD-0003ta-2o for qemu-devel@nongnu.org; Mon, 18 Sep 2023 12:03:03 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-986d8332f50so638199666b.0 for ; Mon, 18 Sep 2023 09:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695052979; x=1695657779; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=R37K2a/Smepsc2iyIaDJqnazCMcEJOOAaYAXmsK0XT0=; b=INxTo8EwLN4aLX9q3m3G+o7FAqm3qrBb+iJBMhwSHCc8OPPiM5RYZH+mTSxjH/fnTk Y2itOxsL33IxL2ye/rLFJISCZ7o3Rqq2qqpid9l7Jtrg92/U5SVMQccTUEDzWG4HA0BD ywK6Mp4LD+urqc5nAlJYSs5X46iC6my+91jN81mYjxk1hoaerQXH+j/CJrDW3ygkH+oI ht/hkx5B4iSQK5DMnO05hmaYV+QgZ9uJpEHOA3rR4aabzWqKp3cjb31P+AAweGQp4RxK cpZs1HXsSc6Itm1LbLWjK0s2+Te3MtTdi2TLnssBg8hx1fqGdS+aIMgPfv/hKAgP7l+W 0Prw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695052979; x=1695657779; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R37K2a/Smepsc2iyIaDJqnazCMcEJOOAaYAXmsK0XT0=; b=wgIMwmLuSm05QCHNj3fQw8G8LK5hL5AbJur9QXIIPX6V+bF6IyVrw9162WliYV4dSR 0RWJ0Ks6m46e9oE2XV5JfuYZcYYmMatJjgv5kn4IKDsz85nV8q0FADJNNw7j258WIy8u HUwpg0J4oDsttFjFP5Oni2MxXOlAeRfyT8CysfZzOZsq0GJplymcj3D/NGlQd1e2+/YX bfPFEnLY0FlrC3jOq+x/lEp8CE8p3jUSofzILgVlLEn/OPZbG4u9dJuXSS1Nmj4+bex7 jrJnQ6JOy/g/r/MGTDPtO2Tj9Km+ux7LnskXUYW2DOOqKJ9tVJmPv7nz+gEhHCuD53aB iqRg== X-Gm-Message-State: AOJu0YwmQm3aX8Tqcqa17NqOxvDJYeAh29pgXF5ryKoB/LOzShL53bTc So0cgLtLtWc+GvYBbOOh9+aMTDmmLQkcDP+eMOPGtRCX X-Received: by 2002:a17:907:a0c6:b0:9a1:cb2c:b55c with SMTP id hw6-20020a170907a0c600b009a1cb2cb55cmr6526293ejc.35.1695052978973; Mon, 18 Sep 2023 09:02:58 -0700 (PDT) Received: from localhost.localdomain (static-212-193-78-212.thenetworkfactory.nl. [212.78.193.212]) by smtp.gmail.com with ESMTPSA id rl20-20020a1709076c1400b009adc81c0c7esm5428731ejc.107.2023.09.18.09.02.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Sep 2023 09:02:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , Max Filippov , David Hildenbrand , Peter Xu , Anton Johansson , Peter Maydell , kvm@vger.kernel.org, Marek Vasut , David Gibson , Brian Cain , Yoshinori Sato , "Edgar E . Iglesias" , Claudio Fontana , Daniel Henrique Barboza , Artyom Tarasenko , Marcelo Tosatti , qemu-ppc@nongnu.org, Liu Zhiwei , Aurelien Jarno , Ilya Leoshkevich , Daniel Henrique Barboza , Bastian Koppelmann , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , Alistair Francis , Alessandro Di Federico , Song Gao , Marcel Apfelbaum , Chris Wulff , "Michael S. Tsirkin" , Alistair Francis , Fabiano Rosas , qemu-s390x@nongnu.org, Yanan Wang , Luc Michel , Weiwei Li , Bin Meng , Stafford Horne , Xiaojuan Yang , "Daniel P . Berrange" , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Jiaxun Yang , Richard Henderson , Aleksandar Rikalo , Bernhard Beschow , Mark Cave-Ayland , qemu-riscv@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Nicholas Piggin , Greg Kurz , Michael Rolnik , Eduardo Habkost , Markus Armbruster , Palmer Dabbelt Subject: [PATCH 00/22] exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize() Date: Mon, 18 Sep 2023 18:02:33 +0200 Message-ID: <20230918160257.30127-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=philmd@linaro.org; helo=mail-ej1-x632.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 Hi, TL;DR: This series factor duplicated common code in CPUs DeviceRealize() handlers out, moving as a single call in cpu_common_realize(). In an effort to have most of: - CPU core code independant of accelerators - CPU core code target agnostic - CPU target code independant of accelerators - and cpu_reset() called automatically without having to rely on global QEMUResetHandler, I'm working on the core CPU code, unfortunately touching files in all targets. I suppose them term "exec" used in various areas of QEMU started from what we call today "accel[erators]" [*]. So cpu_exec_realizefn() can be read as cpu_accel_realize(), or "generic code where an accelerator realizes its internal fields on an abstract (target independent) CPU". This series moves a common pattern used in all target's cpu_realize() handlers to the common cpu_exec_realizefn(). Some optional code is used to check CPU requested features are compatible with the accelerator possibilities. We extracted this code as CPUClass::verify_accel_features() handler. Better name welcomed :) Some targets were calling cpu_reset() *before* cpu_common_realizefn(), we moved it *after* (since RESET shouldn't happen before REALIZE). I still have to audit each target to confirm there are no side effects. Besides this cpu_reset() change, the rest should be relatively trivial to review, still I'd like feedback from the respective target maintainers for the "move HW creation after vCPU one" patches. Regards, Phil. Follow-up: Make cpu_reset() accel-agnostic and move it to cpu_common_realize() (not trivial due to KVM run_on_cpu() calls). [*] If Paolo/Richard confirm, I might post series renaming various APIs s/exec/accel/, because various headers meaning aren't clear to me. Philippe Mathieu-Daudé (21): target/i386: Only realize existing APIC device hw/intc/apic: Pass CPU using QOM link property target/i386/kvm: Correct comment in kvm_cpu_realize() exec/cpu: Never call cpu_reset() before cpu_realize() exec/cpu: Call qemu_init_vcpu() once in cpu_common_realize() exec/cpu: Call cpu_remove_sync() once in cpu_common_unrealize() exec/cpu: RFC Destroy vCPU address spaces in cpu_common_unrealize() target/arm: Create timers *after* accelerator vCPU is realized target/hppa: Create timer *after* accelerator vCPU is realized target/nios2: Create IRQs *after* accelerator vCPU is realized target/mips: Create clock *after* accelerator vCPU is realized target/xtensa: Create IRQs *after* accelerator vCPU is realized target/sparc: Init CPU environment *after* accelerator vCPU is realized exec/cpu: Introduce CPUClass::verify_accel_features() target/arm: Extract verify_accel_features() from cpu_realize() target/i386: Extract verify_accel_features() from cpu_realize() target/s390x: Call s390_cpu_realize_sysemu from s390_realize_cpu_model target/s390x: Have s390_realize_cpu_model() return a boolean target/s390x: Use s390_realize_cpu_model() as verify_accel_features() exec/cpu: Have cpu_exec_realize() return a boolean exec/cpu: Call cpu_exec_realizefn() once in cpu_common_realize() xianglai li (1): exec/cpu: Introduce the CPU address space destruction function include/exec/cpu-common.h | 8 ++++ include/hw/core/cpu.h | 7 +++- target/s390x/s390x-internal.h | 4 +- cpu.c | 11 ++++- hw/core/cpu-common.c | 15 +++++++ hw/intc/apic_common.c | 2 + softmmu/physmem.c | 24 +++++++++++ target/alpha/cpu.c | 10 ----- target/arm/cpu.c | 53 ++++++++++++------------ target/avr/cpu.c | 10 +---- target/cris/cpu.c | 11 +---- target/hexagon/cpu.c | 11 +---- target/hppa/cpu.c | 20 ++------- target/i386/cpu-sysemu.c | 20 ++++----- target/i386/cpu.c | 77 ++++++++++++++++++----------------- target/i386/kvm/kvm-cpu.c | 3 +- target/loongarch/cpu.c | 11 +---- target/m68k/cpu.c | 11 +---- target/microblaze/cpu.c | 9 ---- target/mips/cpu.c | 27 ++++-------- target/nios2/cpu.c | 20 +++------ target/openrisc/cpu.c | 11 +---- target/ppc/cpu_init.c | 8 ---- target/riscv/cpu.c | 10 +---- target/rx/cpu.c | 11 +---- target/s390x/cpu-sysemu.c | 3 +- target/s390x/cpu.c | 21 +--------- target/s390x/cpu_models.c | 16 +++++--- target/sh4/cpu.c | 11 +---- target/sparc/cpu.c | 10 ----- target/tricore/cpu.c | 10 +---- target/xtensa/cpu.c | 13 +----- 32 files changed, 189 insertions(+), 299 deletions(-)