From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20B2CC433E0 for ; Fri, 12 Mar 2021 10:40:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD26764FEA for ; Fri, 12 Mar 2021 10:40:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD26764FEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKfDm-0006oT-Og for qemu-devel@archiver.kernel.org; Fri, 12 Mar 2021 05:40:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKfCe-0005Qt-Oc for qemu-devel@nongnu.org; Fri, 12 Mar 2021 05:39:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55661) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKfCc-0000A2-W6 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 05:39:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615545569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b3F6fDzDkdxSC3cr+OoSx0+5nUAwAT3Hf367KG1X8ks=; b=KdpNvM3g9XyeKDZNoGCfVRsBgwfcheIMlfp4I34n7es50rYz6/iqkOGKSlUKN+gai9Ewny P1wqNuG9yKs1+SyQuXSJ81qub/vuYK13k+lXuWcNT1TyphnN6IfoW0eDsEvuib+UK9RsME ZmdefSb+7c2gCFzr15NUyVKHHTWKx/A= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-CmKKKK1jN9ymr58XTm_rcA-1; Fri, 12 Mar 2021 05:39:26 -0500 X-MC-Unique: CmKKKK1jN9ymr58XTm_rcA-1 Received: by mail-wm1-f70.google.com with SMTP id l16so3016954wmc.0 for ; Fri, 12 Mar 2021 02:39:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=b3F6fDzDkdxSC3cr+OoSx0+5nUAwAT3Hf367KG1X8ks=; b=K4q5W46MRrPaUwFM/vkG7AayWm2gTjBv3S+GQ2IxgZt5lUNUXqhs/yOkTuD4tX9Y+o JvPBoYYregyhkhA71PHVMn+GiKvryGfJ3JRRKDFWCmeMV/IOizB4NBVXo7Gd8WUCoAfr o6BibADm2XXY5A97UTgmeFFDRHOl+8Zoqhlj7QH462eyGU6Zaqaq80LNz+RS9O6HKMZg noiEAQhZ01sNIsE27llPpHxDAWGrZZ+YSyUZD9a1z8s6fDqBVwuEnWc9gY+RWo+oKAxF 9QLMqcFkizKB6jVCfgtObWG83g6sHwTyqcdIws82Z+wCoOoempaqxf2PxF1ASKw3PAaG YCBg== X-Gm-Message-State: AOAM5329P0Orp+3cnyFSMDsbtVFE9TtKDqS2jJ0WQeE5eGh3+Leuizyi DlOHZSGUO2cNE98MN4BYmusYp8kgh0YxT39xVtJCLh7IOROKi2fs076QIn9eqRLZndWVzVb93bT DZyO2dlnrcD9D6e1WBl01334o4SZbBb5b3awM+ZzYdKVUB5fl5P+zG9mKlAl4mRjpY6Q= X-Received: by 2002:a1c:2390:: with SMTP id j138mr12257563wmj.72.1615545565429; Fri, 12 Mar 2021 02:39:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxh2Y8Vv3kJl4thONz0B8na5xjgWkKIegas7iXmfALLObp+NcSnx8RVcMl9Dmzwe/0eLZ28RA== X-Received: by 2002:a1c:2390:: with SMTP id j138mr12257539wmj.72.1615545565188; Fri, 12 Mar 2021 02:39:25 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:63a7:c72e:ea0e:6045? ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id u63sm1716017wmg.24.2021.03.12.02.39.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Mar 2021 02:39:24 -0800 (PST) To: Claudio Fontana , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= References: <3b7c6a4e-c191-063c-affa-0e179227a633@suse.de> From: Paolo Bonzini Subject: Re: all class init functions for all types in QEMU are called in select_machine(). Expected? Message-ID: <26c2b88b-4c9e-09a0-a1c0-350a01e9a697@redhat.com> Date: Fri, 12 Mar 2021 11:39:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <3b7c6a4e-c191-063c-affa-0e179227a633@suse.de> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , qemu-devel Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 12/03/21 11:25, Claudio Fontana wrote: > We can register them from there if needed I think,, but where ever we > do it, we still have to point to the one set of ops or the other, > depending on the cpu model that is finally chosen. > > So when we attach the tcg cpu accelerator object to the cpu, we > currently should check which cpu it is, and behave accordingly. > > Maybe this is better? Ie, not set the tcg ops in different places (in > the v7m cpu class init and in the tcg cpu accel init), > > but rather set them just in a single place, when we attach the accel > cpu object, checking which cpu profile it is somehow (TBD), and then > behave accordingly? Take a look at https://wiki.qemu.org/User:Paolo_Bonzini/Machine_init_sequence#Basic_phases. The phases are: - creating backends (PHASE_NO_MACHINE) - creating machine (after which PHASE_MACHINE_CREATED is entered) - creating accelerator (after which PHASE_ACCEL_CREATED is entered) - initializing embedded devices (in machine_run_board_init, after which PHASE_MACHINE_INITIALIZED is entered), including CPUs - creating devices (in qmp_x_exit_preconfig, after which PHASE_MACHINE_READY is entered) And the last is where the guest actually starts. I think that you should have a callback in the accelerator that runs after -cpu is processed and before PHASE_MACHINE_INITIALIZED is entered. So the right place to add it would be machine_run_board_init. Maybe some kind of double dispatch, where the accelerator has an acc->init_cpu(acc, cc) method and the CPU has a cc->init_tcg_ops(cc) method. Then TCG's init_cpu calls into the latter. Paolo