From patchwork Mon Apr 3 07:41:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13197762 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26DDAC761A6 for ; Mon, 3 Apr 2023 07:42:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.517308.802443 (Exim 4.92) (envelope-from ) id 1pjEot-0000T8-Nk; Mon, 03 Apr 2023 07:41:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 517308.802443; Mon, 03 Apr 2023 07:41:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEot-0000T1-Jh; Mon, 03 Apr 2023 07:41:39 +0000 Received: by outflank-mailman (input) for mailman id 517308; Mon, 03 Apr 2023 07:41:37 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEor-0000Sf-M9 for xen-devel@lists.xenproject.org; Mon, 03 Apr 2023 07:41:37 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f57e5bd8-d1f2-11ed-85db-49a42c6b2330; Mon, 03 Apr 2023 09:41:35 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id o24-20020a05600c511800b003ef59905f26so17440294wms.2 for ; Mon, 03 Apr 2023 00:41:35 -0700 (PDT) Received: from Provence.localdomain (dynamic-078-055-162-106.78.55.pool.telefonica.de. [78.55.162.106]) by smtp.gmail.com with ESMTPSA id s11-20020a5d424b000000b002e5f6f8fc4fsm8414960wrr.100.2023.04.03.00.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 00:41:34 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f57e5bd8-d1f2-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680507695; 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=TeCzVhGVlV6a+Zg2qRJBs5g8PJcLaKDhbJ2idHJxxx0=; b=NOsYWiO46TFwc5m5xQHDhQb58P1Be5veIezV+JjfGZagw4FzoW9qAT0JRFYCG1Egj2 6q00XPm7KcKE7MUNFTIM7GgjU98aTY1zJm5D4vB8qAjZlbnErUSS4LUsH+5+df/dxoUP 0E/k4gNZfqlF5NggV1/s4+AQHdipEvxQQ1nQUjtsp2ehdEujBeHt8RnlyjvDRq6SdcgL EQ6RsxkTM5ehELnOpAbiPcdPxEwrfnGGyLKjQpveSExcoF6JzPNodfRySaFCXvOVzjgt NLBM7Dq02dF3TYQjQ8bHDGAKajXemkJTLwVjK9LwE5h5Pq9U48zyJqpvvli/cdn+9UVR ptSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680507695; 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=TeCzVhGVlV6a+Zg2qRJBs5g8PJcLaKDhbJ2idHJxxx0=; b=yhYHq1tfu5ZzukYJEqg1RGVi/gPUAqb6Hi9bex8vvT3rJNDChryZxgqqNURiRjxkPT 2jhOEQRC7/0ksbQr+y7u75mAJI27ULKINXucBLp/+WAv83RkMu+GC1t/A341wPM1nYI8 RIEPvPNffuQpPUfuioMB9yfH4B+wT0QFSx/AgYije3Z2S3P5fwk86kS2ter5xlbL1Scb mbXxKRwKAb2SfqewAJgfeSXyoFo0COTy+Jiub5ATR/0S+M5n5rHqsDbURnbuauxMzUlT LDdrKnogyNz7YyI8XWKJcJ/Mh507QyoOuVZ9Oaa3mqj3sAEt9xoarFdHVEL9z5j43QVy 3j9Q== X-Gm-Message-State: AO0yUKXKozgJLbOf7J7nXCClVU6UVscYId6K+uQXh8eop8V0BPLbAqNP K6bDQabeMsdlyxkbxeO1tcI= X-Google-Smtp-Source: AK7set93HQ7bKPaN49jz207odhGu/2UkBML7wwW8EKMOxHqY7JzqavV7AWSsQWIMxqbtp26LC7xE8A== X-Received: by 2002:a1c:7406:0:b0:3ed:320a:3721 with SMTP id p6-20020a1c7406000000b003ed320a3721mr27549019wmc.22.1680507694746; Mon, 03 Apr 2023 00:41:34 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Marcel Apfelbaum , David Woodhouse , Eduardo Habkost , Stefano Stabellini , Chuck Zmudzinski , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paul Durrant , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anthony Perard , xen-devel@lists.xenproject.org, Bernhard Beschow Subject: [PATCH v4 1/7] include/hw/xen/xen: Rename xen_piix3_set_irq() to xen_intx_set_irq() Date: Mon, 3 Apr 2023 09:41:18 +0200 Message-Id: <20230403074124.3925-2-shentey@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403074124.3925-1-shentey@gmail.com> References: <20230403074124.3925-1-shentey@gmail.com> MIME-Version: 1.0 xen_piix3_set_irq() isn't PIIX specific: PIIX is a single PCI device while xen_piix3_set_irq() maps multiple PCI devices to their respective IRQs, which is board-specific. Rename xen_piix3_set_irq() to communicate this. Also rename XEN_PIIX_NUM_PIRQS to XEN_IOAPIC_NUM_PIRQS since the Xen's IOAPIC rather than PIIX has this many interrupt routes. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-2-shentey@gmail.com> --- include/hw/xen/xen.h | 2 +- hw/i386/xen/xen-hvm.c | 2 +- hw/isa/piix3.c | 4 ++-- stubs/xen-hw-stub.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 2bd8ec742d..37ecc91fc3 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -39,7 +39,7 @@ extern bool xen_domid_restrict; int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num); int xen_set_pci_link_route(uint8_t link, uint8_t irq); -void xen_piix3_set_irq(void *opaque, int irq_num, int level); +void xen_intx_set_irq(void *opaque, int irq_num, int level); void xen_hvm_inject_msi(uint64_t addr, uint32_t data); int xen_is_pirq_msi(uint32_t msi_data); diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 56641a550e..ab8f1b61ee 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -143,7 +143,7 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) return irq_num + (PCI_SLOT(pci_dev->devfn) << 2); } -void xen_piix3_set_irq(void *opaque, int irq_num, int level) +void xen_intx_set_irq(void *opaque, int irq_num, int level) { xen_set_pci_intx_level(xen_domid, 0, 0, irq_num >> 2, irq_num & 3, level); diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index a9cb39bf21..1b3e23f0d7 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -34,7 +34,7 @@ #include "migration/vmstate.h" #include "hw/acpi/acpi_aml_interface.h" -#define XEN_PIIX_NUM_PIRQS 128ULL +#define XEN_IOAPIC_NUM_PIRQS 128ULL static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq) { @@ -405,7 +405,7 @@ static void piix3_xen_realize(PCIDevice *dev, Error **errp) * connected to the IOAPIC directly. * These additional routes can be discovered through ACPI. */ - pci_bus_irqs(pci_bus, xen_piix3_set_irq, piix3, XEN_PIIX_NUM_PIRQS); + pci_bus_irqs(pci_bus, xen_intx_set_irq, piix3, XEN_IOAPIC_NUM_PIRQS); } static void piix3_xen_class_init(ObjectClass *klass, void *data) diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c index 34a22f2ad7..7d7ffe83a9 100644 --- a/stubs/xen-hw-stub.c +++ b/stubs/xen-hw-stub.c @@ -15,7 +15,7 @@ int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) return -1; } -void xen_piix3_set_irq(void *opaque, int irq_num, int level) +void xen_intx_set_irq(void *opaque, int irq_num, int level) { } From patchwork Mon Apr 3 07:41:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13197761 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F9BCC77B6E for ; Mon, 3 Apr 2023 07:42:02 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.517310.802453 (Exim 4.92) (envelope-from ) id 1pjEou-0000bP-CC; Mon, 03 Apr 2023 07:41:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 517310.802453; Mon, 03 Apr 2023 07:41:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEou-0000Xy-7F; Mon, 03 Apr 2023 07:41:40 +0000 Received: by outflank-mailman (input) for mailman id 517310; Mon, 03 Apr 2023 07:41:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEos-0000Sg-Jq for xen-devel@lists.xenproject.org; Mon, 03 Apr 2023 07:41:38 +0000 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [2a00:1450:4864:20::42c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f686a8af-d1f2-11ed-b464-930f4c7d94ae; Mon, 03 Apr 2023 09:41:36 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id m2so28256759wrh.6 for ; Mon, 03 Apr 2023 00:41:36 -0700 (PDT) Received: from Provence.localdomain (dynamic-078-055-162-106.78.55.pool.telefonica.de. [78.55.162.106]) by smtp.gmail.com with ESMTPSA id s11-20020a5d424b000000b002e5f6f8fc4fsm8414960wrr.100.2023.04.03.00.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 00:41:35 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f686a8af-d1f2-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680507696; 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=+2bxbqf6j4QPQJIwH9ivxbi0oLjhsXkO+rq7lp2Eh9U=; b=WC5szrsbsTKCY9H3NIUWRSbAOse9TsOnH1X01M7jJFEyCnqYih84GDL/KdBhBXgvfZ cxx71VQpcKF9zWdzMnSbkpc1hfesym5CJWKDjgWmFqmwEAZxtxhq8nOHsCyYPynIYrS9 BaLfK4jsrhCeSuXHGsXYL7fNzlE5hnc0hfC+2XsB/zKpBEIWgD6sfzdiEyxE4zaNCnEv 162tllbbB0sUjNuop5fu0nl/n19meZoUfNaKBn50XCNcWvdCal884QeT/q0SEepuboYT CVmM6NveJXfoFPYDUH3UGFCSnAI2AjW/EN4i3xu23N5hvy6np1jlESM9iiQdcFx39cPw K01w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680507696; 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=+2bxbqf6j4QPQJIwH9ivxbi0oLjhsXkO+rq7lp2Eh9U=; b=LhOJ1lrSYnxj9MUFQKCgjRAj4wr02EKrwj0qKL4X0Q1KJ6nnICaPdUCcN83T8IibM5 OC+Rw7sovmPOurnDKhNCYvMU4jGl7C1z6N+813c3+bREstJvF5T4cp+bgw9ox981fj9F SXkmRGdJpvr6F638m5Wh20ROF4bUF0uI/81/DWJsko4WOQtBbVoQUNJvUFBivV23gTE9 ImdwRgEo08kqM7gi+PZ2lGDJNj1ugsutJ1PFgbENyHeGyam153ZwxgFwPcL3Jr4r/MnP 8n+JBC9zZL2jZO73i8j/15Cl2yzn0+LljrmWM1Rm70tYL1LCC+MGkNimz4Suc7ctOtPN rMyw== X-Gm-Message-State: AAQBX9e6sQsde7vVErMC/G6l2yhvuNy3gBcdboCWV/dCPuzxYhE7UP8k OBb4IvexUDRVN5Qg/BfLn5E= X-Google-Smtp-Source: AKy350a8w/UjVGBXm/IvW1eiUEjt7WBOj3GvSpZIn/V9+4KAg1DkfQwNZGfsneF3GohAYNphgxwWGA== X-Received: by 2002:a05:6000:ca:b0:2d6:5afe:7b91 with SMTP id q10-20020a05600000ca00b002d65afe7b91mr11692241wrx.30.1680507696091; Mon, 03 Apr 2023 00:41:36 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Marcel Apfelbaum , David Woodhouse , Eduardo Habkost , Stefano Stabellini , Chuck Zmudzinski , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paul Durrant , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anthony Perard , xen-devel@lists.xenproject.org, Bernhard Beschow Subject: [PATCH v4 2/7] hw/pci/pci.c: Don't leak PCIBus::irq_count[] in pci_bus_irqs() Date: Mon, 3 Apr 2023 09:41:19 +0200 Message-Id: <20230403074124.3925-3-shentey@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403074124.3925-1-shentey@gmail.com> References: <20230403074124.3925-1-shentey@gmail.com> MIME-Version: 1.0 When calling pci_bus_irqs() multiple times on the same object without calling pci_bus_irqs_cleanup() in between PCIBus::irq_count[] is currently leaked. Let's fix this because Xen will do just that in a few commits, and because calling pci_bus_irqs_cleanup() in between seems fragile and cumbersome. Note that pci_bus_irqs_cleanup() now has to NULL irq_count such that pci_bus_irqs() doesn't do a double free. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin --- hw/pci/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index def5000e7b..be1c5d16ec 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -558,6 +558,7 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, bus->set_irq = set_irq; bus->irq_opaque = irq_opaque; bus->nirq = nirq; + g_free(bus->irq_count); bus->irq_count = g_malloc0(nirq * sizeof(bus->irq_count[0])); } @@ -573,6 +574,7 @@ void pci_bus_irqs_cleanup(PCIBus *bus) bus->irq_opaque = NULL; bus->nirq = 0; g_free(bus->irq_count); + bus->irq_count = NULL; } PCIBus *pci_register_root_bus(DeviceState *parent, const char *name, From patchwork Mon Apr 3 07:41:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13197756 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85A93C761A6 for ; Mon, 3 Apr 2023 07:41:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.517311.802462 (Exim 4.92) (envelope-from ) id 1pjEou-0000kS-QN; Mon, 03 Apr 2023 07:41:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 517311.802462; Mon, 03 Apr 2023 07:41:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEou-0000ie-J4; Mon, 03 Apr 2023 07:41:40 +0000 Received: by outflank-mailman (input) for mailman id 517311; Mon, 03 Apr 2023 07:41:38 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEos-0000Sf-IM for xen-devel@lists.xenproject.org; Mon, 03 Apr 2023 07:41:38 +0000 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [2a00:1450:4864:20::432]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f7281ec2-d1f2-11ed-85db-49a42c6b2330; Mon, 03 Apr 2023 09:41:37 +0200 (CEST) Received: by mail-wr1-x432.google.com with SMTP id t4so23024662wra.7 for ; Mon, 03 Apr 2023 00:41:38 -0700 (PDT) Received: from Provence.localdomain (dynamic-078-055-162-106.78.55.pool.telefonica.de. [78.55.162.106]) by smtp.gmail.com with ESMTPSA id s11-20020a5d424b000000b002e5f6f8fc4fsm8414960wrr.100.2023.04.03.00.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 00:41:37 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f7281ec2-d1f2-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680507697; 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=YTX5AlYG9H9wezF7Huuxzz/nE/nKnDO8ny1qnuzLZhc=; b=mtSXWDOaZ+SoOSRY+/QyXRKvT4i+55X7WZtDYWMATiHisig086+0JsHukwNdiJId7A tFqxCAoC4RwIQJM009Vk+jfFfOFlaKQrlmk2bTXjnhvW4+CF9lMXfKv1wHR3ukRMZW6Y CQyFaG+VXbo7bsLaY3JNaZ0O5jKXrhP2qIEG72Vjgf8MVH9BIMi5d+VGm5MfsEvzCudI GyrjyuNPJZrO+zweLhjAv7NojvLIUzr0fIDB8FyORUM/z/yAaS2dYmbZmQwIZzFXhz4c p7LFtBj/nJrdJSF6L2IGVCFNtgwR5DHDosc59QA+1G+LMTWWcV3o/frA6tmQ3zvYZ538 VF4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680507697; 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=YTX5AlYG9H9wezF7Huuxzz/nE/nKnDO8ny1qnuzLZhc=; b=AaGVptg30OZFuThAwmbjtugwjA87nIW8QbuDTEHAzXmyftRhPKHE3q7M1ZaJomU6m8 t/G6SZmG66qvyPNbGXlJdkm4Iw9WZfkDGTfPJWSvYwOvJpalESOk3t/xLJkTseM25M7J fWyK21RCy0VQ4VQwSGdSMN2vYvEogq0mpxhJujwotDzk1namkTN8YbAtG+KZp8kKA1MF XPxa/Yk/LcZuZAiMsSGZQkOAUKghYMa3BJbD5K8p1Y/KUCWYXRdRzi5fNXj2+ECJQc07 bdM647XOqleZUkHQY1gBvV2gZG6JTyH7d1X9w7kvLG+FQUdkpWqZr5fyDCdWx4o1Yroe gq2g== X-Gm-Message-State: AAQBX9caUHF64emzsEUrgQvyZk1mPrV+Munuk6rVUwq9r8nXpbbj9s6s TGVs+5GrHExRL8kI8c46Afw= X-Google-Smtp-Source: AKy350aggVxi8ptGEF+kz7DCXq42gtEfYkUb6ffP2AHigP6K835TVXtAlFx6fFv21AA1vyoQLxAQyA== X-Received: by 2002:adf:f388:0:b0:2db:46ad:7e82 with SMTP id m8-20020adff388000000b002db46ad7e82mr25915768wro.47.1680507697657; Mon, 03 Apr 2023 00:41:37 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Marcel Apfelbaum , David Woodhouse , Eduardo Habkost , Stefano Stabellini , Chuck Zmudzinski , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paul Durrant , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anthony Perard , xen-devel@lists.xenproject.org, Bernhard Beschow Subject: [PATCH v4 3/7] hw/isa/piix3: Reuse piix3_realize() in piix3_xen_realize() Date: Mon, 3 Apr 2023 09:41:20 +0200 Message-Id: <20230403074124.3925-4-shentey@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403074124.3925-1-shentey@gmail.com> References: <20230403074124.3925-1-shentey@gmail.com> MIME-Version: 1.0 This is a preparational patch for the next one to make the following more obvious: First, pci_bus_irqs() is now called twice in case of Xen where the second call overrides the pci_set_irq_fn with the Xen variant. Second, pci_bus_set_route_irq_fn() is now also called in Xen mode. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-3-shentey@gmail.com> --- hw/isa/piix3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 1b3e23f0d7..a86cd23ef4 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -394,7 +394,7 @@ static void piix3_xen_realize(PCIDevice *dev, Error **errp) PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev); PCIBus *pci_bus = pci_get_bus(dev); - pci_piix3_realize(dev, errp); + piix3_realize(dev, errp); if (*errp) { return; } From patchwork Mon Apr 3 07:41:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13197763 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0975DC77B62 for ; Mon, 3 Apr 2023 07:42:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.517312.802483 (Exim 4.92) (envelope-from ) id 1pjEox-0001R2-37; Mon, 03 Apr 2023 07:41:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 517312.802483; Mon, 03 Apr 2023 07:41:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEow-0001Qp-UM; Mon, 03 Apr 2023 07:41:42 +0000 Received: by outflank-mailman (input) for mailman id 517312; Mon, 03 Apr 2023 07:41:41 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEov-0000Sg-Cv for xen-devel@lists.xenproject.org; Mon, 03 Apr 2023 07:41:41 +0000 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [2a00:1450:4864:20::42c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f8582e01-d1f2-11ed-b464-930f4c7d94ae; Mon, 03 Apr 2023 09:41:39 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id m2so28256907wrh.6 for ; Mon, 03 Apr 2023 00:41:39 -0700 (PDT) Received: from Provence.localdomain (dynamic-078-055-162-106.78.55.pool.telefonica.de. [78.55.162.106]) by smtp.gmail.com with ESMTPSA id s11-20020a5d424b000000b002e5f6f8fc4fsm8414960wrr.100.2023.04.03.00.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 00:41:38 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f8582e01-d1f2-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680507699; 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=MUDyOxROyX57/HeZfnPOMpR49OmyPgdDYS4l8CKR3oE=; b=R0zQZHS1SVM2nbqIZon4bg3J/Tgs443HdjKKqxyVKw/W6M8PKg6fF5HqP9chCuyiBZ HJkytr0cpW/VhAlTB3rKHnd519d/mvwUbFIWVLXIvNSr48AXF6vTFq6fJUcOUmUH1iyB ueVnC/xQZaZZHpFPSVhx5W9HBRQbsjok895nYAKptZCyOKoD4Ib82ypomuw9roljaWLe IbWXzVNtIq89BY8uwqhgoY21w0gcpO0L4vbRyFCz5FSL/pxc3tWZ8/gLXOuRE9RPqc0/ 6HjlOpoi2+VFwd5ZeD8MBrf7WTl2dA38nm35BVoLZzH5VWDCu+75pIfnCT84gtQ11hI1 Ozwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680507699; 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=MUDyOxROyX57/HeZfnPOMpR49OmyPgdDYS4l8CKR3oE=; b=pyFym8FJryc37DMfPoMm0BNvathFLweFfvcs7lUdvXHbcLej+Up5li25tFq49LECuA uUGCy7pWwV6hcVyf3XUrrQ/6l7G0CUMbM1d1XTvSCU52V1JFUSLC7jKbnBOVJtEM0dRY +cBnrSrtMMEahxFK13XwSwgsqgQmqSsyebogy1u89YeLn2HphjQz4Fy226sctWfmtMY8 oxUMUUcVZPcwgJLBz0VzCMXpXpDmvokx22Vd1lyQZMNLevA8E5cs0takLFX7jomlwP8s tsXZJt1MwPoIdrL1556IPL6kPd5wO8U+LDxscuRBjR+0ud9bbi+3w6pPPEPr0TVI12P8 Qb7g== X-Gm-Message-State: AAQBX9fzzLab9MPnFqvnemnaAMGARgIZLqHd5wciCDkYm3V2mHvvDaiC stjTS8S4H8yRwtsreAnqTRo= X-Google-Smtp-Source: AKy350Z1aIPseQR+1yV2swwLLDz0AEwlN4YYIJAKAq+O5S9egcGZLOBJfv2d/bu2tqMGfhvjE7XU2g== X-Received: by 2002:adf:ed0e:0:b0:2d1:86e6:bd6 with SMTP id a14-20020adfed0e000000b002d186e60bd6mr26015599wro.22.1680507699461; Mon, 03 Apr 2023 00:41:39 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Marcel Apfelbaum , David Woodhouse , Eduardo Habkost , Stefano Stabellini , Chuck Zmudzinski , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paul Durrant , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anthony Perard , xen-devel@lists.xenproject.org, Bernhard Beschow Subject: [PATCH v4 4/7] hw/isa/piix3: Wire up Xen PCI IRQ handling outside of PIIX3 Date: Mon, 3 Apr 2023 09:41:21 +0200 Message-Id: <20230403074124.3925-5-shentey@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403074124.3925-1-shentey@gmail.com> References: <20230403074124.3925-1-shentey@gmail.com> MIME-Version: 1.0 xen_intx_set_irq() doesn't depend on PIIX3State. In order to resolve TYPE_PIIX3_XEN_DEVICE and in order to make Xen agnostic about the precise south bridge being used, set up Xen's PCI IRQ handling of PIIX3 in the board. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-4-shentey@gmail.com> --- hw/i386/pc_piix.c | 13 +++++++++++++ hw/isa/piix3.c | 24 +----------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 30eedd62a3..99232701b1 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -69,6 +69,7 @@ #include "kvm/kvm-cpu.h" #define MAX_IDE_BUS 2 +#define XEN_IOAPIC_NUM_PIRQS 128ULL #ifdef CONFIG_IDE_ISA static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; @@ -236,6 +237,18 @@ static void pc_init1(MachineState *machine, pcms->bus = pci_bus; pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type); + + if (xen_enabled()) { + /* + * Xen supports additional interrupt routes from the PCI devices to + * the IOAPIC: the four pins of each PCI device on the bus are also + * connected to the IOAPIC directly. + * These additional routes can be discovered through ACPI. + */ + pci_bus_irqs(pci_bus, xen_intx_set_irq, pci_dev, + XEN_IOAPIC_NUM_PIRQS); + } + piix3 = PIIX3_PCI_DEVICE(pci_dev); piix3->pic = x86ms->gsi; piix3_devfn = piix3->dev.devfn; diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index a86cd23ef4..7a31caf2b6 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -34,8 +34,6 @@ #include "migration/vmstate.h" #include "hw/acpi/acpi_aml_interface.h" -#define XEN_IOAPIC_NUM_PIRQS 128ULL - static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq) { qemu_set_irq(piix3->pic[pic_irq], @@ -388,32 +386,12 @@ static const TypeInfo piix3_info = { .class_init = piix3_class_init, }; -static void piix3_xen_realize(PCIDevice *dev, Error **errp) -{ - ERRP_GUARD(); - PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev); - PCIBus *pci_bus = pci_get_bus(dev); - - piix3_realize(dev, errp); - if (*errp) { - return; - } - - /* - * Xen supports additional interrupt routes from the PCI devices to - * the IOAPIC: the four pins of each PCI device on the bus are also - * connected to the IOAPIC directly. - * These additional routes can be discovered through ACPI. - */ - pci_bus_irqs(pci_bus, xen_intx_set_irq, piix3, XEN_IOAPIC_NUM_PIRQS); -} - static void piix3_xen_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->config_write = piix3_write_config_xen; - k->realize = piix3_xen_realize; + k->realize = piix3_realize; } static const TypeInfo piix3_xen_info = { From patchwork Mon Apr 3 07:41:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13197757 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4447C76196 for ; Mon, 3 Apr 2023 07:41:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.517313.802489 (Exim 4.92) (envelope-from ) id 1pjEox-0001Vc-Qg; Mon, 03 Apr 2023 07:41:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 517313.802489; Mon, 03 Apr 2023 07:41:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEox-0001Uw-Fe; Mon, 03 Apr 2023 07:41:43 +0000 Received: by outflank-mailman (input) for mailman id 517313; Mon, 03 Apr 2023 07:41:42 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEow-0000Sg-LN for xen-devel@lists.xenproject.org; Mon, 03 Apr 2023 07:41:42 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f900dbb0-d1f2-11ed-b464-930f4c7d94ae; Mon, 03 Apr 2023 09:41:41 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id q19so25188101wrc.5 for ; Mon, 03 Apr 2023 00:41:41 -0700 (PDT) Received: from Provence.localdomain (dynamic-078-055-162-106.78.55.pool.telefonica.de. [78.55.162.106]) by smtp.gmail.com with ESMTPSA id s11-20020a5d424b000000b002e5f6f8fc4fsm8414960wrr.100.2023.04.03.00.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 00:41:40 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f900dbb0-d1f2-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680507700; 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=/EuJujhhzp9QT+Va/F4M2q8YBrUEweb2g4rehnqe99A=; b=hcViKZ3qPuwgtA4SsDAiRVSOd64zBPnpHxw+0VBLBeB50VFc/rKXi7fhu7V71wdQ1h FxpfO/RXYDuxhNYh2ttxusHsPNk+t2vE9+H9K9bhKMFQmuSkwffp5fkmeD16xMkbxQQ3 LXpNEKoDVtB45+OBM29Ey1FV8APapXHq6pMgasM66BMhL7Waih4O+UCiJoBRyIbd16zz 253w1Lis8Qh0rRlo2FH1+2zh1X8aqANyAQo//WYFAC4MkQPKgVheB4UURa3XhtGzyOrn Ar8I+OmZhfK340m5fuvAT+mWzcInzHAYzg7cJgstXkUtstVizW6nuDwjuLuv0636VIOC vMaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680507700; 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=/EuJujhhzp9QT+Va/F4M2q8YBrUEweb2g4rehnqe99A=; b=6plzb2sA43gsEP/CVhZbUjoeZvud1nFOfz1DbYNc95xZQOw+BubRGk+v5Ou4sDwStb FAqIhkMt3BxAtbcybU4854I6+kHTDmBGWL0HcQtopakmt4f1b0n8DA5VF/MjOTzvTL8k YM5pX35klguz1oKeujsBaxwE9UkoOBOiNVLgwFlOQSdrc6qt7dppZq5tuSyMvXW48Vyd QsajlBU66Quqi2/ZvHLSVyq0j5kSnnz6oIcb0vsbkvpUsa3+mma0kPJ+pFvVyzBCtUE7 9w2pUwFjrpY6QxoUtUgsaBxrL0LuRUY0/aIyHj2fEdmusQVieCqLxC7e0XIjpCcvDpCw P/UQ== X-Gm-Message-State: AAQBX9fLrG0UrKej9kIIo9Yd4CJFt3RFLJVpHiqRmrKJ8cp24I75pwbw UxoFljOlS5XR9wKflhbVRoA= X-Google-Smtp-Source: AKy350ZZP0vLfS334AXJ1QOOCUu1Iz6IfelFWZ0j6MBXF/9ON1OR+oP0rMSuxPQc4qp6H8kpAFlguw== X-Received: by 2002:a5d:68cb:0:b0:2cf:fd6:b83f with SMTP id p11-20020a5d68cb000000b002cf0fd6b83fmr12153147wrw.8.1680507700653; Mon, 03 Apr 2023 00:41:40 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Marcel Apfelbaum , David Woodhouse , Eduardo Habkost , Stefano Stabellini , Chuck Zmudzinski , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paul Durrant , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anthony Perard , xen-devel@lists.xenproject.org, Bernhard Beschow Subject: [PATCH v4 5/7] hw/isa/piix3: Avoid Xen-specific variant of piix3_write_config() Date: Mon, 3 Apr 2023 09:41:22 +0200 Message-Id: <20230403074124.3925-6-shentey@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403074124.3925-1-shentey@gmail.com> References: <20230403074124.3925-1-shentey@gmail.com> MIME-Version: 1.0 Subscribe to pci_bus_fire_intx_routing_notifier() instead which allows for having a common piix3_write_config() for the PIIX3 device models. While at it, move the subscription into machine code to facilitate resolving TYPE_PIIX3_XEN_DEVICE. In a possible future followup, pci_bus_fire_intx_routing_notifier() could be adjusted in such a way that subscribing to it doesn't require knowledge of the device firing it. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-5-shentey@gmail.com> --- hw/i386/pc_piix.c | 18 ++++++++++++++++++ hw/isa/piix3.c | 22 +--------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 99232701b1..1b70470dcd 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -88,6 +88,21 @@ static int pc_pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx) return (pci_intx + slot_addend) & 3; } +static void piix_intx_routing_notifier_xen(PCIDevice *dev) +{ + int i; + + /* Scan for updates to PCI link routes (0x60-0x63). */ + for (i = 0; i < PIIX_NUM_PIRQS; i++) { + uint8_t v = dev->config_read(dev, PIIX_PIRQCA + i, 1); + if (v & 0x80) { + v = 0; + } + v &= 0xf; + xen_set_pci_link_route(i, v); + } +} + /* PC hardware initialisation */ static void pc_init1(MachineState *machine, const char *host_type, const char *pci_type) @@ -239,6 +254,9 @@ static void pc_init1(MachineState *machine, pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type); if (xen_enabled()) { + pci_device_set_intx_routing_notifier( + pci_dev, piix_intx_routing_notifier_xen); + /* * Xen supports additional interrupt routes from the PCI devices to * the IOAPIC: the four pins of each PCI device on the bus are also diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 7a31caf2b6..737f5c6a5d 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -121,26 +121,6 @@ static void piix3_write_config(PCIDevice *dev, } } -static void piix3_write_config_xen(PCIDevice *dev, - uint32_t address, uint32_t val, int len) -{ - int i; - - /* Scan for updates to PCI link routes (0x60-0x63). */ - for (i = 0; i < len; i++) { - uint8_t v = (val >> (8 * i)) & 0xff; - if (v & 0x80) { - v = 0; - } - v &= 0xf; - if (((address + i) >= PIIX_PIRQCA) && ((address + i) <= PIIX_PIRQCD)) { - xen_set_pci_link_route(address + i - PIIX_PIRQCA, v); - } - } - - piix3_write_config(dev, address, val, len); -} - static void piix3_reset(DeviceState *dev) { PIIX3State *d = PIIX3_PCI_DEVICE(dev); @@ -390,7 +370,7 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->config_write = piix3_write_config_xen; + k->config_write = piix3_write_config; k->realize = piix3_realize; } From patchwork Mon Apr 3 07:41:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13197758 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81A5BC77B6D for ; Mon, 3 Apr 2023 07:42:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.517314.802503 (Exim 4.92) (envelope-from ) id 1pjEp0-000206-6x; Mon, 03 Apr 2023 07:41:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 517314.802503; Mon, 03 Apr 2023 07:41:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEoz-0001zq-WC; Mon, 03 Apr 2023 07:41:45 +0000 Received: by outflank-mailman (input) for mailman id 517314; Mon, 03 Apr 2023 07:41:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEox-0000Sg-Vv for xen-devel@lists.xenproject.org; Mon, 03 Apr 2023 07:41:44 +0000 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [2a00:1450:4864:20::331]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f9d7953e-d1f2-11ed-b464-930f4c7d94ae; Mon, 03 Apr 2023 09:41:42 +0200 (CEST) Received: by mail-wm1-x331.google.com with SMTP id i5-20020a05600c354500b003edd24054e0so19144066wmq.4 for ; Mon, 03 Apr 2023 00:41:42 -0700 (PDT) Received: from Provence.localdomain (dynamic-078-055-162-106.78.55.pool.telefonica.de. [78.55.162.106]) by smtp.gmail.com with ESMTPSA id s11-20020a5d424b000000b002e5f6f8fc4fsm8414960wrr.100.2023.04.03.00.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 00:41:41 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f9d7953e-d1f2-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680507702; 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=xfruqCTvdLb6qQjpwkCpa8vgF1IvHI8+CFma9+fgJv8=; b=EAQ6n7WWQXPUjZaBzzBlO5S8qeAHPTlk8U7zS3dcf+8IIdkYRF+t76elBK5JMC6VvR MlevLDBVnopzGlcluD5E3paMkO9gGmS9AiWXwbBxrmfV6aY677J1hA7sEoOMZsusRhCO WtNuC4TBrqU9huTBhT4qaoJ3hKFDLVLwR3Q492RbdYmNN96sEoQRc05zQjYNBPUaYgFS wlTsF3d6qB4+ivcvqD/tRWrRuT7ASZ49jVudbsUe4HaCkTh0Jf88+s+oA9GGmu4u4jN4 MYC4GsrKHzZxdgEsprYEQvYQ9+pe1/Pfl0wcjSFYsZgQhf3t0h8B31q//5p9hTJOJ1Gu dYlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680507702; 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=xfruqCTvdLb6qQjpwkCpa8vgF1IvHI8+CFma9+fgJv8=; b=Enkqb0ZqCfehwenYG9frKYj8zkkeBn40frY8jQ9i+tFNFIziC3p1O7KqWkAYCSC2Wt DLAfN403eElT8qoLHR97cSZDeZiCFTO794t0jZg/P0IBl6/U5oWlGafWiI7qs0MghWBL l6jvVNvMBr+UhLs3hX7VSfs/5KGsekTXahH2+R9QI12QmHrWBa99P/TgbEwRhGl0t94D RNyz3YInT4pTBqv9K3uyrAixugtu7JNJUpBg6hrWI0DBpAthCBvvcuyN4EUV9rLnO+9X QO/S6jWk7TRerZbug6725JYJ7AINZq106tnIDYcFl464N4h5mX/sb2/35ilSTpX3At0Y tfmg== X-Gm-Message-State: AO0yUKX1lAKtH8emrffrpDfAf4dTi/U7FY3N/EaGeH0COB39+XX2iEWx M97HPHRG4wNTFIRE6+wrwXs= X-Google-Smtp-Source: AK7set9rrvyB0aTyq/IlC7IjQSr4MJ3b4hfbs5XNaEHQCEylCJMqyaqqp21kfc6RgszwCmJPmkED8Q== X-Received: by 2002:a1c:770c:0:b0:3ed:454d:36ab with SMTP id t12-20020a1c770c000000b003ed454d36abmr25688857wmi.16.1680507701818; Mon, 03 Apr 2023 00:41:41 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Marcel Apfelbaum , David Woodhouse , Eduardo Habkost , Stefano Stabellini , Chuck Zmudzinski , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paul Durrant , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anthony Perard , xen-devel@lists.xenproject.org, Bernhard Beschow Subject: [PATCH v4 6/7] hw/isa/piix3: Resolve redundant k->config_write assignments Date: Mon, 3 Apr 2023 09:41:23 +0200 Message-Id: <20230403074124.3925-7-shentey@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403074124.3925-1-shentey@gmail.com> References: <20230403074124.3925-1-shentey@gmail.com> MIME-Version: 1.0 The previous patch unified handling of piix3_write_config() accross the PIIX3 device models which allows for assigning k->config_write once in the base class. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-6-shentey@gmail.com> --- hw/isa/piix3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 737f5c6a5d..418940139d 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -308,6 +308,7 @@ static void pci_piix3_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass); + k->config_write = piix3_write_config; dc->reset = piix3_reset; dc->desc = "ISA bridge"; dc->vmsd = &vmstate_piix3; @@ -356,7 +357,6 @@ static void piix3_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->config_write = piix3_write_config; k->realize = piix3_realize; } @@ -370,7 +370,6 @@ static void piix3_xen_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->config_write = piix3_write_config; k->realize = piix3_realize; } From patchwork Mon Apr 3 07:41:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 13197759 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62121C77B62 for ; Mon, 3 Apr 2023 07:42:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.517315.802512 (Exim 4.92) (envelope-from ) id 1pjEp1-0002GR-L7; Mon, 03 Apr 2023 07:41:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 517315.802512; Mon, 03 Apr 2023 07:41:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEp1-0002FC-DC; Mon, 03 Apr 2023 07:41:47 +0000 Received: by outflank-mailman (input) for mailman id 517315; Mon, 03 Apr 2023 07:41:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pjEoz-0000Sg-4z for xen-devel@lists.xenproject.org; Mon, 03 Apr 2023 07:41:45 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fa87ecf0-d1f2-11ed-b464-930f4c7d94ae; Mon, 03 Apr 2023 09:41:43 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id d17so28232998wrb.11 for ; Mon, 03 Apr 2023 00:41:43 -0700 (PDT) Received: from Provence.localdomain (dynamic-078-055-162-106.78.55.pool.telefonica.de. [78.55.162.106]) by smtp.gmail.com with ESMTPSA id s11-20020a5d424b000000b002e5f6f8fc4fsm8414960wrr.100.2023.04.03.00.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Apr 2023 00:41:42 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fa87ecf0-d1f2-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680507703; 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=bFBFz6LEBXPSgQcOvP8yki+MQL0SlRe8vWuNcy1ofyc=; b=JnS3k4VnUoa2yBgFGDVDqacBd2DdaZDlI+9R3AWOFhe3KjznQtcT72nyHz3M0NNxPI BHk7+yVafEuJZsDmpI86KxWZdZSFBDFQejFdT++2yketIkY99aI1HrLv2dP9MnPjHQBs epvt+PyDpEF8mjOGr9ueoeGBlgS296BEv6sUEJ1Plv/gcSrfBpTUUOoN369ZxcDeBnJJ fC5SM5o/FYODXJeS0jB6XOoeGVOgSkOpHdlRV5MgT+SPRphnIdELNl11dGfm/A0PKLPN PjSXjmBBRUqR2fA/eTLELJx/ttMNy1M7gpFYGMCRRK1Cbtc4/GQjStDehV6+jgrR63Ry NCWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680507703; 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=bFBFz6LEBXPSgQcOvP8yki+MQL0SlRe8vWuNcy1ofyc=; b=UR1KvIKcPOl6dT4+2vN9pqbgNlDFTic4ZAxUwuA3FGCvBiPiBvmevhg1RfaVWlkJ+x 8/DA8+1pGHG7AHdsTg5haT0GB9l0zaVkML0NksXGpwJECNWEM/56FuVNc3tAYZY+aJi6 trc0TFIw3JNoOM4O0pQ2ME4JQJw+jgo226wR3LUlldYcP5fPPJaRtJYgMA0Lx+U+EeGd 4nG8JiXLhXYomHd2wJ68GLlStQHroCgWmryKKi7LL7iTLe4kP+KvTEySaOW6rpRrO0YC ekIvMGz3nFFogtYeHP4IAdBbG/IRJXhrRVIdFiFAi3+ZBZT3v1TLypWiaTJ+ToadNm2m zP6A== X-Gm-Message-State: AAQBX9caf9M+lsw9VWm9dKozHB/Zikroy5ktDGtOvN6muE2M3EXavdfp 17S66CJH6ZIX6tn9BBc65fs= X-Google-Smtp-Source: AKy350YQYzXtoXYV33vsug2IkHk8dVMjKWMW4Vgyul9fIIKt/0YfXdy2ovrIHW0LfhNXns7sxctNuA== X-Received: by 2002:adf:fd51:0:b0:2ce:adda:f45a with SMTP id h17-20020adffd51000000b002ceaddaf45amr25195402wrs.62.1680507703148; Mon, 03 Apr 2023 00:41:43 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Marcel Apfelbaum , David Woodhouse , Eduardo Habkost , Stefano Stabellini , Chuck Zmudzinski , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= , Paul Durrant , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anthony Perard , xen-devel@lists.xenproject.org, Bernhard Beschow Subject: [PATCH v4 7/7] hw/isa/piix3: Resolve redundant TYPE_PIIX3_XEN_DEVICE Date: Mon, 3 Apr 2023 09:41:24 +0200 Message-Id: <20230403074124.3925-8-shentey@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230403074124.3925-1-shentey@gmail.com> References: <20230403074124.3925-1-shentey@gmail.com> MIME-Version: 1.0 During the last patches, TYPE_PIIX3_XEN_DEVICE turned into a clone of TYPE_PIIX3_DEVICE. Remove this redundancy. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Reviewed-by: Anthony PERARD Tested-by: Chuck Zmudzinski Message-Id: <20230312120221.99183-7-shentey@gmail.com> --- include/hw/southbridge/piix.h | 1 - hw/i386/pc_piix.c | 5 ++--- hw/isa/piix3.c | 15 --------------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h index 0bf48e936d..51be04e984 100644 --- a/include/hw/southbridge/piix.h +++ b/include/hw/southbridge/piix.h @@ -64,7 +64,6 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE, TYPE_PIIX3_PCI_DEVICE) #define TYPE_PIIX3_DEVICE "PIIX3" -#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen" #define TYPE_PIIX4_PCI_DEVICE "piix4-isa" #endif diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1b70470dcd..7ca0d6d14e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -237,8 +237,6 @@ static void pc_init1(MachineState *machine, if (pcmc->pci_enabled) { PIIX3State *piix3; PCIDevice *pci_dev; - const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE - : TYPE_PIIX3_DEVICE; pci_bus = i440fx_init(pci_type, i440fx_host, @@ -251,7 +249,8 @@ static void pc_init1(MachineState *machine, : pc_pci_slot_get_pirq); pcms->bus = pci_bus; - pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type); + pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, + TYPE_PIIX3_DEVICE); if (xen_enabled()) { pci_device_set_intx_routing_notifier( diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 418940139d..0d6992af67 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -29,7 +29,6 @@ #include "hw/southbridge/piix.h" #include "hw/irq.h" #include "hw/isa/isa.h" -#include "hw/xen/xen.h" #include "sysemu/runstate.h" #include "migration/vmstate.h" #include "hw/acpi/acpi_aml_interface.h" @@ -366,24 +365,10 @@ static const TypeInfo piix3_info = { .class_init = piix3_class_init, }; -static void piix3_xen_class_init(ObjectClass *klass, void *data) -{ - PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - - k->realize = piix3_realize; -} - -static const TypeInfo piix3_xen_info = { - .name = TYPE_PIIX3_XEN_DEVICE, - .parent = TYPE_PIIX3_PCI_DEVICE, - .class_init = piix3_xen_class_init, -}; - static void piix3_register_types(void) { type_register_static(&piix3_pci_type_info); type_register_static(&piix3_info); - type_register_static(&piix3_xen_info); } type_init(piix3_register_types)