From patchwork Tue Oct 3 17:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 728783 Delivered-To: patch@linaro.org Received: by 2002:a5d:60c8:0:b0:31d:da82:a3b4 with SMTP id x8csp2264355wrt; Tue, 3 Oct 2023 10:42:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvA1aM+JqLdRnLZe7ZeTXZqz68jxP6F5HmVQstgFgcdlWvCPralWNufRrxaJgc5WwnX3sL X-Received: by 2002:a0c:e7d1:0:b0:63f:bf70:6796 with SMTP id c17-20020a0ce7d1000000b0063fbf706796mr40050qvo.58.1696354955635; Tue, 03 Oct 2023 10:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696354955; cv=none; d=google.com; s=arc-20160816; b=LCbzZOI2kyOiTrhHUme85YZx19T7QmykHYKxihvm2dYwmYvfa9tbcATRWQr9oktKv6 Afxj5nssIuBgeq8F1e2weH9gLTZxghymy7mmIGet18cS8dm4wZqt0q76P212t60Zk3QI mT8IxOI0KbPcySLAq9UEvoGVu6Kz9bIZ0ZlAFZ17bBF2lDUOm8NNfo5W6ZC1XJkPHuwy SdNIPdYZN03u1bLWy5WB3GbPX2rkjkwkJzLxOuC4V66RE4YWri92lkbaL6srFhYTAEBX fdwx2LP55Tt9AOJbINm4XNe8gsNKCp7QL/PcOW7qfn4kToR/kyWwsk44oF93RpnPsFLR 6SSQ== 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=gUAwLRvxIzeEWVzqxsRkBR/uxMwVWvXQ9DoS+Fr60wM=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=UBhqVrGzmor0AcTtbdeCkb0yfzn7jDCzSI3YOlbD+sQYG28w2K6GfnEK4kJdhTVPB9 Udm+CkUchK754lBDmN9snS9mjLDZ8qN1aqzFzjHdIAfbBONyTQWgMqiHpJxVy0ZaPmS0 oRXmkPDfeLIFpS7SaOqnIEszwTRrc9lKoV5UcWh9YuluwxkJ9QTU/4HlTzNsfnkXfL9M sK9387uGWGggqpGVcwaSzLVQtyp9p2TKwpRYEO8yzy/hCOHtnIL8poD8M4+AeG7mmGea jabXj758Emk2x+ATwgKg5oROLeInHG3myrp9F2oCuvWnWoL785oV8wFuUj1yhTYKLLwT hCyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e21IVnMg; 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 f21-20020a0caa95000000b0065b1160dbb6si703989qvb.440.2023.10.03.10.42.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Oct 2023 10:42:35 -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=e21IVnMg; 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 1qnjF5-0008Su-9E; Tue, 03 Oct 2023 13:31:31 -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 1qnjEe-0008FS-DG for qemu-devel@nongnu.org; Tue, 03 Oct 2023 13:31:07 -0400 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnjEa-0007Rn-UY for qemu-devel@nongnu.org; Tue, 03 Oct 2023 13:31:02 -0400 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-57bc2c2f13dso669465eaf.2 for ; Tue, 03 Oct 2023 10:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696354260; x=1696959060; 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=gUAwLRvxIzeEWVzqxsRkBR/uxMwVWvXQ9DoS+Fr60wM=; b=e21IVnMg0okc4PSxMzV/oQikpKtwsCaw6sFGtgfRmIKXzJI6XQVeg07WYf6rTjdJGS kiM3s4V+2lHymiq0H5ftVojbWwAx2TzZLsdkT4VW0yBu6jAhvAliZGCwIqMNGrzdeO/z hV5TxmpG+MO94uU+J1VNCWwRwNFPit1rTDBYcM1fzxH/E+2QYs+b8NqHmztgc3gr1oJT 2hZ+hzSbDLtjEc4Yj6NDu1nAEV+gk6Ljsap5KyyJZnNE0kYOLYMnZHQ8jzzKhUUCQGbJ Mohh4QsXfFBT+ZteBuKjCxQyBorXRH3FRpzZTANwsgDfWRz15Njz+ZZP7PSmeyEz+xqK KIqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696354260; x=1696959060; 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=gUAwLRvxIzeEWVzqxsRkBR/uxMwVWvXQ9DoS+Fr60wM=; b=lUlTx8dOVXn4za51cI9UAfEngr3qcN/NlJSYsLER/qCeMe+oWHfLun6hX8uCdwp6Qm ioYrmJkm5/p6r3Vbzs/o/0dF4YoJXcSmz3G0mQnhNIDGzCPFu0N32Uyzfh9TbP9gvQ2Z tx2P+lmhkVdPJRLyKs75x2vTPCetDcWhNCCCdVIkSDLqv8MYr8cC0BlmZYUQU+fF6iMF Vfl6XxyVYCFt8PT3R/JLUHE7FDC78Uc10/Ns4mjWNTZVOpG0xpRuZzrLkgU4IIXgZ/4z LKDRxAgoWAQCbdXVqrTSAtMBHaG/Gj4OW8iQuPo6i9zTei/YT5RQ6QXnLA08ZXRTOJNS LqNg== X-Gm-Message-State: AOJu0YwYncHTaq6wC+2ELlTHsBUwRIQPyo94nmys+dBnblZWe6cJgZR9 MOqKfv5pm0mQYrP31146RQbPOIKBSntqY7ATx/Q= X-Received: by 2002:a05:6358:419c:b0:141:ca1:cc62 with SMTP id w28-20020a056358419c00b001410ca1cc62mr99572rwc.27.1696354259720; Tue, 03 Oct 2023 10:30:59 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id n7-20020aa78a47000000b00692c5b1a731sm1620195pfa.186.2023.10.03.10.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 10:30:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 05/47] accel: Declare AccelClass::cpu_common_[un]realize() handlers Date: Tue, 3 Oct 2023 10:30:10 -0700 Message-Id: <20231003173052.1601813-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003173052.1601813-1-richard.henderson@linaro.org> References: <20231003173052.1601813-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2d; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2d.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 From: Philippe Mathieu-Daudé Currently accel_cpu_realize() only performs target-specific realization. Introduce the cpu_common_[un]realize fields in the base AccelClass to be able to perform target-agnostic [un]realization of vCPUs. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231003123026.99229-6-philmd@linaro.org> Signed-off-by: Richard Henderson --- include/qemu/accel.h | 2 ++ accel/accel-common.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/qemu/accel.h b/include/qemu/accel.h index 446153b145..972a849a2b 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -43,6 +43,8 @@ typedef struct AccelClass { bool (*has_memory)(MachineState *ms, AddressSpace *as, hwaddr start_addr, hwaddr size); #endif + bool (*cpu_common_realize)(CPUState *cpu, Error **errp); + void (*cpu_common_unrealize)(CPUState *cpu); /* gdbstub related hooks */ int (*gdbstub_supported_sstep_flags)(void); diff --git a/accel/accel-common.c b/accel/accel-common.c index e9548eac29..11d74b4ad7 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -122,15 +122,32 @@ void accel_cpu_instance_init(CPUState *cpu) bool accel_cpu_common_realize(CPUState *cpu, Error **errp) { CPUClass *cc = CPU_GET_CLASS(cpu); + AccelState *accel = current_accel(); + AccelClass *acc = ACCEL_GET_CLASS(accel); - if (cc->accel_cpu && cc->accel_cpu->cpu_target_realize) { - return cc->accel_cpu->cpu_target_realize(cpu, errp); + /* target specific realization */ + if (cc->accel_cpu && cc->accel_cpu->cpu_target_realize + && !cc->accel_cpu->cpu_target_realize(cpu, errp)) { + return false; } + + /* generic realization */ + if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) { + return false; + } + return true; } void accel_cpu_common_unrealize(CPUState *cpu) { + AccelState *accel = current_accel(); + AccelClass *acc = ACCEL_GET_CLASS(accel); + + /* generic unrealization */ + if (acc->cpu_common_unrealize) { + acc->cpu_common_unrealize(cpu); + } } int accel_supported_gdbstub_sstep_flags(void)