From patchwork Sat Sep 16 21:41:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1835594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Yo3+1zJb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rp4Mx0gLrz1yhy for ; Sun, 17 Sep 2023 07:44:45 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhd3u-0007TN-69; Sat, 16 Sep 2023 17:42:46 -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 1qhd3D-0005Ey-DS for qemu-devel@nongnu.org; Sat, 16 Sep 2023 17:42:04 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qhd3B-0000Wl-Hi for qemu-devel@nongnu.org; Sat, 16 Sep 2023 17:42:03 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-1d643db2c98so1640346fac.0 for ; Sat, 16 Sep 2023 14:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694900520; x=1695505320; 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=9frgVbpvR/cKhB4Eeaz6aEQy82XBehF08OdWl52rupE=; b=Yo3+1zJb4yxuZE9XIRgHbZuTIgu5F67ksKyYPS4JT8QZjMKSuI06v9vQjjKCXFbht1 yiGOY8D9Ct4kaHOtK+1j6Qr0x4zLbzkRMjqQd0TdqCLL1ktoFOgpqTPbt5QzxaOhe8ni g3unY/McDRCAZ+tlGgTmVJ3NQ3UdXTddbEP4JLTowZYGNCxwC8SK6ttmYCnXtx2W8+nd zZLctXIsd27I8jw7EdxL8zurSfVa+gM7FOlvZh2Dg4c2IwuqnI64lkENlw3O/ATDaYr4 H0rZPFr1nVfcrBpdE6R+RBgpjpEvEDDuD6e2zMZqgytnHOLUrWdEhkoDz3Y9JfNBa68/ A37Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694900520; x=1695505320; 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=9frgVbpvR/cKhB4Eeaz6aEQy82XBehF08OdWl52rupE=; b=A00EiEfXHQJ4L5T5UXlaX8ZEiEVT3hewd8Srh3U45uUFJvfBpxoszj8F1tmI5SKZhy 7pLWstBqPQOpInMc+4ESuyY1rFB98fN4WDPsvZ8RRJO+Cxkw+ZjTJxTfSPNJ6egX1ZzU BxU8yO4y/+/Xla7G+d+z63H2tBU4/YdzR7r6IH+ZEkQpcllwF7XPDFr75e1XtB5i8XxY 8PufjsBT9TckEpbHqjZB/j777zK4fqpoMVs6OO58QYxQiao8SZN3mSMkHvDHQw21ormg pmWst9m8Oul5Cv2iajHdq84dOm8UkmKaYtzaYhzu59JrDa+6/h7JHzrr9Wa+wIiDLLm3 n48A== X-Gm-Message-State: AOJu0YwnA6NmS9WHmf3t+Pw0//nA3Kak+/s07Q+OyXlhEgmLFCLEoJlv nknArHomCX7CHclKn20EoMdcTGZDa2B0w6lJkkc= X-Google-Smtp-Source: AGHT+IHJ4nSrLQNu9jUVJlvLbnLxH+GklS/R7rjqp3RhIPkf6woyNEbUVBvgzU/eEDwxJMQWmtevXQ== X-Received: by 2002:a05:6870:95aa:b0:1ba:d044:8a4 with SMTP id k42-20020a05687095aa00b001bad04408a4mr6774135oao.18.1694900519795; Sat, 16 Sep 2023 14:41:59 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id n21-20020aa79055000000b0068fde95aa93sm4871708pfo.135.2023.09.16.14.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 14:41:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, anjo@rev.ng Subject: [PATCH v3 37/39] accel: Declare AccelClass::[un]realize_cpu() handlers Date: Sat, 16 Sep 2023 14:41:21 -0700 Message-Id: <20230916214123.525796-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230916214123.525796-1-richard.henderson@linaro.org> References: <20230916214123.525796-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Philippe Mathieu-Daudé Currently accel_cpu_realize() only performs target-specific realization. Introduce the [un]realize_cpu fields in the base AccelClass to be able to perform target-agnostic [un]realization of vCPUs. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20230915190009.68404-4-philmd@linaro.org> Signed-off-by: Richard Henderson --- include/qemu/accel.h | 2 ++ accel/accel-target.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/qemu/accel.h b/include/qemu/accel.h index 7b02cb40e5..0b6031bd82 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 (*realize_cpu)(CPUState *cpu, Error **errp); + void (*unrealize_cpu)(CPUState *cpu); /* gdbstub related hooks */ int (*gdbstub_supported_sstep_flags)(void); diff --git a/accel/accel-target.c b/accel/accel-target.c index cc3a45e663..6d427f2b9d 100644 --- a/accel/accel-target.c +++ b/accel/accel-target.c @@ -122,15 +122,32 @@ void accel_cpu_instance_init(CPUState *cpu) bool accel_cpu_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_realizefn) { - return cc->accel_cpu->cpu_realizefn(cpu, errp); + /* target specific realization */ + if (cc->accel_cpu && cc->accel_cpu->cpu_realizefn + && !cc->accel_cpu->cpu_realizefn(cpu, errp)) { + return false; } + + /* generic realization */ + if (acc->realize_cpu && !acc->realize_cpu(cpu, errp)) { + return false; + } + return true; } void accel_cpu_unrealize(CPUState *cpu) { + AccelState *accel = current_accel(); + AccelClass *acc = ACCEL_GET_CLASS(accel); + + /* generic unrealization */ + if (acc->unrealize_cpu) { + acc->unrealize_cpu(cpu); + } } int accel_supported_gdbstub_sstep_flags(void)