From patchwork Mon Sep 19 23:17:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12981126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A216C6FA8E for ; Mon, 19 Sep 2022 23:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbiISXTV (ORCPT ); Mon, 19 Sep 2022 19:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbiISXSl (ORCPT ); Mon, 19 Sep 2022 19:18:41 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02DB24DF17 for ; Mon, 19 Sep 2022 16:18:24 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id 29so1405362edv.2 for ; Mon, 19 Sep 2022 16:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Fjo518UYX1pucjz3VPXRbua9nNVIHRhAk9ua0pzX1XA=; b=lbugUhiXpcHvVHxmNQCd7XhVHqDDxchx16Djox3J75B7ePDdncyCGse6eZA2NqPqFh hr1ilTebkO5lbr+2+TZ5mEGLS4PtyKRFbfCqqAv12AEVAMkQWO0zrazSj3q2ZqeRKBT/ NbDJbiJXOnw+DznNgyjbvAx0+B4DavYnJ8efSi50qdYGRhMcVApJ9LYs+43cIJnPnFH9 p7WTSOkQVMZ/TBIgKfij+g6XFoQIUWCHughrTftkcd/1hY2CNeeMm/CAqplFQVur0kCT P6Vi6hDAGyycMZR5ghfx4ycMPoY3eP4zAl+AtKcz4IBZGYhSpX7tdpCvm4nrUNQHxaPV fQVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Fjo518UYX1pucjz3VPXRbua9nNVIHRhAk9ua0pzX1XA=; b=LIMCYERPkBiwYqvBIwRHkGEcxfWNk2EMcyB1/y680w7tjClS8tHXFb7rMlnPx6fc52 Ue2v1KVv2gNv843mOIGenXeJ1nL6whbOixRTaaQ2ne0gTbZhaGtahSCIV7lSpUxXRsMW 9bvQ4ujpXJtGeokAbd9PYqix3wddkp1g4pWOAxLf2jjF86pErkkZKPICy35LCDFr6dpn 9Yr+uVK3api/50TfHMala1NMZLwu8hL0tb+JZNkpChbksVlUqbf8iJcz3Av102W+NcCu CYTsjOz7Vpm6gIGef0P+yFfZ11zKXhuiJAoxU5ifvt7WcrS1J8CA8f8rBC54cDrvWUzt SQoA== X-Gm-Message-State: ACrzQf0Z+OxR0asNLvRcI/HYl32wUHPc9zPk3pbAKYIKmmTbKUDElwk7 ixCWgRx5KK1gY7DzclfRuHc= X-Google-Smtp-Source: AMsMyM59+Un1+bbndkQl90bc+w6Ku/wLNzkfWCb5H+mf7flr0JF2IyQRo4Sr55rK2P8tkNt3yzBwMA== X-Received: by 2002:a50:fc9a:0:b0:454:6a56:7d27 with SMTP id f26-20020a50fc9a000000b004546a567d27mr470765edq.73.1663629502405; Mon, 19 Sep 2022 16:18:22 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-054-077-055.78.54.pool.telefonica.de. [78.54.77.55]) by smtp.gmail.com with ESMTPSA id rn24-20020a170906d93800b00780f6071b5dsm4800926ejb.188.2022.09.19.16.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:18:22 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Christian Borntraeger , =?utf-8?q?C=C3=A9dric_Le?= =?utf-8?q?_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Her?= =?utf-8?q?v=C3=A9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne , Bernhard Beschow Subject: [PATCH 1/9] hw/riscv/sifive_e: Fix inheritance of SiFiveEState Date: Tue, 20 Sep 2022 01:17:12 +0200 Message-Id: <20220919231720.163121-2-shentey@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919231720.163121-1-shentey@gmail.com> References: <20220919231720.163121-1-shentey@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org SiFiveEState inherits from SysBusDevice while it's TypeInfo claims it to inherit from TYPE_MACHINE. This is an inconsistency which can cause undefined behavior such as memory corruption. Change SiFiveEState to inherit from MachineState since it is registered as a machine. Signed-off-by: Bernhard Beschow Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé --- include/hw/riscv/sifive_e.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h index 83604da805..d738745925 100644 --- a/include/hw/riscv/sifive_e.h +++ b/include/hw/riscv/sifive_e.h @@ -22,6 +22,7 @@ #include "hw/riscv/riscv_hart.h" #include "hw/riscv/sifive_cpu.h" #include "hw/gpio/sifive_gpio.h" +#include "hw/boards.h" #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc" #define RISCV_E_SOC(obj) \ @@ -41,7 +42,7 @@ typedef struct SiFiveESoCState { typedef struct SiFiveEState { /*< private >*/ - SysBusDevice parent_obj; + MachineState parent_obj; /*< public >*/ SiFiveESoCState soc; From patchwork Mon Sep 19 23:17:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12981127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F18BC6FA8B for ; Mon, 19 Sep 2022 23:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbiISXTY (ORCPT ); Mon, 19 Sep 2022 19:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbiISXSo (ORCPT ); Mon, 19 Sep 2022 19:18:44 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C7324F6BF for ; Mon, 19 Sep 2022 16:18:30 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id a41so1393097edf.4 for ; Mon, 19 Sep 2022 16:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YuQwXC400wn1XG3lPzRkN46CWgPRCmkTZD5KrMqPnvc=; b=OfOTlhHIdUYcoHKPguW/SrroW/2HH31KpnqDNx1VDOdScP9GFw+hcz6wLKt9qwYKmr tUiVUE0COMOBBIwnlZk33ru5T+PAhA69FfCE40NYduQ5A2+ZLn3WJwfMhsySvcTEX8NG kUvI2CGts6p4THnGkq0xeeKDTU5xPudeCwmi2+6sBCLSQZmuxjpnNtMXwBahzmJp9kZR Ylpol3lEYtvuiLAmcekgtLJXtFpD/8AjmspSTSwXdjX14Lafob9CFzE0RecWT58O2Hq9 Vl+Tlro5icVzofsz7kyjKQ+0/Ll3mwbPbZepIT1+f4hmtu3MFNqsfZTqVJBagsK7iMxp 9/+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=YuQwXC400wn1XG3lPzRkN46CWgPRCmkTZD5KrMqPnvc=; b=hx8TOYpX0z9pmsnGnT9w8wkLTgwZXe1xnE9LEiyagX8o+OMPujpMG3AmLipt5pFjqD i5COkXrwKjiBiK5xJ/q7F4QTSEe6DE8s3/0iG/cVV1392mzRaBGXacZCOMSdOa4KRDH4 TRDa24OKY9mS7y7DEJ+VysEZ4vfSJ5wIUT02SZvv7q9qr+fUMBRcVP2xF+kG8g6Tza2x tUlj1kM4mBXAuRxckNeB0SBJNfnkQujpB2SytLASVyv+zku+BroxU+F3nCiXN1+MAfKS 8A4pN6iiQAdpP8eFctRcHyeTZ5Mr/BV86vRXH4P7/xAmstPULoZVd3DRNBsYlhFt/NiI 3/TA== X-Gm-Message-State: ACrzQf1wYDdP9DZ02nPVPOinV3PgQB9cD2epCijV1VlfF/x93lS08J6U +5atPjDmVzT1nPOAxWRxr8Y= X-Google-Smtp-Source: AMsMyM4dA5dnazvKBz2RVfKC8EJQkafmLFlSOVYf1X2uY4aMLi4DKxlHP7A25Z9KlTvDpLqBqvU2+Q== X-Received: by 2002:a05:6402:1b06:b0:44e:a073:1dd8 with SMTP id by6-20020a0564021b0600b0044ea0731dd8mr16910792edb.391.1663629508436; Mon, 19 Sep 2022 16:18:28 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-054-077-055.78.54.pool.telefonica.de. [78.54.77.55]) by smtp.gmail.com with ESMTPSA id rn24-20020a170906d93800b00780f6071b5dsm4800926ejb.188.2022.09.19.16.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:18:28 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Christian Borntraeger , =?utf-8?q?C=C3=A9dric_Le?= =?utf-8?q?_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Her?= =?utf-8?q?v=C3=A9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne , Bernhard Beschow Subject: [PATCH 2/9] exec/hwaddr.h: Add missing include Date: Tue, 20 Sep 2022 01:17:13 +0200 Message-Id: <20220919231720.163121-3-shentey@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919231720.163121-1-shentey@gmail.com> References: <20220919231720.163121-1-shentey@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The next commit would not compile w/o the include directive. Signed-off-by: Bernhard Beschow --- include/exec/hwaddr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/exec/hwaddr.h b/include/exec/hwaddr.h index 8f16d179a8..616255317c 100644 --- a/include/exec/hwaddr.h +++ b/include/exec/hwaddr.h @@ -3,6 +3,7 @@ #ifndef HWADDR_H #define HWADDR_H +#include "qemu/osdep.h" #define HWADDR_BITS 64 /* hwaddr is the type of a physical address (its size can From patchwork Mon Sep 19 23:17:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12981128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2901EC6FA8B for ; Mon, 19 Sep 2022 23:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230019AbiISXT0 (ORCPT ); Mon, 19 Sep 2022 19:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbiISXSp (ORCPT ); Mon, 19 Sep 2022 19:18:45 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E538B4DB6B for ; Mon, 19 Sep 2022 16:18:35 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id y3so2238818ejc.1 for ; Mon, 19 Sep 2022 16:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ScsUFIDAHrm9/OPFECQYAYLcM3exK8eoaXsBNG48BMc=; b=bklrnXC+Q9cSo2FFOWfTXPpVHkz7irXkFbdyd6/BCU2xuyoZleDIoNMU8HijhM8/f/ 12oHjj6bdYlh8ovjo9fbo/AzzIKh/s88xDprTDDu6uVtD36FZCWsn66rd086C8EY+gRS b3PgE5tctP66cgHs7ldVIlsIuNOVQEBmmny+GbC5huXVVzJ4n4/hjoj0ooNBMuoyC7+/ IwvCtApFdCbrV78O3C5mq3mtM7+Rv7m08+xwa8/kKzar8suXKXKnclqYu1UxttLqEop6 3JIuCuLhTHc4skzYus3eB+AmX/fOGOrCA9D1UqE8mKBQsr1TgwZu8W5CRb5gZpTnS7Dn LqUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=ScsUFIDAHrm9/OPFECQYAYLcM3exK8eoaXsBNG48BMc=; b=irWL01Qe/PGz2wF+CmQrf3jllVYvTtTMTrF3IzhTuQCP9RCVUd/dsp3VPsr55bz4gy 7Q9S00OnMDa09yJv51FhBn+aCA544Yuxs5kmvVcGDqXDZ4lPKB+BuiFwWZx8XwulVwq1 xHDAAcp1sM9Amt2okOtLbyr2jhkdDyLS+XoFIGR74m90ZMsJ12YGLDORaS6K9Nl7RJie 6z7EK/0iOtiydfTk4L2Vhh45sn9R1Hkfx37gIBqp7wvxZvbYIJ/b8gZOGYqu5SzRWfPb h4MYmCMOpFlTpdY+7FPJsUkHLV3zQc3BLl0Pk9XdksarFToJXXzl4yZkA97GYmv+Pu+a xKBQ== X-Gm-Message-State: ACrzQf3bYlGrumSLD/kuK82qyiOG6CESFRbxsTRcQlk+Ub74+9wFtJQ+ jFlcQfhJKtt2VlJotA7mwf0= X-Google-Smtp-Source: AMsMyM5zOFXr+h5fB5zVLEWuIudF3jkOWN1HVQ7NnRGDLPPjOGxYXkHu7b5fRJV74nWfwRAhpeBFrQ== X-Received: by 2002:a17:907:7207:b0:77b:3647:c24 with SMTP id dr7-20020a170907720700b0077b36470c24mr14030221ejc.417.1663629514343; Mon, 19 Sep 2022 16:18:34 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-054-077-055.78.54.pool.telefonica.de. [78.54.77.55]) by smtp.gmail.com with ESMTPSA id rn24-20020a170906d93800b00780f6071b5dsm4800926ejb.188.2022.09.19.16.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:18:33 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Christian Borntraeger , =?utf-8?q?C=C3=A9dric_Le?= =?utf-8?q?_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Her?= =?utf-8?q?v=C3=A9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne , Bernhard Beschow Subject: [PATCH 3/9] hw/core/sysbus: Resolve main_system_bus singleton Date: Tue, 20 Sep 2022 01:17:14 +0200 Message-Id: <20220919231720.163121-4-shentey@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919231720.163121-1-shentey@gmail.com> References: <20220919231720.163121-1-shentey@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In QEMU, a machine and the main_system_bus always go togehter. Usually the bus is part of the machine which suggsts to host it there. Since tere is already a current_machine singleton, all code that accesses the main_system_bus can be changed (behind the scenes) to go through current_machine. This resolves a singleton. Futhermore, by reifying it in code, the every-machine-has-exactly-one-main-system-bus relationship becomes very obvious. Note that the main_system_bus attribute is a value rather than a pointer. This trades pointer dereferences for pointer arithmetic. The idea is to reduce cache misses - a rule of thumb says that every pointer dereference causes a cache miss while arithmetic is basically free. Signed-off-by: Bernhard Beschow --- hw/core/bus.c | 5 ++++- hw/core/machine.c | 3 +++ hw/core/sysbus.c | 22 +++++----------------- include/hw/boards.h | 1 + 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/hw/core/bus.c b/hw/core/bus.c index c7831b5293..e3e807946c 100644 --- a/hw/core/bus.c +++ b/hw/core/bus.c @@ -129,9 +129,12 @@ static void qbus_init_internal(BusState *bus, DeviceState *parent, bus->parent->num_child_bus++; object_property_add_child(OBJECT(bus->parent), bus->name, OBJECT(bus)); object_unref(OBJECT(bus)); + + /* The only bus without a parent is the main system bus */ + assert(sysbus_get_default()); } else { /* The only bus without a parent is the main system bus */ - assert(bus == sysbus_get_default()); + assert(!sysbus_get_default()); } } diff --git a/hw/core/machine.c b/hw/core/machine.c index aa520e74a8..ebd3e0ff08 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1097,6 +1097,9 @@ static void machine_initfn(Object *obj) ms->smp.threads = 1; machine_copy_boot_config(ms, &(BootConfiguration){ 0 }); + + qbus_init(&ms->main_system_bus, sizeof(ms->main_system_bus), + TYPE_SYSTEM_BUS, NULL, "main-system-bus"); } static void machine_finalize(Object *obj) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 05c1da3d31..16a9b4d7a0 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" +#include "hw/boards.h" #include "hw/sysbus.h" #include "monitor/monitor.h" #include "exec/address-spaces.h" @@ -336,26 +337,13 @@ static const TypeInfo sysbus_device_type_info = { .class_init = sysbus_device_class_init, }; -static BusState *main_system_bus; - -static void main_system_bus_create(void) -{ - /* - * assign main_system_bus before qbus_init() - * in order to make "if (bus != sysbus_get_default())" work - */ - main_system_bus = g_malloc0(system_bus_info.instance_size); - qbus_init(main_system_bus, system_bus_info.instance_size, - TYPE_SYSTEM_BUS, NULL, "main-system-bus"); - OBJECT(main_system_bus)->free = g_free; -} - BusState *sysbus_get_default(void) { - if (!main_system_bus) { - main_system_bus_create(); + if (!current_machine) { + return NULL; } - return main_system_bus; + + return ¤t_machine->main_system_bus; } static void sysbus_register_types(void) diff --git a/include/hw/boards.h b/include/hw/boards.h index 311ed17e18..7af940102d 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -346,6 +346,7 @@ struct MachineState { */ MemoryRegion *ram; DeviceMemoryState *device_memory; + BusState main_system_bus; ram_addr_t ram_size; ram_addr_t maxram_size; From patchwork Mon Sep 19 23:17:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12981129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54992C6FA8E for ; Mon, 19 Sep 2022 23:19:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbiISXT2 (ORCPT ); Mon, 19 Sep 2022 19:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbiISXS6 (ORCPT ); Mon, 19 Sep 2022 19:18:58 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A43751413 for ; Mon, 19 Sep 2022 16:18:41 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id z2so1412716edi.1 for ; Mon, 19 Sep 2022 16:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=08Zu8gSbNoVwH6SgINHBVlRGcpHDOzJ+Q2vxMgjaChc=; b=LfVaavpRhFpUWtJPmOxeHcORJMDqIlM8LXxn6uYegGeyIw7Hse/ODmgBL9aKBhrBR+ QDDcqQqAdIZTX3WL1AetyE3jL8Z7UfxdRlbeYmgC3KxoQ1JGUO5P/z0aHKwwmXDVbECj AuFfIQm7sMB0W8Fn1uWO/41uzUy2iQROSJACK1zFtCB5Ab5h3m+zMu7WKhoWQK1NOfC6 FGmzCigSE7vWW/M9qBClZbQwtO4eC/7gkX0vt5SaBL49Jx2Ea8iuUqxrqNunzGJXm1oE JWUZFC3ZmBZazxQinxj2ElsyYVRjc4rohZ/gwlRQDOLEWPgCW/Y5CMxXPPgmtldeeeIg RE6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=08Zu8gSbNoVwH6SgINHBVlRGcpHDOzJ+Q2vxMgjaChc=; b=jsm+QSDjQVYJRWc6K7AshbXmbN5iOEnnSxjSWhDJqkv3yXB28OM6oQuHyR67mOynYz o76g8c1lNf6se4mknGhDkfwkKk8fgK8aP13ILcEG48sNrZxqW40MBEuT1nWlkVcg7+wK A/EZAY35XkS1GqQs2+Waie58PJZBgADEjmv+48Y2F07R5XlfTsRhIjcOgaeZKZrulDkr V9+0gighZxqOux24q1fLjsncFR4j+wSKMlIX1DYAq6gQkdjdZD46c+WEFyhUVu+0YM2P NmHt1aDbG2blUA+qQi1JCyo9lwYyztg5lrbXK4QsT+Ls8IXnLrPE49TknaRF5qJQEucZ hbKw== X-Gm-Message-State: ACrzQf1cw15hrx1JrJLVxAAUiOYRFv1vP6b+QhdhmqSFDDyS8SiExES+ lw7Bref1rcek9VkzJMVujls= X-Google-Smtp-Source: AMsMyM6+ebOfksS7/dKAeoPOeQiFYFMU9VBsL7Wg1bKooGg4PafvZv5MknBjnq/lOyGHV8ZLR+girw== X-Received: by 2002:a05:6402:50ca:b0:451:a711:1389 with SMTP id h10-20020a05640250ca00b00451a7111389mr17116111edb.239.1663629520004; Mon, 19 Sep 2022 16:18:40 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-054-077-055.78.54.pool.telefonica.de. [78.54.77.55]) by smtp.gmail.com with ESMTPSA id rn24-20020a170906d93800b00780f6071b5dsm4800926ejb.188.2022.09.19.16.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:18:39 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Christian Borntraeger , =?utf-8?q?C=C3=A9dric_Le?= =?utf-8?q?_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Her?= =?utf-8?q?v=C3=A9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne , Bernhard Beschow Subject: [PATCH 4/9] hw/ppc/spapr: Fix code style problems reported by checkpatch Date: Tue, 20 Sep 2022 01:17:15 +0200 Message-Id: <20220919231720.163121-5-shentey@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919231720.163121-1-shentey@gmail.com> References: <20220919231720.163121-1-shentey@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Bernhard Beschow Reviewed-by: Daniel Henrique Barboza --- include/hw/ppc/spapr.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 530d739b1d..04a95669ab 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -848,7 +848,8 @@ static inline uint64_t ppc64_phys_to_real(uint64_t addr) static inline uint32_t rtas_ld(target_ulong phys, int n) { - return ldl_be_phys(&address_space_memory, ppc64_phys_to_real(phys + 4*n)); + return ldl_be_phys(&address_space_memory, + ppc64_phys_to_real(phys + 4 * n)); } static inline uint64_t rtas_ldq(target_ulong phys, int n) @@ -858,7 +859,7 @@ static inline uint64_t rtas_ldq(target_ulong phys, int n) static inline void rtas_st(target_ulong phys, int n, uint32_t val) { - stl_be_phys(&address_space_memory, ppc64_phys_to_real(phys + 4*n), val); + stl_be_phys(&address_space_memory, ppc64_phys_to_real(phys + 4 * n), val); } typedef void (*spapr_rtas_fn)(PowerPCCPU *cpu, SpaprMachineState *sm, From patchwork Mon Sep 19 23:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12981130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04D2FC6FA82 for ; Mon, 19 Sep 2022 23:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbiISXTc (ORCPT ); Mon, 19 Sep 2022 19:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbiISXTD (ORCPT ); Mon, 19 Sep 2022 19:19:03 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF624501A1 for ; Mon, 19 Sep 2022 16:18:54 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id e17so1381478edc.5 for ; Mon, 19 Sep 2022 16:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=5XlQ1VpPqIV9nkbL5heHBJQIeqw1Mqo2GOdHAQq5+II=; b=V1Xkq1+a6hse0yYR3fG7QmZf7eJLZ9IHXShDEimvhNxJCgJXQZEhiB7rS29v8mOpv8 P6Q/NgzpGGR1zjQswFV9oVsIkApjiLp/TuMLa8asbQeDVSJ9xcqsRDBMPPfvubQ/ud8M 6dma9SHs8xseeoX1geC075YVhTJkg5UYKK9V145qBxKkDYQso+5CEuESYbx9GpS5ITt/ geAPZY2mvKURWXNpdq+82LS5ePfVg2MiJ8HHMrB93gDn3YIy3WMpYdI3RCQ1Wj2jPwFe D51PhycmYQXgI5PX3syysunfpaQHEnp6cVcDiO8I65JrGDV+oaRZA47creHSMX5+vVkK EpTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=5XlQ1VpPqIV9nkbL5heHBJQIeqw1Mqo2GOdHAQq5+II=; b=MunTEGyP8Y5LnVYyX9qFgGn9bOI+m+ql89nolT7EGK17E2GvNR49xR6pqj5p4GQalI ybPbNOKhSsmdtzzfNVqap58fGWwfFwQ0OA3BIpwQzzCP8bZVnHuZuO1X+JsWc2Wb+VaJ TB0woI9rA53b/Gtu4adrUO06eLlHwnVrGoWuLZ+p405j63bZ6g2yJpjCpkcMrlTdQkey wcNPOBlZjaD6TeIfipqRm6E9Y7F30wOVMn/bdz2hWTYlGE0vhrSNwSHOk4xD/Jzt43ia 4sZ7RMhO6twaXT8kZGeICKbd1VOonhjrSiGSP/dRU2Co5oMfj05IJzU4oKMoCrxyj4RB 9OjQ== X-Gm-Message-State: ACrzQf3rShCU86KmdHo3dobWep+n4Qb1xpi0+3sSnqg6PYZ9C9tO0gra SSEjHmle70Vvj/47h8dXAOY= X-Google-Smtp-Source: AMsMyM6LQ7zX0snjJOKDhu4y1VtCyR5HxEAeYDZgQV0qmXEZF7bGIa6sBksILYTX9vlQa3QJPxyguw== X-Received: by 2002:a05:6402:2711:b0:451:327a:365f with SMTP id y17-20020a056402271100b00451327a365fmr17131653edd.315.1663629533162; Mon, 19 Sep 2022 16:18:53 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-054-077-055.78.54.pool.telefonica.de. [78.54.77.55]) by smtp.gmail.com with ESMTPSA id rn24-20020a170906d93800b00780f6071b5dsm4800926ejb.188.2022.09.19.16.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:18:52 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Christian Borntraeger , =?utf-8?q?C=C3=A9dric_Le?= =?utf-8?q?_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Her?= =?utf-8?q?v=C3=A9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne , Bernhard Beschow Subject: [PATCH 6/9] target/loongarch/cpu: Remove unneeded include directive Date: Tue, 20 Sep 2022 01:17:17 +0200 Message-Id: <20220919231720.163121-7-shentey@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919231720.163121-1-shentey@gmail.com> References: <20220919231720.163121-1-shentey@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The cpu is used in both user and system emulation context while sysbus.h is system-only. Remove it since it's not needed anyway. Furthermore, it would cause a compile error in the next commit. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- target/loongarch/cpu.h | 1 - 1 file changed, 1 deletion(-) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index dce999aaac..c9ed2cb3e7 100644 --- a/target/loongarch/cpu.h +++ b/target/loongarch/cpu.h @@ -13,7 +13,6 @@ #include "hw/registerfields.h" #include "qemu/timer.h" #include "exec/memory.h" -#include "hw/sysbus.h" #define IOCSRF_TEMP 0 #define IOCSRF_NODECNT 1 From patchwork Mon Sep 19 23:17:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12981132 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FE86C6FA8B for ; Mon, 19 Sep 2022 23:19:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbiISXTn (ORCPT ); Mon, 19 Sep 2022 19:19:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230322AbiISXTF (ORCPT ); Mon, 19 Sep 2022 19:19:05 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC8925073B for ; Mon, 19 Sep 2022 16:19:00 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id go34so2242123ejc.2 for ; Mon, 19 Sep 2022 16:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=18L1CetNQZRcWgrF+bLfFklTWcjPuzsdD8LCMjAGf1E=; b=V5XT6ePhglxVVnzO7wTKlIaCCViZpN/zYqMG+wnd7lcxvsQ6bFt9WuDSwUs61yQfOq pOOrLokv5qVrEanQf1jerp+JQbj02Jx+4/DTXLbk4VGzNoVT9LMVzK0PC7mepLvnFIDH zNU2Iq8+Tt8hwKBJJHRAekFsH64zOK5KDx2DOj+3xLFeQHbqLBayBI84MwLSLyDfmRzn Bn02SXOCet8dJvaSko0kLZJJa9dUhgUekK1verWyRQXlYweUX2DfajwnVTkn8xSB6xdY xhTzjewc6CjRhf/YtZTPMPm/29EOtiCPc87CrZipbkfmhngf1laAFdu+hBwMKfqzao83 81vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=18L1CetNQZRcWgrF+bLfFklTWcjPuzsdD8LCMjAGf1E=; b=H3Rfh/v564ByjR4YeDXCCEtQbs1uRbmg0G14tiTGMl8Umlxy8zxcbcG/SaC6vBsnGw /fLP7zGA5DUaaj2pEyLZEgnyuOpEZdXgv/iF7a6f7odGxK62r9mtDh8Na155rHKxyvgO N009j4CM0xO/1x16v/btESv1DXE5XuP+unVieRAlAmELtbURO6b/5KvS0PGN/6bA/xRz V76kh1Th+8oJlw3ajbmp3FIAxllpCC1FYhLOie6z/ZrTk/kmZPDmqRZDkV83l9RKXHeY KrsSXRUVzbnp1lRvy+q1lCgjW1CBNmbuhipCMOQ+L9zsoKzzCCehe7OiyQea4djZXDE8 v23g== X-Gm-Message-State: ACrzQf2jNzJVK1qi95NEtp69Yk3px3+OLNP474Lqi3gcEJ5KR85qW7Se 8LyyQ8eMM0bE93TxLQdLVys= X-Google-Smtp-Source: AMsMyM4eJjU/NOUzNOFcRv5on/MypRLn/EbDnZquypCWBAyuQiQwWxxTAmP7wvB5d1YGt/EQ80NS8w== X-Received: by 2002:a17:907:2e0b:b0:77f:5fd8:8712 with SMTP id ig11-20020a1709072e0b00b0077f5fd88712mr13751388ejc.575.1663629539177; Mon, 19 Sep 2022 16:18:59 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-054-077-055.78.54.pool.telefonica.de. [78.54.77.55]) by smtp.gmail.com with ESMTPSA id rn24-20020a170906d93800b00780f6071b5dsm4800926ejb.188.2022.09.19.16.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:18:58 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Christian Borntraeger , =?utf-8?q?C=C3=A9dric_Le?= =?utf-8?q?_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Her?= =?utf-8?q?v=C3=A9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne , Bernhard Beschow Subject: [PATCH 7/9] hw/sysbus: Introduce dedicated struct SysBusState for TYPE_SYSTEM_BUS Date: Tue, 20 Sep 2022 01:17:18 +0200 Message-Id: <20220919231720.163121-8-shentey@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919231720.163121-1-shentey@gmail.com> References: <20220919231720.163121-1-shentey@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org With this out of the way, in the next step, SysBusState gains attributes for its memory and address recouces. Signed-off-by: Bernhard Beschow --- hw/core/sysbus.c | 4 ++-- include/hw/boards.h | 3 ++- include/hw/misc/macio/macio.h | 2 +- include/hw/sysbus.h | 8 ++++++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 16a9b4d7a0..1100f3ad6c 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -84,7 +84,7 @@ static void system_bus_class_init(ObjectClass *klass, void *data) static const TypeInfo system_bus_info = { .name = TYPE_SYSTEM_BUS, .parent = TYPE_BUS, - .instance_size = sizeof(BusState), + .instance_size = sizeof(SysBusState), .class_init = system_bus_class_init, }; @@ -343,7 +343,7 @@ BusState *sysbus_get_default(void) return NULL; } - return ¤t_machine->main_system_bus; + return ¤t_machine->main_system_bus.parent_obj; } static void sysbus_register_types(void) diff --git a/include/hw/boards.h b/include/hw/boards.h index 7af940102d..63a4f990ea 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -11,6 +11,7 @@ #include "qemu/module.h" #include "qom/object.h" #include "hw/core/cpu.h" +#include "hw/sysbus.h" #define TYPE_MACHINE_SUFFIX "-machine" @@ -346,7 +347,7 @@ struct MachineState { */ MemoryRegion *ram; DeviceMemoryState *device_memory; - BusState main_system_bus; + SysBusState main_system_bus; ram_addr_t ram_size; ram_addr_t maxram_size; diff --git a/include/hw/misc/macio/macio.h b/include/hw/misc/macio/macio.h index 6c05f3bfd2..0944be587f 100644 --- a/include/hw/misc/macio/macio.h +++ b/include/hw/misc/macio/macio.h @@ -44,7 +44,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(MacIOBusState, MACIO_BUS) struct MacIOBusState { /*< private >*/ - BusState parent_obj; + SysBusState parent_obj; }; /* MacIO IDE */ diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index 3564b7b6a2..5bb3b88501 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -11,9 +11,13 @@ #define QDEV_MAX_PIO 32 #define TYPE_SYSTEM_BUS "System" -DECLARE_INSTANCE_CHECKER(BusState, SYSTEM_BUS, - TYPE_SYSTEM_BUS) +OBJECT_DECLARE_SIMPLE_TYPE(SysBusState, SYSTEM_BUS) +struct SysBusState { + /*< private >*/ + BusState parent_obj; + /*< public >*/ +}; #define TYPE_SYS_BUS_DEVICE "sys-bus-device" OBJECT_DECLARE_TYPE(SysBusDevice, SysBusDeviceClass, From patchwork Mon Sep 19 23:17:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12981131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CDF0C6FA82 for ; Mon, 19 Sep 2022 23:19:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbiISXTi (ORCPT ); Mon, 19 Sep 2022 19:19:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbiISXTI (ORCPT ); Mon, 19 Sep 2022 19:19:08 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10C9C4B0F8 for ; Mon, 19 Sep 2022 16:19:07 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id u9so2193742ejy.5 for ; Mon, 19 Sep 2022 16:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=GY9FLwpbhpko1ROroTaJ6wfQD1OQmuRWRFOe6XO0HkE=; b=WvtWhaz7RfTahuePkkE9xIcuGxfWCiGa1wTboB9PRKNnjFohCiK5pF4LK4IJs9vf5N yZ9b8tZiP/Tk5sTxggCXSX9hx4EUFuokcV4BrpDDY1zJG3SQgv2WDt7AMvozCWevYw/y FMq1uucw4j5Oqi3St2U+VPdyyKPs808bAQonJw6bTfZqftbvg4Azml8efQ5tZ1HTfiv1 i2uAlpDSRqaRvcSiFKosYvLwQd4zFza7DGwVf1WV4BT2+jgksxTrQDJm9O6L00Q8j9I8 4KmIJLgd7IBUyEMozx+cv/IZSOQLBXyIH5zHVtq82KU+JwLn3+FsLbrutbLKXuQqQsVI bQYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=GY9FLwpbhpko1ROroTaJ6wfQD1OQmuRWRFOe6XO0HkE=; b=ERPZQSlgnM5CUfwVP+twA03pyxS7nzkYhUZCRMdmwtwS7ZL+YtqTqAXchxp6h2BZPl 91J+iHuFp6p8UBTVX6JQwkVMEp9s5B6jqGac07F4yFc4emHEUAxeB8lLhKqO6iiWNrnT C6qFsnekShfo//FZXfscqvt3Wpxr+Mz2leTCH9hF0JWloAo95YNm0+s+35DiKKK76W9K aDsdx1L069t+4lv6/Fie8a+CA3RL0XRx41ln75OZw/w1DSFqY5yz61li552Cseq0qNO1 x7oZwt7qAo0KyrO8w0NMj8rBF8r8/NkK0UQKSkpE45yahx/LEicUHuTkHFwBVmNsoLyX uyOw== X-Gm-Message-State: ACrzQf2gLEU6Mu0pQRgvm32UJlZyrUU0DYk5Z600rvQLt5hGJnCIt/qn tjKEJzpNprZF0RFfhEWGcwQ= X-Google-Smtp-Source: AMsMyM4qkgaEMGM0QJXD77Pkxb2n4WftV+KsIglPwhyeQygcGRI6lNjr6tviLaBlIrFPXV7KHzllzg== X-Received: by 2002:a17:907:3e86:b0:6f5:917:10cc with SMTP id hs6-20020a1709073e8600b006f5091710ccmr15309153ejc.53.1663629545495; Mon, 19 Sep 2022 16:19:05 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-054-077-055.78.54.pool.telefonica.de. [78.54.77.55]) by smtp.gmail.com with ESMTPSA id rn24-20020a170906d93800b00780f6071b5dsm4800926ejb.188.2022.09.19.16.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:19:05 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Christian Borntraeger , =?utf-8?q?C=C3=A9dric_Le?= =?utf-8?q?_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Her?= =?utf-8?q?v=C3=A9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne , Bernhard Beschow Subject: [PATCH 8/9] softmmu/physmem: Let SysBusState absorb memory region and address space singletons Date: Tue, 20 Sep 2022 01:17:19 +0200 Message-Id: <20220919231720.163121-9-shentey@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919231720.163121-1-shentey@gmail.com> References: <20220919231720.163121-1-shentey@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org These singletons are actually properties of the system bus but so far it hasn't been modelled that way. Fix this to make this relationship very obvious. The idea of the patch is to restrain futher proliferation of the use of get_system_memory() and get_system_io() which are "temprary interfaces" "until a proper bus interface is available". This should now be the case. Note that the new attributes are values rather than a pointers. This trades pointer dereferences for pointer arithmetic. The idea is to reduce cache misses - a rule of thumb says that every pointer dereference causes a cache miss while arithmetic is basically free. Signed-off-by: Bernhard Beschow --- include/exec/address-spaces.h | 19 ++++++++++++--- include/hw/sysbus.h | 6 +++++ softmmu/physmem.c | 46 ++++++++++++++++++----------------- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h index d5c8cbd718..b31bd8dcf0 100644 --- a/include/exec/address-spaces.h +++ b/include/exec/address-spaces.h @@ -23,17 +23,28 @@ #ifndef CONFIG_USER_ONLY -/* Get the root memory region. This interface should only be used temporarily - * until a proper bus interface is available. +/** + * Get the root memory region. This is a legacy function, provided for + * compatibility. Prefer using SysBusState::system_memory directly. */ MemoryRegion *get_system_memory(void); -/* Get the root I/O port region. This interface should only be used - * temporarily until a proper bus interface is available. +/** + * Get the root I/O port region. This is a legacy function, provided for + * compatibility. Prefer using SysBusState::system_io directly. */ MemoryRegion *get_system_io(void); +/** + * Get the root memory address space. This is a legacy function, provided for + * compatibility. Prefer using SysBusState::address_space_memory directly. + */ AddressSpace *get_address_space_memory(void); + +/** + * Get the root I/O port address space. This is a legacy function, provided + * for compatibility. Prefer using SysBusState::address_space_io directly. + */ AddressSpace *get_address_space_io(void); #endif diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index 5bb3b88501..516e9091dc 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -17,6 +17,12 @@ struct SysBusState { /*< private >*/ BusState parent_obj; /*< public >*/ + + MemoryRegion system_memory; + MemoryRegion system_io; + + AddressSpace address_space_io; + AddressSpace address_space_memory; }; #define TYPE_SYS_BUS_DEVICE "sys-bus-device" diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 0ac920d446..07e9a9171c 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -86,12 +86,6 @@ */ RAMList ram_list = { .blocks = QLIST_HEAD_INITIALIZER(ram_list.blocks) }; -static MemoryRegion *system_memory; -static MemoryRegion *system_io; - -static AddressSpace address_space_io; -static AddressSpace address_space_memory; - static MemoryRegion io_mem_unassigned; typedef struct PhysPageEntry PhysPageEntry; @@ -146,7 +140,7 @@ typedef struct subpage_t { #define PHYS_SECTION_UNASSIGNED 0 static void io_mem_init(void); -static void memory_map_init(void); +static void memory_map_init(SysBusState *sysbus); static void tcg_log_global_after_sync(MemoryListener *listener); static void tcg_commit(MemoryListener *listener); @@ -2667,37 +2661,45 @@ static void tcg_commit(MemoryListener *listener) tlb_flush(cpuas->cpu); } -static void memory_map_init(void) +static void memory_map_init(SysBusState *sysbus) { - system_memory = g_malloc(sizeof(*system_memory)); + MemoryRegion *system_memory = &sysbus->system_memory; + MemoryRegion *system_io = &sysbus->system_io; memory_region_init(system_memory, NULL, "system", UINT64_MAX); - address_space_init(&address_space_memory, system_memory, "memory"); + address_space_init(&sysbus->address_space_memory, system_memory, "memory"); - system_io = g_malloc(sizeof(*system_io)); memory_region_init_io(system_io, NULL, &unassigned_io_ops, NULL, "io", 65536); - address_space_init(&address_space_io, system_io, "I/O"); + address_space_init(&sysbus->address_space_io, system_io, "I/O"); } MemoryRegion *get_system_memory(void) { - return system_memory; + assert(current_machine); + + return ¤t_machine->main_system_bus.system_memory; } MemoryRegion *get_system_io(void) { - return system_io; + assert(current_machine); + + return ¤t_machine->main_system_bus.system_io; } AddressSpace *get_address_space_memory(void) { - return &address_space_memory; + assert(current_machine); + + return ¤t_machine->main_system_bus.address_space_memory; } AddressSpace *get_address_space_io(void) { - return &address_space_io; + assert(current_machine); + + return ¤t_machine->main_system_bus.address_space_io; } static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr, @@ -3003,7 +3005,7 @@ MemTxResult address_space_set(AddressSpace *as, hwaddr addr, void cpu_physical_memory_rw(hwaddr addr, void *buf, hwaddr len, bool is_write) { - address_space_rw(&address_space_memory, addr, MEMTXATTRS_UNSPECIFIED, + address_space_rw(get_address_space_memory(), addr, MEMTXATTRS_UNSPECIFIED, buf, len, is_write); } @@ -3074,7 +3076,7 @@ void cpu_flush_icache_range(hwaddr start, hwaddr len) return; } - address_space_write_rom_internal(&address_space_memory, + address_space_write_rom_internal(get_address_space_memory(), start, MEMTXATTRS_UNSPECIFIED, NULL, len, FLUSH_CACHE); } @@ -3140,7 +3142,7 @@ void cpu_exec_init_all(void) */ finalize_target_page_bits(); io_mem_init(); - memory_map_init(); + memory_map_init(¤t_machine->main_system_bus); qemu_mutex_init(&map_client_list_lock); } @@ -3322,14 +3324,14 @@ void *cpu_physical_memory_map(hwaddr addr, hwaddr *plen, bool is_write) { - return address_space_map(&address_space_memory, addr, plen, is_write, + return address_space_map(get_address_space_memory(), addr, plen, is_write, MEMTXATTRS_UNSPECIFIED); } void cpu_physical_memory_unmap(void *buffer, hwaddr len, bool is_write, hwaddr access_len) { - return address_space_unmap(&address_space_memory, buffer, len, + return address_space_unmap(get_address_space_memory(), buffer, len, is_write, access_len); } @@ -3554,7 +3556,7 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr) bool res; RCU_READ_LOCK_GUARD(); - mr = address_space_translate(&address_space_memory, + mr = address_space_translate(get_address_space_memory(), phys_addr, &phys_addr, &l, false, MEMTXATTRS_UNSPECIFIED); From patchwork Mon Sep 19 23:17:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 12981133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E570CC6FA8B for ; Mon, 19 Sep 2022 23:19:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230000AbiISXTr (ORCPT ); Mon, 19 Sep 2022 19:19:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbiISXTO (ORCPT ); Mon, 19 Sep 2022 19:19:14 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70FE95019A for ; Mon, 19 Sep 2022 16:19:13 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id q21so1351622edc.9 for ; Mon, 19 Sep 2022 16:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=CsS8/+NcmmUwF5Nr1L7YiFLpUSnCt26Ro0cbZ1iTpA0=; b=LvQxLOmJmGVQ6sYu0MsAHfg8Ds6mykcGi7e3toDd9OFsfFEnWXTEkQZsRgcA0qsBVK Ax5qZ/FGRkcXZjgQXjmpXzOndgONzyLEOfYdR+g0wP59Ui6GKvlOYss+hr/WgF94LAQG ax/WwLFBL1+LRyQIy+7lhc0PSm9DLccB1NsqeZVjbmbqGQFnyw6exKqa/w0WN+cCU129 HszwSLx/FOWeL2QB5xupKDxKOyewPDDsvvE6piEkWTsl/i3Bmnlz2slYtvmUZUAw6hb3 NZGTv/8KL9eBHuB2KB1+1rAmJut32xrcuUgfT1HQYK6PmCKcw+vZEvVx72whU341ZIbN rvxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=CsS8/+NcmmUwF5Nr1L7YiFLpUSnCt26Ro0cbZ1iTpA0=; b=h9iPQz+FG/q72vFI1qLOYe2y2zVUh5zjlu1Nw6nnlNSqzGYwqruSjFrX3phtV5hKY4 VtD9GF64Z7ywg1xeFKAfIfOAsWKrw3rnScsP/G8bHNO13k6zPAUPv96FuDey2CsKJaWn cB7HqrbBcqRrXOtPV650rCt6yYb+nDSU49vhgKJ81F0nXtharpSmQzpov5MlVOZCn9eP +gqjZv4XjmCFSkAEHL9RKdnaqwAhLHaSLLzPN6UOkWZ+HYZCcs+y7v+kTk2kD+UKewXp d+gop5cIH41RtH8phnEdJ2FrbWSXvZ5XPENSVNzGLbzHJjGBn+9oR26yt+A2uAjiKS9U FJQg== X-Gm-Message-State: ACrzQf2aUUqhDv65PoMIel0OBXYXiDJzLkjrf7CBsD/IgbDtyzHffVEU wcOZG050jz3IquCZzx6WEaY= X-Google-Smtp-Source: AMsMyM54oAh1Hs8YDp/oSyEMdroOBdvLpZ3fCGRY2SIbSMd17jic9985Tclql7Fyu3Qp56FgVgfeBA== X-Received: by 2002:aa7:da83:0:b0:44e:69ba:81c7 with SMTP id q3-20020aa7da83000000b0044e69ba81c7mr17400003eds.323.1663629551883; Mon, 19 Sep 2022 16:19:11 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-054-077-055.78.54.pool.telefonica.de. [78.54.77.55]) by smtp.gmail.com with ESMTPSA id rn24-20020a170906d93800b00780f6071b5dsm4800926ejb.188.2022.09.19.16.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 16:19:11 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Magnus Damm , Aleksandar Rikalo , Bandan Das , Matthew Rosato , Daniel Henrique Barboza , Sergio Lopez , Alexey Kardashevskiy , Xiaojuan Yang , Cameron Esfahani , Michael Rolnik , Song Gao , Jagannathan Raman , Greg Kurz , Kamil Rytarowski , Peter Xu , Joel Stanley , Alistair Francis , "Dr. David Alan Gilbert" , Paolo Bonzini , haxm-team@intel.com, Roman Bolshakov , Markus Armbruster , Eric Auger , David Gibson , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Christian Borntraeger , =?utf-8?q?C=C3=A9dric_Le?= =?utf-8?q?_Goater?= , Stefan Hajnoczi , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Her?= =?utf-8?q?v=C3=A9_Poussineau?= , qemu-ppc@nongnu.org, Cornelia Huck , Palmer Dabbelt , Helge Deller , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Stafford Horne , Paul Durrant , Havard Skinnemoen , Elena Ufimtseva , Alexander Graf , Thomas Huth , Alex Williamson , Wenchao Wang , Tony Krowiak , Marcel Apfelbaum , qemu-s390x@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland , Eric Farman , Reinoud Zandijk , Alexander Bulekov , Yanan Wang , "Edgar E. Iglesias" , Gerd Hoffmann , Tyrone Ting , xen-devel@lists.xenproject.org, Yoshinori Sato , John Snow , Richard Henderson , Darren Kenny , kvm@vger.kernel.org, Qiuhao Li , John G Johnson , Bin Meng , Sunil Muthuswamy , Max Filippov , qemu-arm@nongnu.org, Marcelo Tosatti , Peter Maydell , Anthony Perard , Andrew Jeffery , Artyom Tarasenko , Halil Pasic , "Maciej S. Szmigiero" , Jason Wang , David Hildenbrand , Laurent Vivier , Alistair Francis , Jason Herne , Bernhard Beschow Subject: [PATCH 9/9] exec/address-spaces: Inline legacy functions Date: Tue, 20 Sep 2022 01:17:20 +0200 Message-Id: <20220919231720.163121-10-shentey@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220919231720.163121-1-shentey@gmail.com> References: <20220919231720.163121-1-shentey@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The functions just access a global pointer and perform some pointer arithmetic on top. Allow the compiler to see through this by inlining. Signed-off-by: Bernhard Beschow --- include/exec/address-spaces.h | 30 ++++++++++++++++++++++++++---- softmmu/physmem.c | 28 ---------------------------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h index b31bd8dcf0..182af27cad 100644 --- a/include/exec/address-spaces.h +++ b/include/exec/address-spaces.h @@ -23,29 +23,51 @@ #ifndef CONFIG_USER_ONLY +#include "hw/boards.h" + /** * Get the root memory region. This is a legacy function, provided for * compatibility. Prefer using SysBusState::system_memory directly. */ -MemoryRegion *get_system_memory(void); +inline MemoryRegion *get_system_memory(void) +{ + assert(current_machine); + + return ¤t_machine->main_system_bus.system_memory; +} /** * Get the root I/O port region. This is a legacy function, provided for * compatibility. Prefer using SysBusState::system_io directly. */ -MemoryRegion *get_system_io(void); +inline MemoryRegion *get_system_io(void) +{ + assert(current_machine); + + return ¤t_machine->main_system_bus.system_io; +} /** * Get the root memory address space. This is a legacy function, provided for * compatibility. Prefer using SysBusState::address_space_memory directly. */ -AddressSpace *get_address_space_memory(void); +inline AddressSpace *get_address_space_memory(void) +{ + assert(current_machine); + + return ¤t_machine->main_system_bus.address_space_memory; +} /** * Get the root I/O port address space. This is a legacy function, provided * for compatibility. Prefer using SysBusState::address_space_io directly. */ -AddressSpace *get_address_space_io(void); +inline AddressSpace *get_address_space_io(void) +{ + assert(current_machine); + + return ¤t_machine->main_system_bus.address_space_io; +} #endif diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 07e9a9171c..dce088f55c 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -2674,34 +2674,6 @@ static void memory_map_init(SysBusState *sysbus) address_space_init(&sysbus->address_space_io, system_io, "I/O"); } -MemoryRegion *get_system_memory(void) -{ - assert(current_machine); - - return ¤t_machine->main_system_bus.system_memory; -} - -MemoryRegion *get_system_io(void) -{ - assert(current_machine); - - return ¤t_machine->main_system_bus.system_io; -} - -AddressSpace *get_address_space_memory(void) -{ - assert(current_machine); - - return ¤t_machine->main_system_bus.address_space_memory; -} - -AddressSpace *get_address_space_io(void) -{ - assert(current_machine); - - return ¤t_machine->main_system_bus.address_space_io; -} - static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr, hwaddr length) {