From patchwork Tue Dec 31 20:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854413 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089764wrq; Tue, 31 Dec 2024 12:24:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUYK5tivxfLkvCm7F8yNoBVn2l3gpXcNnQNqyBTYbQ8ewjtoCV6JOTiSQVnSqBVkmj2dwEsig==@linaro.org X-Google-Smtp-Source: AGHT+IEb76MPMf5wNGcFA82bSpsvPOUpEWpzw8DG8EJKTJtkITBzAagD5VHiwIv2sag8BGyI1Rms X-Received: by 2002:a05:622a:1994:b0:467:5d0b:c750 with SMTP id d75a77b69052e-46a4a8dcbdbmr668482951cf.22.1735676678807; Tue, 31 Dec 2024 12:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676678; cv=none; d=google.com; s=arc-20240605; b=RyF452lAI5YUuz4dvBUNNEk+TPFWAXQihlbLQgHswnCO84tsMWCst4ZV+0ZE17gjFH RATu5np9PVBbOLeBlkyqDZRekQvRQpH/g99QLkmzeibctGbBssUwoopULAqkalMNG45l F6W4Flq7pamvUT6Xpv96+oSIOc4qNabVx6gOtt9iiJhK3XVQ8MKcLI9F1ZkGQbWwwzYW lYyoxWcAL0tkYbAtbjVv91oHim15C2ikTgH+5qVpFurdKlAbHpBhG/X16ITgdfSNFpP/ 1f4CSUAFHuGHwPC/9Sq4OMAvDDRK8upjRiO63dgTXZdntTYKT0kg0884h/vBs+dmkkFl q6AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nBzM81uP30tLCurlqk6Z1egorAnZptANh2R3BtB1/rs=; fh=JfjgrjACOQYSbU1oI5IucLYY0iFzHOFn64TDAErOBec=; b=dbO1BZz5Z0/mKW63flsQCb5qxxNIIKQVz5zyIEIbPOswy5m/uhMQq/zxN24itd+fP8 Tdxst+vvY06oTCcRBzGucishHd75wyWW2OoQCO/xW4Ct0RBRUEYKmyFMEtr1eZYO3gzk Xgtt9hTSP8NNybW8d+NsmrMoWI18nRVE/xosF8AhFH968SLL2iz7rJBwneut0Eh/31jb TyUtvn3kL7p5P304k2jvideHhSTSRDjhNhmDV7q/TZUnp4WcmQVN5QJQb7iRV+MVdzpn p6n1SmBG3auauzVs50q8czJylQpRM+qQ0wkVxQfShv7dThpBB6z42NFgNkmicMYz8HW3 nlMg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dQmwFEOC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac2ab8bcsi3588871785a.128.2024.12.31.12.24.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dQmwFEOC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSilE-0002It-RY; Tue, 31 Dec 2024 15:22:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilD-0002Ik-6G for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:39 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilA-0000o8-UP for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:38 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4363dc916ceso66465595e9.0 for ; Tue, 31 Dec 2024 12:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676555; x=1736281355; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nBzM81uP30tLCurlqk6Z1egorAnZptANh2R3BtB1/rs=; b=dQmwFEOCny7cV4YjRZ8AziOeKEznkxBAlpTISNVSXdzTcekpmHefqvz3kNOtuMzNaa TEjFdwUZAG9LmVtelv/IrULzE7TgqwXKsw6Rzm+kOy2N+IEf1fjpim68zGumMiRLn2f9 63J+NrUrUE3NgzIuR9gSJww2Dy8qE5295UlPIngy6YV9Qe7msSZHO1a/EwhaY8hSjbkz eZEHRj2Jr1G0jxUtNbhjN0hng2SDdXe90YFTK1dS6YZRmElVP1sfDG9bZGF5NUP2H7Wc xYEkQIVB8OZ283BfBE8wC+mQp7ocYW721sf3bJUYNfaR6ZiWeLIfw9ohBNdeCxnUwoNz B02w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676555; x=1736281355; 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=nBzM81uP30tLCurlqk6Z1egorAnZptANh2R3BtB1/rs=; b=OtXEufTN+o3RcdPiotbly3CONVRqfC9e1W4ILjarjdpLZ+2CXY/+Db4F05t1C7+QJl o+2zhv7lJBoZoRXsy8jfKXI22sUd79L45cpuNdGaQjwQqoNpX26cGCfcsSqq+IaqYliH x5Z2nX6qnQadagBH3T8z8EeDGyRXLhaxDn6fMMDA4fOsw3CmYeAdIrC/FASlg+doSiqY gXVQh0VK1pwdq7D+EFFAaZyQvbKXlXUJ4+K4cqrdoX1GR7iNNr812RHU9hq212PMrcem h3NK6LVCrqRYc3gGTAaljkG0v8vmLkow0a5nCZOIs+PNJT8+0V1ZYXc1gk9CeGUkFpyY RNoQ== X-Gm-Message-State: AOJu0YxiBieV6KfnZUETijslrHrVbEi/DUCf5pePSTjhKXq+yjpo1AbQ TqpZogseXPE/QexFzXyeADeS/ZgK7Vdou1zDI4ihZRD7zXQx01yi2Wbgg+mNMRIYANVA3Xcj3OM yR9o= X-Gm-Gg: ASbGnctKXlHKCKy1jFrK/fijtSI2B9YSOHMRODO4iaXwkTabwKs3pYLlxudXn/YWCwn zTunAFjy1xvnLcJb+kfbt3GkaKGLUNy8aaZ7IZwEZ8bQs4C2rCcPL8LnJcn2PXfbtShr4pJYqvl UpZXsp/PM9bIsRf89Xq6N2gShrhHI5Sktv+cb3HNMyq86C42g1Q9yHNx6irRIvoE4OBrKfL6jcp k3qomRrRwCG0oHgquj7cDKxkPDyAG+AH2BTNAyEFPajO53FC55JW6Xyh1PxZ3wChPLl7SWko5kB 5cCpY0WqPnaM0XGgr8VEdqZAPl9rNsM= X-Received: by 2002:a05:600c:450f:b0:434:9f90:2583 with SMTP id 5b1f17b1804b1-4365c79294amr370722205e9.11.1735676554995; Tue, 31 Dec 2024 12:22:34 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366128a62asm394652375e9.44.2024.12.31.12.22.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:22:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alexander Graf , Phil Dennis-Jordan , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 01/29] hw/pci-host/gpex: Allow more than 4 legacy IRQs Date: Tue, 31 Dec 2024 21:22:00 +0100 Message-ID: <20241231202228.28819-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alexander Graf Some boards such as vmapple don't do real legacy PCI IRQ swizzling. Instead, they just keep allocating more board IRQ lines for each new legacy IRQ. Let's support that mode by giving instantiators a new "nr_irqs" property they can use to support more than 4 legacy IRQ lines. In this mode, GPEX will export more IRQ lines, one for each device. Signed-off-by: Alexander Graf Signed-off-by: Phil Dennis-Jordan Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241223221645.29911-9-phil@philjordan.eu> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci-host/gpex.h | 7 +++---- hw/arm/sbsa-ref.c | 2 +- hw/arm/virt.c | 2 +- hw/i386/microvm.c | 2 +- hw/loongarch/virt.c | 12 +++++------ hw/mips/loongson3_virt.c | 2 +- hw/openrisc/virt.c | 12 +++++------ hw/pci-host/gpex.c | 43 ++++++++++++++++++++++++++++++-------- hw/riscv/virt.c | 12 +++++------ hw/xen/xen-pvh-common.c | 2 +- hw/xtensa/virt.c | 2 +- 11 files changed, 61 insertions(+), 37 deletions(-) diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h index dce883573ba..84471533af0 100644 --- a/include/hw/pci-host/gpex.h +++ b/include/hw/pci-host/gpex.h @@ -32,8 +32,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(GPEXHost, GPEX_HOST) #define TYPE_GPEX_ROOT_DEVICE "gpex-root" OBJECT_DECLARE_SIMPLE_TYPE(GPEXRootState, GPEX_ROOT_DEVICE) -#define GPEX_NUM_IRQS 4 - struct GPEXRootState { /*< private >*/ PCIDevice parent_obj; @@ -49,6 +47,7 @@ struct GPEXConfig { PCIBus *bus; }; +typedef struct GPEXIrq GPEXIrq; struct GPEXHost { /*< private >*/ PCIExpressHost parent_obj; @@ -60,8 +59,8 @@ struct GPEXHost { MemoryRegion io_mmio; MemoryRegion io_ioport_window; MemoryRegion io_mmio_window; - qemu_irq irq[GPEX_NUM_IRQS]; - int irq_num[GPEX_NUM_IRQS]; + GPEXIrq *irq; + uint8_t num_irqs; bool allow_unmapped_accesses; diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 581655d7716..6183111f2de 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -673,7 +673,7 @@ static void create_pcie(SBSAMachineState *sms) /* Map IO port space */ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, qdev_get_gpio_in(sms->gic, irq + i)); gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index f9b33808157..99e0a68b6c5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1547,7 +1547,7 @@ static void create_pcie(VirtMachineState *vms) /* Map IO port space */ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, qdev_get_gpio_in(vms->gic, irq + i)); gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index c3d7fe3c428..a8d354aabe5 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -139,7 +139,7 @@ static void create_gpex(MicrovmMachineState *mms) mms->gpex.mmio64.base, mmio64_alias); } - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, x86ms->gsi[mms->gpex.irq + i]); } diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 99594a13a0c..60bd4dc9d35 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -452,7 +452,7 @@ static void fdt_add_pcie_irq_map_node(const LoongArchVirtMachineState *lvms, { int pin, dev; uint32_t irq_map_stride = 0; - uint32_t full_irq_map[GPEX_NUM_IRQS *GPEX_NUM_IRQS * 10] = {}; + uint32_t full_irq_map[PCI_NUM_PINS * PCI_NUM_PINS * 10] = {}; uint32_t *irq_map = full_irq_map; const MachineState *ms = MACHINE(lvms); @@ -465,11 +465,11 @@ static void fdt_add_pcie_irq_map_node(const LoongArchVirtMachineState *lvms, * to wrap to any number of devices. */ - for (dev = 0; dev < GPEX_NUM_IRQS; dev++) { + for (dev = 0; dev < PCI_NUM_PINS; dev++) { int devfn = dev * 0x8; - for (pin = 0; pin < GPEX_NUM_IRQS; pin++) { - int irq_nr = 16 + ((pin + PCI_SLOT(devfn)) % GPEX_NUM_IRQS); + for (pin = 0; pin < PCI_NUM_PINS; pin++) { + int irq_nr = 16 + ((pin + PCI_SLOT(devfn)) % PCI_NUM_PINS); int i = 0; /* Fill PCI address cells */ @@ -493,7 +493,7 @@ static void fdt_add_pcie_irq_map_node(const LoongArchVirtMachineState *lvms, qemu_fdt_setprop(ms->fdt, nodename, "interrupt-map", full_irq_map, - GPEX_NUM_IRQS * GPEX_NUM_IRQS * + PCI_NUM_PINS * PCI_NUM_PINS * irq_map_stride * sizeof(uint32_t)); qemu_fdt_setprop_cells(ms->fdt, nodename, "interrupt-map-mask", 0x1800, 0, 0, 0x7); @@ -805,7 +805,7 @@ static void virt_devices_init(DeviceState *pch_pic, memory_region_add_subregion(get_system_memory(), VIRT_PCI_IO_BASE, pio_alias); - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { sysbus_connect_irq(d, i, qdev_get_gpio_in(pch_pic, 16 + i)); gpex_set_irq_num(GPEX_HOST(gpex_dev), i, 16 + i); diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index f12f8c3d3cc..f3cc7a8376f 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -458,7 +458,7 @@ static inline void loongson3_virt_devices_init(MachineState *machine, virt_memmap[VIRT_PCIE_PIO].base, s->pio_alias); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, virt_memmap[VIRT_PCIE_PIO].base); - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { irq = qdev_get_gpio_in(pic, PCIE_IRQ_BASE + i); sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); gpex_set_irq_num(GPEX_HOST(dev), i, PCIE_IRQ_BASE + i); diff --git a/hw/openrisc/virt.c b/hw/openrisc/virt.c index 0d83e33f9ea..22ae057992e 100644 --- a/hw/openrisc/virt.c +++ b/hw/openrisc/virt.c @@ -318,7 +318,7 @@ static void create_pcie_irq_map(void *fdt, char *nodename, int irq_base, { int pin, dev; uint32_t irq_map_stride = 0; - uint32_t full_irq_map[GPEX_NUM_IRQS * GPEX_NUM_IRQS * 6] = {}; + uint32_t full_irq_map[PCI_NUM_PINS * PCI_NUM_PINS * 6] = {}; uint32_t *irq_map = full_irq_map; /* @@ -330,11 +330,11 @@ static void create_pcie_irq_map(void *fdt, char *nodename, int irq_base, * possible slot) seeing the interrupt-map-mask will allow the table * to wrap to any number of devices. */ - for (dev = 0; dev < GPEX_NUM_IRQS; dev++) { + for (dev = 0; dev < PCI_NUM_PINS; dev++) { int devfn = dev << 3; - for (pin = 0; pin < GPEX_NUM_IRQS; pin++) { - int irq_nr = irq_base + ((pin + PCI_SLOT(devfn)) % GPEX_NUM_IRQS); + for (pin = 0; pin < PCI_NUM_PINS; pin++) { + int irq_nr = irq_base + ((pin + PCI_SLOT(devfn)) % PCI_NUM_PINS); int i = 0; /* Fill PCI address cells */ @@ -357,7 +357,7 @@ static void create_pcie_irq_map(void *fdt, char *nodename, int irq_base, } qemu_fdt_setprop(fdt, nodename, "interrupt-map", full_irq_map, - GPEX_NUM_IRQS * GPEX_NUM_IRQS * + PCI_NUM_PINS * PCI_NUM_PINS * irq_map_stride * sizeof(uint32_t)); qemu_fdt_setprop_cells(fdt, nodename, "interrupt-map-mask", @@ -409,7 +409,7 @@ static void openrisc_virt_pcie_init(OR1KVirtState *state, memory_region_add_subregion(get_system_memory(), pio_base, alias); /* Connect IRQ lines. */ - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { pcie_irq = get_per_cpu_irq(cpus, num_cpus, irq_base + i); sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pcie_irq); diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c index c6aa8e87a22..9fcedd7fc58 100644 --- a/hw/pci-host/gpex.c +++ b/hw/pci-host/gpex.c @@ -32,6 +32,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/irq.h" +#include "hw/pci/pci_bus.h" #include "hw/pci-host/gpex.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" @@ -41,20 +42,25 @@ * GPEX host */ +struct GPEXIrq { + qemu_irq irq; + int irq_num; +}; + static void gpex_set_irq(void *opaque, int irq_num, int level) { GPEXHost *s = opaque; - qemu_set_irq(s->irq[irq_num], level); + qemu_set_irq(s->irq[irq_num].irq, level); } int gpex_set_irq_num(GPEXHost *s, int index, int gsi) { - if (index >= GPEX_NUM_IRQS) { + if (index >= s->num_irqs) { return -EINVAL; } - s->irq_num[index] = gsi; + s->irq[index].irq_num = gsi; return 0; } @@ -62,7 +68,7 @@ static PCIINTxRoute gpex_route_intx_pin_to_irq(void *opaque, int pin) { PCIINTxRoute route; GPEXHost *s = opaque; - int gsi = s->irq_num[pin]; + int gsi = s->irq[pin].irq_num; route.irq = gsi; if (gsi < 0) { @@ -74,6 +80,13 @@ static PCIINTxRoute gpex_route_intx_pin_to_irq(void *opaque, int pin) return route; } +static int gpex_swizzle_map_irq_fn(PCIDevice *pci_dev, int pin) +{ + PCIBus *bus = pci_device_root_bus(pci_dev); + + return (PCI_SLOT(pci_dev->devfn) + pin) % bus->nirq; +} + static void gpex_host_realize(DeviceState *dev, Error **errp) { PCIHostState *pci = PCI_HOST_BRIDGE(dev); @@ -82,6 +95,8 @@ static void gpex_host_realize(DeviceState *dev, Error **errp) PCIExpressHost *pex = PCIE_HOST_BRIDGE(dev); int i; + s->irq = g_malloc0_n(s->num_irqs, sizeof(*s->irq)); + pcie_host_mmcfg_init(pex, PCIE_MMCFG_SIZE_MAX); sysbus_init_mmio(sbd, &pex->mmio); @@ -128,19 +143,27 @@ static void gpex_host_realize(DeviceState *dev, Error **errp) sysbus_init_mmio(sbd, &s->io_ioport); } - for (i = 0; i < GPEX_NUM_IRQS; i++) { - sysbus_init_irq(sbd, &s->irq[i]); - s->irq_num[i] = -1; + for (i = 0; i < s->num_irqs; i++) { + sysbus_init_irq(sbd, &s->irq[i].irq); + s->irq[i].irq_num = -1; } pci->bus = pci_register_root_bus(dev, "pcie.0", gpex_set_irq, - pci_swizzle_map_irq_fn, s, &s->io_mmio, - &s->io_ioport, 0, 4, TYPE_PCIE_BUS); + gpex_swizzle_map_irq_fn, + s, &s->io_mmio, &s->io_ioport, 0, + s->num_irqs, TYPE_PCIE_BUS); pci_bus_set_route_irq_fn(pci->bus, gpex_route_intx_pin_to_irq); qdev_realize(DEVICE(&s->gpex_root), BUS(pci->bus), &error_fatal); } +static void gpex_host_unrealize(DeviceState *dev) +{ + GPEXHost *s = GPEX_HOST(dev); + + g_free(s->irq); +} + static const char *gpex_host_root_bus_path(PCIHostState *host_bridge, PCIBus *rootbus) { @@ -166,6 +189,7 @@ static const Property gpex_host_properties[] = { gpex_cfg.mmio64.base, 0), DEFINE_PROP_SIZE(PCI_HOST_ABOVE_4G_MMIO_SIZE, GPEXHost, gpex_cfg.mmio64.size, 0), + DEFINE_PROP_UINT8("num-irqs", GPEXHost, num_irqs, PCI_NUM_PINS), }; static void gpex_host_class_init(ObjectClass *klass, void *data) @@ -175,6 +199,7 @@ static void gpex_host_class_init(ObjectClass *klass, void *data) hc->root_bus_path = gpex_host_root_bus_path; dc->realize = gpex_host_realize; + dc->unrealize = gpex_host_unrealize; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); dc->fw_name = "pci"; device_class_set_props(dc, gpex_host_properties); diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index c792ab9c359..2bc5a9dd981 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -179,7 +179,7 @@ static void create_pcie_irq_map(RISCVVirtState *s, void *fdt, char *nodename, { int pin, dev; uint32_t irq_map_stride = 0; - uint32_t full_irq_map[GPEX_NUM_IRQS * GPEX_NUM_IRQS * + uint32_t full_irq_map[PCI_NUM_PINS * PCI_NUM_PINS * FDT_MAX_INT_MAP_WIDTH] = {}; uint32_t *irq_map = full_irq_map; @@ -191,11 +191,11 @@ static void create_pcie_irq_map(RISCVVirtState *s, void *fdt, char *nodename, * possible slot) seeing the interrupt-map-mask will allow the table * to wrap to any number of devices. */ - for (dev = 0; dev < GPEX_NUM_IRQS; dev++) { + for (dev = 0; dev < PCI_NUM_PINS; dev++) { int devfn = dev * 0x8; - for (pin = 0; pin < GPEX_NUM_IRQS; pin++) { - int irq_nr = PCIE_IRQ + ((pin + PCI_SLOT(devfn)) % GPEX_NUM_IRQS); + for (pin = 0; pin < PCI_NUM_PINS; pin++) { + int irq_nr = PCIE_IRQ + ((pin + PCI_SLOT(devfn)) % PCI_NUM_PINS); int i = 0; /* Fill PCI address cells */ @@ -221,7 +221,7 @@ static void create_pcie_irq_map(RISCVVirtState *s, void *fdt, char *nodename, } qemu_fdt_setprop(fdt, nodename, "interrupt-map", full_irq_map, - GPEX_NUM_IRQS * GPEX_NUM_IRQS * + PCI_NUM_PINS * PCI_NUM_PINS * irq_map_stride * sizeof(uint32_t)); qemu_fdt_setprop_cells(fdt, nodename, "interrupt-map-mask", @@ -1246,7 +1246,7 @@ static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem, sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, pio_base); - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { irq = qdev_get_gpio_in(irqchip, PCIE_IRQ + i); sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); diff --git a/hw/xen/xen-pvh-common.c b/hw/xen/xen-pvh-common.c index a10c44cc758..9c21fa858d3 100644 --- a/hw/xen/xen-pvh-common.c +++ b/hw/xen/xen-pvh-common.c @@ -169,7 +169,7 @@ static inline void xenpvh_gpex_init(XenPVHMachineState *s, */ assert(xpc->set_pci_intx_irq); - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { qemu_irq irq = qemu_allocate_irq(xpc->set_pci_intx_irq, s, i); sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, irq); diff --git a/hw/xtensa/virt.c b/hw/xtensa/virt.c index 98622ae86dc..b08404fc17c 100644 --- a/hw/xtensa/virt.c +++ b/hw/xtensa/virt.c @@ -93,7 +93,7 @@ static void create_pcie(MachineState *ms, CPUXtensaState *env, int irq_base, /* Connect IRQ lines. */ extints = xtensa_get_extints(env); - for (i = 0; i < GPEX_NUM_IRQS; i++) { + for (i = 0; i < PCI_NUM_PINS; i++) { void *q = extints[irq_base + i]; sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, q); From patchwork Tue Dec 31 20:22:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854402 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089507wrq; Tue, 31 Dec 2024 12:23:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX9meULdIQml9PqsKue/2Ze9XvR+oKIIK7uDEle96zIYIhg2F9KtAIhgjAWe4X8KhoCqcvj0Q==@linaro.org X-Google-Smtp-Source: AGHT+IEhMQwo9cs85Goht8PLpbGjunfJwnZhmUCRqcYSN9Xi0zY7O/AEZPdcdqpvkbJ1SV3S4aTx X-Received: by 2002:a05:620a:454d:b0:7b6:da92:fcd0 with SMTP id af79cd13be357-7b9ba715ea9mr6022296785a.8.1735676624250; Tue, 31 Dec 2024 12:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676624; cv=none; d=google.com; s=arc-20240605; b=WoorcBk3fI04StFgNdYkaNWJXVanbs6i/dvs2eeSRjSl4BR+YeL8TVRwhkseS0G47B zDOGkbVg53faFcpDOaycgYlhuCOl+NohnikcTfssy9A4UwtkldNcPOCxR+0X8Oe3AAd3 qOL3ZW8TCdKR15GY6sKxFgKDHeLWwrfql2qH/vTqAHQdOpTgXQ+WLW5POEEUKBvAa9hH 5CVSzzGFrhlivK5O0MjOL3bO9NsighLX0vmcYlpDLHJdwh904Xaz7KaSIg/K1BozgfIK KGFf4yRm1XLUf6fFIKM6jQKoPy+ArHf5dg+xlXB9F83naw3WWppbQyFE3qYl5Qu2ufin H3Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dCP5hjm/gpYZgw/PjfuM8otM9YlBBnNaOYeUM4uWhjA=; fh=ePyGoEiUVsGq5muf6+HqrCJFUwgxhWNYwaYwKs9b+Tk=; b=YzZS/yFH9j6Fl+lSQHLKYq938tnBjejnAeGo/Hi03bKKHYARTm66Jiew0g0SBBVvqp CYT/FYHNiCbeB86y9XN2eWYRkhOY39rjKDkRxTb2gax+KHbGqD5cpDarLnQAZIQyxBF4 QhLuj/chkmYkTIOUBZCG41RPJqb9raXG1DdefMq04d48IaV/IvVo6oPZZo5YpkvMvZLL 0WqiET9Ozhsqh1UjWfEplSu0SoP2r4kmGfBb89OO7wQS9F83Y00xfYv8Km/FKaOf35ta Eui8I6n1VQRgq5LT31kyRdNlHoriQcMlT2YbOwzYQgIDvNh138iUSvUQK+BESUjA7egv EcYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h+tfZmL0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac4f106asi3348549885a.493.2024.12.31.12.23.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:23:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h+tfZmL0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSilJ-0002JR-NH; Tue, 31 Dec 2024 15:22:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilI-0002JG-Eq for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:44 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilF-0000oT-If for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:44 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3862ca8e0bbso7979441f8f.0 for ; Tue, 31 Dec 2024 12:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676560; x=1736281360; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dCP5hjm/gpYZgw/PjfuM8otM9YlBBnNaOYeUM4uWhjA=; b=h+tfZmL0SGhndZFHaz1alFJxXZawhe8xFa6xcD7TtM2iAO+I8mUGum4Wtd000hdC0O PWf/Y5jQGFrk5S5CAOf4s1GFhNg2kptpn4xjh3a/PuMfLl/N8aFLmqIhbg4p8q/Y18sv kZWwGYnjb5DFtURd5Un39nSj7qZ6T19D68fx/CkI44AHyGaKM9+Z4YhLb34uiBFMaDCo 5w0M1B+MdULjaM7AJbxIxIIQ/pIzPRXdQtB6X4a9wIw3xKXI+npp6DK7ogQr688YH6lV GdqEJ7NlDVjhCL2z0OmlwM7RalsmWjlbXJWkx7qHC0HVXlVj0zClHmhHVOR5Rm5uj90t ubpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676560; x=1736281360; 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=dCP5hjm/gpYZgw/PjfuM8otM9YlBBnNaOYeUM4uWhjA=; b=WCdQbqdia+g5MgiW7RkBuGlTJideWVi565cEmz6hTmScYaOthYI4RUB4r9O99/Vsix O63HN7OOGgFLnutABOmys5faSWrsyjJFYY7aw7t28/jBoWwjdAq+oo+HAX0VZsygQGzR Rvi7ktISVsEIlTdxDp4MV1cBYvDfb4pgGUbdC59FjOeyepasA8mKpMznZ8KFy56uSxFf EBuYxu4VT7I5DdpyRkv2z4qaSJUeK0dRhZuFN0P1/xhCSrueQmPmaga7Z0VlTHMGMqH9 E+4efJnfGdviSSarmiQMoIaCoKFWTEnkvQHlqln/SryoheB0v1oFgusowXA3FcDorej7 X6WQ== X-Gm-Message-State: AOJu0YxprJSgSXKPGtTy5nzuXmFpPVFCiA09kA5XB5hNaaHDrijSqG0W vhNBaiB2LbSzuc6OkK/64SoR+ndnX2C38WKwTFR07UY41eVZI8O5i4e/GpTrktLig3zZShggg/M 3zT4= X-Gm-Gg: ASbGncv/p5io3/Cy0HERSKaUhM/VMe6rdwwb6J7JB+R0RRPeOysNPeW8DoBv2zRR91s //wcdic5KCCqFLK6iikL4OvW5KAavqJHIgQBRJ/a/r4sC0z/ODODqqhErRabTYBMM8ofRgMlO1r Av4SxHGNMvY7InGCpHMFSBT3+XSDmNBmc1v376mGWGtZ4yONBJFSavCW4GXV5pO1c0W9+YotgV0 79s61z1ltepadF9pEut1lXQw7XHNzIzu0H/LDvQIlk9wWs8k2yg2/3SxDilUdRkTtSYlW/xgfTG mQokEtuExUbij0O6A3ytmS8IVAwsMHo= X-Received: by 2002:a5d:47ab:0:b0:386:1ab5:f0e1 with SMTP id ffacd0b85a97d-38a221ea67fmr38764148f8f.14.1735676559634; Tue, 31 Dec 2024 12:22:39 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8acabbsm33342667f8f.93.2024.12.31.12.22.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:22:39 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Gustavo Romero , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= Subject: [PULL 02/29] hw/misc/ivshmem-flat: Add ivshmem-flat device Date: Tue, 31 Dec 2024 21:22:01 +0100 Message-ID: <20241231202228.28819-3-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gustavo Romero Add a new device, ivshmem-flat, which is similar to the ivshmem PCI but does not require a PCI bus. It's meant to be used on machines like those with Cortex-M MCUs, which usually lack a PCI/PCIe bus, e.g. lm3s6965evb and mps2-an385. The device currently only supports the sysbus bus. The new device, just like the ivshmem PCI device, supports both peer notification via hardware interrupts and shared memory. The device shared memory size can be set using the 'shmem-size' option and it defaults to 4 MiB, which is the default size of shmem allocated by the ivshmem server. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1134 Signed-off-by: Gustavo Romero [PMD: Rebased updating Property and using DEFINE_TYPES macro] Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20241216141818.111255-2-gustavo.romero@linaro.org> --- docs/system/device-emulation.rst | 1 + docs/system/devices/ivshmem-flat.rst | 33 ++ include/hw/misc/ivshmem-flat.h | 85 +++++ hw/misc/ivshmem-flat.c | 459 +++++++++++++++++++++++++++ hw/misc/Kconfig | 5 + hw/misc/meson.build | 2 + hw/misc/trace-events | 16 + 7 files changed, 601 insertions(+) create mode 100644 docs/system/devices/ivshmem-flat.rst create mode 100644 include/hw/misc/ivshmem-flat.h create mode 100644 hw/misc/ivshmem-flat.c diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index f19777411cd..a1b0d7997e0 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -86,6 +86,7 @@ Emulated Devices devices/ccid.rst devices/cxl.rst devices/ivshmem.rst + devices/ivshmem-flat.rst devices/keyboard.rst devices/net.rst devices/nvme.rst diff --git a/docs/system/devices/ivshmem-flat.rst b/docs/system/devices/ivshmem-flat.rst new file mode 100644 index 00000000000..1f97052804a --- /dev/null +++ b/docs/system/devices/ivshmem-flat.rst @@ -0,0 +1,33 @@ +Inter-VM Shared Memory Flat Device +---------------------------------- + +The ivshmem-flat device is meant to be used on machines that lack a PCI bus, +making them unsuitable for the use of the traditional ivshmem device modeled as +a PCI device. Machines like those with a Cortex-M MCU are good candidates to use +the ivshmem-flat device. Also, since the flat version maps the control and +status registers directly to the memory, it requires a quite tiny "device +driver" to interact with other VMs, which is useful in some RTOSes, like +Zephyr, which usually run on constrained resource targets. + +Similar to the ivshmem device, the ivshmem-flat device supports both peer +notification via HW interrupts and Inter-VM shared memory. This allows the +device to be used together with the traditional ivshmem, enabling communication +between, for instance, an aarch64 VM (using the traditional ivshmem device and +running Linux), and an arm VM (using the ivshmem-flat device and running Zephyr +instead). + +The ivshmem-flat device does not support the use of a ``memdev`` option (see +ivshmem.rst for more details). It relies on the ivshmem server to create and +distribute the proper shared memory file descriptor and the eventfd(s) to notify +(interrupt) the peers. Therefore, to use this device, it is always necessary to +have an ivshmem server up and running for proper device creation. + +Although the ivshmem-flat supports both peer notification (interrupts) and +shared memory, the interrupt mechanism is optional. If no input IRQ is +specified for the device it is disabled, preventing the VM from notifying or +being notified by other VMs (a warning will be displayed to the user to inform +the IRQ mechanism is disabled). The shared memory region is always present. + +The MMRs (INTRMASK, INTRSTATUS, IVPOSITION, and DOORBELL registers) offsets at +the MMR region, and their functions, follow the ivshmem spec, so they work +exactly as in the ivshmem PCI device (see ./specs/ivshmem-spec.txt). diff --git a/include/hw/misc/ivshmem-flat.h b/include/hw/misc/ivshmem-flat.h new file mode 100644 index 00000000000..97ca0ddce61 --- /dev/null +++ b/include/hw/misc/ivshmem-flat.h @@ -0,0 +1,85 @@ +/* + * Inter-VM Shared Memory Flat Device + * + * SPDX-FileCopyrightText: 2023 Linaro Ltd. + * SPDX-FileContributor: Gustavo Romero + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#ifndef IVSHMEM_FLAT_H +#define IVSHMEM_FLAT_H + +#include "qemu/queue.h" +#include "qemu/event_notifier.h" +#include "chardev/char-fe.h" +#include "exec/memory.h" +#include "qom/object.h" +#include "hw/sysbus.h" + +#define IVSHMEM_MAX_VECTOR_NUM 64 + +/* + * QEMU interface: + * + QOM property "chardev" is the character device id of the ivshmem server + * socket + * + QOM property "shmem-size" sets the size of the RAM region shared between + * the device and the ivshmem server + * + sysbus MMIO region 0: device I/O mapped registers + * + sysbus MMIO region 1: shared memory with ivshmem server + * + sysbus IRQ 0: single output interrupt + */ + +#define TYPE_IVSHMEM_FLAT "ivshmem-flat" +typedef struct IvshmemFTState IvshmemFTState; + +DECLARE_INSTANCE_CHECKER(IvshmemFTState, IVSHMEM_FLAT, TYPE_IVSHMEM_FLAT) + +/* Ivshmem registers. See ./docs/specs/ivshmem-spec.txt for details. */ +enum ivshmem_registers { + INTMASK = 0, + INTSTATUS = 4, + IVPOSITION = 8, + DOORBELL = 12, +}; + +typedef struct VectorInfo { + EventNotifier event_notifier; + uint16_t id; +} VectorInfo; + +typedef struct IvshmemPeer { + QTAILQ_ENTRY(IvshmemPeer) next; + VectorInfo vector[IVSHMEM_MAX_VECTOR_NUM]; + int vector_counter; + uint16_t id; +} IvshmemPeer; + +struct IvshmemFTState { + SysBusDevice parent_obj; + + uint64_t msg_buf; + int msg_buffered_bytes; + + QTAILQ_HEAD(, IvshmemPeer) peer; + IvshmemPeer own; + + CharBackend server_chr; + + /* IRQ */ + qemu_irq irq; + + /* I/O registers */ + MemoryRegion iomem; + uint32_t intmask; + uint32_t intstatus; + uint32_t ivposition; + uint32_t doorbell; + + /* Shared memory */ + MemoryRegion shmem; + int shmem_fd; + uint32_t shmem_size; +}; + +#endif /* IVSHMEM_FLAT_H */ diff --git a/hw/misc/ivshmem-flat.c b/hw/misc/ivshmem-flat.c new file mode 100644 index 00000000000..33fc9425d20 --- /dev/null +++ b/hw/misc/ivshmem-flat.c @@ -0,0 +1,459 @@ +/* + * Inter-VM Shared Memory Flat Device + * + * SPDX-FileCopyrightText: 2023 Linaro Ltd. + * SPDX-FileContributor: Gustavo Romero + * SPDX-License-Identifier: GPL-2.0-or-later + * + */ + +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "qemu/error-report.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "hw/irq.h" +#include "hw/qdev-properties-system.h" +#include "hw/sysbus.h" +#include "chardev/char-fe.h" +#include "exec/address-spaces.h" +#include "trace.h" + +#include "hw/misc/ivshmem-flat.h" + +static int64_t ivshmem_flat_recv_msg(IvshmemFTState *s, int *pfd) +{ + int64_t msg; + int n, ret; + + n = 0; + do { + ret = qemu_chr_fe_read_all(&s->server_chr, (uint8_t *)&msg + n, + sizeof(msg) - n); + if (ret < 0) { + if (ret == -EINTR) { + continue; + } + exit(1); + } + n += ret; + } while (n < sizeof(msg)); + + if (pfd) { + *pfd = qemu_chr_fe_get_msgfd(&s->server_chr); + } + return le64_to_cpu(msg); +} + +static void ivshmem_flat_irq_handler(void *opaque) +{ + VectorInfo *vi = opaque; + EventNotifier *e = &vi->event_notifier; + uint16_t vector_id; + const VectorInfo (*v)[64]; + + assert(e->initialized); + + vector_id = vi->id; + + /* + * The vector info struct is passed to the handler via the 'opaque' pointer. + * This struct pointer allows the retrieval of the vector ID and its + * associated event notifier. However, for triggering an interrupt using + * qemu_set_irq, it's necessary to also have a pointer to the device state, + * i.e., a pointer to the IvshmemFTState struct. Since the vector info + * struct is contained within the IvshmemFTState struct, its pointer can be + * used to obtain the pointer to IvshmemFTState through simple pointer math. + */ + v = (void *)(vi - vector_id); /* v = &IvshmemPeer->vector[0] */ + IvshmemPeer *own_peer = container_of(v, IvshmemPeer, vector); + IvshmemFTState *s = container_of(own_peer, IvshmemFTState, own); + + /* Clear event */ + if (!event_notifier_test_and_clear(e)) { + return; + } + + trace_ivshmem_flat_irq_handler(vector_id); + + /* + * Toggle device's output line, which is connected to interrupt controller, + * generating an interrupt request to the CPU. + */ + qemu_irq_pulse(s->irq); +} + +static IvshmemPeer *ivshmem_flat_find_peer(IvshmemFTState *s, uint16_t peer_id) +{ + IvshmemPeer *peer; + + /* Own ID */ + if (s->own.id == peer_id) { + return &s->own; + } + + /* Peer ID */ + QTAILQ_FOREACH(peer, &s->peer, next) { + if (peer->id == peer_id) { + return peer; + } + } + + return NULL; +} + +static IvshmemPeer *ivshmem_flat_add_peer(IvshmemFTState *s, uint16_t peer_id) +{ + IvshmemPeer *new_peer; + + new_peer = g_malloc0(sizeof(*new_peer)); + new_peer->id = peer_id; + new_peer->vector_counter = 0; + + QTAILQ_INSERT_TAIL(&s->peer, new_peer, next); + + trace_ivshmem_flat_new_peer(peer_id); + + return new_peer; +} + +static void ivshmem_flat_remove_peer(IvshmemFTState *s, uint16_t peer_id) +{ + IvshmemPeer *peer; + + peer = ivshmem_flat_find_peer(s, peer_id); + assert(peer); + + QTAILQ_REMOVE(&s->peer, peer, next); + for (int n = 0; n < peer->vector_counter; n++) { + int efd; + efd = event_notifier_get_fd(&(peer->vector[n].event_notifier)); + close(efd); + } + + g_free(peer); +} + +static void ivshmem_flat_add_vector(IvshmemFTState *s, IvshmemPeer *peer, + int vector_fd) +{ + if (peer->vector_counter >= IVSHMEM_MAX_VECTOR_NUM) { + trace_ivshmem_flat_add_vector_failure(peer->vector_counter, + vector_fd, peer->id); + close(vector_fd); + + return; + } + + trace_ivshmem_flat_add_vector_success(peer->vector_counter, + vector_fd, peer->id); + + /* + * Set vector ID and its associated eventfd notifier and add them to the + * peer. + */ + peer->vector[peer->vector_counter].id = peer->vector_counter; + g_unix_set_fd_nonblocking(vector_fd, true, NULL); + event_notifier_init_fd(&peer->vector[peer->vector_counter].event_notifier, + vector_fd); + + /* + * If it's the device's own ID, register also the handler for the eventfd + * so the device can be notified by the other peers. + */ + if (peer == &s->own) { + qemu_set_fd_handler(vector_fd, ivshmem_flat_irq_handler, NULL, + &peer->vector); + } + + peer->vector_counter++; +} + +static void ivshmem_flat_process_msg(IvshmemFTState *s, uint64_t msg, int fd) +{ + uint16_t peer_id; + IvshmemPeer *peer; + + peer_id = msg & 0xFFFF; + peer = ivshmem_flat_find_peer(s, peer_id); + + if (!peer) { + peer = ivshmem_flat_add_peer(s, peer_id); + } + + if (fd >= 0) { + ivshmem_flat_add_vector(s, peer, fd); + } else { /* fd == -1, which is received when peers disconnect. */ + ivshmem_flat_remove_peer(s, peer_id); + } +} + +static int ivshmem_flat_can_receive_data(void *opaque) +{ + IvshmemFTState *s = opaque; + + assert(s->msg_buffered_bytes < sizeof(s->msg_buf)); + return sizeof(s->msg_buf) - s->msg_buffered_bytes; +} + +static void ivshmem_flat_read_msg(void *opaque, const uint8_t *buf, int size) +{ + IvshmemFTState *s = opaque; + int fd; + int64_t msg; + + assert(size >= 0 && s->msg_buffered_bytes + size <= sizeof(s->msg_buf)); + memcpy((unsigned char *)&s->msg_buf + s->msg_buffered_bytes, buf, size); + s->msg_buffered_bytes += size; + if (s->msg_buffered_bytes < sizeof(s->msg_buf)) { + return; + } + msg = le64_to_cpu(s->msg_buf); + s->msg_buffered_bytes = 0; + + fd = qemu_chr_fe_get_msgfd(&s->server_chr); + + ivshmem_flat_process_msg(s, msg, fd); +} + +static uint64_t ivshmem_flat_iomem_read(void *opaque, + hwaddr offset, unsigned size) +{ + IvshmemFTState *s = opaque; + uint32_t ret; + + trace_ivshmem_flat_read_mmr(offset); + + switch (offset) { + case INTMASK: + ret = 0; /* Ignore read since all bits are reserved in rev 1. */ + break; + case INTSTATUS: + ret = 0; /* Ignore read since all bits are reserved in rev 1. */ + break; + case IVPOSITION: + ret = s->own.id; + break; + case DOORBELL: + trace_ivshmem_flat_read_mmr_doorbell(); /* DOORBELL is write-only */ + ret = 0; + break; + default: + /* Should never reach out here due to iomem map range being exact */ + trace_ivshmem_flat_read_write_mmr_invalid(offset); + ret = 0; + } + + return ret; +} + +static int ivshmem_flat_interrupt_peer(IvshmemFTState *s, + uint16_t peer_id, uint16_t vector_id) +{ + IvshmemPeer *peer; + + peer = ivshmem_flat_find_peer(s, peer_id); + if (!peer) { + trace_ivshmem_flat_interrupt_invalid_peer(peer_id); + return 1; + } + + event_notifier_set(&(peer->vector[vector_id].event_notifier)); + + return 0; +} + +static void ivshmem_flat_iomem_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + IvshmemFTState *s = opaque; + uint16_t peer_id = (value >> 16) & 0xFFFF; + uint16_t vector_id = value & 0xFFFF; + + trace_ivshmem_flat_write_mmr(offset); + + switch (offset) { + case INTMASK: + break; + case INTSTATUS: + break; + case IVPOSITION: + break; + case DOORBELL: + trace_ivshmem_flat_interrupt_peer(peer_id, vector_id); + ivshmem_flat_interrupt_peer(s, peer_id, vector_id); + break; + default: + /* Should never reach out here due to iomem map range being exact. */ + trace_ivshmem_flat_read_write_mmr_invalid(offset); + break; + } + + return; +} + +static const MemoryRegionOps ivshmem_flat_ops = { + .read = ivshmem_flat_iomem_read, + .write = ivshmem_flat_iomem_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .impl = { /* Read/write aligned at 32 bits. */ + .min_access_size = 4, + .max_access_size = 4, + }, +}; + +static void ivshmem_flat_instance_init(Object *obj) +{ + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); + IvshmemFTState *s = IVSHMEM_FLAT(obj); + + /* + * Init mem region for 4 MMRs (ivshmem_registers), + * 32 bits each => 16 bytes (0x10). + */ + memory_region_init_io(&s->iomem, obj, &ivshmem_flat_ops, s, + "ivshmem-mmio", 0x10); + sysbus_init_mmio(sbd, &s->iomem); + + /* + * Create one output IRQ that will be connect to the + * machine's interrupt controller. + */ + sysbus_init_irq(sbd, &s->irq); + + QTAILQ_INIT(&s->peer); +} + +static bool ivshmem_flat_connect_server(DeviceState *dev, Error **errp) +{ + IvshmemFTState *s = IVSHMEM_FLAT(dev); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + int64_t protocol_version, msg; + int shmem_fd; + uint16_t peer_id; + struct stat fdstat; + + /* Check ivshmem server connection. */ + if (!qemu_chr_fe_backend_connected(&s->server_chr)) { + error_setg(errp, "ivshmem server socket not specified or incorret." + " Can't create device."); + return false; + } + + /* + * Message sequence from server on new connection: + * _____________________________________ + * |STEP| uint64_t msg | int fd | + * ------------------------------------- + * + * 0 PROTOCOL -1 \ + * 1 OWN PEER ID -1 |-- Header/Greeting + * 2 -1 shmem fd / + * + * 3 PEER IDx Other peer's Vector 0 eventfd + * 4 PEER IDx Other peer's Vector 1 eventfd + * . . + * . . + * . . + * N PEER IDy Other peer's Vector 0 eventfd + * N+1 PEER IDy Other peer's Vector 1 eventfd + * . . + * . . + * . . + * + * ivshmem_flat_recv_msg() calls return 'msg' and 'fd'. + * + * See ./docs/specs/ivshmem-spec.txt for details on the protocol. + */ + + /* Step 0 */ + protocol_version = ivshmem_flat_recv_msg(s, NULL); + + /* Step 1 */ + msg = ivshmem_flat_recv_msg(s, NULL); + peer_id = 0xFFFF & msg; + s->own.id = peer_id; + s->own.vector_counter = 0; + + trace_ivshmem_flat_proto_ver_own_id(protocol_version, s->own.id); + + /* Step 2 */ + msg = ivshmem_flat_recv_msg(s, &shmem_fd); + /* Map shmem fd and MMRs into memory regions. */ + if (msg != -1 || shmem_fd < 0) { + error_setg(errp, "Could not receive valid shmem fd." + " Can't create device!"); + return false; + } + + if (fstat(shmem_fd, &fdstat) != 0) { + error_setg(errp, "Could not determine shmem fd size." + " Can't create device!"); + return false; + } + trace_ivshmem_flat_shmem_size(shmem_fd, fdstat.st_size); + + /* + * Shmem size provided by the ivshmem server must be equal to + * device's shmem size. + */ + if (fdstat.st_size != s->shmem_size) { + error_setg(errp, "Can't map shmem fd: shmem size different" + " from device size!"); + return false; + } + + /* + * Beyond step 2 ivshmem_process_msg, called by ivshmem_flat_read_msg + * handler -- when data is available on the server socket -- will handle + * the additional messages that will be generated by the server as peers + * connect or disconnect. + */ + qemu_chr_fe_set_handlers(&s->server_chr, ivshmem_flat_can_receive_data, + ivshmem_flat_read_msg, NULL, NULL, s, NULL, true); + + memory_region_init_ram_from_fd(&s->shmem, OBJECT(s), + "ivshmem-shmem", s->shmem_size, + RAM_SHARED, shmem_fd, 0, NULL); + sysbus_init_mmio(sbd, &s->shmem); + + return true; +} + +static void ivshmem_flat_realize(DeviceState *dev, Error **errp) +{ + if (!ivshmem_flat_connect_server(dev, errp)) { + return; + } +} + +static const Property ivshmem_flat_props[] = { + DEFINE_PROP_CHR("chardev", IvshmemFTState, server_chr), + DEFINE_PROP_UINT32("shmem-size", IvshmemFTState, shmem_size, 4 * MiB), +}; + +static void ivshmem_flat_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->hotpluggable = true; + dc->realize = ivshmem_flat_realize; + + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + device_class_set_props(dc, ivshmem_flat_props); + + /* Reason: Must be wired up in code (sysbus MRs and IRQ) */ + dc->user_creatable = false; +} + +static const TypeInfo ivshmem_flat_types[] = { + { + .name = TYPE_IVSHMEM_FLAT, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(IvshmemFTState), + .instance_init = ivshmem_flat_instance_init, + .class_init = ivshmem_flat_class_init, + }, +}; + +DEFINE_TYPES(ivshmem_flat_types) diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 1f1baa5dde9..8f9ce2f68c3 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -72,6 +72,11 @@ config IVSHMEM_DEVICE default y if PCI_DEVICES depends on PCI && LINUX && IVSHMEM && MSI_NONBROKEN +config IVSHMEM_FLAT_DEVICE + bool + default y + depends on LINUX && IVSHMEM + config ECCMEMCTL bool diff --git a/hw/misc/meson.build b/hw/misc/meson.build index d02d96e403b..7a16ddb1dcc 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -37,7 +37,9 @@ system_ss.add(when: 'CONFIG_SIFIVE_U_PRCI', if_true: files('sifive_u_prci.c')) subdir('macio') +# ivshmem devices system_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c')) +system_ss.add(when: 'CONFIG_IVSHMEM_FLAT_DEVICE', if_true: files('ivshmem-flat.c')) system_ss.add(when: 'CONFIG_ALLWINNER_SRAMC', if_true: files('allwinner-sramc.c')) system_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c')) diff --git a/hw/misc/trace-events b/hw/misc/trace-events index b9fbcb09249..0f5d2b56660 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -368,3 +368,19 @@ aspeed_sli_read(uint64_t offset, unsigned int size, uint32_t data) "To 0x%" PRIx aspeed_sliio_write(uint64_t offset, unsigned int size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32 aspeed_sliio_read(uint64_t offset, unsigned int size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32 +# ivshmem-flat.c +ivshmem_flat_irq_handler(uint16_t vector_id) "Caught interrupt request: vector %d" +ivshmem_flat_new_peer(uint16_t peer_id) "New peer ID: %d" +ivshmem_flat_add_vector_failure(uint16_t vector_id, uint32_t vector_fd, uint16_t peer_id) "Failed to add vector %u (fd = %u) to peer ID %u, maximum number of vectors reached" +ivshmem_flat_add_vector_success(uint16_t vector_id, uint32_t vector_fd, uint16_t peer_id) "Successful addition of vector %u (fd = %u) to peer ID %u" +ivshmem_flat_irq_resolved(const char *irq_qompath) "IRQ QOM path '%s' correctly resolved" +ivshmem_flat_proto_ver_own_id(uint64_t proto_ver, uint16_t peer_id) "Protocol Version = 0x%"PRIx64", Own Peer ID = %u" +ivshmem_flat_shmem_size(int fd, uint64_t size) "Shmem fd (%d) total size is %"PRIu64" byte(s)" +ivshmem_flat_shmem_map(uint64_t addr) "Mapping shmem @ 0x%"PRIx64 +ivshmem_flat_mmio_map(uint64_t addr) "Mapping MMRs @ 0x%"PRIx64 +ivshmem_flat_read_mmr(uint64_t addr_offset) "Read access at offset %"PRIu64 +ivshmem_flat_read_mmr_doorbell(void) "DOORBELL register is write-only!" +ivshmem_flat_read_write_mmr_invalid(uint64_t addr_offset) "No ivshmem register mapped at offset %"PRIu64 +ivshmem_flat_interrupt_invalid_peer(uint16_t peer_id) "Can't interrupt non-existing peer %u" +ivshmem_flat_write_mmr(uint64_t addr_offset) "Write access at offset %"PRIu64 +ivshmem_flat_interrupt_peer(uint16_t peer_id, uint16_t vector_id) "Interrupting peer ID %u, vector %u..." From patchwork Tue Dec 31 20:22:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854404 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089552wrq; Tue, 31 Dec 2024 12:23:55 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVign6gPybuAtypXUe7C0VoE0aRGLV5CkK65JPIo/J8E1t1uGOlMaVI6Ganm0uC0BQBAy5Cew==@linaro.org X-Google-Smtp-Source: AGHT+IFqRw7IV+CoSxSaLgw6lgQZeMfim2mwCORnKv7rF6UKu4E0jDuEHGy3B5R89/+Edr9df3Mb X-Received: by 2002:a05:6214:b6c:b0:6d8:8fbf:d1b7 with SMTP id 6a1803df08f44-6dd233a6778mr663675066d6.43.1735676634825; Tue, 31 Dec 2024 12:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676634; cv=none; d=google.com; s=arc-20240605; b=WZUZebodtydXZ/Agi6ke4WSJbJSOfz+hXs2HwnWXiMvdV9oJ4kXWyn/8KXRj35zZcU 1IRqauQTftKwBF1r6l2Sfk8RwLxMdqLkraCBk7WpZGRTakAfq+qbBacjYAGsOVwd0mjO jeru2w/ZHVz2eNmvtKyDGzFyXPiYAFYcuVx9MfS0iTXbQsScv6kB9AatjQ+1kqXrjdbM QE3qnbe3V6iPzjLpmfY9EAauw4DJ4izAhoEymI58Ykn15g/COpRuqlm9rCPn2HsXXjio E6m/bHwlOWxs7tZlsVhgpq26RwlQRRObPLBmYfp2DzU69Hs6fPUK31890xH9NexBl2pn EnJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dhTqWfXfzThhBSQGIlzSaIlp49wauFvDxBkt6/SSna8=; fh=ePyGoEiUVsGq5muf6+HqrCJFUwgxhWNYwaYwKs9b+Tk=; b=lZAOgeL+KrcZjl+4n60fP/ezwVSl2nKJN4SgGipAH1wRDh/wLcHB+cslzdRa81P/W6 Q1BgSOkIIXsQaAbYBiozI7+J+fPyfoKDWvtX0SB1AL94NgJ2URQo5wSR6p5KwwEaHNX7 5O1+VcJUH7NX6aVzSomaeFiiVjejGWhpqWao8nM/Sw/sHfWJstnsjwPmK8TSz5by7S20 410LLlGEXwG15aGmvQSot3tGJiwxCNAahF4LM1VtyaSaHu4x3R6QvFaggfR0MfLUFgT4 ijNDp1UvxOntuadH5PP5qAxvbvUyG29ebMn1w1w2mzYUVAN31abFGI3TPg0NXlgFowz2 TbXg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=inxzuC9J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd182364d3si326782496d6.261.2024.12.31.12.23.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:23:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=inxzuC9J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSilN-0002K4-FE; Tue, 31 Dec 2024 15:22:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilM-0002Jm-2b for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:48 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilK-0000p2-GD for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:47 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-38789e5b6a7so5248089f8f.1 for ; Tue, 31 Dec 2024 12:22:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676565; x=1736281365; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dhTqWfXfzThhBSQGIlzSaIlp49wauFvDxBkt6/SSna8=; b=inxzuC9JXvEIxPiAWIyj6bh292mi6eIpA9hiiHzEKwT/DjjBbN4QFkrhKdpY2YG05+ MwtOebQu3kFKDZi5XQgAKUb6ITJnhLOHg5R0vNKUrbfpGqnO5pyEZLWK/m3ksk73e8Ji rLoZkMS42DYoX+kdicU4LaHBuW/aCKYaal6jAp2rQM9SXjPRUTbYxl8BfXUs36wFPbiB lsOnVUt5dVqK0j9uA783xKUG81THubUHuf8aCXuMMxVBGihuecBRVy4bMpyEhI+yzmmQ 3Nx1qeoJ3vwjb++DRAfrxoLGkMuMQ4Y9wvNAoKKKfwUn/QCO4CoTMvfCvWTt7uXZqeBo +nVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676565; x=1736281365; 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=dhTqWfXfzThhBSQGIlzSaIlp49wauFvDxBkt6/SSna8=; b=KXsUezpehFNzoiXZ2VUbOgbf1RavGGKcHMtLCA0LifjO52JVyt4wRM5OxC8559aP+4 BCpqhDtqR5lgyU+YpWQZT5uFldY2EuXU0a4V/iKyOxVJRs7epMYoPkb2s2ny8d+73Z7t 2g4T+0UK0o62bBa6BR6ShefC3ZLM0wQxmnbkYScExglhmLtO5VOWXHxHV6mmu2clkVTy jEKlMZ03Rh90xMEs+3svjYNdXqjp4jr+w66sMjZOxBGQrj35WDiA+tveNGUugDqra83j eFN1jTkNGCauFMWaWq9vv+x4mdRf9Mp+/+YFUAHn5WWfQQ35EX3tJfpWRaxQ+Af9MEcD D3LA== X-Gm-Message-State: AOJu0YxH4eGxH12I6XrbNhDAIzFubk1yDhbcLDknKZ/muw0vU1A893wJ 6iijtUDIPavpyC3jnzQD3d19eDwiczZfOvp961rGLwZq/EwSR7WAZ8QYbgrXGjdTAxHXK70Fflc Tvds= X-Gm-Gg: ASbGncvMZKB7ziNhL+vPR/cPETZrLi5fZ9o2qfjZwGdKKF0jtU1gYj90deKW74VnlOm F2SgwhUv+80JR6VhdYc0KuHsfjGWjAA84SABgPZS7yVB8Aioj6zuA6Xo8O9WeiPZYSKRBEUKmfv 1neGX1PEyA+OEeO0/uam0g+NzNmmx5KoRHQ+kU4n21xF6Rpr1um4M7wbXlQDXOsZ3USXgT2YMoK naQHmFJ0oUFgfwLCVRdvVBB4WVmwQxqRJOR+ceGpGFu5jMuaDAkNIWMBd9MUgU+/WptZD/1jMWy k4p6X0CVDDKTMAKfRsOLhx6IAV5T7mg= X-Received: by 2002:a05:6000:704:b0:385:fc00:f5d4 with SMTP id ffacd0b85a97d-38a221f9f79mr34675441f8f.29.1735676564888; Tue, 31 Dec 2024 12:22:44 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43665cd9c29sm379714905e9.14.2024.12.31.12.22.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:22:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Gustavo Romero , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= Subject: [PULL 03/29] hw/misc/ivshmem: Rename ivshmem to ivshmem-pci Date: Tue, 31 Dec 2024 21:22:02 +0100 Message-ID: <20241231202228.28819-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Gustavo Romero Because now there is also an MMIO ivshmem device (ivshmem-flat.c), and ivshmem.c is a PCI specific implementation, rename it to ivshmem-pci.c. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Gustavo Romero Message-ID: <20241216141818.111255-5-gustavo.romero@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/misc/{ivshmem.c => ivshmem-pci.c} | 0 hw/misc/meson.build | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename hw/misc/{ivshmem.c => ivshmem-pci.c} (100%) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem-pci.c similarity index 100% rename from hw/misc/ivshmem.c rename to hw/misc/ivshmem-pci.c diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 7a16ddb1dcc..55f493521be 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -38,7 +38,7 @@ system_ss.add(when: 'CONFIG_SIFIVE_U_PRCI', if_true: files('sifive_u_prci.c')) subdir('macio') # ivshmem devices -system_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c')) +system_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem-pci.c')) system_ss.add(when: 'CONFIG_IVSHMEM_FLAT_DEVICE', if_true: files('ivshmem-flat.c')) system_ss.add(when: 'CONFIG_ALLWINNER_SRAMC', if_true: files('allwinner-sramc.c')) From patchwork Tue Dec 31 20:22:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854411 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089754wrq; Tue, 31 Dec 2024 12:24:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU9AcbSD9+rCB263u6JIzLz0VfxLyn408+C7tsyMo7CMx6km5ui4cOXQGCMf8s2cXzWQdqX2w==@linaro.org X-Google-Smtp-Source: AGHT+IG3TkYqNS1kkCvBIBzk0kUrV88Vk1QHwtr2LjrEQsJ1Qx95SOl07Ifs6WK7zqVhBUsJidGk X-Received: by 2002:a05:620a:2992:b0:79d:759d:4016 with SMTP id af79cd13be357-7b9ba6fda9fmr5997661085a.11.1735676676239; Tue, 31 Dec 2024 12:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676676; cv=none; d=google.com; s=arc-20240605; b=GbWdGK8fG/mHK2aCVONW6H2YQHp5/4gpkC6oBXZOnKikW/grWn69+k7Bpxq8+Q2uDZ diIorOBI/jOFZnDA5yO6+NU6P2BrhvpH5zCeIbHnqKXJeB+Q7s4obT6/K3dAsQQHgBPt s0jZ1e4pbMClfNZD+ZyLxjD1CsI9sQFBO2QDjSEn9wihLHvd9+MLTRKUg9BU9c4Pi0fI b0TyMgnwqhgiXL13dBoS8AWqmMhIxveYNshBBWHlj6YgdVuCpCWBiLKYSD/tGI7DW3zc 3xnJj0TsqWVia3bl4Ve1qvvoddIc0/CRVC/Wv1ZF148R+xAR5YGit68UpmbXiIi6eq2N vjSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uCJRF8nuQG5tTIgpEkMZRXzly7JdxqT3IkSChLfB/Aw=; fh=yiU9Mxm8CcFWWs+6HrK0rKYVwNIxU4NZv47C3VUKcmQ=; b=CfnZ1QMwYVBfcuidCt+bcIWhsLoKfufKN8y9JUqBKVmIdWtBKmjJ1WvP3+lJg7pS/N hZrDim0VWzSipBhuLfkHgneADsXCc2XEOVBBirzo3y4GI7Ht4e2gk8HoWEpIPmMi7BaJ NX4FNwVNUMZ9o8zLD7JZOS5Zn4oi6XkCN2TgxniN3H8bfIvl1S4raIqMkszhTxNaZBLn CZroLD8/hpZqnJ6C1XeRZsv8YFLJupTJi1Jg3S9rTtCumAcmWnVZCWEZEkNw8l5QbQTc b0tKsZ15exhKVzGtDTmdiRRqLKwhBYB7bUoOXgMZt37Y90Z34dwTmNyAekzXjNVufYlX Ep7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E5wpc+FT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac478c28si3124485985a.312.2024.12.31.12.24.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E5wpc+FT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSilT-0002Ke-6u; Tue, 31 Dec 2024 15:22:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilS-0002KR-1N for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:54 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilQ-0000pL-6U for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:53 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361f796586so106894485e9.3 for ; Tue, 31 Dec 2024 12:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676570; x=1736281370; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uCJRF8nuQG5tTIgpEkMZRXzly7JdxqT3IkSChLfB/Aw=; b=E5wpc+FT1Z4A0Z4IQArvNN0UPzcKFoyFEVofPXwiv6jycoCEQKmmX0Fk9XL1TDXQUK rSZGQ6ESDrk0Vrjd9rRgTTW9xO8PIYDI432sMDjMfEKWxsf2HzVF+51uHqRIB5yAVvNy t67YwTPlsgwRoCA54hI2+SWZ8BDiF822FQylO4sSmVWAT7RmOKUrx03MeuCR53l72QWg l4q9Ykj9Fd7L5NCrG+VOmjiseCh7v4z7VsWKXUo+01xCScN6odd05SoR4FB797mRA/x3 sXvhVSuKso2dosCl/gWVPFzS63OdzTUdh3k9RjRuudP5Xtn1Gyt+zWIx8u/DcDmb2CPb K6Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676570; x=1736281370; 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=uCJRF8nuQG5tTIgpEkMZRXzly7JdxqT3IkSChLfB/Aw=; b=logMu1FJiLJUrVMKyzhVcUKZziyJ7vDg2EwUNW+B8jOVTHw7B41I285M3GsYy1PREl xoHwuxW0BOHwVCWWN026Jmw4vw/pWlL4Rl+jnGN25BJNa1T5HHc1Blwe0gCvlMgelEOC JNXk90nLSetTiFhOgwFmtK+obirezBOoIs1IfaeHFGmQIrfagljkkCg/6Cdgb2w0d9y+ bh8UAWmM/FNtXx8L+OpAwDoqia6MePaFuF/xZxlYdaDTAT9gLycMvjiJRUotG9LhPV0A tves/dLBd0T8VM3rtbxHqIgSfANgLlBH3yUMCORVlHs1vFsjtPmJPJaVkL6xmG8Js2LC kFgg== X-Gm-Message-State: AOJu0YzHyIbLIn0E3yrf4nO2PyF+s17G0Ta31oiBPTg73ZXiV6QF+0Mf i4WpKO/rg6h/I0vhc4FeFZisRR+/cighhTr/QwjafjH6Nu39jXbCizYyU/Jc2PXayI1xvTNJdfE RdRI= X-Gm-Gg: ASbGncu3wMrEqpNG10n3dnBw+fssQpJ0epstPnQFybVhTjnD5xyFPf5rkD2XBSq3Cli KDmze99gDAjwh0V7Z0+6+LoO1ZFS6L4c0BYivpE0tGvxRXXK+77BoJlb4l42bIdsetAizS6WtpG Zq+j/JCBc1r6oCaZskVMRmRRXAjU6V0rB7YFFtbsfovG3G7Oe9CQx5yEHSbRfaeEkIWKzprMMRH dnZkxKM8gF0OJ4WVjcmd978tBcwWLcsI08mqwDnqbrdKb9quyf0Y5OCHGhbipoGwC9olEsjLN2A ZhOQtsPWNgO+hniLJe+KtI340OPT3A4= X-Received: by 2002:a05:600c:4709:b0:436:1ac2:1acf with SMTP id 5b1f17b1804b1-43668a3a35dmr305419875e9.20.1735676570234; Tue, 31 Dec 2024 12:22:50 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656af6c4esm432571125e9.4.2024.12.31.12.22.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:22:49 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Guenter Roeck , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Math?= =?utf-8?q?ieu-Daud=C3=A9?= Subject: [PULL 04/29] hw/usb/uhci: checkpatch cleanup Date: Tue, 31 Dec 2024 21:22:03 +0100 Message-ID: <20241231202228.28819-5-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Guenter Roeck Fix reported checkpatch issues to prepare for next patches in the series. No functional change. Signed-off-by: Guenter Roeck Reviewed-by: Cédric Le Goater Message-ID: <20240906122542.3808997-2-linux@roeck-us.net> Signed-off-by: Philippe Mathieu-Daudé --- hw/usb/hcd-uhci.c | 90 +++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 0559b3ae3e1..7c0cc694554 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -67,7 +67,7 @@ struct UHCIPCIDeviceClass { UHCIInfo info; }; -/* +/* * Pending async transaction. * 'packet' must be the first field because completion * handler does "(UHCIAsync *) pkt" cast. @@ -220,8 +220,9 @@ static void uhci_async_cancel(UHCIAsync *async) uhci_async_unlink(async); trace_usb_uhci_packet_cancel(async->queue->token, async->td_addr, async->done); - if (!async->done) + if (!async->done) { usb_cancel_packet(&async->packet); + } uhci_async_free(async); } @@ -322,7 +323,7 @@ static void uhci_reset(DeviceState *dev) s->fl_base_addr = 0; s->sof_timing = 64; - for(i = 0; i < UHCI_PORTS; i++) { + for (i = 0; i < UHCI_PORTS; i++) { port = &s->ports[i]; port->ctrl = 0x0080; if (port->port.dev && port->port.dev->attached) { @@ -387,7 +388,7 @@ static void uhci_port_write(void *opaque, hwaddr addr, trace_usb_uhci_mmio_writew(addr, val); - switch(addr) { + switch (addr) { case 0x00: if ((val & UHCI_CMD_RS) && !(s->cmd & UHCI_CMD_RS)) { /* start frame processing */ @@ -404,7 +405,7 @@ static void uhci_port_write(void *opaque, hwaddr addr, int i; /* send reset on the USB bus */ - for(i = 0; i < UHCI_PORTS; i++) { + for (i = 0; i < UHCI_PORTS; i++) { port = &s->ports[i]; usb_device_reset(port->port.dev); } @@ -425,10 +426,13 @@ static void uhci_port_write(void *opaque, hwaddr addr, break; case 0x02: s->status &= ~val; - /* XXX: the chip spec is not coherent, so we add a hidden - register to distinguish between IOC and SPD */ - if (val & UHCI_STS_USBINT) + /* + * XXX: the chip spec is not coherent, so we add a hidden + * register to distinguish between IOC and SPD + */ + if (val & UHCI_STS_USBINT) { s->status2 = 0; + } uhci_update_irq(s); break; case 0x04: @@ -436,8 +440,9 @@ static void uhci_port_write(void *opaque, hwaddr addr, uhci_update_irq(s); break; case 0x06: - if (s->status & UHCI_STS_HCHALTED) + if (s->status & UHCI_STS_HCHALTED) { s->frnum = val & 0x7ff; + } break; case 0x08: s->fl_base_addr &= 0xffff0000; @@ -464,8 +469,8 @@ static void uhci_port_write(void *opaque, hwaddr addr, dev = port->port.dev; if (dev && dev->attached) { /* port reset */ - if ( (val & UHCI_PORT_RESET) && - !(port->ctrl & UHCI_PORT_RESET) ) { + if ((val & UHCI_PORT_RESET) && + !(port->ctrl & UHCI_PORT_RESET)) { usb_device_reset(dev); } } @@ -487,7 +492,7 @@ static uint64_t uhci_port_read(void *opaque, hwaddr addr, unsigned size) UHCIState *s = opaque; uint32_t val; - switch(addr) { + switch (addr) { case 0x00: val = s->cmd; break; @@ -533,12 +538,13 @@ static uint64_t uhci_port_read(void *opaque, hwaddr addr, unsigned size) } /* signal resume if controller suspended */ -static void uhci_resume (void *opaque) +static void uhci_resume(void *opaque) { UHCIState *s = (UHCIState *)opaque; - if (!s) + if (!s) { return; + } if (s->cmd & UHCI_CMD_EGSM) { s->cmd |= UHCI_CMD_FGR; @@ -674,7 +680,8 @@ static int uhci_handle_td_error(UHCIState *s, UHCI_TD *td, uint32_t td_addr, return ret; } -static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_t *int_mask) +static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, + uint32_t *int_mask) { int len = 0, max_len; uint8_t pid; @@ -682,8 +689,9 @@ static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_ max_len = ((td->token >> 21) + 1) & 0x7ff; pid = td->token & 0xff; - if (td->ctrl & TD_CTRL_IOS) + if (td->ctrl & TD_CTRL_IOS) { td->ctrl &= ~TD_CTRL_ACTIVE; + } if (async->packet.status != USB_RET_SUCCESS) { return uhci_handle_td_error(s, td, async->td_addr, @@ -693,12 +701,15 @@ static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_ len = async->packet.actual_length; td->ctrl = (td->ctrl & ~0x7ff) | ((len - 1) & 0x7ff); - /* The NAK bit may have been set by a previous frame, so clear it - here. The docs are somewhat unclear, but win2k relies on this - behavior. */ + /* + * The NAK bit may have been set by a previous frame, so clear it + * here. The docs are somewhat unclear, but win2k relies on this + * behavior. + */ td->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK); - if (td->ctrl & TD_CTRL_IOC) + if (td->ctrl & TD_CTRL_IOC) { *int_mask |= 0x01; + } if (pid == USB_TOKEN_IN) { pci_dma_write(&s->dev, td->buffer, async->buf, len); @@ -780,9 +791,11 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, if (async) { if (queuing) { - /* we are busy filling the queue, we are not prepared - to consume completed packages then, just leave them - in async state */ + /* + * we are busy filling the queue, we are not prepared + * to consume completed packages then, just leave them + * in async state + */ return TD_RESULT_ASYNC_CONT; } if (!async->done) { @@ -832,7 +845,7 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, } usb_packet_addbuf(&async->packet, async->buf, max_len); - switch(pid) { + switch (pid) { case USB_TOKEN_OUT: case USB_TOKEN_SETUP: pci_dma_read(&s->dev, td->buffer, async->buf, max_len); @@ -911,12 +924,15 @@ static void qhdb_reset(QhDb *db) static int qhdb_insert(QhDb *db, uint32_t addr) { int i; - for (i = 0; i < db->count; i++) - if (db->addr[i] == addr) + for (i = 0; i < db->count; i++) { + if (db->addr[i] == addr) { return 1; + } + } - if (db->count >= UHCI_MAX_QUEUES) + if (db->count >= UHCI_MAX_QUEUES) { return 1; + } db->addr[db->count++] = addr; return 0; @@ -970,8 +986,10 @@ static void uhci_process_frame(UHCIState *s) for (cnt = FRAME_MAX_LOOPS; is_valid(link) && cnt; cnt--) { if (!s->completions_only && s->frame_bytes >= s->frame_bandwidth) { - /* We've reached the usb 1.1 bandwidth, which is - 1280 bytes/frame, stop processing */ + /* + * We've reached the usb 1.1 bandwidth, which is + * 1280 bytes/frame, stop processing + */ trace_usb_uhci_frame_stop_bandwidth(); break; } @@ -1120,8 +1138,10 @@ static void uhci_frame_timer(void *opaque) uhci_async_validate_begin(s); uhci_process_frame(s); uhci_async_validate_end(s); - /* The spec says frnum is the frame currently being processed, and - * the guest must look at frnum - 1 on interrupt, so inc frnum now */ + /* + * The spec says frnum is the frame currently being processed, and + * the guest must look at frnum - 1 on interrupt, so inc frnum now + */ s->frnum = (s->frnum + 1) & 0x7ff; s->expire_time += frame_t; } @@ -1174,7 +1194,7 @@ void usb_uhci_common_realize(PCIDevice *dev, Error **errp) if (s->masterbus) { USBPort *ports[UHCI_PORTS]; - for(i = 0; i < UHCI_PORTS; i++) { + for (i = 0; i < UHCI_PORTS; i++) { ports[i] = &s->ports[i].port; } usb_register_companion(s->masterbus, ports, UHCI_PORTS, @@ -1200,8 +1220,10 @@ void usb_uhci_common_realize(PCIDevice *dev, Error **errp) memory_region_init_io(&s->io_bar, OBJECT(s), &uhci_ioport_ops, s, "uhci", 0x20); - /* Use region 4 for consistency with real hardware. BSD guests seem - to rely on this. */ + /* + * Use region 4 for consistency with real hardware. BSD guests seem + * to rely on this. + */ pci_register_bar(&s->dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar); } From patchwork Tue Dec 31 20:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854410 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089753wrq; Tue, 31 Dec 2024 12:24:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUSCb7bS/WB8A8hDXISx56c1+MoapSVtbdw2MSdWhB6IXdnl6xVSDgq7GaskDve5FHqOrKTPg==@linaro.org X-Google-Smtp-Source: AGHT+IGqppR2KjTrbRY/UT+YI9TCy/coCM66LrhLxJJA/Y2TqLMAzDOfqOGymkAC6TTegw56i2mJ X-Received: by 2002:a05:620a:172a:b0:7ae:4b83:daf2 with SMTP id af79cd13be357-7b9ba86cfa2mr5929051185a.61.1735676676209; Tue, 31 Dec 2024 12:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676676; cv=none; d=google.com; s=arc-20240605; b=Ue1r8A9mDvI7d9j7aQL1Lh6iFpIlbQPuANkJywT/qcaI8lesWEQOgITwwrcaDEJwEr XMPLQ/qL188DcqjPy9yEPBgSOlOLu2Heg8A0Txb8VV9d6GOHc6qn7S1X8nmenpDQr0ie cmiX0oGXMsyGlf/ef+yuOZSLVr2beKykwqFCajh89ZHxZjpBd2jKZMnsD3ab05IOiU3K HgXaeXJ/LR5VuFD4seXHIZ4L9A8xPWgS5EndXjwJCDaXmARi885LzmilzoTbjy3A+9TB 0hCWUthsLQhZPdewLyOlh9JM19/heTWCZ8r8dWMO3StVVRfdPBsgTW+u33rHvOrxQPnM Qv9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JXQtPIRMHtqCLfqXYGaOwpsFtz/fcVXJzzd8RkMtGSE=; fh=yiU9Mxm8CcFWWs+6HrK0rKYVwNIxU4NZv47C3VUKcmQ=; b=fuRjr3V9N4ryeKGRUd6kUkcq3edsjYaj89Ub1Mjh+tLhXdYsb/tNOpDgm7H9YNdSU7 rTizCe/qOkqBQ/zEVdRr3IdMDUT3zrYSLODZaxcQpXynt10bUJsPZulMi9Ywvy86jMvZ KzV+JmCSRAbFD6IcviWJSJO0GliwZ6K/jdPn/WXcDR3bfGODel9zLYRjvKYeY6LEJf/6 S6rSPXBR2LHRIMQx5IotRVEB5dliayAZSzIw0yZXrBNGyFZFbOWKG1eyCZ9aUuMMphtz m2p0PzWJ5gWymFP4k+v85JH2PTH/nsShRhhszY2QJ52NFvhy4W8GJDwk7ynMU9vefKlX rrHw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gsV8Hq7S; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac54d749si2959095885a.664.2024.12.31.12.24.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gsV8Hq7S; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSila-0002LB-Ci; Tue, 31 Dec 2024 15:23:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilX-0002L1-8B for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:00 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilV-0000pw-Lw for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:22:59 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-385e1fcb0e1so5601584f8f.2 for ; Tue, 31 Dec 2024 12:22:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676575; x=1736281375; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JXQtPIRMHtqCLfqXYGaOwpsFtz/fcVXJzzd8RkMtGSE=; b=gsV8Hq7STBVOh+0BpR82gIL7Gtja3O5OIVFkFW93VNchvVPmLfmdmuvf/dtIYLExlV AzOC0HEE18Uu7L0X8eeSQwI2p9fJoZWy8SFeYEh9SexUGaXyWs0czJdVRmTbDVPhgWcZ jIRD8Gje7OaDIseAteRvk2nBtMtALPkPBhHMQQiumGCouGOm+adq0t3MHbUIoTPp/jUW 0Rj9Ab1sm7UvqF1k6Sk2EY4e55X2/N8PS8XV+3+SD3bkjtf6gkAMxdTQOyj17JYvIA7y P0GNAEVaRsQhnyIkXeh1bJFaGY9uOWIn40l0oTYcqGM7PfG3EyiKVaLPXwwtZkMx77lq wXkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676575; x=1736281375; 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=JXQtPIRMHtqCLfqXYGaOwpsFtz/fcVXJzzd8RkMtGSE=; b=G31n5gxAl2CSJpXUrsr/9NvaQqsFNGrqqeUgzdvbElW6o9oafjEvhEiMEiGK2ULrYi oRGfRSDbqVQxWge8ak+GFI4lQZL1WrXAREgLYLjeRwRDj3gwE30gX3l7TFRqOg4Fkb3w XrjNG27yKInwsdHoNqMwONp16FjsPeOGgRgUtbHR4TjYZ0mWsYNN1kCz0u1QsMY9tTdg uvG2e1hEoWUeR6H8X1DimPEjEX2FomanTw6gvdnZFnzgPkom3pbEM/81SzGtd23g8oiZ ZFtWnKJJmkJxBvY5e+9w7DkDvU/t7p1JGXrB/qD8MCKBMpVuk1bwVFJ4BDxpT0Yb58B1 k37A== X-Gm-Message-State: AOJu0Yw7Iqpytb5f8/Rinq6MjkBl1Dqf9y78gnvilOafNPsesUTjl/G8 8iEEr4LJh1ykYsZwZGgnn5gEJrNHFsn5CN14/88QeUyM8LUfb6tOFgw3fgloEl+TH1C9ogvxeRM W4B8= X-Gm-Gg: ASbGncvice4+dILTjSzHZ5maqSat/pgfVQ8Yx8VS4g5i3+YhG2NYYtDLcFe4fFiZ+JO BgXqEabgd8LrQcZOcLERbf6SN9p1RHDlU/6cfnhQpqx6XKaUoz2otQRIXx2CF0xqCZcCyXDXZWu 8BI1LLDJ7flVYJMwOIjgLAkPf9sk6FXrvQ3TB5heRtdjRV5uumBR1Xp+LKLlqaXeSCFBJE276zl yYYm9VPHtSg7rDvbdhoqAyqrUjA3abWX0n7p98Qhp/qQEW07LWdm/s8GnH5u5m9J/RwyReQqeaB bLisocUj4xdMJHm9tq0sQyi50HQ10OM= X-Received: by 2002:a05:6000:188e:b0:382:5010:c8de with SMTP id ffacd0b85a97d-38a223fd729mr35020802f8f.46.1735676574781; Tue, 31 Dec 2024 12:22:54 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656a0b361sm431645315e9.0.2024.12.31.12.22.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:22:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Guenter Roeck , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Math?= =?utf-8?q?ieu-Daud=C3=A9?= Subject: [PULL 05/29] hw/usb/uhci: Introduce and use register defines Date: Tue, 31 Dec 2024 21:22:04 +0100 Message-ID: <20241231202228.28819-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Guenter Roeck Introduce defines for UHCI registers to simplify adding register access in subsequent patches of the series. No functional change. Signed-off-by: Guenter Roeck Reviewed-by: Cédric Le Goater Message-ID: <20240906122542.3808997-3-linux@roeck-us.net> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/usb/uhci-regs.h | 11 +++++++++++ hw/usb/hcd-uhci.c | 32 ++++++++++++++++---------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/include/hw/usb/uhci-regs.h b/include/hw/usb/uhci-regs.h index fd45d29db0f..5b81714e5c2 100644 --- a/include/hw/usb/uhci-regs.h +++ b/include/hw/usb/uhci-regs.h @@ -1,6 +1,17 @@ #ifndef HW_USB_UHCI_REGS_H #define HW_USB_UHCI_REGS_H +#define UHCI_USBCMD 0 +#define UHCI_USBSTS 2 +#define UHCI_USBINTR 4 +#define UHCI_USBFRNUM 6 +#define UHCI_USBFLBASEADD 8 +#define UHCI_USBSOF 0x0c +#define UHCI_USBPORTSC1 0x10 +#define UHCI_USBPORTSC2 0x12 +#define UHCI_USBPORTSC3 0x14 +#define UHCI_USBPORTSC4 0x16 + #define UHCI_CMD_FGR (1 << 4) #define UHCI_CMD_EGSM (1 << 3) #define UHCI_CMD_GRESET (1 << 2) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 7c0cc694554..8528d493d63 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -389,7 +389,7 @@ static void uhci_port_write(void *opaque, hwaddr addr, trace_usb_uhci_mmio_writew(addr, val); switch (addr) { - case 0x00: + case UHCI_USBCMD: if ((val & UHCI_CMD_RS) && !(s->cmd & UHCI_CMD_RS)) { /* start frame processing */ trace_usb_uhci_schedule_start(); @@ -424,7 +424,7 @@ static void uhci_port_write(void *opaque, hwaddr addr, } } break; - case 0x02: + case UHCI_USBSTS: s->status &= ~val; /* * XXX: the chip spec is not coherent, so we add a hidden @@ -435,27 +435,27 @@ static void uhci_port_write(void *opaque, hwaddr addr, } uhci_update_irq(s); break; - case 0x04: + case UHCI_USBINTR: s->intr = val; uhci_update_irq(s); break; - case 0x06: + case UHCI_USBFRNUM: if (s->status & UHCI_STS_HCHALTED) { s->frnum = val & 0x7ff; } break; - case 0x08: + case UHCI_USBFLBASEADD: s->fl_base_addr &= 0xffff0000; s->fl_base_addr |= val & ~0xfff; break; - case 0x0a: + case UHCI_USBFLBASEADD + 2: s->fl_base_addr &= 0x0000ffff; s->fl_base_addr |= (val << 16); break; - case 0x0c: + case UHCI_USBSOF: s->sof_timing = val & 0xff; break; - case 0x10 ... 0x1f: + case UHCI_USBPORTSC1 ... UHCI_USBPORTSC4: { UHCIPort *port; USBDevice *dev; @@ -493,28 +493,28 @@ static uint64_t uhci_port_read(void *opaque, hwaddr addr, unsigned size) uint32_t val; switch (addr) { - case 0x00: + case UHCI_USBCMD: val = s->cmd; break; - case 0x02: + case UHCI_USBSTS: val = s->status; break; - case 0x04: + case UHCI_USBINTR: val = s->intr; break; - case 0x06: + case UHCI_USBFRNUM: val = s->frnum; break; - case 0x08: + case UHCI_USBFLBASEADD: val = s->fl_base_addr & 0xffff; break; - case 0x0a: + case UHCI_USBFLBASEADD + 2: val = (s->fl_base_addr >> 16) & 0xffff; break; - case 0x0c: + case UHCI_USBSOF: val = s->sof_timing; break; - case 0x10 ... 0x1f: + case UHCI_USBPORTSC1 ... UHCI_USBPORTSC4: { UHCIPort *port; int n; From patchwork Tue Dec 31 20:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854401 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089509wrq; Tue, 31 Dec 2024 12:23:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXRGMUcvGg0YkEOpQ02OppLQH0TvWoREAW3IXihYK041vZ0wn8HDHQb/7ERltfohyGH6dXxxg==@linaro.org X-Google-Smtp-Source: AGHT+IG6pqfhDlcwfAMPBOw4P7D4gbJALFAjWf4jSUZ+uQJnBxEp0mYxeOslZZKUzpqX+kQ4pi4z X-Received: by 2002:a05:620a:1706:b0:7b6:ebc6:181a with SMTP id af79cd13be357-7b9ba7f68d8mr5710063385a.41.1735676624571; Tue, 31 Dec 2024 12:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676624; cv=none; d=google.com; s=arc-20240605; b=GPyAwBzvPIRQqFIOvOcs3/VAMDJmN7MZrvl4pZebNWM4YypL4e02aUDSoUKu3eCsNs aG2oTW81W1ChPDDxyIkZomKg5z7t87Ye9gYns1JNr4EZ2gUOcfgXZbLiJermWC4lZ+i2 lLQj30rxRp4BEF8lMWwQu9HnWe1NLPzO1NbtyfW3pPgtlWI7efcXHXqiMymkCTfilXnm Devt6snu8/YUe8XR16UxGEk/F0DzOuQ8Dg31CDZvqv3iCcwM7+NJfFDiKIO3oW/YFqdi 3RhPT1ckmgNdoc5nl3/W4iIXMKqZKhbEXYSyGXkjUXL5M+XOAyFnLso7K5d4bUQb1V87 p/5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9UzpwHwbOoYdzO4Z1to6i1SI44M6INou8CYiONK44XQ=; fh=9ryy5d9yM4+mge+SJGod7b/IwVykaYdArJ0wPRnwp4o=; b=i4QjHwN4B5PB+BeVoJu2aJXMY5ADM38wCgU8s8I7+wkPQzm75y1dqBjgjK1pp+MtGn PZjNQ+vF9PcsailC/7jCLmVW7KWoUPvt5naQNMJmNS9qyrB90nrvGGSP7rK8DfnNa1YS Zp0lh/ytQ2Gc8LS10OPQhlH+1KzNf8bgDv9VxcU7Zr0GOgr+73tUBlbVnkUZdaTR6XEp +A8JgxBEnIjtqCZPmu0dfnxJx09GIP+kRFquXJAhegRZpD369dJ9IeQQ4PeHuK9cfpV6 4ytrMdItmpsW0pDEwvmgzW5rBPwjYShMf0/Ye4KT8CP+mYG0zifcmn2aLa8wWyy0gRKV dXTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W+hNRuPU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3ec058a7si89884581cf.712.2024.12.31.12.23.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:23:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W+hNRuPU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSilc-0002M3-TM; Tue, 31 Dec 2024 15:23:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilb-0002La-FN for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:03 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilZ-0000qF-PI for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:03 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-436202dd730so74017235e9.2 for ; Tue, 31 Dec 2024 12:23:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676579; x=1736281379; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9UzpwHwbOoYdzO4Z1to6i1SI44M6INou8CYiONK44XQ=; b=W+hNRuPUlDM1UKHUN/m3lWuKpEgcRgzZWFZ30DcU6NtSIOUpuMEQSRs1DwG152X74U 7FRaQ9Ptcx2jKW8/emrU63Jn74TocIIWtvicRtsxXzEreTYweYlXyhjq09KWNSjLWnuj m9Xhgjj3uNvsNwFwbmL4xLGEojTsVHz3s52sVgJjOjQoKPD3Lpy5yNWdaJwE5r9Jnxnt +pouPKzaFcHTOP1c983aojZ0pkLpXMIwMNNEVOnZn0FasDtAu30R+n/5NYkmBsaeyIi1 MzU5/Ntw4qjS4UICvUNeKOiA030itOX0h65K4sGDZTWVRNo0YTa6+gc00eNbC4fFcPNT TFzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676579; x=1736281379; 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=9UzpwHwbOoYdzO4Z1to6i1SI44M6INou8CYiONK44XQ=; b=fWbuKh512ICV315Ey3RI+EiDhKfP5LNE1hzLUhhz4hhUTzL+9ueJh3PC8rJlboxEFQ 3eLCR+dj1zqsRXvcu8X8XT/HHQgnIJfQdkzJnJQcAsWkooHzfv9XQoPD16PKMm4+VZaO QRq2JZauTnNXETvYP26WJ8Ws1IPZmPmNv1OnG7HzbDMZIEuLJvb0PSQtcZe1vex0rFoM XQwxiXW0Lk8BzPvGjAkrEGiBBalqd+P//mlTpRGhSJ7Ut984h9xy7KkgNT5wnvysBFlP gGyDhSt08/2nIIydRIltCjokeEmg+YYlSmT6m20YpX2392+bW5XruQ7KUTs/CEOT+WRI 0q4A== X-Gm-Message-State: AOJu0YwvAtYF+auebCNVWjdn4FjRSuCq1QfgDVJB0BPJ921AMabiYqiV g798YJnUap1F7KeD74HHUVUPA9d3L5o9xZDlN6vnC9NMYbb6I7mpcDMNL1dHrxpUqZfrBXjgGdT k+r4= X-Gm-Gg: ASbGncvhlpDuVsI28g38M00I/Wur5g8cE2GW2d2b15pozxScVBM2cwNadsrSuYcvqiv Od+XKDWXxdq0qq8D+9FKr0Pku4EewZqg38SSQkvTQetgwIvUPUxq9eaMGUzUF5SelJVgNV7Ic/C OFv4bDf0eK0v/xq6HoEFkambbJLno3JId5dBC01TwIZFxtz7se4sAvXZD9fuxOvo8R9LU7AFRAJ i2SMHUtyaNkIx/4AsFR50zwVVmcImS/cCyktTdIJtp4rnTOcroGTvVSbFEK7tODDSGDcv2F5qL8 xzFfm+ljcMsSuWU1tOW1ic7opYIgBjU= X-Received: by 2002:a5d:6da3:0:b0:385:fb59:8358 with SMTP id ffacd0b85a97d-38a223fd8c8mr30036251f8f.53.1735676579330; Tue, 31 Dec 2024 12:22:59 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c89e150sm33551345f8f.66.2024.12.31.12.22.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:22:58 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anton Johansson , Alistair Francis , "Edgar E. Iglesias" , Richard Henderson Subject: [PULL 06/29] hw/microblaze: Propagate CPU endianness to microblaze_load_kernel() Date: Tue, 31 Dec 2024 21:22:05 +0100 Message-ID: <20241231202228.28819-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Pass vCPU endianness as argument so we can load kernels with different endianness (different from the qemu-system-binary builtin one). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Anton Johansson Reviewed-by: Alistair Francis Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-Id: <20241107012223.94337-3-philmd@linaro.org> --- hw/microblaze/boot.h | 4 ++-- hw/microblaze/boot.c | 8 ++++---- hw/microblaze/petalogix_ml605_mmu.c | 2 +- hw/microblaze/petalogix_s3adsp1800_mmu.c | 2 +- hw/microblaze/xlnx-zynqmp-pmu.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/microblaze/boot.h b/hw/microblaze/boot.h index 5a8c2f79750..d179a551a69 100644 --- a/hw/microblaze/boot.h +++ b/hw/microblaze/boot.h @@ -2,8 +2,8 @@ #define MICROBLAZE_BOOT_H -void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base, - uint32_t ramsize, +void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is_little_endian, + hwaddr ddr_base, uint32_t ramsize, const char *initrd_filename, const char *dtb_filename, void (*machine_cpu_reset)(MicroBlazeCPU *)); diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index 966fb2cb2a3..3854bc2291b 100644 --- a/hw/microblaze/boot.c +++ b/hw/microblaze/boot.c @@ -114,8 +114,8 @@ static uint64_t translate_kernel_address(void *opaque, uint64_t addr) return addr - 0x30000000LL; } -void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base, - uint32_t ramsize, +void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is_little_endian, + hwaddr ddr_base, uint32_t ramsize, const char *initrd_filename, const char *dtb_filename, void (*machine_cpu_reset)(MicroBlazeCPU *)) @@ -144,13 +144,13 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base, /* Boots a kernel elf binary. */ kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &entry, NULL, &high, NULL, - TARGET_BIG_ENDIAN, EM_MICROBLAZE, 0, 0); + !is_little_endian, EM_MICROBLAZE, 0, 0); base32 = entry; if (base32 == 0xc0000000) { kernel_size = load_elf(kernel_filename, NULL, translate_kernel_address, NULL, &entry, NULL, NULL, NULL, - TARGET_BIG_ENDIAN, EM_MICROBLAZE, 0, 0); + !is_little_endian, EM_MICROBLAZE, 0, 0); } /* Always boot into physical ram. */ boot_info.bootstrap_pc = (uint32_t)entry; diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c index deab275495d..8b44be75a22 100644 --- a/hw/microblaze/petalogix_ml605_mmu.c +++ b/hw/microblaze/petalogix_ml605_mmu.c @@ -204,7 +204,7 @@ petalogix_ml605_init(MachineState *machine) cpu->cfg.pvr_regs[5] = 0xc56be000; cpu->cfg.pvr_regs[10] = 0x0e000000; /* virtex 6 */ - microblaze_load_kernel(cpu, MEMORY_BASEADDR, ram_size, + microblaze_load_kernel(cpu, true, MEMORY_BASEADDR, ram_size, machine->initrd_filename, BINARY_DEVICE_TREE_FILE, NULL); diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c index 4a969af1a01..2c0d8c34cd2 100644 --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c @@ -129,7 +129,7 @@ petalogix_s3adsp1800_init(MachineState *machine) create_unimplemented_device("xps_gpio", GPIO_BASEADDR, 0x10000); - microblaze_load_kernel(cpu, ddr_base, ram_size, + microblaze_load_kernel(cpu, !TARGET_BIG_ENDIAN, ddr_base, ram_size, machine->initrd_filename, BINARY_DEVICE_TREE_FILE, NULL); diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c index 567aad47bfc..bdbf7328bf4 100644 --- a/hw/microblaze/xlnx-zynqmp-pmu.c +++ b/hw/microblaze/xlnx-zynqmp-pmu.c @@ -172,7 +172,7 @@ static void xlnx_zynqmp_pmu_init(MachineState *machine) qdev_realize(DEVICE(pmu), NULL, &error_fatal); /* Load the kernel */ - microblaze_load_kernel(&pmu->cpu, XLNX_ZYNQMP_PMU_RAM_ADDR, + microblaze_load_kernel(&pmu->cpu, true, XLNX_ZYNQMP_PMU_RAM_ADDR, machine->ram_size, machine->initrd_filename, machine->dtb, From patchwork Tue Dec 31 20:22:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854406 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089585wrq; Tue, 31 Dec 2024 12:24:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXU7hEepMVLwKt1/uEFjDRWwlyaHlDXRgVqWF0n6VzBX1Rh1J6vYs03iRfoTY+NbopaSPo44g==@linaro.org X-Google-Smtp-Source: AGHT+IHrA07JGSTCDbjLXxuEXsAX5p3P3Qi3kkSzmMONps+QyARD6wEFkNvbGuq/6LlPmTFAAAWJ X-Received: by 2002:a05:622a:1802:b0:466:82b7:8bc2 with SMTP id d75a77b69052e-46a4b1a8872mr627341331cf.25.1735676643310; Tue, 31 Dec 2024 12:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676643; cv=none; d=google.com; s=arc-20240605; b=HJFx8j3RkH8FJcYTR8lcsK+Bkqy+41f6F4cizukUbP76Rb0Wq/8C73IttR78XnVouq 6Ugk8c+XUDNB8J8uJxhyZLmAfprHxtm6vsDIPWd90a8ACMlx/HXruqOwKpj9jSZqTa0d JY2Vfg9t+6EfBdqcofgJ4L6z1uQbcOKnEMQM54lBL70aDMGwThzByQWeo+XaE5tr0Trp BqOtoNONXwfRnPWq6u197ZygujY3/J8RK9SBskfhmIFlPbfj1csYuhY3wL/nN2ps/gs0 /vVCh9SxbUuW1yXraZzUTxcPDY/xC0WjU2nig9LkUfP8NGSJhq+u6jE+OB4kAJcMtuEu QycA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GTH2NS4uBQl2BnMaC5NUzMTAA4jFlWhBioB2cxgitBU=; fh=MSsnF9v2bmvHZJkRgOZBuXbVPVh7ndcEbvi08yUt/bE=; b=UjP2Rdh+uCQHYz3GqWm2Tv9zvtiKaivzQlQ8hLGQkf1ET/FG9rCwWWSO2Uihylm7LO Sgk4oxIIRyw7uGA5LS+r11t01flaWBRy9iNVXVNmNZsrYl3/1msUWY/rnjdGX/ngIzhY kMY8a3Z6o9V6qHgP5XdwLb0ShESyZKvtcvxo1dpY5q8bkUYUN3tQDVmfeGDrHRe6q2Wu c6W9eR8rgGFmTRhfB31BrhM3DhOtqhLbvuWSi04P9gKGlkNxvnzH+wDAzdyVw+UjlQev Wc6K25OWpTGsl0VkptQ8WIIW2Nr1WeUb7x1PLyasfijr/8wgyi8LjZy0KnpLp9GoXR52 Cfdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K1KX2neA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac4ccc19si3285325585a.397.2024.12.31.12.24.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K1KX2neA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSili-0002MN-7N; Tue, 31 Dec 2024 15:23:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilg-0002M8-8k for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:08 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSile-0000qY-LB for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:08 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4361f796586so106895275e9.3 for ; Tue, 31 Dec 2024 12:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676584; x=1736281384; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GTH2NS4uBQl2BnMaC5NUzMTAA4jFlWhBioB2cxgitBU=; b=K1KX2neA/ULhbEPrDQau4crtUIeLDFnDBBx9s7RaM/D0hHo37fPROQwk+CUAYK1mMS lFmGMcHWuzVCqvZVrH4sHogchJwXufs6mRQ0Uz8wuN3g2pt/0BPuzCaZbdtYKsBlq3aj I6TTsTxjK8a7yvkU4CWcZY4SlKLcpHk9ySLNRphUVXLh10RCnY62lDvijAnMS2uOqUBu 3nlliTO/nJDp3dsfX0/WTRkkCUpedeRHJebaZFSu3rdlax2LGwmah4UbFqbOk0BF7APv XW++vC5XSykILT7aAN39iArtp8DIQqdFI7ysyit1FFQ8UKWrtliXP+sgjj6V823Gznbf XjPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676584; x=1736281384; 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=GTH2NS4uBQl2BnMaC5NUzMTAA4jFlWhBioB2cxgitBU=; b=McBpFYzrMNHpIMJRBRaxu/9fT+C0pv/+JOj07w1qbGngHsWckVzQnUB1QKZ8cqP9zl FXYu17PyquhVKhHn5xnBLAmEF7v74hTittBEcLOsavz+W7CzP3PYX8ch02hmCERH3BFb p/K6ouqe3fTxS9Xdc8P7MmkP8RD99++Ax8w64H+vZUYOyxzak/mbqxb8q4WROhAydQMP cdzX/SBIGvXdGz9kHmh2/qclMGTczZ1FRxdbkaY9F9r/Qi0c3Q2zGjaS6xvBt5yaD36q jFyU/IoyGgwWzOsPOFSrBPhHIMDv6h8Yc57eOLPdR1Vo0Sn8/I54xfpOIbSbCmQ3s5XY u9FQ== X-Gm-Message-State: AOJu0YxmbB7c/ia9wsjxnW5J9lV4HeBkClpOD/E742d6QjCUCV6gRI1H oT1fS+39UR0o4utI2yZpQJ3AYf64mpQkRC3xDRNG3MOpK2mL9YnNqnzC7VkEdNZYvZir8x9OjRM C6AY= X-Gm-Gg: ASbGncvxCDFhXs04qWv8bvq7ZQLRLK1tRG9RDp6iULbEsjeKOAc9D61554YCsejjBW4 MD5zHlnEzPyGRhN9voMxNsCfFNe6lufeg6SoHzMnX2c818JJBI2S3BjJY1ep7w2fgtP8kaHAa0C TPW+tOqyKrievu+1OFsQQ6Y5hKK/3tjdOlqX/IRSuAh+OaNTmNNgA3jUDxOcqfZj/YnVgGE391n 5BLCiDKuSa7n2nwyTzeufKVun+EO1jv2xKhN/iGaOh3jEQqw9QjKj34w/oZd7sTg778RonUkSvC itf7Tc6/iVfsv7/Kq7DmTOSP44IL8o4= X-Received: by 2002:a05:600c:1383:b0:434:fddf:5c0c with SMTP id 5b1f17b1804b1-4366835c41emr342504985e9.4.1735676584615; Tue, 31 Dec 2024 12:23:04 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b4471bsm431993565e9.44.2024.12.31.12.23.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Thomas Huth Subject: [PULL 07/29] hw/i386: Mark devices as little-endian Date: Tue, 31 Dec 2024 21:22:06 +0100 Message-ID: <20241231202228.28819-8-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These devices are only used by the X86 targets, which are only built as little-endian. Therefore the DEVICE_NATIVE_ENDIAN definition expand to DEVICE_LITTLE_ENDIAN (besides, the DEVICE_BIG_ENDIAN case isn't tested). Simplify directly using DEVICE_LITTLE_ENDIAN. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-Id: <20241106184612.71897-2-philmd@linaro.org> --- hw/i386/kvm/apic.c | 2 +- hw/i386/pc.c | 4 ++-- hw/i386/vapic.c | 2 +- hw/i386/xen/xen_apic.c | 2 +- hw/i386/xen/xen_platform.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c index 602c7696565..75751060009 100644 --- a/hw/i386/kvm/apic.c +++ b/hw/i386/kvm/apic.c @@ -214,7 +214,7 @@ static void kvm_apic_mem_write(void *opaque, hwaddr addr, static const MemoryRegionOps kvm_apic_io_ops = { .read = kvm_apic_mem_read, .write = kvm_apic_mem_write, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, }; static void kvm_apic_reset(APICCommonState *s) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 53a2f226d03..71118765884 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1068,7 +1068,7 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus) static const MemoryRegionOps ioport80_io_ops = { .write = ioport80_write, .read = ioport80_read, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, .impl = { .min_access_size = 1, .max_access_size = 1, @@ -1078,7 +1078,7 @@ static const MemoryRegionOps ioport80_io_ops = { static const MemoryRegionOps ioportF0_io_ops = { .write = ioportF0_write, .read = ioportF0_read, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, .impl = { .min_access_size = 1, .max_access_size = 1, diff --git a/hw/i386/vapic.c b/hw/i386/vapic.c index 0e6d058d063..14de9b7a820 100644 --- a/hw/i386/vapic.c +++ b/hw/i386/vapic.c @@ -718,7 +718,7 @@ static uint64_t vapic_read(void *opaque, hwaddr addr, unsigned size) static const MemoryRegionOps vapic_ops = { .write = vapic_write, .read = vapic_read, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, }; static void vapic_realize(DeviceState *dev, Error **errp) diff --git a/hw/i386/xen/xen_apic.c b/hw/i386/xen/xen_apic.c index 101e16a7662..a94e9005cbe 100644 --- a/hw/i386/xen/xen_apic.c +++ b/hw/i386/xen/xen_apic.c @@ -36,7 +36,7 @@ static void xen_apic_mem_write(void *opaque, hwaddr addr, static const MemoryRegionOps xen_apic_io_ops = { .read = xen_apic_mem_read, .write = xen_apic_mem_write, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, }; static void xen_apic_realize(DeviceState *dev, Error **errp) diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c index 0f68c3fe7b3..dd648a2ee94 100644 --- a/hw/i386/xen/xen_platform.c +++ b/hw/i386/xen/xen_platform.c @@ -514,7 +514,7 @@ static void platform_mmio_write(void *opaque, hwaddr addr, static const MemoryRegionOps platform_mmio_handler = { .read = &platform_mmio_read, .write = &platform_mmio_write, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, }; static void platform_mmio_setup(PCIXenPlatformState *d) From patchwork Tue Dec 31 20:22:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854420 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090119wrq; Tue, 31 Dec 2024 12:25:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV2oEA2Q1gMNas4JjH7Gs1/VeMq+dJlmsQ3dvQKBDlCYNcl0lRCOnPaF0mRKGMyLnLPeupbLw==@linaro.org X-Google-Smtp-Source: AGHT+IEpxqoyxegRjo7UYNPSTLPdfLhpJJ5TWboTl466PnXIWrsz3YMkhJVnlHyvZAMg36ZltTsF X-Received: by 2002:a05:620a:2a12:b0:7b6:cb07:24bc with SMTP id af79cd13be357-7b9ba7f6642mr6365315085a.48.1735676758002; Tue, 31 Dec 2024 12:25:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676757; cv=none; d=google.com; s=arc-20240605; b=Pdx9g9Of8qP2SlrKvyeRUlYVSBgUJ+VX6CD6GZMIToUkT+D9Epi3SHJxI1NWSR58D4 1MXgKCJNUDMxBCL5w0QTgSGcg160jUjh8w2wLz7T6RGOYaOOR3FKXlGEGG2hmWDgPQyW hxrlZyKyuHCnOywW7yDoM1QM2CGIbdEtXW+EhxALhqpX1e9Bk/Ndj30h5o2j+6cJbjX/ pAZyVhtP9IlJZuXDTGnFiA8nBaPoyuH+D++S09IxH9LMc1hsz8/0Ub3kFf3bCgWWWEMP JzwODSDSsIR/bjwPw7oX9EqJLo7EbzUoNRRamjrsMkCLnd/Ex1NlAc1+C4kOrH9BYVb3 ZZMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dGNPsqtn6WrBcmWHUQltDVOOi9FS/uGzmcny5x2XTrE=; fh=MSsnF9v2bmvHZJkRgOZBuXbVPVh7ndcEbvi08yUt/bE=; b=UTTpFLUxAu6OdVGEdJ6wNPAM+mULzGiZ1gQqyg5p5QyFNo/MDJI3T7q3r9NrAb9jRT xYSTQW/MupwmfMGPIX3gY9JugSgJWWzoQCkeqiGxyE8SSw5uaTlneww5ogM2tvDJyzUj clJ2kzU7ig+rvfJqUzUC0GVXByg31aXwi/fm+dKcPDdlUhoMYYxGF7X92tDyi4HXdSS6 RPGoiub/kmcX8Vv+uSdvJ76lfV4UFFJoWPMd+Y9Pd9cVsO4g1cgbFUf1N7+dlqqHEUAi WNg7K1rJm4VmOaXrC4qwD9cAWU1eILLhEJHcvcb8K5/FxUXzBhJcof5L5O8UO/4Erqy2 d5EA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nvHoZ4uS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3e6ad5ffsi329963311cf.184.2024.12.31.12.25.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:25:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nvHoZ4uS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSilm-0002Rm-K0; Tue, 31 Dec 2024 15:23:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSill-0002Mp-5S for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:13 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilj-0000r3-Jz for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:12 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-43618283dedso102591515e9.3 for ; Tue, 31 Dec 2024 12:23:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676590; x=1736281390; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dGNPsqtn6WrBcmWHUQltDVOOi9FS/uGzmcny5x2XTrE=; b=nvHoZ4uSutqa9yDJfSBV0lFIacSJoQz5NKtDFt5Sgt1f8VBYBz0EeiiMKcarN3orwd Hnl63TTZ2wM0jZAvQpC0gD9VeOK1SeHzK3ElLafqMNx+oJN2ae5IoaHKqX6TsRH6kbEk lQD0rg2+kfZkonbihJR0tWVZcz+tXICnV86IMcA125hmcJmtDg0gzIHywqX232ePoeCh e2wo3wsiW3f19YQin/Be6hex3+fVUIcTGHuv9oMBV9vxAzY0e9ExddPuBJDfdOQNDFpM iafPc682QYTbtaaIfnSoCRyliXJwe9yhCIVpWviO8gjpcZlcRRFdIRXPlj308kGzDRKB zacQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676590; x=1736281390; 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=dGNPsqtn6WrBcmWHUQltDVOOi9FS/uGzmcny5x2XTrE=; b=SmZs0rWKv640fZCNfYOr3MOPnZS3XM6Hh6z6HCYFuNzA69FGOH/213mT+Tr11okb+c fQ0b0K4kek12kl3JP43E6P4O5z6PGsqSXBAcrq8BXRE5xodBCeqzXJZ6RpOFhIeAF1H/ YTcumEPsl7ApX93K1b0ibF+qictAUPDqui2miMN29ljiH1CVRibpaHALtraDXWhuihc/ k3VUyWe8MhC2nG2um2uqbD6g0KrQvRtLewgs+UyZhYHlhUse/zPZQSRpnJaSFzMpp9FY QWDzBIhEMhO0iK0z5wIL+lCfN8+XxlO1dDSmvd7Mdr7LYzFlxWONmtRg6wXmuB1uj8B+ TzFA== X-Gm-Message-State: AOJu0YyVetL3R6lgp4ScgH+XOc6KgUSZrFV9GvNYE15WtD2HEZVpueRU VVhPWvLABKouHSDATxe3M8r/k4sgv3N+6ho8T+xvMu7e/huAtaA5CKx6wdPum5zhnNL8DhHrZl0 1vc8= X-Gm-Gg: ASbGncsC2VRmQyJHbwwTukQoOBZ9vF1os3AKIBbHUqGxGIvLhKPh/HWKT6y73fluUj+ SwQ04hy5NwBoZMfQz1w7JoLH0Rn8KQkQvwCQ4H1sn/2lIzQ97rtz/NdPszMtC3vyjNEUQGVpATR /OWbxr30m3BKCcfDwkhfi/FYePY8YsyhY6D/ahHs/2kYXSeKIcKOlqnfcBkS6Uzx+F6hU/Limm0 1h9IhtuFAK1F12n807RZ1eFmHgXl0k8tumlOy/qY0wPvQQDlLqhJLYcaOdSRBRJ5TX/xNd4aWgG rbHDvqMLPt6Y+OS2imo8y4NEWkqGjbw= X-Received: by 2002:a05:600c:45cf:b0:434:a781:f5e2 with SMTP id 5b1f17b1804b1-43668642289mr322212115e9.8.1735676589468; Tue, 31 Dec 2024 12:23:09 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8a636asm34466725f8f.88.2024.12.31.12.23.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:09 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Thomas Huth Subject: [PULL 08/29] hw/tricore: Mark devices as little-endian Date: Tue, 31 Dec 2024 21:22:07 +0100 Message-ID: <20241231202228.28819-9-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These devices are only used by the TriCore target, which is only built as little-endian. Therefore the DEVICE_NATIVE_ENDIAN definition expand to DEVICE_LITTLE_ENDIAN (besides, the DEVICE_BIG_ENDIAN case isn't tested). Simplify directly using DEVICE_LITTLE_ENDIAN. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-Id: <20241106184612.71897-3-philmd@linaro.org> --- hw/tricore/tricore_testdevice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/tricore/tricore_testdevice.c b/hw/tricore/tricore_testdevice.c index e60866d76fa..d2da74e3846 100644 --- a/hw/tricore/tricore_testdevice.c +++ b/hw/tricore/tricore_testdevice.c @@ -47,7 +47,7 @@ static const MemoryRegionOps tricore_testdevice_ops = { .min_access_size = 4, .max_access_size = 4, }, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, }; static void tricore_testdevice_init(Object *obj) From patchwork Tue Dec 31 20:22:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854428 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090372wrq; Tue, 31 Dec 2024 12:26:53 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWDi9iX3N3hRNoDlhnJKGCn5fmX6ujGaar6YKH0qnS2i4J//dHrAlN36zp9P+O/7YwtCwmzWQ==@linaro.org X-Google-Smtp-Source: AGHT+IFi8go/WAkRiD/26WJDtcxdInrQpNLvoK5vM+qnMkbt89iuA3aotdvghdI/73DqxHdXwNpg X-Received: by 2002:a05:6214:401c:b0:6d8:9a85:5b4d with SMTP id 6a1803df08f44-6dd2332ed93mr754630146d6.5.1735676813698; Tue, 31 Dec 2024 12:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676813; cv=none; d=google.com; s=arc-20240605; b=EHLXLcAbwr8CQScwO4eeSQguZCtZ5JiQnMWPtoCl9oSH6ns+1M2YMJOzgX3tdgI8f6 xy5m6Lw5hIHVgVgYkTsiRTI6vtAEYrERAGueNtkFSvdPROPUEXtuc4aJSPIg2cy9T9ib vujbiHc6AX+g281UN4G3uuu1zkASXb2F8/TwZ/9AVgnmRxNW2X68PmzT8W2si7FVLvL6 UQBuS6+2Alxw0OUgurApjrMA/V9XA7IoakULJgx15kuN1uxwKzi3UEvjMUPcVLdflz9D nPrIHlnY/eWfJhNUL0TTs6Z82KPk+lbLEqgOsl18D9uPUjieCilic090nRGc4TrymIF2 /irA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x7T+GlWRYF0Ex9ElHkkhY2T3uL+OJyFZhB0eOR+pvv0=; fh=MSsnF9v2bmvHZJkRgOZBuXbVPVh7ndcEbvi08yUt/bE=; b=ejugn/GLizW4rbZaY/PMMngAJUsGuOBal1qCPZX7wChqCFsOGRApdgVEZ5tTf/imr5 YtHLwN0Bx4fzpjkhcivVJ1EhbO6FhVLuOpcs33OlEE3+wNbj31sgTApKamVbbFYe2QIe qI1GU1iuGdv8LRkgXn2Rv2iLHmOgTfoZBXi2HPx1kXvnI21NPXOmx2qa5I3f91ZBBbLa TfeyZzz/C8qr2MiBkX6HVu0q54XBlibyF7Frp0fcf2S8cljvbvSn8u/+O6zyukvIdkCb 6Ebp0R1U+xpDBjUxM4rOcpLqFhmxzQCAjgeXZsRNh9QlmutfARs70p3+jE74/87+WdWQ r6GA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kvBkjxFP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18136b29si325298816d6.136.2024.12.31.12.26.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:26:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kvBkjxFP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSilq-0002h5-Pk; Tue, 31 Dec 2024 15:23:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilp-0002dZ-F2 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:17 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSiln-0000rG-Vz for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:17 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-43626213fffso66375075e9.1 for ; Tue, 31 Dec 2024 12:23:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676594; x=1736281394; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x7T+GlWRYF0Ex9ElHkkhY2T3uL+OJyFZhB0eOR+pvv0=; b=kvBkjxFPAymMmQI0UqRCBCZ+rF/O4AWH1THWFE6q4ufDnDWR+K9WRV9NpIP+iv4kiM 7TU3DjaGL7ZSsj2DBIDtuKFedeCkA5JkpiBDx8HDuVIg2ezp+1wK4TAOrc1M6UC8LbwO SiMlfs7Vun7adxdVAiRdxLmwhQV618VxQHQ3dCMfTcgs9pRI3+e4TkuhJxpcsdG/5K+1 P0RX5deySXrTJj4Qs+SsH8fp7TAZl2T3YWvKzvYiAcH5bMinPZ8kppoSeDmxSCkJCxpx tIcrpgW9/k+m5c7nL5dOsGyQ9dsm3sQ9Wq0XJ6ZOLWyHqTpi+V9F/Dmcm4+i/Dua1WTw HfOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676594; x=1736281394; 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=x7T+GlWRYF0Ex9ElHkkhY2T3uL+OJyFZhB0eOR+pvv0=; b=HfC4xBcUWa4b9z+tiaxy6lv4tt4nnPSbovBGuNsH4P4oPuOilwFYaf6CyRVUnRkYmX 0puxlrWMC4fNP4pP3taWN77K7GopCimzDO/fuUvcmzFLfpYOg8geOES+0k/KlGqvIrHg bNykmUehpKaRwqHXGEGugOH+oqd9gn2cmdujM4/JtUFc1oPnzWeaXqNpRDE94XtK7rnh X/9npCwZ+iDvhAVeAB61cZEEBwyQf0NQC2i2rRWMqW87bpTfGf0L7nGEu02ClTvEGm7Y 3QV46sY65SYr8KvEaVQ+rhsqvs033ocz/blW1uFFp3MllNKJVaSmVd2yRUywBlhsA6wd EiJg== X-Gm-Message-State: AOJu0Yyji9Qc873B2qRQsuhVkq2EfyimI/lpbDDQ6I8jCZhXyHTjleqp aKhkC9xuc0VdFmCMYL8H3pnTZuctoe4qq0ZY+CR29QRceGOcqRQpojKgNMfD1XnIJ6X0jQ0NHar XF2o= X-Gm-Gg: ASbGnctuz6zI8mdYW3LD7/2Izf63+IxdBYHQLbsdWAwikrKboJYCZvDBnUpPI0gkKBp Ujbtch2ihUSfpDQXRCAZNkMIU1t6XMiHZSuV9EIILjX1/uQHi1/5DIUuzbYmK+5eJNLiFTmOE8c 9Xo01+S2SQTAa2OdN5yF8B2KMtnmtrGz04YqxDW6ZK319SyhUo/43fzAypUxAIGYcCxLSxNy6TZ Z6wp1bn3sMJrUoDvzXwwO9L90XV5uQU2fyT4En0Zz0vC1TyCfKwEvj99ZCdraVTc0gjfw9dPadA jdm79PPKr/o4zjWe4W+XmcaVsnKq0oU= X-Received: by 2002:a05:600c:1c20:b0:436:76bf:51cc with SMTP id 5b1f17b1804b1-43676bf5382mr290252255e9.12.1735676593933; Tue, 31 Dec 2024 12:23:13 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43661219a7csm396013175e9.24.2024.12.31.12.23.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:13 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Thomas Huth Subject: [PULL 09/29] hw/openrisc: Mark devices as big-endian Date: Tue, 31 Dec 2024 21:22:08 +0100 Message-ID: <20241231202228.28819-10-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The openrisc little-endian control is in a control register: SR[LEE] (which we do not implement at present). These devices are only used by the OpenRISC target, which is only built as big-endian. Therefore the DEVICE_NATIVE_ENDIAN definition expand to DEVICE_BIG_ENDIAN (besides, the DEVICE_LITTLE_ENDIAN case isn't tested). Simplify directly using DEVICE_BIG_ENDIAN. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-Id: <20241106184612.71897-5-philmd@linaro.org> --- hw/openrisc/openrisc_sim.c | 2 +- hw/openrisc/virt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c index 87f9cbc3001..e0da4067ba3 100644 --- a/hw/openrisc/openrisc_sim.c +++ b/hw/openrisc/openrisc_sim.c @@ -266,7 +266,7 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base, } serial_mm_init(get_system_memory(), base, 0, serial_irq, 115200, serial_hd(uart_idx), - DEVICE_NATIVE_ENDIAN); + DEVICE_BIG_ENDIAN); /* Add device tree node for serial. */ nodename = g_strdup_printf("/serial@%" HWADDR_PRIx, base); diff --git a/hw/openrisc/virt.c b/hw/openrisc/virt.c index 22ae057992e..7b60bf85094 100644 --- a/hw/openrisc/virt.c +++ b/hw/openrisc/virt.c @@ -236,7 +236,7 @@ static void openrisc_virt_serial_init(OR1KVirtState *state, hwaddr base, qemu_irq serial_irq = get_per_cpu_irq(cpus, num_cpus, irq_pin); serial_mm_init(get_system_memory(), base, 0, serial_irq, 115200, - serial_hd(0), DEVICE_NATIVE_ENDIAN); + serial_hd(0), DEVICE_BIG_ENDIAN); /* Add device tree node for serial. */ nodename = g_strdup_printf("/serial@%" HWADDR_PRIx, base); From patchwork Tue Dec 31 20:22:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854405 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089576wrq; Tue, 31 Dec 2024 12:24:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWAxfmVNkajGcSe/rGG9N0Ju8AFfWf2pJYBweJPknkuejL4s9Ls0jdj1YHDnxqwwk1adSx75A==@linaro.org X-Google-Smtp-Source: AGHT+IENY/iqc9dN1wolmf3UjoubhG8uZIvZCvOEfYGgjpdOGYcYt0Z/VIa96j6e1gPgOTeMKXtG X-Received: by 2002:a05:620a:24ce:b0:7b6:913f:3df3 with SMTP id af79cd13be357-7b9ba83650amr6924002485a.47.1735676640719; Tue, 31 Dec 2024 12:24:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676640; cv=none; d=google.com; s=arc-20240605; b=IR9ihLNQeV6B9muanMWlctKxUirU7YMaPRFHhJyabkKFOOq6pLWopqIGlgL61esB92 SoMgRj1KGs1Pp0f7uU4m69sZPasdogaZHqLrn0PgVtUu/k5rgOfY5fqTus46TYdcRcxd ERh5iDBi6LfDWCC0Z1CmO2Fu8NGaEgPMSKA8+IBz0YXe76Ci4s08ORVDkLGeOEyUB/Fo MXm76Vp8dfHbw60zlXg/w5tFGL9vCjQzSFuiYofGNVNxNnLbtqfqtImeVjt3bPg+2b54 EyCSk5TtIwOZCkI0HH9+Sae/9kFnhQfr7+0CWWtiZBts/tv7nXVhNAj+RR8ciWlO1t58 ydKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YOJaY0d1Ex8WD3TOwLpxywEdEMi/4x2kRkhM5+bgzLY=; fh=36933UH1/pG2LNWMXX1IXTjk4mwRdlRyYSyVdahGwjQ=; b=TmRbpfjYt/KCS8PAOGG1BszXWHw/8EQyjzM7LgtL9ukgi1PLNp+bLspCRcfZz5awto RU4zBAFDd3LUJ/3NVeIQdhTdurhEu/QmEEq7UjenNl7HNkCSXQbNDg1eMqcN/8vC0f3K 2btThHPn6cXOWxhj94YICl91wlHIWGlCplLl+UrGsJfSqx2SCRPg05YLYC30XPSi1AQS 3dWzQncxSqBUgWf62SeF7UL8+xLTmFtYqMu4kU12se2Idu7jiggeAHjKtbxmma6aIwlQ FK7dGRILu7pU3ERY7HGEF+ZecgKO6lg0Q45Ma4nRjDhA3eAQ7FPy2ANSStI5kZBhWMVD y/0w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HOMwW6T7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac4f2904si2978000085a.528.2024.12.31.12.24.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HOMwW6T7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSilx-00034K-TX; Tue, 31 Dec 2024 15:23:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilv-0002yJ-46 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:23 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilt-0000rV-7q for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:22 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-436ae3e14b4so11279855e9.1 for ; Tue, 31 Dec 2024 12:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676599; x=1736281399; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YOJaY0d1Ex8WD3TOwLpxywEdEMi/4x2kRkhM5+bgzLY=; b=HOMwW6T7+m/tJ/D/J6OCe/kFymO1rYbQOIuZDaBWw7VNcUeWK6+lcq/bbwdjgMKz6R AyXxGx16yIDL44J/kqNTDdfSzBqiRtNgCVTxyxgcPBsT8wExRdbHPWyNSmNeVv0UZRhB TAyNgaZdGVX0a/1MlZ2lEVvzkMPS45n9U/Dkj/cRyMZZcv19+bXQPBPMAetjMurPRMEV L6PiKksQz8jk/dRYsN6MV9/wiQHP3K9qVcaz5rXYHYhLkWiO9ogeL8umgyKEDWX/dpRm fXle0SEBjwkxZldwF6bxsP/4cMLnZSJavDDpfNF+/mi0h7z41N/9/boiQwLaFOd++3Lv ZhjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676599; x=1736281399; 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=YOJaY0d1Ex8WD3TOwLpxywEdEMi/4x2kRkhM5+bgzLY=; b=fzh7CcQTWVqz0gSpG+aOAfdFUqH07hNqTsFDcYR3v0NuC1SDFZpgXIKTVpl1bLwlAC WjjsMu/oMYpBObBsko6HDNLCl3q9KwPrXsa2db7nJatDyhc1naMPI6xYch/CPmS35MtL TCXQnG4sSIDeiYOcqfXG5ZLJ2c8htcLy9/xh4t+tJz1p3kfwCN1o3RkNEzagI/fDYUt1 r+TwO1TDKTzGIBVP+ElRnAP/Egbtmb2uEIiY2XphrXpIt6mO1vb3pAJQSnx8GsVg5Ojm 3waLEe6EsweWd7gYVAQSGs4ZWSFoBhGwaO+ocZkyt6nvf+FQ/NpG1Xpeiy76U2c6lyul 3TTQ== X-Gm-Message-State: AOJu0YxSGmq5HlI3N8D2sJ81H4I8NMIuZV6PhVYzMpPjKf8VT9R0mDBe V0zG7aL4XtD/hTpl/PGFX7KtTgMm240bC5n310J3KX9l4MKL621lKsZnOIRAvYECsCTkrizWXk7 x/yk= X-Gm-Gg: ASbGncti8bMRHNEmFc1ysEzH4xFfTnEGHX4OsJ1bhePOtybrUsWASMUm7FUJ+I+vvp5 /SDKOUSzIK1JUol3EE/n1RRRj4xQpDCz4hF84Dj6P9Kn7+RNJYR5N5XJ1B4E6o6b/PdY2NucaNp Ww0o70mouc/xZV06fLOeyhDYtuSv8kdm20WyU51MuUcz4h4dMO4HIsusmLVetxK8b9yBQr+bsi8 vFj3KwwlMdYCuLZ4HvTaPcLtrme5fQpK47Jfn+s8sQtWAegqX4wNVSiNjfPLIYGY3TKZjUWRcK0 ae4aPIqn4uEjYyAW4zoDQl41cjPgON8= X-Received: by 2002:a05:6000:1867:b0:385:df73:2f24 with SMTP id ffacd0b85a97d-38a223f5cd1mr36018908f8f.39.1735676599318; Tue, 31 Dec 2024 12:23:19 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b42757sm437392675e9.39.2024.12.31.12.23.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:18 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Richard Henderson Subject: [PULL 10/29] hw/sparc: Mark devices as big-endian Date: Tue, 31 Dec 2024 21:22:09 +0100 Message-ID: <20241231202228.28819-11-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These devices are only used by the SPARC targets, which are only built as big-endian. Therefore the DEVICE_NATIVE_ENDIAN definition expand to DEVICE_BIG_ENDIAN (besides, the DEVICE_LITTLE_ENDIAN case isn't tested). Simplify directly using DEVICE_BIG_ENDIAN. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Mark Cave-Ayland Reviewed-by: Richard Henderson Message-Id: <20241106184612.71897-6-philmd@linaro.org> --- hw/sparc/sun4m_iommu.c | 2 +- hw/sparc64/sun4u.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sparc/sun4m_iommu.c b/hw/sparc/sun4m_iommu.c index 8c1fc82534f..5a4c1f5e3bd 100644 --- a/hw/sparc/sun4m_iommu.c +++ b/hw/sparc/sun4m_iommu.c @@ -238,7 +238,7 @@ static void iommu_mem_write(void *opaque, hwaddr addr, static const MemoryRegionOps iommu_mem_ops = { .read = iommu_mem_read, .write = iommu_mem_write, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_BIG_ENDIAN, .valid = { .min_access_size = 4, .max_access_size = 4, diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 5778709b412..0980b446593 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -254,7 +254,7 @@ static void power_mem_write(void *opaque, hwaddr addr, static const MemoryRegionOps power_mem_ops = { .read = power_mem_read, .write = power_mem_write, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_BIG_ENDIAN, .valid = { .min_access_size = 4, .max_access_size = 4, From patchwork Tue Dec 31 20:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854414 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089809wrq; Tue, 31 Dec 2024 12:24:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUVBv/nBDRv4qO7Eu6RlyuJTkXO9TayHShxzfIJ5uUzAfLhtBk0SYm6+BVsyImZ/0+QTHgrRQ==@linaro.org X-Google-Smtp-Source: AGHT+IHRWS6fqziEoBLzPxDekKwbYXbj41+auKaP/fvHdCKllojJ3Tk0GY2YVH+1tgWubTEA+S3h X-Received: by 2002:a05:620a:4113:b0:7b6:f1be:4f7e with SMTP id af79cd13be357-7b9ba79d383mr6048056085a.26.1735676686975; Tue, 31 Dec 2024 12:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676686; cv=none; d=google.com; s=arc-20240605; b=C3RTXsDmvYTcO6+izuWro2vR416hE1PuGmZLxos6tq5TzqWgueBUlfV8BzNjXXaslR FSPztroKd54Uyd+nSf1/rYdlMw5ji8x6yF6LzSVBFgKxRIW4PRycrixomRicNrYVHjFP si0yundJn9MBqy+JbJFij5IOk5VkiDbXm3qoMf4brvTYp8chOHeuP2Gl0i+SfjdEWwbe qYzW8VQzZSzfyOWVL39UvMHCueDpYlT0+KW9DIs/0M04IQ6+JxiVXw0JKCgeD82CeTBm 3rqLFSPCmFCVfx7sdKmh6VEpS6m7vZn6rfm0GrgKTetCVP1BLAVAY6ZwZk438O568dsq vOaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zAtQI+p6Q7jzylh2/ogAG38eWfi5o3sJewecVz2TXgE=; fh=lA8KdGRRCLcXxei5dR52XWsTSutqQE1F1yBegzCCPPE=; b=iC2wH9ultU4WVOrdR+uTVcg6T7CGC7aKuZbzXsYVuEsL5mQTqbh9q2y3PwClYxb41f aYAFBXJDZXErxdGpRNxLtrL2X14jz7kMe3VF1EnKfta0yl2f8IMY93EOB/7TgY6TVyyx x2IDKwUdH/OwkwQPCcPBLyp67Rh4NVnDSKWw1HgOlJklEwe6LXXskl7lr8gOhx36Zw9k nvr3hqaFtV50MziHONK7oEbafvnu50neOr+tBO8utY5cIy+H+G/ofZ6OlQhFayJR3PWC FR/gtb8GHwPUfzw8iinHzwGMEYeU6O6w0SEHnpMR09jA3+92mivIrUFT+ur9vGdaiHd4 oGmA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lksDLVO8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac53e593si3141260385a.639.2024.12.31.12.24.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:46 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lksDLVO8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSim0-0003Dm-PS; Tue, 31 Dec 2024 15:23:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSilz-00038R-AF for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:27 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSilx-0000s1-OB for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:27 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4361f65ca01so102676625e9.1 for ; Tue, 31 Dec 2024 12:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676604; x=1736281404; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zAtQI+p6Q7jzylh2/ogAG38eWfi5o3sJewecVz2TXgE=; b=lksDLVO8MMT2zdTou2LfD8DJx//bj3uL0V/ljn3CPhGdNd9ZEYsY7blc9bMKehGHoQ s1K/9KWiRmX2QWvT0kF8AZqTCLZ09JJzfrPz28FwrLDX0/wDyasfUjd2pMEuROKW0Uli MS87MDAaBF32jVdo2FZ/8LH0YMcShfzboPhV+hKFPQZ4Y6A1387F4DAmxktp0dMgdBt/ FZeVi3V93rJiNY7h0js7rkuI9G35pXcN3oOxOQYAlkl/EApXiNi03aAVAt9XADX2UMZf 2nY4Ds0S+kYlL11Xo17hJf2Gdv957u6T8legACLjtANcQMrcNf+kN0i1zI5/TzWVum4u y9YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676604; x=1736281404; 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=zAtQI+p6Q7jzylh2/ogAG38eWfi5o3sJewecVz2TXgE=; b=O5lQKUeRITCIA95g2nAWv/HT7wFr9S9WX9ArrR0fm01Cq0i/4hKAsbZXIF/mHeNcOL ciV8lzXSy94TDcRkd3dlbA1UPNLm2lUeDfqUzqWMHr83F27RubzbRzfkxCoFlWNSAvg8 Dc2NNbNeRcxhMG57gDeamhbjnoifw8vUcOilgLxJ+/CzY3oKdxAqxSso96S3/vyVX87K sfHwfjKd5wR6X3NfE53xEO9iyiAiAyGZ/RSBHKyoosu/EUgXgqBhRXj5E6C1k+Hpxak9 bbauPantMvx3fmZ5lAJp5truAtm+PjiDIdXovk7Ob57QRm51yWiBxAufQCu/3L8bZ4Ov pLFw== X-Gm-Message-State: AOJu0YyObfitvyTnvza/gN+rLK1HO/i/iTwCAb5ICyx75qPNQyk5TeHE i4vI6jpq1a4pHPxfukqIWBQpqWTlZGQQkFr1F/Us4+N1BQb2t1mtesjd/8XO19fiGFst8lxmTiC 1UnA= X-Gm-Gg: ASbGnctF6uio+mf4lwE42TJ4Y0qY2xsuPdjMJ6DDFSIRRqYDwqT7cvmUGhLsbInaG+L A5fQsWZc7N+eUsWQD3KjqC5L3y434qsmf33g5rRu3yybwqxEJ4ZI4iWHcLFmsX2xTim1RQlI/ZI wEIhomt81GMb5JRqs1yAlkaDWnVOsWwtLe2E8Je3EKOjKySJIR6ZEK9HQlJkVgRL4Qas1lIDbNN DVD8pOIi0rM1FTpglw/+Tu+1CxlmQYGLwUJAk+WH3wZ8nh0xOr4dm6BJ6ufYn2Yb1fF2WRVuSu+ QK4NPcFuBgRQBfCtzHhK1WbATHbtS64= X-Received: by 2002:a05:600c:4fd3:b0:436:5165:f1ec with SMTP id 5b1f17b1804b1-43668b769f8mr360121505e9.30.1735676603868; Tue, 31 Dec 2024 12:23:23 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656a0b361sm431655555e9.0.2024.12.31.12.23.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:23 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Edgar E. Iglesias" Subject: [PULL 11/29] hw/net/xilinx_ethlite: Convert some debug logs to trace events Date: Tue, 31 Dec 2024 21:22:10 +0100 Message-ID: <20241231202228.28819-12-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Message-Id: <20241112181044.92193-3-philmd@linaro.org> --- hw/net/xilinx_ethlite.c | 5 +++-- hw/net/trace-events | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index f3eb2af1934..c38a71c71be 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -30,6 +30,7 @@ #include "hw/irq.h" #include "hw/qdev-properties.h" #include "net/net.h" +#include "trace.h" #define D(x) #define R_TX_BUF0 0 @@ -194,13 +195,13 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) return size; if (s->regs[rxbase + R_RX_CTRL0] & CTRL_S) { - D(qemu_log("ethlite lost packet %x\n", s->regs[R_RX_CTRL0])); + trace_ethlite_pkt_lost(s->regs[R_RX_CTRL0]); return -1; } D(qemu_log("%s %zd rxbase=%x\n", __func__, size, rxbase)); if (size > (R_MAX - R_RX_BUF0 - rxbase) * 4) { - D(qemu_log("ethlite packet is too big, size=%x\n", size)); + trace_ethlite_pkt_size_too_big(size); return -1; } memcpy(&s->regs[rxbase + R_RX_BUF0], buf, size); diff --git a/hw/net/trace-events b/hw/net/trace-events index 6100ec324a7..c35bfb2eb8d 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -513,3 +513,7 @@ xen_netdev_connect(int dev, unsigned int tx, unsigned int rx, int port) "vif%u t xen_netdev_frontend_changed(const char *dev, int state) "vif%s state %d" xen_netdev_tx(int dev, int ref, int off, int len, unsigned int flags, const char *c, const char *d, const char *m, const char *e) "vif%u ref %u off %u len %u flags 0x%x%s%s%s%s" xen_netdev_rx(int dev, int idx, int status, int flags) "vif%u idx %d status %d flags 0x%x" + +# xilinx_ethlite.c +ethlite_pkt_lost(uint32_t rx_ctrl) "rx_ctrl:0x%" PRIx32 +ethlite_pkt_size_too_big(uint64_t size) "size:0x%" PRIx64 From patchwork Tue Dec 31 20:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854399 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089505wrq; Tue, 31 Dec 2024 12:23:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVWFSPxJSUX41ODiM45pw1RB/009/TqpF/DjD52jofacFsIixBl86JRQG5Wu1JolnRcJaNX/w==@linaro.org X-Google-Smtp-Source: AGHT+IFcp8lPXV/0joyMBl8bJk9Z/dteoLxPKTifnH5jzNzJk1GaFm79k2/F4nGzjjVl1JO+EBhs X-Received: by 2002:a05:620a:2a12:b0:7ac:b04e:34c6 with SMTP id af79cd13be357-7b9ba7eae86mr6078150485a.50.1735676624250; Tue, 31 Dec 2024 12:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676624; cv=none; d=google.com; s=arc-20240605; b=aLBxFZqiqclEgDFsXKwyb2437FuB+9hNTW4pZnmIxSMNG3b8NsehGEpsdhXH+sO8gt QfWucOPG7RAxkq+5TYV9hirbhPJWmXy9JBcodaB9hXOAOPPiiihCHWPOkfN72NRM1QN8 tJQ6+n3GginsOgGyFT7dO3CNzvGIlTieFpobN63l2E+UgiTL8pZPZidpRg7zKegVcMXH MP60CbFQ4EmLace6I7g5j0qhaizFmxEGEpj+SHaq3M+3alLt5IfWwkY/XtKdOADx7IlW wcqr9h4N9l5GZFnUET/WmXcIlcMWQ4WBxeZKsKeYsH/fMeOs1mS2+CPmDsKNezqCTe49 uMJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0BigQsrri04m3/+lBK80umChQDK82DoGxTPyI0a/+No=; fh=lA8KdGRRCLcXxei5dR52XWsTSutqQE1F1yBegzCCPPE=; b=eXvvNP7ibs6mrUy5xrGG12YLpTSs7VJf3MdhN4zZZh/9yItu+0mPDjT45zJmiVRmyi 0HOtvQGS3oCampiyb7TzQFm7Vw4hUcjTtMZpcIKGUdgGMv9kuQpo8pCmR3irhosZQQ6n S3/q+msRMrb4JzkGiBleQLuh6JuHiV/3VN+b45g/GnKtqGVOgy2lbxMx05MrIEEJvxz2 taSluaj/A65LAgp3DvZqZnXh3g873+1P2VUaVrvxZShAg2qNLtN/hzQSMcByces+Hsh8 mcnm1J7Odpj0BR6hfPC5KEAHM/3viqqZjVvfAbBtGnIhk2kNCts+SqAF8fPIInfOg5iS +dAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dhwYBEtv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac4f1014si3428880285a.517.2024.12.31.12.23.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:23:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dhwYBEtv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSim6-0003GF-OM; Tue, 31 Dec 2024 15:23:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSim4-0003Fw-UU for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:32 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSim3-0000sW-Cw for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:32 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-436202dd7f6so116414345e9.0 for ; Tue, 31 Dec 2024 12:23:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676609; x=1736281409; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0BigQsrri04m3/+lBK80umChQDK82DoGxTPyI0a/+No=; b=dhwYBEtv/rRKJ/pWOCNu3ebknCZZ+B8eU5y251Z0rQENA+gkm1tZ1BLda0Q5QmXYc+ xyZ6p7/w0sM6asUAiGzHmJuuqlXwSITkpJuF6FPzCR+6FJsmXKxnx6PFvTsQ2OkxCyaN WNb0ULtwU7qz7BqVGSvgjjwxo9YMgWw4OgD2nxEFONdAg57GAVyu6cS4vgu2Km2+dRPN 0rmPC2PDElAqc321pEJ8LYLPwx1CUVAkSKOjBv7UvcAtM8GPxE93Pm9vdTYulfIzw4mI 5BEQnxggqbBYUaMswvqjdlneEfuTyIucfYsnpEXVYRGygdIUo5j3+s5bF6A+DmrLe95p kEYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676609; x=1736281409; 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=0BigQsrri04m3/+lBK80umChQDK82DoGxTPyI0a/+No=; b=DnvzTqGNxHSp5YuF9iRTpIrVlpei4nz3NpjtvKtpXc7Q/obURKQA2MwUNxNOk9nldo 99Qvg5mEDiE0hK9bmt6RgDSal+9t+ccyLnvd0qOMB9QSvlZ4OzPkPONwKSgPm4LijO4o LaPpsaHEXq+ZBNq6AR/pudF8M60UfRyn0LjA7eFeH4xa7SlRN0ihE3DGWIbAAdWwpHwC AxEFHRHdURo6kb34IZZoEGNEWyC9edsQXKU9UPykl1vLVHkPFNFSUgFFHUAUvbwqcIhn jIid9OAxhzwvlNclTo7uHbxp6PMwRBQ3K1fY/ryX/yPjA9PpoIfZ26Y7vMyITqBRX2ig 0ELg== X-Gm-Message-State: AOJu0YwC9SWUSFaAj5tGeglYh+p7IysMDqF8nsuQSwuBipIEezygb2ye O3d+7jnVBLY2LwjN+/N0iBljXfLxeFS0ve5AOCyIdIcQprW19Tqn7jJx1tfMNeXhk8YF2PpX3FS dZhw= X-Gm-Gg: ASbGncvD/VgiAXzMWVFgbdTqUDUmSiOohYRYFfk5YmJ5c2jVuOsu6AT03rvALS37EAW N+y3XhSe6iL0cQYAr3p4URwJ3TISqwOfVGPrHV9cI7uiWyeqxHWcGWmSlae5XRqRLYhtMfV+z81 88m6K37nab3Tea5Ke42fpfeXjaXbriP3937drzv7aHV2eGrEnehLMFwaV8KDJ97Nlaaq4z3b2Kl riONBOC1h1IzDdMejhRe2De/GTjzQXWpLTnm309+6Jv36vPm2WKupUDuzFeqlRjUyWPs2FSfGF0 RsGSwhg8AL1nq7PJg5aIwf7M1IIgD3w= X-Received: by 2002:a05:600c:450b:b0:434:f804:a992 with SMTP id 5b1f17b1804b1-43668b93b7bmr296080235e9.32.1735676609039; Tue, 31 Dec 2024 12:23:29 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c828cc8sm33551122f8f.17.2024.12.31.12.23.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Edgar E. Iglesias" Subject: [PULL 12/29] hw/net/xilinx_ethlite: Remove unuseful debug logs Date: Tue, 31 Dec 2024 21:22:11 +0100 Message-ID: <20241231202228.28819-13-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Message-Id: <20241112181044.92193-4-philmd@linaro.org> --- hw/net/xilinx_ethlite.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index c38a71c71be..4626a55b069 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -32,7 +32,6 @@ #include "net/net.h" #include "trace.h" -#define D(x) #define R_TX_BUF0 0 #define R_TX_LEN0 (0x07f4 / 4) #define R_TX_GIE0 (0x07f8 / 4) @@ -100,7 +99,6 @@ eth_read(void *opaque, hwaddr addr, unsigned int size) case R_RX_CTRL1: case R_RX_CTRL0: r = s->regs[addr]; - D(qemu_log("%s " HWADDR_FMT_plx "=%x\n", __func__, addr * 4, r)); break; default: @@ -126,13 +124,10 @@ eth_write(void *opaque, hwaddr addr, if (addr == R_TX_CTRL1) base = 0x800 / 4; - D(qemu_log("%s addr=" HWADDR_FMT_plx " val=%x\n", - __func__, addr * 4, value)); if ((value & (CTRL_P | CTRL_S)) == CTRL_S) { qemu_send_packet(qemu_get_queue(s->nic), (void *) &s->regs[base], s->regs[base + R_TX_LEN0]); - D(qemu_log("eth_tx %d\n", s->regs[base + R_TX_LEN0])); if (s->regs[base + R_TX_CTRL0] & CTRL_I) eth_pulse_irq(s); } else if ((value & (CTRL_P | CTRL_S)) == (CTRL_P | CTRL_S)) { @@ -156,8 +151,6 @@ eth_write(void *opaque, hwaddr addr, case R_TX_LEN0: case R_TX_LEN1: case R_TX_GIE0: - D(qemu_log("%s addr=" HWADDR_FMT_plx " val=%x\n", - __func__, addr * 4, value)); s->regs[addr] = value; break; @@ -199,7 +192,6 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) return -1; } - D(qemu_log("%s %zd rxbase=%x\n", __func__, size, rxbase)); if (size > (R_MAX - R_RX_BUF0 - rxbase) * 4) { trace_ethlite_pkt_size_too_big(size); return -1; From patchwork Tue Dec 31 20:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854403 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089529wrq; Tue, 31 Dec 2024 12:23:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUTchnzwSXN9EAFdeOaVlqezXZ5XwOGxGIQ14IhNNnnO/FTHK8psdREj+XzZ9e0ieXkiftWiA==@linaro.org X-Google-Smtp-Source: AGHT+IGTlut0H1rVoasvgQtnVwR465dvBeSjyra2fYFYCnR2uCgsd8SDhNmNXy2MA2L3d8O6i0PO X-Received: by 2002:a05:622a:1892:b0:466:8cc1:6221 with SMTP id d75a77b69052e-46a4a9a2b57mr818032311cf.50.1735676627020; Tue, 31 Dec 2024 12:23:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676627; cv=none; d=google.com; s=arc-20240605; b=aMRr0KrUvUrk3xObSDguj2mi1HEBZVrpNOUD7nDu9J6uTXruhimUF9j3cpNkYpdCPW CUNSdEYSTr/AdumtOKzlyoVY9AxvxQaHOdRDWm2ZgwTUiBXRO2TFjKstw0KG2yn5RSn3 20cgMDlFC5PEZWvFztpc1vWHJr69sgT6fuNSWe8zr/ncn41EijeTooEo23bqMkt6OKi+ XFUkv8Zo2vWUHUpEaVj8P2ivvDXwBspb7SZogAFR60SuTzMiL1aZMXk0kNUbIya39mjG WJeFMq4/1DWZOuEyG1UHy/9ItE9/Gb4rQj4cH58yJffKTpP1PbPi5bi5Zml4hAzFRV/l yPLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aBx+XgL3+wHjk0kADMiKJc0p/3jViH600fZFb8NkyI4=; fh=lA8KdGRRCLcXxei5dR52XWsTSutqQE1F1yBegzCCPPE=; b=ZlrHvoiinTgcj1yvnYPKlf8xL+vJmcM72kv8mj6JcMnHyI6tQOk5PyiR7gVm/y0KBo b6jAU2nfKRzRDWpR5R+lOFhPO6nVGk7SOOcSNhsk5T9VIZSBPw+R9USZomLJcvmaCPga RRTno0ctdJktoYXP1UAxzbIyKClxDtQkmiSLp0lr7kc6n8Jw30GS3lJpMVbjckZH2OCz 9hcAoUDiBVycjJJ2+2o+DebS0IBSTDDyAWXhX+MMBYEijbvRFZJngkEGXc3D41LU94En EWBOTwmaWFLksiY6xT/YIPOZnxCztZA0S9qxnjyms8e5kgyUG/lk1rvTvsoRqsKf2EoR PWkg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NDRicbFq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3e6811d6si328754421cf.89.2024.12.31.12.23.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:23:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NDRicbFq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSimB-0003Hk-Pi; Tue, 31 Dec 2024 15:23:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSim9-0003HI-U1 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:37 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSim7-0000st-Vd for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:37 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4361dc6322fso67542355e9.3 for ; Tue, 31 Dec 2024 12:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676613; x=1736281413; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aBx+XgL3+wHjk0kADMiKJc0p/3jViH600fZFb8NkyI4=; b=NDRicbFqHJLNsVS86qJfOk0KGab2o0ltuDpiELI/FuGWnOQxAF606BO9umtQgfTSJq TYAapaX0JHWIAtE0exi8snZkh0Lfouk/iSaD2Ac66K5YO6TVS8yNQhOg/vT40O5vCaZa ZsKE61+phMkjgZgwMn2JnQxAmyyvvJ7PpDeg9D8GGyxzPMMtUy2MQxYKCeOaeNkEKJiM D661Zy6XNnjW1MBa4BJwoXU2B3GOLpq5He1ssbAIKVdLSGcJHoqGZcCMV7il0hPT6eMw VQydszWiOvSUeL35gZilpX+aKDHY1Fewn7Vir2LMSd7z1W/tr13opabVJAlV0VW0FMei c0pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676613; x=1736281413; 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=aBx+XgL3+wHjk0kADMiKJc0p/3jViH600fZFb8NkyI4=; b=GIeW0dZj6G/t0uQOpWM0nMlb8C6NQrqPmyXYgg7xkr0iJqQKmMkXKYEE6DeqtDQPhp A62CjIe5udRg5OstD8S0N6ryg2fAwnSG+70RTZ/iEfFbSDEpT3xJaK/ierw41ag301fE ggR4NGIaTtEak43laOgTmDLLBgKqcQzU5jxm64kHyp7FbEpmu3jTNN+8hjYNUuWGg+m1 holum7g+6cGr1bdOdeUuW/7FcCufFfJR3Lwc1V48xavanNyGhBTNfFgEjSlwXyxrNxUx 0vhLSpVtDj3Unv+UOlTT5ihUjzWd4QA2E1l7czH4qpgrlRTGW/owpbv9UUMapVyfaYsF m84g== X-Gm-Message-State: AOJu0YyZ3sYz/yT3N5+aOLJgIv+J6gwktxycJOl65islE4ipHte/jPY0 bBpLW3Wd5uPv1kWyx6d1J4HWqS95BZX6ZyYkPkMXprJ+e3BNxbCMfMZd/RFVmdFbGHDxEMvOC1O ueZY= X-Gm-Gg: ASbGncv9zRNyjshsMw1ZGLZXVy0MYRtF4AiMlFyoRRL+M/YN/lyswOKCQ4nA/vGrPhi JT4K0kdgrSiEfG1KYpIZkkBWPmuDSNZ7hA2IuorDktXqkCGg58lGC3TpUpIjHw+TguDTtYE0G9E k/jQjiI5bZfOpVHAFPecofN8RHj9KzvVgJEz/OGtcnoeDsMcwcHLTlRS6VOZw4lWUFFZTm3U+cl GgnrwyjGYCU59++11qEpqEf14sXX/HmTPyHAkpOZS4mCfGVHatiXXU3wv3wajKs3jqaG16MDLWm y8M0pn1ZCe77+7n/FqfjWVOfAnmDA14= X-Received: by 2002:a05:600c:138d:b0:434:a4fe:cd71 with SMTP id 5b1f17b1804b1-436686439e6mr363755435e9.12.1735676613458; Tue, 31 Dec 2024 12:23:33 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43661219a71sm395623055e9.26.2024.12.31.12.23.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:33 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Edgar E. Iglesias" Subject: [PULL 13/29] hw/net/xilinx_ethlite: Update QOM style Date: Tue, 31 Dec 2024 21:22:12 +0100 Message-ID: <20241231202228.28819-14-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use XlnxXpsEthLite typedef, OBJECT_DECLARE_SIMPLE_TYPE macro; convert type_init() to DEFINE_TYPES(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Message-Id: <20241112181044.92193-5-philmd@linaro.org> --- hw/net/xilinx_ethlite.c | 48 +++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index 4626a55b069..330dccb83df 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -53,10 +53,9 @@ #define CTRL_S 0x1 #define TYPE_XILINX_ETHLITE "xlnx.xps-ethernetlite" -DECLARE_INSTANCE_CHECKER(struct xlx_ethlite, XILINX_ETHLITE, - TYPE_XILINX_ETHLITE) +OBJECT_DECLARE_SIMPLE_TYPE(XlnxXpsEthLite, XILINX_ETHLITE) -struct xlx_ethlite +struct XlnxXpsEthLite { SysBusDevice parent_obj; @@ -73,7 +72,7 @@ struct xlx_ethlite uint32_t regs[R_MAX]; }; -static inline void eth_pulse_irq(struct xlx_ethlite *s) +static inline void eth_pulse_irq(XlnxXpsEthLite *s) { /* Only the first gie reg is active. */ if (s->regs[R_TX_GIE0] & GIE_GIE) { @@ -84,7 +83,7 @@ static inline void eth_pulse_irq(struct xlx_ethlite *s) static uint64_t eth_read(void *opaque, hwaddr addr, unsigned int size) { - struct xlx_ethlite *s = opaque; + XlnxXpsEthLite *s = opaque; uint32_t r = 0; addr >>= 2; @@ -112,7 +111,7 @@ static void eth_write(void *opaque, hwaddr addr, uint64_t val64, unsigned int size) { - struct xlx_ethlite *s = opaque; + XlnxXpsEthLite *s = opaque; unsigned int base = 0; uint32_t value = val64; @@ -172,7 +171,7 @@ static const MemoryRegionOps eth_ops = { static bool eth_can_rx(NetClientState *nc) { - struct xlx_ethlite *s = qemu_get_nic_opaque(nc); + XlnxXpsEthLite *s = qemu_get_nic_opaque(nc); unsigned int rxbase = s->rxbuf * (0x800 / 4); return !(s->regs[rxbase + R_RX_CTRL0] & CTRL_S); @@ -180,7 +179,7 @@ static bool eth_can_rx(NetClientState *nc) static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) { - struct xlx_ethlite *s = qemu_get_nic_opaque(nc); + XlnxXpsEthLite *s = qemu_get_nic_opaque(nc); unsigned int rxbase = s->rxbuf * (0x800 / 4); /* DA filter. */ @@ -210,7 +209,7 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) static void xilinx_ethlite_reset(DeviceState *dev) { - struct xlx_ethlite *s = XILINX_ETHLITE(dev); + XlnxXpsEthLite *s = XILINX_ETHLITE(dev); s->rxbuf = 0; } @@ -224,7 +223,7 @@ static NetClientInfo net_xilinx_ethlite_info = { static void xilinx_ethlite_realize(DeviceState *dev, Error **errp) { - struct xlx_ethlite *s = XILINX_ETHLITE(dev); + XlnxXpsEthLite *s = XILINX_ETHLITE(dev); qemu_macaddr_default_if_unset(&s->conf.macaddr); s->nic = qemu_new_nic(&net_xilinx_ethlite_info, &s->conf, @@ -235,7 +234,7 @@ static void xilinx_ethlite_realize(DeviceState *dev, Error **errp) static void xilinx_ethlite_init(Object *obj) { - struct xlx_ethlite *s = XILINX_ETHLITE(obj); + XlnxXpsEthLite *s = XILINX_ETHLITE(obj); sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); @@ -245,9 +244,9 @@ static void xilinx_ethlite_init(Object *obj) } static const Property xilinx_ethlite_properties[] = { - DEFINE_PROP_UINT32("tx-ping-pong", struct xlx_ethlite, c_tx_pingpong, 1), - DEFINE_PROP_UINT32("rx-ping-pong", struct xlx_ethlite, c_rx_pingpong, 1), - DEFINE_NIC_PROPERTIES(struct xlx_ethlite, conf), + DEFINE_PROP_UINT32("tx-ping-pong", XlnxXpsEthLite, c_tx_pingpong, 1), + DEFINE_PROP_UINT32("rx-ping-pong", XlnxXpsEthLite, c_rx_pingpong, 1), + DEFINE_NIC_PROPERTIES(XlnxXpsEthLite, conf), }; static void xilinx_ethlite_class_init(ObjectClass *klass, void *data) @@ -259,17 +258,14 @@ static void xilinx_ethlite_class_init(ObjectClass *klass, void *data) device_class_set_props(dc, xilinx_ethlite_properties); } -static const TypeInfo xilinx_ethlite_info = { - .name = TYPE_XILINX_ETHLITE, - .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(struct xlx_ethlite), - .instance_init = xilinx_ethlite_init, - .class_init = xilinx_ethlite_class_init, +static const TypeInfo xilinx_ethlite_types[] = { + { + .name = TYPE_XILINX_ETHLITE, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(XlnxXpsEthLite), + .instance_init = xilinx_ethlite_init, + .class_init = xilinx_ethlite_class_init, + }, }; -static void xilinx_ethlite_register_types(void) -{ - type_register_static(&xilinx_ethlite_info); -} - -type_init(xilinx_ethlite_register_types) +DEFINE_TYPES(xilinx_ethlite_types) From patchwork Tue Dec 31 20:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854412 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089758wrq; Tue, 31 Dec 2024 12:24:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXrvPoFymxbhQMO5jfder+8SGUorewtOd3eoX1oBad7fAsiF+SacAI1UQuKWkfjaoIC4LGkeA==@linaro.org X-Google-Smtp-Source: AGHT+IFp9LpZUq20iOmSvFyVvKFgWmCS+BMIiOdamQ5c0bQqmXJBAL4aZO8mN7ayKaLWcOlr2Lfa X-Received: by 2002:ac8:7f14:0:b0:463:1039:fc2c with SMTP id d75a77b69052e-46a4a9a5a71mr607156791cf.37.1735676676821; Tue, 31 Dec 2024 12:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676676; cv=none; d=google.com; s=arc-20240605; b=hnb5UKabs3rTnPad5s7R4Fxx8Kah3n0TEFF3Zxj28rWcoA7FQO3/ttuMeUqjJoYN1n oUrL8GiIV0iVvnYECtIZpk4OkVmJp7GHJ+D2xbgjn1AoKE8aYuZldJBTN9JHgKdu1qc2 fmWXKzT/60LplwH6ATk8VOSL8pVO4LBAzkNjVdRER3L09vcrruuBEkoFN80n9sFHvGbX +0yyuD7uvmxRr9J6YwsQ9c3tJDwSkA7A2rrC4jvSPMwXY3fOoSxtmdxUhcViQIeuWyM2 lXIaIy/xBCzJHiZP/OrRbevBx+RKtYe2vdEhdI6DExHyzh+XRbPtZsrqcSHkd1uB5KwX Ab1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xgwd1lvGYcpUC2JHW14mBK9dwBsC4XtKSYjNzKqRdck=; fh=lA8KdGRRCLcXxei5dR52XWsTSutqQE1F1yBegzCCPPE=; b=KFE9VJr63V/wsfAmycb7m0Ow5iLrDWfuXFO0K9Rk/EgjBaDJRl76JG7dRlaB5hz2Ie htCE3Lk/7ERUdRf9gpWdeqdPqK+SxcvI2hbG4WTPzyc/ATNfrwcMNEgVCK8owyD9xuB6 sOF/0Zn44lhnqMV5C9VrKTywRfTl9I2cX+8Wrm8CmkvDlPzqQ6x88FVHHsAW2qYb8oOh LXfr6Zd01wlYlqbY1NRh+h+XAHgs5yHGlWZSkQCJECtnEcHR4HNdyc9yma3DfcUs5hSl 3L+JIN+Gp8Lqu24yHcNiHctt9h6xUkBX5pBBztTssOs5FE7Vxi5YxReX2uVsi2GMv2Zr NKpg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=swnWsqVp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3ebd71d6si285417411cf.540.2024.12.31.12.24.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=swnWsqVp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSimI-0003PR-KH; Tue, 31 Dec 2024 15:23:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimD-0003I9-Bx for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:41 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimB-0000tY-L2 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:41 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-43690d4605dso34026835e9.0 for ; Tue, 31 Dec 2024 12:23:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676618; x=1736281418; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xgwd1lvGYcpUC2JHW14mBK9dwBsC4XtKSYjNzKqRdck=; b=swnWsqVpbC7q9SXuk+BhApyDoHAombLyxiuOKTaRDIpVj3m+tonAAvS0BeQ7ORvb/o YKbRcXNvcK9p8OCKKdjSjU6/YSpocaZE7city17G+boeBApnE7uRZ1ue1geqikcvq6RT WrPXH4/GgJQMmW5YBbGJv87DIltoqwwhwjfp6fysPFndUeg+JLHIeA9+6/9i7mrNZq5R 1OyWyQMgTJV3YXIJwHLwzrQGifP/wo6YtLqS9xesKR7sXKLPqXOpKH8b5zoQ1bju78/m uyHu9lgZ1XrZ1UxJIPrr1eT1R5wUgRlAB2bSDuGqLUcspAArAefjYYH3JEhRsNX4mCuz 6y7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676618; x=1736281418; 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=xgwd1lvGYcpUC2JHW14mBK9dwBsC4XtKSYjNzKqRdck=; b=sQ5J3HX27EYAO15giv9bNrY9OmzVSnDKniuQrt6CTU9ukpOWo0EzADYIvbr97V8zrh w2cV2eKQ1NttO919eZ3oJAbWy4XAVnetzzTjln7tkKswBwX8IM3l1rvky4NIyKhOyybe 28wb/af0+AYXF4njTc24JsGN2Bq+PKcyCuDhcEE2fIKj1NIYqdV2LsG0B3t5AAW5Wqvd KjzZE1sm2oTPd5KlUmjlYJdUJgyIMJjBOiYbVivoupG5zzom/SPM2AkSrbZaf3y5AYx9 Tx2AbGzBNRckjU7v83DrSQBrsFAyqjpOIGMiT1nlMXewvVtcBc5q5up/CLp2HnmLkGwk jBzw== X-Gm-Message-State: AOJu0Yynew9JaRbS1SFhptsEiCOFnj/pD4HXzXTMyEtmzb5g9OsF05ou NzkhUamzWLhrPeJyLk429DVLk8CwRHm2roKK8F1B5y670WtTnweujZp+NNV0CkRJSrgqG7ov+Sg pYTI= X-Gm-Gg: ASbGnctFtRutHoqT7O4CSRfRGdiGNR2bJ4NwM41uUMnVNGc7Yt5SvUyhMnvgxchGJmU fU+WBEr48KAhZMLghlsWElcKIKwY4h7NSleg+GndCnoYnx6eYVVvlmb0oTBX42+OaBCZuR8ESVC L4SWxStIBanEkAT4fc/WOiqPysZwC2Tcu0UAZ+f92WEFNuvrKYE7M37TcTNDMgnp48kdWY3oppG iV7EuVVJGlhyBHdekTY4rch5TAYIUbGp8LSZI+RlSgYN2zOnCb9CqDp9CxScvvmZoRPvjS5fGfG orwTi9JhWgzBjNd/a0aVicrvA0dAEr0= X-Received: by 2002:a05:600c:5129:b0:434:a04f:2557 with SMTP id 5b1f17b1804b1-4366854830cmr331283735e9.4.1735676618022; Tue, 31 Dec 2024 12:23:38 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436611ea487sm396406505e9.8.2024.12.31.12.23.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Edgar E. Iglesias" Subject: [PULL 14/29] hw/net/xilinx_ethlite: Correct maximum RX buffer size Date: Tue, 31 Dec 2024 21:22:13 +0100 Message-ID: <20241231202228.28819-15-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The current max RX bufsize is set to 0x800. This is invalid, since it contains the MMIO registers region. Add the correct definition (valid for both TX & RX, see datasheet p. 20, Table 11 "XPS Ethernet Lite MAC Memory Map") and use it. Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20241112181044.92193-6-philmd@linaro.org> --- hw/net/xilinx_ethlite.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index 330dccb83df..d54f96df243 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -3,6 +3,9 @@ * * Copyright (c) 2009 Edgar E. Iglesias. * + * DS580: https://docs.amd.com/v/u/en-US/xps_ethernetlite + * LogiCORE IP XPS Ethernet Lite Media Access Controller + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights @@ -33,6 +36,7 @@ #include "trace.h" #define R_TX_BUF0 0 +#define BUFSZ_MAX 0x07e4 #define R_TX_LEN0 (0x07f4 / 4) #define R_TX_GIE0 (0x07f8 / 4) #define R_TX_CTRL0 (0x07fc / 4) @@ -191,7 +195,7 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) return -1; } - if (size > (R_MAX - R_RX_BUF0 - rxbase) * 4) { + if (size >= BUFSZ_MAX) { trace_ethlite_pkt_size_too_big(size); return -1; } From patchwork Tue Dec 31 20:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854426 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090347wrq; Tue, 31 Dec 2024 12:26:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVu3ShW8m07GQXFyG4e+FgMe30j41xf+iviR6TOZ7qn5nqA63qPajHZ7r5fG5iT5wTecDYtTQ==@linaro.org X-Google-Smtp-Source: AGHT+IHVOfkGpIvB5bSs5RTFDljwcuAgOdiMd2jVVCp1PNbSLFLiocsgP5M5ldxMEhHCNE6afad4 X-Received: by 2002:a05:622a:4c7:b0:458:3c2a:1d6f with SMTP id d75a77b69052e-46a4a8ebb96mr557695401cf.31.1735676804258; Tue, 31 Dec 2024 12:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676804; cv=none; d=google.com; s=arc-20240605; b=YfAQYfpMJCNQtPXfF63pNoHUeFxghi2mgtNgzZBzf7fQAGgzvvrFS/vbMvGnCuFvKn vh+DaFMyXgD1mRy1z+NTVbMxNUigNwj9QJWMwV/PKv4zKpYd6G0GYw6cWhF3Q/g93oFQ DB07J2M9N58r5e2NXITee3Nq7+kWxipgabI2RzCIV+IqO7BFzf+CSV5h2+G6UxqVmXps dgbtthTsQ14ABXX2tEnRWulELs7e1fZBbinyYPrqSDtVvTag+UQLjFGe7PpBaDYBxm+9 D8Ie0uZ/KpYEaPFbz5cSa3tT1+/PhRjtMJKT6xJpY5YfjMHQ1v0fS4p+uhNtSQDyf40N +OZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QvYdTYMW+dIfPF+uKcm/HE6zS5JfQaQKVI9r227X6ME=; fh=lA8KdGRRCLcXxei5dR52XWsTSutqQE1F1yBegzCCPPE=; b=ihLV7oFFf5eReW2GZY1pCMUZ+XEN24p8/YVRHF/ZIfOArK4dK4EwkBZpC+gNrH+aCQ B0jSKxF3fy8hhfrrysi8FWX2bPPSnILNISGpVkK2lIpQx6XvKTCpSMy94uSDob3ykVTL m0DF62lYKbwRd77pW7PKReusF9QvC1vPq6+m2wKjUXLZzSQDLb++oydT10mF068/sBGc RgiChyr/sfD0gSkmqm9HNbDx1GrC/nxxrbuQuZZ2jQ5AT2QBc2TvOCycVUW5IWwBYhFK MaTyZOFY3t+go6uc1vVNi7+c8DTD8nnyc1A8hnnU9rjVQheR1eWgzazxQJyaEHhB+jN+ zoPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YKPz9dAz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3ebd839fsi293203811cf.611.2024.12.31.12.26.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:26:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YKPz9dAz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSimK-0003zB-VT; Tue, 31 Dec 2024 15:23:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimJ-0003nU-5s for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:47 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimH-0000tv-AN for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:46 -0500 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-38a34e8410bso3056299f8f.2 for ; Tue, 31 Dec 2024 12:23:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676622; x=1736281422; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QvYdTYMW+dIfPF+uKcm/HE6zS5JfQaQKVI9r227X6ME=; b=YKPz9dAzPV5iJAf7q80r9sh9FkGmrA5vm5yviKyHbojPyaayRqTDsSWigj9z/mliYG ePgfUFbDMQnMLk5pYhF00JmHG5Gs4+OAQHDFGoupZ64w1kAlhNfwZinGweQ0+voGr4FM S/xKcir8pckAIRINEJfVauhISbD0XaGaTorRI+4jYOS83F8/+t03hjVb5Rd8FlJnHwSl wffIgndi4bbRLaBR1i7pLvveVkaaaC0OhRAfcCRuyTXiKNLwTJrIg0cqn+A5QdBv1S+h +KA8o9bNvJpIIBvtak/rTK11eCdiBcXlBlsGKywVo/1cS0Yu2YEiMIfz02GKKxe/gS5q wc+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676622; x=1736281422; 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=QvYdTYMW+dIfPF+uKcm/HE6zS5JfQaQKVI9r227X6ME=; b=iDYqCEeKoUyvgFhCHbZx0w40cUPgEgMoV1pCx7adsu2gFZEThjd80hFnK4e+T9/YO2 rXG8DjwgN1WZARNfzF+2gNThK5TWumT2bFrlkf2DNzHFt/5UuUyEAoOhI9f8qRCMiZEr AKJ6+KzEtweVUqampdJVO/sbGBuIGbxc1eqcVP1ic5JWQi2+GAa4Ugtzkhr3h0P/cI2y furRS5y5IfnsFMoMjx1uILnPETUF7kuDa9ZjSph/hounHB1HV8xLcT3YPtqU7M7lsgWi BV81Pu5AG1iIcAYo4rC7V+/waW6xu4IXwu1NF3H0OvJ6B3+SczN6luut+GKYnuQZoL+a /gBg== X-Gm-Message-State: AOJu0YxSmX8X+UUlrBdTlvSdo7jTF9xc3fQyPbz0g90gJup7HOX8oQzQ oP9B6mK/nuWdtl3vlkPTbMP0m/kJeQabdUgOC4M43qjGkC9+Jt6UlEyFjLYzou+iuLyGG6a277e yvf8= X-Gm-Gg: ASbGncvXmVwIkZfSbb8yjozMRM5eraVXB8lPwZLZsVgtRW47WeqzRnf7pJfgJtIIq9N HRG/rSXD/KYjn1SokJfCKafLS5467DKpSLQtt7BI6VpjqPLrOoHUsoRKINQfRHtvdjoCstRhDv+ Z7AVpgGIRGXKXO7Ddx0+Wwwts30FXfD9Z4/f3ql7wfilpByHtiNx+qNor4Q0B3wNNi5cKAmpgYy cQv/PrZ4ryufIqkOh96esFf/ytMeAipxfuggXViGSemAGW8IkTiM7xhtEv50lZf8qovIPmtHh6x r1D99z7avsUVam+/NCz8hKBHx3vyZJ4= X-Received: by 2002:a05:6000:4615:b0:386:3328:6106 with SMTP id ffacd0b85a97d-38a222019d8mr38061343f8f.35.1735676622460; Tue, 31 Dec 2024 12:23:42 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436612008b1sm395392315e9.15.2024.12.31.12.23.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:42 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Edgar E. Iglesias" Subject: [PULL 15/29] hw/net/xilinx_ethlite: Rename rxbuf -> port_index Date: Tue, 31 Dec 2024 21:22:14 +0100 Message-ID: <20241231202228.28819-16-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 'rxbuf' is the index of the dual port RAM used. Rename it as 'port_index'. Reviewed-by: Edgar E. Iglesias Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20241112181044.92193-8-philmd@linaro.org> --- hw/net/xilinx_ethlite.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index d54f96df243..4c0c7fcae3e 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -70,8 +70,7 @@ struct XlnxXpsEthLite uint32_t c_tx_pingpong; uint32_t c_rx_pingpong; - unsigned int txbuf; - unsigned int rxbuf; + unsigned int port_index; /* dual port RAM index */ uint32_t regs[R_MAX]; }; @@ -176,7 +175,7 @@ static const MemoryRegionOps eth_ops = { static bool eth_can_rx(NetClientState *nc) { XlnxXpsEthLite *s = qemu_get_nic_opaque(nc); - unsigned int rxbase = s->rxbuf * (0x800 / 4); + unsigned int rxbase = s->port_index * (0x800 / 4); return !(s->regs[rxbase + R_RX_CTRL0] & CTRL_S); } @@ -184,7 +183,7 @@ static bool eth_can_rx(NetClientState *nc) static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) { XlnxXpsEthLite *s = qemu_get_nic_opaque(nc); - unsigned int rxbase = s->rxbuf * (0x800 / 4); + unsigned int rxbase = s->port_index * (0x800 / 4); /* DA filter. */ if (!(buf[0] & 0x80) && memcmp(&s->conf.macaddr.a[0], buf, 6)) @@ -207,7 +206,7 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) } /* If c_rx_pingpong was set flip buffers. */ - s->rxbuf ^= s->c_rx_pingpong; + s->port_index ^= s->c_rx_pingpong; return size; } @@ -215,7 +214,7 @@ static void xilinx_ethlite_reset(DeviceState *dev) { XlnxXpsEthLite *s = XILINX_ETHLITE(dev); - s->rxbuf = 0; + s->port_index = 0; } static NetClientInfo net_xilinx_ethlite_info = { From patchwork Tue Dec 31 20:22:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854408 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089633wrq; Tue, 31 Dec 2024 12:24:10 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXOz39Xx7GO+Idy7V8FnnqIB52qiHb3KZhw+puhjYRAtlyymB45NCfFJUBz7UW4w8FfCgI2iA==@linaro.org X-Google-Smtp-Source: AGHT+IHMREAdQVQFgA6ngCRSerXr1E+8a3Px5OwBmIdYjsJJ/8OJKIFPLehfpcT2cIa++z831Mwv X-Received: by 2002:a05:620a:8801:b0:7b8:5629:5d65 with SMTP id af79cd13be357-7b9ba79d2e9mr6602353985a.24.1735676650030; Tue, 31 Dec 2024 12:24:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676650; cv=none; d=google.com; s=arc-20240605; b=jGcl5ObpCmBkNsXwURmlGMxeNcDWVrK16Y2WgoCiwuLi/JFNYKBFodt0LHLZXsHSTT vkxRWFcOQzp3pUC5vj4uaORcSzwIeEeG8eRTHCEeyjumU7/7KXT7wYO9V1xN4kpiJmWk BDI5QpB4Y8c/ZfetxCJ1llxrw0vlbW36UJNEBA0T7l92N0a6dUbls7uzonzQYmZ3+c3Q MZ7dVhljMm0gHG/VzrtKchJbWZ2n6lL9p60FJkqQciEZ4ZBmKQDMtMeJ9D5x+96/ruad wEfFYCC2N5mYVqVlMIgHEU0yFXQkNhc8RPhlfOxxrGeBT/IAiN1JixQwGFw8L7Rwoh/d HkVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F+dgLv0wfL6nmroxZWYAcgcYxnsCqWNeqAXHsqfOxaI=; fh=neUyoekOkSHTTz6M0JBJF391/o9nhGpSIN84/mRvWtk=; b=c7T0TrkQfKrYc0KOdrwxMLix2lgg/LipGBd3mfB8wy2a1GBIaTEFB8yOmkaxGJqsx9 u0JCtv+jQEj+sbvEu1y89UMHmKtrGmuMoclToGLxgnr8b8d809IxmoACOZj1FoAlnPzG USB6dIMXZvQ3IrkeeitQDR+Q5i9WDL7gKjijUEe34IoJSiuKut2Na6p5tCRagsDQiIgW E2QQ4RbvfDokyWAFcXJkVialoENDF2D0t+AbX45PbxCGUOOkBO8WPYQiO5Mtnw0bIIas 3URuFGKGumUcvtVM1hMgdR9TPn5JSbKaRfmrD8PwIJzTVQnNTk3K6ZgKQWVH1i0N6xvc Xz4Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jvX29wyK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac50f5afsi45746385a.573.2024.12.31.12.24.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:10 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jvX29wyK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSimO-0004Ox-M9; Tue, 31 Dec 2024 15:23:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimN-0004H6-6z for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:51 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimL-0000uc-Jg for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:50 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43623f0c574so69922665e9.2 for ; Tue, 31 Dec 2024 12:23:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676628; x=1736281428; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F+dgLv0wfL6nmroxZWYAcgcYxnsCqWNeqAXHsqfOxaI=; b=jvX29wyKK3tGQOQgtk53IBoo8SPFil2jYdUZBj7cPfMX8avp0aSuB+aL206il0X+2p bmbE/bgd+pFWOie6dxRV6cW4/9Wu16RHD81WpoCDaXfi3gDtZNIkRJaXnYdbnTuEJ8Wd 9AJA90c1NvIu0RC7RXr9BIWQBuTFKFdE9lR+TXCY0h7cEFNgEwLRLxNJi91cBoQ2O0Yn C8CnlAiCl4qYfW1q44NRMQEneSrX1f6VL5ayD9DW5jjgKxsNoM6AQJFbrAYQxenmulZa 0hAuab0BjrbXtH8cDeL6uM0PwSr9p28XkzIy1VlmyfSNwut2okArSABgrx3TiirMwfNE TU+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676628; x=1736281428; 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=F+dgLv0wfL6nmroxZWYAcgcYxnsCqWNeqAXHsqfOxaI=; b=kZ9YehmptE+eVy8O0rxzfWe/eRycB694a4VDhDR29S1BWhQhnCO6xwc/1aA9iqRFCe LPPRMVjKcAOVEhE6t5FvtsorCNYpbI4IFv7xnH1QHCEFH0uhO4YDL6v+cBiSGx8P4dkx lARX/XPDRFfvnx6AF4/xn+X+KPF/hjQ4gpFyCAcCkbAwIxGBn1DuxzY7qWzSg+Z3tfMW 48JJZtzZMqD9iXgPhKgmlQRRWdUQh2SLDcdq49CipVZyK2gSSYaIGF2H3GRX//Wk8Poa SLLe2KMkBkceys/THxdW7A/i5YW41hdErGWPaK5GFz7Go5t0pS3Y/ie5hWmhfiPGqmmO Smng== X-Gm-Message-State: AOJu0YzydrszRHdw+FqFUPcKZNC5tmnRydwr3SI8d4/VJRMdqOcKIgR1 ntVsxxzkJ2fZLtyyMFPInz5OYgbPoB/wqNvDB8NROVQLySaKDwlAfr8auw0nAEG7ZkU3cHt4S44 ewLk= X-Gm-Gg: ASbGncuE1R1Qo7bTZuUCDdHLywy3jZ+zIc2cp3O+M4E4H7ztLsD+SKUGlgW0ikQMKLk 0nfExNhF3pLZxZhCjxPmjIIUVftrSw9RTpcWA7GH8RlpSd2Rh0zwWPpMk5cAKqSrvQmYJoBJ3xN cbbYNbS3FSJJ7L0hiFX68v+SdGPQeL1F7bAlKQVkKd0sDmb1iBw3ui7Ok8RWLqIH7DFGTXKU4L9 8g93C3s6Ec/8xknBc+7T86HU2ZIzOeo0GWVX3p6FOhlcTtxd7A4j/xerWnR1Ge2JUigv86D41Xb 2kpXX26veS+5BwcK7VPMLpWbxvviuMA= X-Received: by 2002:a05:600c:4ec9:b0:436:51bb:7a43 with SMTP id 5b1f17b1804b1-4366854852dmr339650865e9.5.1735676627765; Tue, 31 Dec 2024 12:23:47 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c89e375sm34171659f8f.73.2024.12.31.12.23.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:46 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Shameer Kolothum , chenxiang , Igor Mammedov , Gerd Hoffmann , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 16/29] fw_cfg: Don't set callback_opaque NULL in fw_cfg_modify_bytes_read() Date: Tue, 31 Dec 2024 21:22:15 +0100 Message-ID: <20241231202228.28819-17-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Shameer Kolothum On arm/virt platform, Chen Xiang reported a Guest crash while attempting the below steps, 1. Launch the Guest with nvdimm=on 2. Hot-add a NVDIMM dev 3. Reboot 4. Guest boots fine. 5. Reboot again. 6. Guest boot fails. QEMU_EFI reports the below error: ProcessCmdAddPointer: invalid pointer value in "etc/acpi/tables" OnRootBridgesConnected: InstallAcpiTables: Protocol Error Debugging shows that on first reboot(after hot adding NVDIMM), Qemu updates the etc/table-loader len, qemu_ram_resize()   fw_cfg_modify_file()      fw_cfg_modify_bytes_read() And in fw_cfg_modify_bytes_read() we set the "callback_opaque" for the key entry to NULL. Because of this, on the second reboot, virt_acpi_build_update() is called with a NULL "build_state" and returns without updating the ACPI tables. This seems to be upsetting the firmware. To fix this, don't change the callback_opaque in fw_cfg_modify_bytes_read(). Fixes: bdbb5b1706d165 ("fw_cfg: add fw_cfg_machine_reset function") Reported-by: chenxiang Acked-by: Igor Mammedov Acked-by: Gerd Hoffmann Signed-off-by: Shameer Kolothum Message-ID: <20241203131806.37548-1-shameerali.kolothum.thodi@huawei.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/nvram/fw_cfg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index c5537166d97..a757939cfb7 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -729,7 +729,6 @@ static void *fw_cfg_modify_bytes_read(FWCfgState *s, uint16_t key, ptr = s->entries[arch][key].data; s->entries[arch][key].data = data; s->entries[arch][key].len = len; - s->entries[arch][key].callback_opaque = NULL; s->entries[arch][key].allow_write = false; return ptr; From patchwork Tue Dec 31 20:22:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854407 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089614wrq; Tue, 31 Dec 2024 12:24:07 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV+geKKPpra+oIY3//dI/+r7HrznHEMt4aT1N0CyGi/F+g/30/N4D34dzPQ3QlrBJomXDcprA==@linaro.org X-Google-Smtp-Source: AGHT+IEdV5V0NnXile2qOdveEhnapQNcNn4vJeU2yM5UE9rldcLli7fCfVII+yusXh+HsdKAVWj4 X-Received: by 2002:a05:6214:ca5:b0:6d8:9127:e71e with SMTP id 6a1803df08f44-6dd233ac203mr660394246d6.41.1735676647291; Tue, 31 Dec 2024 12:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676647; cv=none; d=google.com; s=arc-20240605; b=fkFbXnHeGVS8gc+FAqqpLuhR5q+CFs97F9cJkrFNhMebkJfAzuACDDUhKF7/6c5GLr Oj5pP2tDRqNTZqZHm9btkDDdEQ8YgE/lBOH23AXFT9r46tejiosABXEuk+/siY7Ym2aC jC5Qpt6NMBfhu21sEj6PGadDoHQ00c6r183bO7SeDxv/STe1hOsdtATRPTidHOY2whfD QHIx0lPiKlNvenuNG/3ZxutstU6WU0yzu9So7R3BusmbioutTQUVgqFQuSRugvGDatEj dMRBz999AcMS/Qk7ce8i/TfAWqs+d5PJi+ZuALgrxslFWC41PhXXuxtqyyy3X0QnGsRs ZXsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=24stuC9Tej+Nlsj2a7JI1tcgZwdo9U7YvTPvHeYqEOg=; fh=9WRnyL38aYsp8aAc4GCnnt6DPSS3ieJwiF5wkNbWJXc=; b=Fcr+s8VPyrFcVnIP2uQx/FDRYKSUgN45qalQcBP/BqstLS6JfgkhPSAoibAnzMCROw snpamWFJedKOpFKdI7mIolkZ3fAMEQ4Qn9aHaBFb1ZaE/BpJLQuIFkUlWvvc1TYSvNGN o4onwa+mo0mSYzSLumAFq2M4AdVr6TtzL1vSB2CO/r+3cBc1CS8Rfwh8zRpiFKMdoKrn XRA74Pd4LqmryPUH6rsqNUlAn/C9LijQGhGuoMkHcYGE7khwBQ6TBelwrEPUZzJ+rGig VfIoQSh/CawDJ2vaWWMyS92TcDDexdIgOVEwuTfNlEDxc7/xvu578BZJKC9qkkp6Pigc qIxg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T3865P7t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18102aa8si316142226d6.71.2024.12.31.12.24.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T3865P7t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSimV-0004wk-Hb; Tue, 31 Dec 2024 15:23:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimT-0004po-Ca for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:57 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimQ-0000v2-CN for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:23:57 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-436a03197b2so22693825e9.2 for ; Tue, 31 Dec 2024 12:23:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676632; x=1736281432; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=24stuC9Tej+Nlsj2a7JI1tcgZwdo9U7YvTPvHeYqEOg=; b=T3865P7teJ34HIBo6CBKzJhVfGyg1V/5I9y8bynOOb6j7vjPZ3wdmixb4vbWh6es7w FYZgReyt21TB6M0TI3Vln9UUOYJzd62kuxJihtQpOeLodys7quSDXMDoAcioAs3dfzHC gDWemRv3LfvTThckII5YtHj1T6hTPcOV1lAg4mQgeLzDm0dxkslJnVHU4XaByQxRYgK9 e72WsbbHst/QeIz/BvvOt04QbM+xXIMn2Dd92yaImO13MflRuxvWILnEpULdVjFzDOFg bcAUWQs8Vp1WZUTYMzNei71Ep4ER3bXtxRYZmS6+aGW4z4/Eh8nbGRjPCF1t6hWXE1z5 Zn4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676632; x=1736281432; 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=24stuC9Tej+Nlsj2a7JI1tcgZwdo9U7YvTPvHeYqEOg=; b=DmxWDkinY5uJgUqcycFu5MMHPQAT8vootO7tFxb5Ydo9RCaFg2/Ne9eO8ijyJpebfJ UrkTef2BsSAufy02ZCW2ba2idNSVnZlsjCpH2zs3SzoD4UAtLk5OiFNUuUKTV151U3VZ OyHDvSvPnnj0jUpyJERTLPsOoWjxF7sMpUjrjooaV1DnGpl8Wxrt2n4Pd8+GtsJHYEAj 93KcR3simVRbtlN02+mUj72JANn1C2hJ8CXx4YHV/2qmTs14fwx++CTe0HgSFJ39Q11c EDJjwubOjlivNqUnsn/Yw0Dces+u5sQST+/2IrF5jyGRd3IKnYl9WZXfUpM4Jw5zZQiJ bwEA== X-Gm-Message-State: AOJu0YwZdasMiFh18qxp3yBy6EX3unpsVNa/M0a8Vkrzbtr7GH5Nr66E w1axGmpXNKQOUIxPSzRkrbs7VHAJDWLomLfMF0bqP7t2NrarPHc7grRZKXrvcBTeWM4AAsz0q5r jzY0= X-Gm-Gg: ASbGncuOpU5GidbGu8aftfWD/U3RjqpJz9d0Fu/WTvkk5vhkizavPfGhChwyOCoPTkX DmOcl6LdjP0iwl2ghn3zbW9M7A9GbA88cOvLirCbQQtKYe6rYrHIMfrQA3NE9GOfS0SJOJ/uRAP 6EkB1lqY04d6PFgGbrC018qlc4VCQAyI3huBVGN7MhFwN61KqOb/T1U8RmpmvRZLolkvv7E4uLJ //EpZueIg2Nkfq0xDAal7Is35ywhc3rfxFKyIwEUnt1yAHl2NwEfXTbRPMirYboa+GyItSg8+ap YWGaRU2gByXjwOBLMqDQvhGiGejFfcc= X-Received: by 2002:a05:6000:4024:b0:385:f6b9:e750 with SMTP id ffacd0b85a97d-38a221f31a9mr29076092f8f.9.1735676632326; Tue, 31 Dec 2024 12:23:52 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4364a3766dcsm329449335e9.0.2024.12.31.12.23.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?D?= =?utf-8?q?aniel_P=2E_Berrang=C3=A9?= Subject: [PULL 17/29] hw/misc/vmcoreinfo: Declare QOM type using DEFINE_TYPES macro Date: Tue, 31 Dec 2024 21:22:16 +0100 Message-ID: <20241231202228.28819-18-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Message-Id: <20241219153857.57450-2-philmd@linaro.org> --- hw/misc/vmcoreinfo.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c index 0910c64866f..31073c8de2a 100644 --- a/hw/misc/vmcoreinfo.c +++ b/hw/misc/vmcoreinfo.c @@ -93,16 +93,13 @@ static void vmcoreinfo_device_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); } -static const TypeInfo vmcoreinfo_device_info = { - .name = VMCOREINFO_DEVICE, - .parent = TYPE_DEVICE, - .instance_size = sizeof(VMCoreInfoState), - .class_init = vmcoreinfo_device_class_init, +static const TypeInfo vmcoreinfo_types[] = { + { + .name = VMCOREINFO_DEVICE, + .parent = TYPE_DEVICE, + .instance_size = sizeof(VMCoreInfoState), + .class_init = vmcoreinfo_device_class_init, + } }; -static void vmcoreinfo_register_types(void) -{ - type_register_static(&vmcoreinfo_device_info); -} - -type_init(vmcoreinfo_register_types) +DEFINE_TYPES(vmcoreinfo_types) From patchwork Tue Dec 31 20:22:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854418 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090109wrq; Tue, 31 Dec 2024 12:25:56 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXGmwf/6/ZnlZLAMw3XVkM/Z8I2QjCvvjIWu+GCsMWlV81mhJw/RuewkdI1psg3oMKBzyM5Hg==@linaro.org X-Google-Smtp-Source: AGHT+IFzEeq4YuWaYvbeV8ZCekhH5UZQXOD+cmFIrjiTfD/07s9ATKL1OZiKcrgLylVrBCa8v7Y7 X-Received: by 2002:a05:620a:4104:b0:7ac:bc66:5efb with SMTP id af79cd13be357-7b9aaad5e1fmr6880287485a.27.1735676756427; Tue, 31 Dec 2024 12:25:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676756; cv=none; d=google.com; s=arc-20240605; b=bcBYTsCVxSqIS7fvoRXmlRp6XjUDAOC9JBbPh2zh024ugJf30xMhj0TOqmpS8AY6jB b8zQ8A5r+U6g83ckY+K4dNhP3bofc0tDOskKkjEfIPBZwaqGkkcA4ZhlDn/jut4ILeAp cSz7MgEkBWIJHgIdIwEZzG1fT5NGaybO4hPa6+EruwcwbMxAy6R/itE+0eM/NBa44F1M FTqJjzu6nnieVE5y+kOtrfxHZ5PX9MOmO23s8Shr+lqi4qZ/5uNvDJgq4YXgiwtMTxzA KxfAcjLRWo/RGsukIEU8kxp5OhUv7zNABLHXOrvQcu2bdnZbWWybVJscHYVz0LqxsXSa lafg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qFV9r81Ea/Fg1ZQ98Ka7pViQ6qvJe57bkPT4B6LFdHo=; fh=9WRnyL38aYsp8aAc4GCnnt6DPSS3ieJwiF5wkNbWJXc=; b=NchAt2OqX3f1/8xuYiSdZnRpiAifAXASPJLNibaSKQbIXN8pmpWso+SImhCh6Ns2SF VzI/aeDBX1ANpiVdtmribEWBZvE7Hf1oUfnJgisxzLe9X4RUQ1Zo8pefrC2KEqqmKqrE +YQSBf+iW28o6kaDl3VkgLwS6kpT2cB1e805H7XEuctx8mPqT/hJRQr19bT4NtSIBnWB aT/q7kYtE+PUZIumBP4vtwR0P/hPHVepMFEcT9357wYyrXHefDmE+xGXf7vqlxMn2nkd KaIsxottuEDG2vsOFr1O73JfZUJ3JSpJLMUfkViNBgy3dpV2eFK3byGV16MOyqmfkdPn nxIw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rRJQ3mOv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac53e6e1si3038417085a.645.2024.12.31.12.25.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:25:56 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rRJQ3mOv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSimZ-0005Oc-Im; Tue, 31 Dec 2024 15:24:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimX-0005Av-9v for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:01 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimV-0000vv-K5 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:00 -0500 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-38a25d4b9d4so3523092f8f.0 for ; Tue, 31 Dec 2024 12:23:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676637; x=1736281437; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qFV9r81Ea/Fg1ZQ98Ka7pViQ6qvJe57bkPT4B6LFdHo=; b=rRJQ3mOvb9k+6p+Joh5Xec44VhFiRyuTPV3v+PFy7eW0Sk8WNHVrlBQ6eLiRSFrXzi u2lcCjCDaimXi44vlFWUXwvo8DX9ay9Vb6Vmx2e6kApStbQSJ8jJb3FMpJniZhZzyYSG tTA4M6NU6eIvfwAfHM2No+O/VyfM57TaZVg6a8kD3Lxx5HqUvfcToKlIjAfNvhNASEuW jkbahCHs5r3dZElmdxTj+r3JfNlycsCEzvYUerN7YIKSWla33ta1BcpcOWdbKSj6Tqjg e4q7OO8qrcD8zOVZUyw5Sh5VR7yBfyHk/9wLIn+hxmohK3CJnYu/XE11WUfqLg0QkfN0 P8Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676637; x=1736281437; 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=qFV9r81Ea/Fg1ZQ98Ka7pViQ6qvJe57bkPT4B6LFdHo=; b=mkz75J4o+w/qqnVuAchEZRtbAFI8+ZWgbuBgRvCx2JEsvCYLdiN44ftdYsQV5pK5t3 xzE75n2OAW8TunTTWnQ6W4pF7HWbSVnBybq84CkdXVvtj4p7PaxdB4Z52FCe1lLuLPVj CEX8xUfGRmL7brHq/HpCV9OesRKMSZPbHERCRJh3meKLE7E0DdMCwtAyc7nLbZdLOWV3 OLubkJpiAYB0XHjIIJrIkAwXwYCawBjTLIT9EU5UP9KqWUEOFpiilwAvwM9tn4WGXyAb 1LTGkOyoZeQ6tRjvFILSrHMfX/Gox+WlV9RYHKLMS/wzikndSbWuT0y2ie7jMDLP3HKz xFkw== X-Gm-Message-State: AOJu0YwIEkuMAr76WKlsQF3eszjj+pSsRpHBQGZEZoZbT/5DfAIFuUnj 82c609So+DnbNmPgAwvH3kVQiUG37j1czgXhMs5gXg9XaNh/Ff5ve1L9xuFMZr+4ZN/DretaHlf 7Qkw= X-Gm-Gg: ASbGncuVsyI2k5vM2BJWfRiKeyWce951nrx/9p04HAp/rOpuCKyYgYgWq6dcXoiZypp sQwZlQxrC63+HknrrUj9lXh8tHWTwaOUoiOag/ZM+IDTtxAjqtEfess6OaczKkTyYbEt49pv6ix CLqC+pEpwe5RxyJLxK7ZbY7abq7nK83+5FN2IDbTBR66aWVtZFhxr4uP733unjnXUS9UBV+5ze6 Tr2DtbujMwdA8mTz7mOB6mkJZtYbGbYCIzpOfD8LeWEMaY1Lxh4ykhP1KjTnUwyHQHUuR5nrnBM IYucsMRu8AKjDWx+wtJ2+CM5uw1OcFM= X-Received: by 2002:a5d:6da1:0:b0:386:4a0c:fe17 with SMTP id ffacd0b85a97d-38a2220039fmr33339788f8f.27.1735676637556; Tue, 31 Dec 2024 12:23:57 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8a6ca5sm34389184f8f.86.2024.12.31.12.23.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:23:56 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?D?= =?utf-8?q?aniel_P=2E_Berrang=C3=A9?= Subject: [PULL 18/29] hw/misc/vmcoreinfo: Rename opaque pointer as 'opaque' Date: Tue, 31 Dec 2024 21:22:17 +0100 Message-ID: <20241231202228.28819-19-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Both QEMUResetHandler and FWCfgWriteCallback take an opaque pointer argument, no need to cast. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Daniel P. Berrangé Message-Id: <20241219153857.57450-3-philmd@linaro.org> --- hw/misc/vmcoreinfo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c index 31073c8de2a..b1fcc22e92b 100644 --- a/hw/misc/vmcoreinfo.c +++ b/hw/misc/vmcoreinfo.c @@ -18,17 +18,17 @@ #include "migration/vmstate.h" #include "hw/misc/vmcoreinfo.h" -static void fw_cfg_vmci_write(void *dev, off_t offset, size_t len) +static void fw_cfg_vmci_write(void *opaque, off_t offset, size_t len) { - VMCoreInfoState *s = VMCOREINFO(dev); + VMCoreInfoState *s = opaque; s->has_vmcoreinfo = offset == 0 && len == sizeof(s->vmcoreinfo) && s->vmcoreinfo.guest_format != FW_CFG_VMCOREINFO_FORMAT_NONE; } -static void vmcoreinfo_reset(void *dev) +static void vmcoreinfo_reset(void *opaque) { - VMCoreInfoState *s = VMCOREINFO(dev); + VMCoreInfoState *s = opaque; s->has_vmcoreinfo = false; memset(&s->vmcoreinfo, 0, sizeof(s->vmcoreinfo)); @@ -65,7 +65,7 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **errp) * This device requires to register a global reset because it is * not plugged to a bus (which, as its QOM parent, would reset it). */ - qemu_register_reset(vmcoreinfo_reset, dev); + qemu_register_reset(vmcoreinfo_reset, s); vmcoreinfo_state = s; } From patchwork Tue Dec 31 20:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854409 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089665wrq; Tue, 31 Dec 2024 12:24:14 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXl6udq9pczqxVh/NKLFnzs8Rf/H3HtvpBQL8Iu+04OyYHIhL1iYSw6+7lFf2mD4gzQd5M4Xg==@linaro.org X-Google-Smtp-Source: AGHT+IGbbOjVV5b7pp4FZCxnR/IEIH9pPe0HlCbU+9H+7hG958y2J90opjAgZwxRwWhKLgj+lnWD X-Received: by 2002:a05:620a:3904:b0:7b6:e933:b2 with SMTP id af79cd13be357-7b9ba7ec9d5mr5764587685a.41.1735676654704; Tue, 31 Dec 2024 12:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676654; cv=none; d=google.com; s=arc-20240605; b=BRt+5qjgd8JThbkOK+3tegcQ7tOPd/RP97rgRbytMs1tYD8IzE+cn7vWiXu40Qcbp5 3ZDKQ44Wb5m52nADqnQNV6xuZqqk8dVmS8QznFKQQg/7+lfmuUZFeXzPR4/4rxYEAykq TuyBUQRuP7GGfXLrgFGM87hWT6LtVBdDOzH1WlyXnkl/q+qDeLM23kDYtDeAPZ6//e+f 619ksxHBSTlOL+VaeIhgIZAqQ08BAYswCotsOEJBr7SwQLkR2qQIXff+CxOMmckbMzAI qTXXDztt/imwoQVKffeBooVuTSc1OYDduA6VB1bzvkoafQKkh7I96sH+wF447fFXOnp1 22ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4eBUfaZOV4VpWuEPg0imAAbPSgeX3YWDxsrL3NZUv+w=; fh=nn+pMfi92jzRRZ7DEyzc8zv4dvJLsw6Sxln98shN7RI=; b=cpwo7ld9jhcXT8rDhYuFVc8XFolDMRfr6s9bS2yKpI60RYiju/9KvGoTIWFSajb9F1 1HlmyOi6qLu8IwdUER9E5zrUM4xVqj0XoaeH0aeDYjoFGeyU6u0fFDS4AqQTiqvCoZ0O uV7DQdyFdsXNZll5FcVjYvV62wqxqKXNlfRq1Ht1D6JBFCl5eQGRGw/jnpkPgAhzEQLS a/HO3E5Zm4+Gq7wfrvKrcBINE5kewmjVUR9MMghES7hwwSrNiaAn9Z6ZvIILPS1ltvjX 5jLnVtNIT0lcp+R+blVbYq7OPZLltocjCmq8iBxqs898kT4MK1x21rDFlGbqiYa8VFgM ORlg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z3eYRnO1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac4dbf8esi3039945085a.450.2024.12.31.12.24.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z3eYRnO1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSimg-0006Fw-0i; Tue, 31 Dec 2024 15:24:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimd-0005zG-DS for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:07 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimb-0000we-8Z for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:06 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4361f796586so106898765e9.3 for ; Tue, 31 Dec 2024 12:24:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676643; x=1736281443; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4eBUfaZOV4VpWuEPg0imAAbPSgeX3YWDxsrL3NZUv+w=; b=Z3eYRnO16r6Vi72Y64DmN6UPldK4TDxt4NbFYqN4Re2kzULpKYV3ePmmdpaBx8qC+r 8U1530m5ZhHq7thiFFaKZjcfjzZBd0bnhZXJy5T0NADbQlFR++8kNQc70g+8mDypVEvK p+sEJGZQS4qZ2Vd7bZlb3IAKT5UJYW4APTCt2MlfxQomWrs2tnjXkgB6Rpcvweyz6zfT shxABJ8D7YCT65w0XSpQA0muxg/kC0GBESTSjoKhwvohJSqq8Ypgm4t+w6J69vDovwKE keHwviMRfuguvSIQ0YfRU6gAnvmhkyAsv2qUFZ1swbrkDBGd0LBl92QQlraSIHophVuq hYrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676643; x=1736281443; 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=4eBUfaZOV4VpWuEPg0imAAbPSgeX3YWDxsrL3NZUv+w=; b=JsLnq3cYIYwHN/UElCTjidtmiLDzWjk4vQfdEiIrqjUn+T+yU1bGVF5GG2nEokTPUn w8LhF9umtINsZxzzUcOQorTJOpE26jZ4Z8fKgYRhOSOqdHHvrjiWe5Uun62d9alAbLM3 gFF+GY5Ubl2Yv7SeU7k0/1RQ1jKFgNwop/Tx2be67IONOfy0kPYY+ZL3GxpV6XO/baO1 WiFXBYrB91O6pkV4DE5aJYTZQRmAgwNuy7hUSeEwggyQDF8/gjCCGbAZ3MYRnYyR83KC 9ABCJP46QMcrxy1mLPVkEXobE8hmjNfX2fO9rrIcWFRU4eqTXwtG7uUlN8Naq5ecfwe2 zRWg== X-Gm-Message-State: AOJu0YzeCvbL4EGAynjRLJB8l32qtVS/wfMYu+Et02rZZ28p0+R0MiIr GfMkV7tfheYhpH2JAdMMKY15doe2JTcGjSfPlxspS8krPmVRZ1KqC/hBwmaa4w7xfgdng/aMSWS 1HoE= X-Gm-Gg: ASbGncs5swjNXiKTJlignfsK9VVbLM+6uNlXs2gZxhiu7bABlYoHr/LkW728RRr+P9D sljexUGNjYOseZ0bOR3x+W9zJGj1yTYNVm648QutQbDQ2NFwHUyM2j6erBPSULODk2uKiVfoJaN BNxDqUEW6Plnh+nmBKoWE4eyHhM/P3OkOx5Qt7moPLEMyVFuHsHaUYizNvvdLTnrLfXI35OdvnE 6xf18BPHGdHgEv529XWZVa65oJ5R88Nf5fxJaEi0roD7v8A9N4MK/skD2tsiA/FBP9d9PZSVEOd RyBigqJNJ5cpRV8/W2phQuUEmHok1Qs= X-Received: by 2002:a05:6000:713:b0:386:3903:86eb with SMTP id ffacd0b85a97d-38a221f1fd1mr32023610f8f.23.1735676643483; Tue, 31 Dec 2024 12:24:03 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c89e150sm33553091f8f.66.2024.12.31.12.24.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:02 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vasant Hegde Subject: [PULL 19/29] hw/i386/amd_iommu: Simplify non-KVM checks on XTSup feature Date: Tue, 31 Dec 2024 21:22:18 +0100 Message-ID: <20241231202228.28819-20-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Generic code wanting to access KVM specific methods should do so being protected by the 'kvm_enabled()' helper. Doing so avoid link failures when optimization is disabled (using --enable-debug), see for example commits c04cfb4596a ("hw/i386: fix short-circuit logic with non-optimizing builds") and 0266aef8cd6 ("amd_iommu: Fix kvm_enable_x2apic link error with clang in non-KVM builds"). XTSup feature depends on KVM, so protect the whole block checking the XTSup feature with a check on whether KVM is enabled. Since x86_cpus_init() already checks APIC ID > 255 imply kernel support for irqchip and X2APIC, remove the confuse and unlikely reachable "AMD IOMMU xtsup=on requires support on the KVM side" message. Fix a type in "configuration" in error message. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Vasant Hegde Message-Id: <20241129155802.35534-1-philmd@linaro.org> --- hw/i386/amd_iommu.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index be522b5d7dc..6b13ce894b1 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1652,17 +1652,10 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) memory_region_add_subregion_overlap(&s->mr_sys, AMDVI_INT_ADDR_FIRST, &s->mr_ir, 1); - /* AMD IOMMU with x2APIC mode requires xtsup=on */ - if (x86ms->apic_id_limit > 255 && !s->xtsup) { - error_report("AMD IOMMU with x2APIC confguration requires xtsup=on"); + if (kvm_enabled() && x86ms->apic_id_limit > 255 && !s->xtsup) { + error_report("AMD IOMMU with x2APIC configuration requires xtsup=on"); exit(EXIT_FAILURE); } - if (s->xtsup) { - if (kvm_irqchip_is_split() && !kvm_enable_x2apic()) { - error_report("AMD IOMMU xtsup=on requires support on the KVM side"); - exit(EXIT_FAILURE); - } - } pci_setup_iommu(bus, &amdvi_iommu_ops, s); amdvi_init(s); From patchwork Tue Dec 31 20:22:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854417 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089989wrq; Tue, 31 Dec 2024 12:25:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV0N01n2srZq4oA1qG3mEaaMFICbHtwPKfNLDUjvLiazAMlky7srrSc49XWkDSbSePI8E9rbw==@linaro.org X-Google-Smtp-Source: AGHT+IEbX4DiBACYlNNOs0tsqorinJ7c5eLZgBWokGsp6DvfPJWs8MuEZMmBXy9rMPR/aCsQRHw9 X-Received: by 2002:a05:620a:3185:b0:7b7:106a:19a0 with SMTP id af79cd13be357-7b9ba799addmr6361910885a.24.1735676723878; Tue, 31 Dec 2024 12:25:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676723; cv=none; d=google.com; s=arc-20240605; b=jnZeZvCBXq7gfva8qIfy2/yNroqIdUzNii4Ap1Son5CK0+KqKup5GNAKtKPXxjX3H5 0PmHhE13HK3900FwtfCrWgmDOE49jvEy2JCAftMe/kbMXIp/hK/SS6Wrf09vJ2q7FZV8 3zEAFIYjvNeCjkR1G9csWtJ2Rn0rlhK1dHhQmpTApbdLI+WGw4FDANM497dOaDuMqhuX KS/shl7PAiSP3Y3IWQeMF5RUMxcHymdNxXCzrSmAqLWIc/I/VgIxmrGP5kfE6V1hF3Al ObnO1az3cHXlEKz/2+GJR8RD2rhSMaFbEIIL4sAwv1FuOEo2LilY0vOZFxgkyS9UjwPS /42w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yVuDlgyVY1jvmkQEUInHR9nAZd4EhLEP8pFEQwDV8v4=; fh=tyn3H0ySGZ/3GeTr+63AnxEBt54onnjIpRgEvvPl10Q=; b=i7r0ccKRrEBD7ee2k+vEC/CLyqd0Nd+S5HP15cfroSHwU49qsh3kqFpZSRApDCBYXf mD4s3qg48G9+qr97M0K9bxc8+4vSTARts2A4hnnkA731urP+6OfI0PC+JK1kKERkjxOi IkxpUxnno7ke/NleSY+FBOIm/iGjmryfyRFuv5GQUj5hT/k0aNAFqG1Sc9qI4e1WuTpt 92RMLMjTuE62+f7AJ4f+8kOnBQDFsMt4bdUnMH6jIoAc6UJksDygBAWKQMNG1JtdttjL 3ruGVSd/Y/nUOA/+EoCWt0Z8wJX8iCEwRjzF6fNhAx55F0mfw2U16/GfAUagjAi2eFdb db2g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q45qF+VQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac4fa5acsi3110831785a.554.2024.12.31.12.25.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:25:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q45qF+VQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSimx-0006px-Iq; Tue, 31 Dec 2024 15:24:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimj-0006Zx-BU for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:13 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimg-0000ww-0h for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:13 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4363dc916ceso66468765e9.0 for ; Tue, 31 Dec 2024 12:24:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676648; x=1736281448; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yVuDlgyVY1jvmkQEUInHR9nAZd4EhLEP8pFEQwDV8v4=; b=Q45qF+VQmDXRnVLVfeIY/tv+dgeYWuHK20J4XcaCvCJVbhRLMtjPXHB29aqA/ULY8M +X3mq2LkxkrAFzsG7rml4DXFxP3Pg+8r/k5tR2mw62YohJ9gUaAW4qa5m7MKaYbp5mSn 81hxERT8u7HaL471F2kY/z2/VExQc2+wJkUN04qF5aMKlpRDCr7uhLSzvbGi9Mb5cC0N peunCl1QMheLKArliuylcKPzBpNz86ghQYknQRYIWGsWMTkUMNz4Bh5D3xZjM9u0h+oj r01ReQgb498QOgwVYAJaiTS4cLDB+WHNSy6KrVQD5mT5CIrF1pYmEexaNc/16gU0tCC3 4IAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676648; x=1736281448; 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=yVuDlgyVY1jvmkQEUInHR9nAZd4EhLEP8pFEQwDV8v4=; b=oTvaxEAYb3ZsZXOo9j6Ze9jjway4VoenNg+xFBuGNh0xo+6O2tQXnzF/YSmR/0L44i 1VXSYED2h562B6fYMJEFDCP99/wyZN1eHZwOAEZMk8ENakpPsjwZJBgwZgHGJxDM5Pjg ha1uz0wshh6N8msVEDC6jLmQs5tli42x+ID8YpSsdtsG7Y84lA+88cJdozk+aSzMJVJj LMR74j6Sr/e/40qL4onI6xT+fS5Xg4uxxy56uBbrbZtuxraiCoEVdLkXSw5+lRBY7bsl MXZsbkpdghC7TV4xH0kr6dbYjBv0Yn+3JQ3rOQqbi+JMMUO1z1g5Y94c9WFngsB4zC/v /iFQ== X-Gm-Message-State: AOJu0Yzv41Y3jQ9XVFQ4qnvnScnUa7LL/OjJwRreiaTMO4ltQWJ0NbKc /Sb2W/Xas/k5PSmTeHnpdNY95aH35k4igw+11Cabp95Xd5+s2JcFBBc2I7no4+1TLwNBp2s7XtA Bncc= X-Gm-Gg: ASbGncuy0UxNBi/A2Aq1K/Pv76/M/kbjtT7+5z4kL6H6RV2yrVsUcXjyjjgO+OpcMZ7 DwTgoFVEcym53dshKmTZskM+rqY1tekaD4KAosVt6IVlDlSuc1AVGesMQ1NJBFIvyo8eK4sVfJ8 uYfNd++7WHElHjwA18HenuD3jdLr5JrlmAX3AtRJRBkQQp4F46x/fE1EjpSwLTWcxgwhcxPrsar y6txepTE/bfIzSeSyC9QgOJnbPhNlpuwi8yOFGs76EMxzies5oUUgKKv45OBt3SEiNCnwYsWteF c1OTj/yZZnIzSwrv6oLGM8DFtyM9iHU= X-Received: by 2002:adf:a392:0:b0:385:fc35:1f75 with SMTP id ffacd0b85a97d-38a22a11b62mr28089066f8f.12.1735676647994; Tue, 31 Dec 2024 12:24:07 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c6ad3e3sm34816944f8f.0.2024.12.31.12.24.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:07 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 20/29] hw/block/virtio-blk: Replaces request free function with g_free Date: Tue, 31 Dec 2024 21:22:19 +0100 Message-ID: <20241231202228.28819-21-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Phil Dennis-Jordan The virtio_blk_free_request() function has been a 1-liner forwarding to g_free() for a while now. We may as well call g_free on the request pointer directly. Signed-off-by: Phil Dennis-Jordan Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Message-ID: <20241223221645.29911-14-phil@philjordan.eu> Signed-off-by: Philippe Mathieu-Daudé --- hw/block/virtio-blk.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 8806c03f7c6..e0acce89e1e 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -50,11 +50,6 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, req->mr_next = NULL; } -static void virtio_blk_free_request(VirtIOBlockReq *req) -{ - g_free(req); -} - static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status) { VirtIOBlock *s = req->dev; @@ -93,7 +88,7 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, if (acct_failed) { block_acct_failed(blk_get_stats(s->blk), &req->acct); } - virtio_blk_free_request(req); + g_free(req); } blk_error_action(s->blk, action, is_read, error); @@ -136,7 +131,7 @@ static void virtio_blk_rw_complete(void *opaque, int ret) virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); block_acct_done(blk_get_stats(s->blk), &req->acct); - virtio_blk_free_request(req); + g_free(req); } } @@ -151,7 +146,7 @@ static void virtio_blk_flush_complete(void *opaque, int ret) virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); block_acct_done(blk_get_stats(s->blk), &req->acct); - virtio_blk_free_request(req); + g_free(req); } static void virtio_blk_discard_write_zeroes_complete(void *opaque, int ret) @@ -169,7 +164,7 @@ static void virtio_blk_discard_write_zeroes_complete(void *opaque, int ret) if (is_write_zeroes) { block_acct_done(blk_get_stats(s->blk), &req->acct); } - virtio_blk_free_request(req); + g_free(req); } static VirtIOBlockReq *virtio_blk_get_request(VirtIOBlock *s, VirtQueue *vq) @@ -214,7 +209,7 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req) fail: virtio_blk_req_complete(req, status); - virtio_blk_free_request(req); + g_free(req); } static inline void submit_requests(VirtIOBlock *s, MultiReqBuffer *mrb, @@ -612,7 +607,7 @@ static void virtio_blk_zone_report_complete(void *opaque, int ret) out: virtio_blk_req_complete(req, err_status); - virtio_blk_free_request(req); + g_free(req); g_free(data->zone_report_data.zones); g_free(data); } @@ -661,7 +656,7 @@ static void virtio_blk_handle_zone_report(VirtIOBlockReq *req, return; out: virtio_blk_req_complete(req, err_status); - virtio_blk_free_request(req); + g_free(req); } static void virtio_blk_zone_mgmt_complete(void *opaque, int ret) @@ -677,7 +672,7 @@ static void virtio_blk_zone_mgmt_complete(void *opaque, int ret) } virtio_blk_req_complete(req, err_status); - virtio_blk_free_request(req); + g_free(req); } static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *req, BlockZoneOp op) @@ -719,7 +714,7 @@ static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *req, BlockZoneOp op) return 0; out: virtio_blk_req_complete(req, err_status); - virtio_blk_free_request(req); + g_free(req); return err_status; } @@ -750,7 +745,7 @@ static void virtio_blk_zone_append_complete(void *opaque, int ret) out: virtio_blk_req_complete(req, err_status); - virtio_blk_free_request(req); + g_free(req); g_free(data); } @@ -788,7 +783,7 @@ static int virtio_blk_handle_zone_append(VirtIOBlockReq *req, out: virtio_blk_req_complete(req, err_status); - virtio_blk_free_request(req); + g_free(req); return err_status; } @@ -855,7 +850,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb) virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); block_acct_invalid(blk_get_stats(s->blk), is_write ? BLOCK_ACCT_WRITE : BLOCK_ACCT_READ); - virtio_blk_free_request(req); + g_free(req); return 0; } @@ -911,7 +906,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb) VIRTIO_BLK_ID_BYTES)); iov_from_buf(in_iov, in_num, 0, serial, size); virtio_blk_req_complete(req, VIRTIO_BLK_S_OK); - virtio_blk_free_request(req); + g_free(req); break; } case VIRTIO_BLK_T_ZONE_APPEND & ~VIRTIO_BLK_T_OUT: @@ -943,7 +938,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb) if (unlikely(!(type & VIRTIO_BLK_T_OUT) || out_len > sizeof(dwz_hdr))) { virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP); - virtio_blk_free_request(req); + g_free(req); return 0; } @@ -960,14 +955,14 @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb) is_write_zeroes); if (err_status != VIRTIO_BLK_S_OK) { virtio_blk_req_complete(req, err_status); - virtio_blk_free_request(req); + g_free(req); } break; } default: virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP); - virtio_blk_free_request(req); + g_free(req); } return 0; } @@ -988,7 +983,7 @@ void virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq) while ((req = virtio_blk_get_request(s, vq))) { if (virtio_blk_handle_request(req, &mrb)) { virtqueue_detach_element(req->vq, &req->elem, 0); - virtio_blk_free_request(req); + g_free(req); break; } } @@ -1038,7 +1033,7 @@ static void virtio_blk_dma_restart_bh(void *opaque) while (req) { next = req->next; virtqueue_detach_element(req->vq, &req->elem, 0); - virtio_blk_free_request(req); + g_free(req); req = next; } break; @@ -1121,7 +1116,7 @@ static void virtio_blk_reset(VirtIODevice *vdev) /* No other threads can access req->vq here */ virtqueue_detach_element(req->vq, &req->elem, 0); - virtio_blk_free_request(req); + g_free(req); } } From patchwork Tue Dec 31 20:22:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854423 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090237wrq; Tue, 31 Dec 2024 12:26:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXOlwkQjyW9kxMhQYdlyGz8pAJOo1OxU3+z+B1FZTP8g9grg2nStUhTvqyfDnXqnBGvn1tvUw==@linaro.org X-Google-Smtp-Source: AGHT+IH/IWFyWQDb27gwZX5i8F6odwXJ2YK11hc5GV74uFDNE7RfjlxwBW4i+MDOgMnnHNnohVDm X-Received: by 2002:ac8:584e:0:b0:467:4fc5:9d72 with SMTP id d75a77b69052e-46a4a976e18mr634285411cf.36.1735676783265; Tue, 31 Dec 2024 12:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676783; cv=none; d=google.com; s=arc-20240605; b=g7DZHn/89sYExMEqK0m3jRY9TLegfm1eglgm3UUxg7qWht6xGEPL7BZPqRSq/x96t9 zKMySmi/8JEPA5tS/R5tFj2pD/OGLtCVtWyg7yUQMBvsOZPoWrvLjCBppSGUIaGBUvDA jaQ2kQ74Bx3PxY2UQkIKeIhgkNaFHxZa6HNhQeYga2PKltgUqr3u9sxT+oV51q2xg28k XcL0QVJuDkZLjXRjmK15ku7J9AA+Q+dimrUt1x4i+GGY0lOJ2bO3mhAEr8dI3xQ1x3+Z SBa5ayipNRKPuLa5sy6Zkq3pblktGuP9eqWiWh2E4DhL/ua/n/J82unU2cU+HvuRMoJm i66Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vts4Pv6wqeOpsJqeP0LsusmybTITtJOTCbWV0U0dSWI=; fh=WFBdicru1D9bSpCyezuvlbmKZ6DpYs++MhPzIQUvDzA=; b=PIjgVaaHKpBBu3KHtr8IsaSBy70+k+yaDFSofobxTJXgRC+HRa091zSkvbn0QXvau1 ORSbllYory2grx5gc887HPRS9TUUjTTfFrrrqCnG9lghEKdacCTHhIo29biC8mCAiWUr 50DrpQhdkaiqln1G2DyDMCCNX0JJx9DLY8Z338qFyeQIR1v62WIBcyd86O1ji05uXpHC ptXQsWo445hmoe/l9L9WP1fNcbRETZ0UgxMg4WzvMwF9RVsl5iKgRdMdxMw63EBxcnXx 0t9UJwPcM5l5d8xsnY0sK3MK2+Q8Fq1aP4tDlVr5uLUqvlUgPma3wpy6p2ON/EwcLsDg ksRw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pW/fiKM8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac4792c1si3419425785a.347.2024.12.31.12.26.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:26:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pW/fiKM8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSin4-0007I3-0P; Tue, 31 Dec 2024 15:24:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimn-0006l5-HS for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:19 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSiml-0000xb-Dq for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:16 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3862ca8e0bbso7979993f8f.0 for ; Tue, 31 Dec 2024 12:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676652; x=1736281452; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vts4Pv6wqeOpsJqeP0LsusmybTITtJOTCbWV0U0dSWI=; b=pW/fiKM8L3ePnn7/lZNCBK57FslT/G/auwNlTEZaUrSh5OdH67zP70S3Ts1b0MsR9s bc+tW/OBvxCbo17K1cRi/jJrDTB6WxRG+Rva5T9Ltp0L1/FQnaUft0RVYG82iUbctK8b epDarUCdML0x31tAAP+wWz0hkRrdG7lesO2avy3psq0DMskVTzCGDB7DX7+v9VcOF1J1 8MSzMkRpqU3rj+a2gKCKg9lsbcrcPbdjFU7xe64ElEfLssCML4Rwzm52WdZvIMmdux6Q GL+BsTGKD2WH5Xctkdvqny2iNF2EGS9i5Z3CP0Q6sdA1ESON2ChbS5o5tFNIjvGYSqvG dviA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676652; x=1736281452; 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=Vts4Pv6wqeOpsJqeP0LsusmybTITtJOTCbWV0U0dSWI=; b=fPb8CUNH0LvmJ1PPCQ67/4GlR7n+Fp9X5kLHoWrV0h49MCqg9nELDYqGp85iqBoB6q 0JQFkxN+NXmx9K1XiV+I2GQp7jGGGZJm8ZKYpiF17n7UagV+4V1wU+pf+genuxhHqV6B byDYTzJ9P9xgbgF5Vaej3+F/iOsJ5UKtQHQ282bOFk4hlDme3MQ8uhdrbFQT1fOPeK+E asroLicQEJ3pEh1qaQTNgQD03EKtn+G5b45b9ArsoNEM7i0wNWKIMpJjI2UBxjlJTURY Y79CEQ6Qz09ulNNCKZaCVgPgmEYRgGyaGGYI23BOodNudrk/gbLLkwBb5z6LLfyN4Ayr PCrQ== X-Gm-Message-State: AOJu0YwgNHSvfFGV8SmVfJ7YwVBxOXlAYpgMhMg14kNzCOwZBb7Yi3Rv GfQZFcIKrx4jclB9Xe5VTKx0G/Rfi8QilAvQD3wBr/rqncJVT4R/nC1bbz6h0SPoLy6MUIZ79Hv 6yec= X-Gm-Gg: ASbGncsRTGpqUGQhUs+7s1ajldTHWM8JxRuy21dZx+VbdTVeF0dw1N7eEfsE7zgrFJv Rjsa4obgL5MPgosGb7hJJVmfzn65vPVL4WWuEveMcVxjiCaSbzDZR3QT6YeLiWcVw6PCLarm0wC PZLzI5xQtSeIF0cHNaXa+kNCqNpxM3uIGB1Lve9OcI31a2+/wvX1GNo0fYRHE2SxPBx0ZKvk2Ac bGQ+8bmO7yPv6CnY3VDVG3tG3jzRhdyQsxjZan6eOrGpA2ABMbHaGKuRtfOLFvfgEFafh3Qo4VW dyPIrHKKuDRVTjejld89+Dc/zZQ9PMw= X-Received: by 2002:a5d:5e09:0:b0:385:e4a7:df09 with SMTP id ffacd0b85a97d-38a223f75fbmr44072192f8f.44.1735676652519; Tue, 31 Dec 2024 12:24:12 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8a636asm34468588f8f.88.2024.12.31.12.24.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:12 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 21/29] hw/usb/hcd-xhci-pci: Move msi/msix properties from NEC to superclass Date: Tue, 31 Dec 2024 21:22:20 +0100 Message-ID: <20241231202228.28819-22-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Phil Dennis-Jordan The NEC XHCI controller exposes the underlying PCI device's msi and msix properties, but the superclass and thus the qemu-xhci device do not. There does not seem to be any obvious reason for this limitation. This change moves these properties to the superclass so they are exposed by both PCI XHCI device variants. Signed-off-by: Phil Dennis-Jordan Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241227121336.25838-3-phil@philjordan.eu> Signed-off-by: Philippe Mathieu-Daudé --- hw/usb/hcd-xhci-nec.c | 2 -- hw/usb/hcd-xhci-pci.c | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/usb/hcd-xhci-nec.c b/hw/usb/hcd-xhci-nec.c index b1df95b52a5..1df518baf59 100644 --- a/hw/usb/hcd-xhci-nec.c +++ b/hw/usb/hcd-xhci-nec.c @@ -37,8 +37,6 @@ struct XHCINecState { }; static const Property nec_xhci_properties[] = { - DEFINE_PROP_ON_OFF_AUTO("msi", XHCIPciState, msi, ON_OFF_AUTO_AUTO), - DEFINE_PROP_ON_OFF_AUTO("msix", XHCIPciState, msix, ON_OFF_AUTO_AUTO), DEFINE_PROP_UINT32("intrs", XHCINecState, intrs, XHCI_MAXINTRS), DEFINE_PROP_UINT32("slots", XHCINecState, slots, XHCI_MAXSLOTS), }; diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c index e110840c7a0..a069b423388 100644 --- a/hw/usb/hcd-xhci-pci.c +++ b/hw/usb/hcd-xhci-pci.c @@ -197,6 +197,11 @@ static void xhci_instance_init(Object *obj) qdev_alias_all_properties(DEVICE(&s->xhci), obj); } +static const Property xhci_pci_properties[] = { + DEFINE_PROP_ON_OFF_AUTO("msi", XHCIPciState, msi, ON_OFF_AUTO_AUTO), + DEFINE_PROP_ON_OFF_AUTO("msix", XHCIPciState, msix, ON_OFF_AUTO_AUTO), +}; + static void xhci_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); @@ -208,6 +213,7 @@ static void xhci_class_init(ObjectClass *klass, void *data) k->realize = usb_xhci_pci_realize; k->exit = usb_xhci_pci_exit; k->class_id = PCI_CLASS_SERIAL_USB; + device_class_set_props(dc, xhci_pci_properties); } static const TypeInfo xhci_pci_info = { From patchwork Tue Dec 31 20:22:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854427 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090363wrq; Tue, 31 Dec 2024 12:26:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWChsb9nhlAE5V3vhKliXRnlOz1jboJWJYDok7Y0Q7biUOvoAyH6dbNHWhrozLDGXiozbCvKg==@linaro.org X-Google-Smtp-Source: AGHT+IFHuozMTEu0kPQN3zd7aJ9877UC+i1FWv6xauiOadE7TDyGpUFhzuOVbT3w2xTeCm/o7XUf X-Received: by 2002:a05:620a:40c1:b0:7b8:6242:18b8 with SMTP id af79cd13be357-7b9ba73f788mr5959491985a.16.1735676809737; Tue, 31 Dec 2024 12:26:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676809; cv=none; d=google.com; s=arc-20240605; b=M9aI+krWN1F4JC4Mt6m9hgfrl++kyvEeyIFFbrKAq0Q0HQZeCyaKdg5tl9KrVjWK9w +MxqthYD23h5y7J4ykNLlWATRT9n0O80daLtvxl25z1y3Za32UxX9D/iH5m0dqq0jR+z 69ULxwPiXTh9HTyx2oimdyJAzqLOqH/MQJq6loMivu0EHR556aNhH9a5RP+1UgwVnmPh E5wUiz7ve6ixi2kGn9A+nzDzb62cIPgBWhD9++83q6hIG+LWUTmmUdAeXTBEn3C+BKow mCo0RNUUkB1YfisYYCmmvqORSfGMqxbG+2mEkmufplgqN3x7YU/qjrIS00cGF5YGkUbd F9+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1OsyYuL+27oK54ZGKawyCinUOguZIMyJUg2PlLlormY=; fh=WFBdicru1D9bSpCyezuvlbmKZ6DpYs++MhPzIQUvDzA=; b=LaFZi3r2XNRQZ99D5K3o1DLu6FVdrOZNClDJvDGZm7dSlZOqhOdflBDpdhSDqwgNRg FLwn9csvGT38pIU2T8EGZpeZR6ftgBJeVuRuYH4VMj9ywh1UYtrVMvQfb79y89waxqMl IIAwDNHLd496UnFX7WxSalV7ynqjXzV6Rw5JinDZck+mtammmvEkLGQqmyutPikv4NAG 9hhGkk0He9sn0IgkUAWLbkDS/Bg+su85Jn+c0NfaWidIfkEnC+Xz3ayDLol7qva09UMl +spGCd5tKXhFQ277AyCEkm5b5F8M6H0XNxuxulCdknxreelte0AOrhre4aNwyuuczRIp sNmg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RGH+ILdZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac2ad91asi3399800285a.39.2024.12.31.12.26.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:26:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RGH+ILdZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSin1-000726-UH; Tue, 31 Dec 2024 15:24:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimr-0006ne-A6 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:22 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimp-0000yM-83 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:20 -0500 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-436326dcb1cso67675895e9.0 for ; Tue, 31 Dec 2024 12:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676657; x=1736281457; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1OsyYuL+27oK54ZGKawyCinUOguZIMyJUg2PlLlormY=; b=RGH+ILdZAKGJBYa2U4p4PmIkbx64MJPwmIHr1sWm5qCUjgFv9Ek+ZrSbvgVxbmZr11 nqsg8zbUrCbvnUzqAneapNyIt+TpjwqCb5aZW42U6J4+ayNCAr4xxed0oHC355txLQf3 BLAv+s2rRnBD+RlVeYVDHdfPpnjDCR574iDcHDWxPF8HSZln31bMSxG0VJM4leEimriS wiRy9ubRFeYV28b0P52GS7Ee20Vw7xTD8hYMXWgtwrovs+h7LtcNYBB9oeq+FLHCoXK7 IjdF/EIFkRLMlIufVKsgUBllu4nPXArgZkd8SjZjN9x8Rd6ZOoK0a+ZgPBdeH+BG7ZHC psfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676657; x=1736281457; 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=1OsyYuL+27oK54ZGKawyCinUOguZIMyJUg2PlLlormY=; b=i3XuDN1NbP5ap+ZV5WCiztn/QnoBAvIBHHpk1dyDZfzjUc9yFj0k20hLznBY85JTlI /0zz1tNEodH69mn9RVdeCmreik0CpZvHsVweXS3XUCqXz1S1fSoJSUM6J6a5gd7+S671 9EwtDLDpEC28VKVRsxY2cXXbfoyUF0jHrNh1I9w57oix05/Eo50LWi2glfbo6chcA4lf SPPZvgaUU4O9IcUxVTuZrEWfh4QAkCeM4BJuksvBPsSd+6m7FzNFLbCet8NgQCTlva3A BJK90GaJnKBitDOqBqLWmpWHc2ro+HgGXmEq75ZMsAmV4ws16/6Kol/+gg8YY9fRCrZl M4cw== X-Gm-Message-State: AOJu0Yw1EkJnJw9jPkj1lNmAoLBNzVdLJX202fEhJOYZd2NT58AcK1N4 uude0pAsZHs1GydmtEj/W3UWx3boQN336giQblqF0oQ7j+QAvzMvjqBxYMi6CntZaBxuC0Dmxr3 DdqI= X-Gm-Gg: ASbGncsd9wb6Lvw9ypVd4RX9mHfxVqta4Qq2IyxsZVA/Lmvrir4a75UBYptnYTVIzGG RyNQxBnBclkg7/bIdnBvNllzCiliGdAR0ZB8f9xGYe3EpL56dputuEPdgpKAjtJZ8nAXybynINz sT0Gt4B9xN5PjW5x78dGKCE6BqFBzgKb1r7TM0MpaD1uKRqOhTdkaHWEDjg11sFBWS9TvQyVLQZ o6kjjl8CJwaHH9wu1Uxa5fh3//jmYhqdvDllPJP6tEDyDrgVlCfqshw0TryT1feaQwawrbRZ8tu hER9jjevk8TwClg68qo1MfNwplGCOyY= X-Received: by 2002:a05:6000:2c3:b0:385:df73:2f3a with SMTP id ffacd0b85a97d-38a221fa8eemr31826814f8f.14.1735676657207; Tue, 31 Dec 2024 12:24:17 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c828a8dsm33868515f8f.2.2024.12.31.12.24.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:16 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 22/29] hw/usb/hcd-xhci: Unimplemented/guest error logging for port MMIO Date: Tue, 31 Dec 2024 21:22:21 +0100 Message-ID: <20241231202228.28819-23-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Phil Dennis-Jordan The XHCI device code uses tracing rather than logging on various code paths that are so far unimplemented. In some cases, these code paths actually indicate faulty guest software. This patch switches instances in the read and write handlers for the port MMIO region to use qemu_log_mask() with LOG_UNIMP or LOG_GUEST_ERROR, as appropriate in each case. Signed-off-by: Phil Dennis-Jordan Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241227121336.25838-5-phil@philjordan.eu> Signed-off-by: Philippe Mathieu-Daudé --- hw/usb/hcd-xhci.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 3719c0f190d..7dc0994c89c 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2810,9 +2810,15 @@ static uint64_t xhci_port_read(void *ptr, hwaddr reg, unsigned size) case 0x08: /* PORTLI */ ret = 0; break; - case 0x0c: /* reserved */ + case 0x0c: /* PORTHLPMC */ + ret = 0; + qemu_log_mask(LOG_UNIMP, "%s: read from port register PORTHLPMC", + __func__); + break; default: - trace_usb_xhci_unimplemented("port read", reg); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: read from port offset 0x%" HWADDR_PRIx, + __func__, reg); ret = 0; } @@ -2881,9 +2887,22 @@ static void xhci_port_write(void *ptr, hwaddr reg, } break; case 0x04: /* PORTPMSC */ + case 0x0c: /* PORTHLPMC */ + qemu_log_mask(LOG_UNIMP, + "%s: write 0x%" PRIx64 + " (%u bytes) to port register at offset 0x%" HWADDR_PRIx, + __func__, val, size, reg); + break; case 0x08: /* PORTLI */ + qemu_log_mask(LOG_GUEST_ERROR, "%s: Write to read-only PORTLI register", + __func__); + break; default: - trace_usb_xhci_unimplemented("port write", reg); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: write 0x%" PRIx64 " (%u bytes) to unknown port " + "register at offset 0x%" HWADDR_PRIx, + __func__, val, size, reg); + break; } } From patchwork Tue Dec 31 20:22:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854415 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089844wrq; Tue, 31 Dec 2024 12:24:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUTq6lPn+XjljZ4lXATQpH2PAOGzDk2xl8441Fb4y9WP3fd6WMD6UDDykXvqcpa6wF+6G2n0A==@linaro.org X-Google-Smtp-Source: AGHT+IEJDUXp/lDj+gxTAaF+YJv0gL1asz4rzv1L9la+BRtrhX73b41z+cvxtWNtdjrqbSPAMZmN X-Received: by 2002:a05:620a:bcb:b0:7b7:142d:53a9 with SMTP id af79cd13be357-7b9ba80ee41mr6673193685a.51.1735676698442; Tue, 31 Dec 2024 12:24:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676698; cv=none; d=google.com; s=arc-20240605; b=JWQbCL5Mif62VQhwKWllymOFdtL8bh3+kTaTq1ekG6jYMwG4DxcZWpKqplYdNWUQNv R2p5wGTVq/9/tOOQDGAOAhZdodYAkSXTxQZaTjqtGupSyKZJVtS426B8x6PmaoiW6n65 1pdqaEaNAeRUgyjgAuUiihrm6YL73yQ5WMSMa5zmKEsY/Ex2sW5XDhlaDkxKUAbcVVqj QZlhJiQdDBA1HHjwvz4jIW0KpEf25By8l/BPF1Ba87KVGf2OrcVkJedZUeXrnZA0MZu3 Z2bni77+seggl1DD9Gb8RUKhWpoFjU6KufgSBw2H4dvMuKOQszs9dQnaUPe7TsrwAzEM vbCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fL6CqFV2XJ8KJ3BBRtLlQRb5c8u0PDVdJeqa3ko7D9c=; fh=tyn3H0ySGZ/3GeTr+63AnxEBt54onnjIpRgEvvPl10Q=; b=KGh63B9+a9rm59BR/C4xHBux47QGzTgyr7vdeoUjaqD2QlECtv4BtbvxzXEa1y4Jdd qK5v1habfRRY0EKPrwkZ8drNEsDlCJFRCSvwMvmbiv+iWesnHqp6lAjdiD1PoRET9Vdg 3GAdws0sLjs63LdKWAjpJkp0aC5WjEqTOdYA7bRBhjzMdaUAem0ebR3VLnkYvALA3aL7 LoOA3oIb5BORv4s0b7xLLmg2Sg+qXgoMhTydn/TCXUSq72NAz3qT2JwKOb1XNm4zAsL4 fMookS0AscqzDyTJZXZCg3qgMdaRbULZThyHFjOcWVKH7K1+MjBcvfK3u/U/WiOyI34T 2zGQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kHNDxQcw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac2ada79si3375789785a.115.2024.12.31.12.24.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:24:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kHNDxQcw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSin3-0007BM-DF; Tue, 31 Dec 2024 15:24:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSimw-0006v4-Tz for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:27 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSimu-0000z1-HU for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:26 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-385d7b4da2bso8735122f8f.1 for ; Tue, 31 Dec 2024 12:24:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676663; x=1736281463; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fL6CqFV2XJ8KJ3BBRtLlQRb5c8u0PDVdJeqa3ko7D9c=; b=kHNDxQcwANRCbNSydJZ8sh/6CXV4szL2+JDzcO4J+a4mUb1KEu9EWB0sjt6cXN9UNe yWidApsKkxYNJEVD3U2JP9hscwsZR+7B5O4YKMmoOSTXkmXaiRH07/IxPMT5bt22+JjO iErW6hbhUzrv9x5Pd9/+1bGmGP7u9zEtqmaNYvZbcFIgiIGT9cL7Tprg9OMld7yKUMC5 J2Rwy1r4XAwQdgNH3EF2rA2nBITfzTzRwJsY29ucrtmKOJMqoY2WqLiugy1Om3hi+K4i sQmplWXHEiWHxrFtoZjs+nrmXpbgmluZui41ywSZM1ogbDt8fkj+EOYTFWxr5IEZoN5l ur0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676663; x=1736281463; 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=fL6CqFV2XJ8KJ3BBRtLlQRb5c8u0PDVdJeqa3ko7D9c=; b=cFYM8glUNMBD5duKhIs6vvgGfuoq8QT3PFJVh6HgQxvvyfu5A9xS+c+cgWoGTNNufS vS0tZunS3QCXvxG27guDLkcEjandvUo5jKrU6PMBnhPij1TFpnVNBjaqsG6UuOzfalke g/ARod0AE/oct2YK8tDHVVtIToBCmXRapezauDck/s2Knv+cbjr8cbMoECFJ3fGKuCNa KP2hqyx0qjD7BRw9IsKuMZGzqY1+6Ur5zyKP0x/HVPYxJ9xSIHOFfH7ReB4rvQHpuFxL lhbkPMvqaQwqaeQ+YllBSTNbyJ54nm0vC12vl03KbpIvP0nZtMUnLL4Sl1QxZ4Jz3fGV iAwQ== X-Gm-Message-State: AOJu0YwW1ZcwkwbqAcgFzduNHifw6a0xLo/DgKY6KYu6lLx2lXrMoVai L3gy0yB0o9f8VbVcf4NDhPY/sSrkgKMJ6ctn3bxlvOu9MygffLnV95Bl2VDJMj9eCBauUwXHekS j+sg= X-Gm-Gg: ASbGncvONJnOGHVsmXI9+/adBnnDMxZ9dcOWqGspJlCtmGGvaag0ohSuSupXWSUnJtT EUwI9x++dpbKMc1wcwXHzZr66qyRZDA7AaWFFVAweyif8zY529AoB1xhLsIqh/UeQ88+aw8630P 4mIrb6G9bOuNmDXfRFR/Kta85Mec3dw39+FPznF40k3PSMykIJueRxdpa3lEtDSZxzrGdcxZJ0X ol8pZkkFugbvqK+ja7/2alrYNrXhnPaV+GGDhj6yfbdBeA371DHSazIblGr5n6mX8CBBhCaPAJr Eo95+rmhi+8yf3Go3wYcuwx86f1Dj5g= X-Received: by 2002:a5d:6d8b:0:b0:385:eb7c:5d0f with SMTP id ffacd0b85a97d-38a221f2fdemr37967117f8f.26.1735676662510; Tue, 31 Dec 2024 12:24:22 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656af6c4esm432602465e9.4.2024.12.31.12.24.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:22 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 23/29] ui & main loop: Redesign of system-specific main thread event handling Date: Tue, 31 Dec 2024 21:22:22 +0100 Message-ID: <20241231202228.28819-24-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Phil Dennis-Jordan macOS's Cocoa event handling must be done on the initial (main) thread of the process. Furthermore, if library or application code uses libdispatch, the main dispatch queue must be handling events on the main thread as well. So far, this has affected Qemu in both the Cocoa and SDL UIs, although in different ways: the Cocoa UI replaces the default qemu_main function with one that spins Qemu's internal main event loop off onto a background thread. SDL (which uses Cocoa internally) on the other hand uses a polling approach within Qemu's main event loop. Events are polled during the SDL UI's dpy_refresh callback, which happens to run on the main thread by default. As UIs are mutually exclusive, this works OK as long as nothing else needs platform-native event handling. In the next patch, a new device is introduced based on the ParavirtualizedGraphics.framework in macOS. This uses libdispatch internally, and only works when events are being handled on the main runloop. With the current system, it works when using either the Cocoa or the SDL UI. However, it does not when running headless. Moreover, any attempt to install a similar scheme to the Cocoa UI's main thread replacement fails when combined with the SDL UI. This change tidies up main thread management to be more flexible. * The qemu_main global function pointer is a custom function for the main thread, and it may now be NULL. When it is, the main thread runs the main Qemu loop. This represents the traditional setup. * When non-null, spawning the main Qemu event loop on a separate thread is now done centrally rather than inside the Cocoa UI code. * For most platforms, qemu_main is indeed NULL by default, but on Darwin, it defaults to a function that runs the CFRunLoop. * The Cocoa UI sets qemu_main to a function which runs the NSApplication event handling runloop, as is usual for a Cocoa app. * The SDL UI overrides the qemu_main function to NULL, thus specifying that Qemu's main loop must run on the main thread. * The GTK UI also overrides the qemu_main function to NULL. * For other UIs, or in the absence of UIs, the platform's default behaviour is followed. This means that on macOS, the platform's runloop events are always handled, regardless of chosen UI. The new PV graphics device will thus work in all configurations. There is no functional change on other operating systems. Implementing this via a global function pointer variable is a bit ugly, but it's probably worth investigating the existing UI thread rule violations in the SDL (e.g. #2537) and GTK+ back-ends. Fixing those issues might precipitate requirements similar but not identical to those of the Cocoa UI; hopefully we'll see some kind of pattern emerge, which can then be used as a basis for an overhaul. (In fact, it may turn out to be simplest to split the UI/native platform event thread from the QEMU main event loop on all platforms, with any UI or even none at all.) Signed-off-by: Phil Dennis-Jordan Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Message-ID: <20241223221645.29911-2-phil@philjordan.eu> [PMD: Declare 'qemu_main' symbol in tests/qtest/fuzz/fuzz.c, add missing g_assert_not_reached() call in main()] Signed-off-by: Philippe Mathieu-Daudé --- include/qemu-main.h | 14 ++++++++++- system/main.c | 38 ++++++++++++++++++++++++++--- tests/qtest/fuzz/fuzz.c | 1 + ui/gtk.c | 4 +++ ui/sdl2.c | 4 +++ ui/cocoa.m | 54 ++++++++++------------------------------- 6 files changed, 69 insertions(+), 46 deletions(-) diff --git a/include/qemu-main.h b/include/qemu-main.h index 940960a7dbc..2ee83bedff3 100644 --- a/include/qemu-main.h +++ b/include/qemu-main.h @@ -5,7 +5,19 @@ #ifndef QEMU_MAIN_H #define QEMU_MAIN_H -int qemu_default_main(void); +/* + * The function to run on the main (initial) thread of the process. + * NULL means QEMU's main event loop. + * When non-NULL, QEMU's main event loop will run on a purposely created + * thread, after which the provided function pointer will be invoked on + * the initial thread. + * This is useful on platforms which treat the main thread as special + * (macOS/Darwin) and/or require all UI API calls to occur from the main + * thread. Those platforms can initialise it to a specific function, + * while UI implementations may reset it to NULL during their init if they + * will handle system and UI events on the main thread via QEMU's own main + * event loop. + */ extern int (*qemu_main)(void); #endif /* QEMU_MAIN_H */ diff --git a/system/main.c b/system/main.c index 4923520741c..ecb12fd397c 100644 --- a/system/main.c +++ b/system/main.c @@ -24,26 +24,56 @@ #include "qemu/osdep.h" #include "qemu-main.h" +#include "qemu/main-loop.h" #include "system/system.h" #ifdef CONFIG_SDL +/* + * SDL insists on wrapping the main() function with its own implementation on + * some platforms; it does so via a macro that renames our main function, so + * must be #included here even with no SDL code called from this file. + */ #include #endif -int qemu_default_main(void) +#ifdef CONFIG_DARWIN +#include +#endif + +static void *qemu_default_main(void *opaque) { int status; + bql_lock(); status = qemu_main_loop(); qemu_cleanup(status); + bql_unlock(); - return status; + exit(status); } -int (*qemu_main)(void) = qemu_default_main; +int (*qemu_main)(void); + +#ifdef CONFIG_DARWIN +static int os_darwin_cfrunloop_main(void) +{ + CFRunLoopRun(); + g_assert_not_reached(); +} +int (*qemu_main)(void) = os_darwin_cfrunloop_main; +#endif int main(int argc, char **argv) { qemu_init(argc, argv); - return qemu_main(); + bql_unlock(); + if (qemu_main) { + QemuThread main_loop_thread; + qemu_thread_create(&main_loop_thread, "qemu_main", + qemu_default_main, NULL, QEMU_THREAD_DETACHED); + return qemu_main(); + } else { + qemu_default_main(NULL); + g_assert_not_reached(); + } } diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 8274000bd55..ca248a51a6c 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -41,6 +41,7 @@ static FuzzTargetList *fuzz_target_list; static FuzzTarget *fuzz_target; static QTestState *fuzz_qts; +int (*qemu_main)(void); void flush_events(QTestState *s) diff --git a/ui/gtk.c b/ui/gtk.c index 0d38c070e40..c0237431489 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -38,6 +38,7 @@ #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" +#include "qemu-main.h" #include "ui/console.h" #include "ui/gtk.h" @@ -2485,6 +2486,9 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) #ifdef CONFIG_GTK_CLIPBOARD gd_clipboard_init(s); #endif /* CONFIG_GTK_CLIPBOARD */ + + /* GTK's event polling must happen on the main thread. */ + qemu_main = NULL; } static void early_gtk_display_init(DisplayOptions *opts) diff --git a/ui/sdl2.c b/ui/sdl2.c index 1fb72f67a6f..445eb1dd9f9 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -34,6 +34,7 @@ #include "system/system.h" #include "ui/win32-kbd-hook.h" #include "qemu/log.h" +#include "qemu-main.h" static int sdl2_num_outputs; static struct sdl2_console *sdl2_console; @@ -965,6 +966,9 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o) } atexit(sdl_cleanup); + + /* SDL's event polling (in dpy_refresh) must happen on the main thread. */ + qemu_main = NULL; } static QemuDisplay qemu_display_sdl2 = { diff --git a/ui/cocoa.m b/ui/cocoa.m index 3a88535374d..23b7a736d70 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -73,6 +73,8 @@ int height; } QEMUScreen; +@class QemuCocoaPasteboardTypeOwner; + static void cocoa_update(DisplayChangeListener *dcl, int x, int y, int w, int h); @@ -107,6 +109,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, static NSInteger cbchangecount = -1; static QemuClipboardInfo *cbinfo; static QemuEvent cbevent; +static QemuCocoaPasteboardTypeOwner *cbowner; // Utility functions to run specified code block with the BQL held typedef void (^CodeBlock)(void); @@ -1326,8 +1329,10 @@ - (void) dealloc { COCOA_DEBUG("QemuCocoaAppController: dealloc\n"); - if (cocoaView) - [cocoaView release]; + [cocoaView release]; + [cbowner release]; + cbowner = nil; + [super dealloc]; } @@ -1943,8 +1948,6 @@ - (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSPasteboardType)t @end -static QemuCocoaPasteboardTypeOwner *cbowner; - static void cocoa_clipboard_notify(Notifier *notifier, void *data); static void cocoa_clipboard_request(QemuClipboardInfo *info, QemuClipboardType type); @@ -2007,43 +2010,8 @@ static void cocoa_clipboard_request(QemuClipboardInfo *info, } } -/* - * The startup process for the OSX/Cocoa UI is complicated, because - * OSX insists that the UI runs on the initial main thread, and so we - * need to start a second thread which runs the qemu_default_main(): - * in main(): - * in cocoa_display_init(): - * assign cocoa_main to qemu_main - * create application, menus, etc - * in cocoa_main(): - * create qemu-main thread - * enter OSX run loop - */ - -static void *call_qemu_main(void *opaque) -{ - int status; - - COCOA_DEBUG("Second thread: calling qemu_default_main()\n"); - bql_lock(); - status = qemu_default_main(); - bql_unlock(); - COCOA_DEBUG("Second thread: qemu_default_main() returned, exiting\n"); - [cbowner release]; - exit(status); -} - static int cocoa_main(void) { - QemuThread thread; - - COCOA_DEBUG("Entered %s()\n", __func__); - - bql_unlock(); - qemu_thread_create(&thread, "qemu_main", call_qemu_main, - NULL, QEMU_THREAD_DETACHED); - - // Start the main event loop COCOA_DEBUG("Main thread: entering OSX run loop\n"); [NSApp run]; COCOA_DEBUG("Main thread: left OSX run loop, which should never happen\n"); @@ -2125,8 +2093,6 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n"); - qemu_main = cocoa_main; - // Pull this console process up to being a fully-fledged graphical // app with a menubar and Dock icon ProcessSerialNumber psn = { 0, kCurrentProcess }; @@ -2190,6 +2156,12 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) qemu_clipboard_peer_register(&cbpeer); [pool release]; + + /* + * The Cocoa UI will run the NSApplication runloop on the main thread + * rather than the default Core Foundation one. + */ + qemu_main = cocoa_main; } static QemuDisplay qemu_display_cocoa = { From patchwork Tue Dec 31 20:22:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854419 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090107wrq; Tue, 31 Dec 2024 12:25:56 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVXd98nvQItMMAQ2IvjpePPT7PEKcTIVlBmBySk6Bi4ndOOcSrLA6oRJpYPkNVQ6V/bL031TQ==@linaro.org X-Google-Smtp-Source: AGHT+IHXdHmfRYnS9y6wb16RAMo+DIThVWHYTfYTSu41UOurBZQU0C9I5nW/kPxLEmn+9YqlHx4C X-Received: by 2002:a05:620a:3181:b0:7b6:d643:599c with SMTP id af79cd13be357-7b9ba7f68b5mr6187193485a.43.1735676755981; Tue, 31 Dec 2024 12:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676755; cv=none; d=google.com; s=arc-20240605; b=k1TRxcOLU222x7RzvV1e2bPaq1QlbbvkmW+EW16DqcqZdR0qL/dXg0n7ZdHpZf9INt 5QYIszRmapu0nrwULL1wWV3439CHMtlXXjK4bzz85hgHKCYqwMfomo8cpwxPr0wPmgIU bPQHivXSguVguKkmhKDHlbD6no074vTXayBGsiMyJ2Dj68GsK05UPwSX1rw4/Pme1uvE d9Uj5iKk26b2ytTaP6CIoG6WkA/BMvImmnwHGWiTFxrZ3Bc4gEv+yEN+B4FVaaNx9lao HbXG7eSlPDaybvbgQ5YQkEOOy8G5xquXfg42KHu/BRI4Ww5snVNtYuUC9TKrJmW/dvIh UBcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3RQ1G/rAkTnuPXVyhiMXuuMGNYs/qvCZ6JH4K+A9qpI=; fh=Bk2K7G0IqtIXtNQG4biul3AqTcMJsZBCf1IAuncjxz4=; b=LOwZjUw371jo98RssDDmqr/mDxZ/Z0RHYM/i1sSdeX+9bGyDH+InAdhvdRjw1k1wQH Pf5xNE1csyQiolV6snpBdO74709PsI+U21x4LkmLTH40xI8hs/7Sq8SIVOB06CEjir/s vTHKcnNVmR2TbcmQ9I355ZEIy2pHb3/dyVLf28l1+AOrvG7Q2yv2LaYHMKNN5kLGzsuL DE6vIa4dkgm0DIDkY8G3IwN0ghOzCg+nokY917JEZJ1s2Z+tnLkXKCGOH9tXeQe0sccq gWdJJ3Hl4JByK7Jt/HIRtj22j+AnsqEtVaHtcYouEMawCzAtcc/jEpjM6eCmCDE0ui6t wRhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bOWuEAdZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac478ea1si3025355785a.254.2024.12.31.12.25.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:25:55 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bOWuEAdZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSin8-0007p5-0p; Tue, 31 Dec 2024 15:24:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSin5-0007Yd-PO for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:35 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSin1-0000zx-6f for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:35 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4362f61757fso102611055e9.2 for ; Tue, 31 Dec 2024 12:24:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676669; x=1736281469; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3RQ1G/rAkTnuPXVyhiMXuuMGNYs/qvCZ6JH4K+A9qpI=; b=bOWuEAdZ4gZOhkterRRs2bNuyE3PMpL7TeE99ANsuOC9NpwtahOTCv7B1vsHnwdga0 b8+q3S2X4bvaM5BZSGOd2fAehgrEY3Hvz7NTtyhUM2HxyqRgPcblv6YeTu/Ognmh74Oa lR/+jakVh+nVemrijlco8VCZCnbGghDLrT9Xe7H7GV5YIkIwmnkD4C8HVEkSWAIhnA1e eiL6Df/37t9V6Hl5KZnu+3iGnpbi8irhd+y5hZew7/50IW92fh8V1jwGLgkEimYdVYXg aG6OItWDSDr4ATjutOoFGCr60Si3mhjeLUhEkP0VOJ8jcdpHI8PFUeDDOpM9edpU1ycH IQCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676669; x=1736281469; 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=3RQ1G/rAkTnuPXVyhiMXuuMGNYs/qvCZ6JH4K+A9qpI=; b=xE4PcNET8DmBzhRHA+ScAALMo0E+D1iFKFVHAD1dmuDqo1q4Gvz2jNnSDilDwpAWG6 /ZHvKCpU6i1SRaY658CyQvkfLLhYLxJ0GhCFT5aWJr0f4wwUuk/+vKetbyLTvyzwSSRK kPBnx1gs4o2AmTqsOU2UC50NsrWz/Ja1/evoIHcypWtHwyZ6i4T9CaNQR7PKXHJytQFA wzA0HgPKCGY8yfZo8N+AJz6T+nVgk9Qf3dI67C9zSkr3xWk8rVYlaWFYNr0LvhkE0lYw HFpyeX+RE7/Tm/78W+xXZW1CHMTK7LiTM0CvX9r4cPiXQoYjhkQTFR/ALw8h8gta3kSf UyzA== X-Gm-Message-State: AOJu0YzV8VPeLBtrd6FASa25rclbTxLXftWnLtNLTLv7oMKiJ9T/bbYZ ubxP1fSLk/eR3yU0TBNjojL25kVU0S57IEhBku0FBEWPHYHs1QlAfnhM3KLne3bMdmeOQIkMpgb olAs= X-Gm-Gg: ASbGncs6oHIZJEWEYscSy+Z7Qd5No/2sPQC9NCms1UcMctcfn/fZtZ7Fx6XPBG9ihqT 5QGcGWFjotzndbYUnbKaR6IUt5VYMY8KZz4rm8tkpNMvkOqj2DxbdXkSOS0sTu/sUQRGuNt8GY2 aaIKr2aBxYLnh/t5GVs/pSrRTvg9STC8iC0yLdxH6FaieqekVO87Q7djqh5FHh70awoLoe7Pfej OA4fT9w6FtP0qOeS9jmloDVI0bCcYUH0KomEjwSc0/v9IA4IIurYa/Z+HfSetiCqA4lLHvqfR/d RwWt2erbizmz4fyyWwKpNovcPKRpXMM= X-Received: by 2002:a05:600c:3b9a:b0:42c:bb10:7292 with SMTP id 5b1f17b1804b1-436685470f8mr268048835e9.1.1735676668961; Tue, 31 Dec 2024 12:24:28 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366112e780sm397014445e9.0.2024.12.31.12.24.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Alexander Graf , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 24/29] hw/display/apple-gfx: Introduce ParavirtualizedGraphics.Framework support Date: Tue, 31 Dec 2024 21:22:23 +0100 Message-ID: <20241231202228.28819-25-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Phil Dennis-Jordan MacOS provides a framework (library) that allows any vmm to implement a paravirtualized 3d graphics passthrough to the host metal stack called ParavirtualizedGraphics.Framework (PVG). The library abstracts away almost every aspect of the paravirtualized device model and only provides and receives callbacks on MMIO access as well as to share memory address space between the VM and PVG. This patch implements a QEMU device that drives PVG for the VMApple variant of it. Signed-off-by: Alexander Graf Co-authored-by: Alexander Graf Subsequent changes: * Cherry-pick/rebase conflict fixes, API use updates. * Moved from hw/vmapple/ (useful outside that machine type) * Overhaul of threading model, many thread safety improvements. * Asynchronous rendering. * Memory and object lifetime fixes. * Refactoring to split generic and (vmapple) MMIO variant specific code. Implementation wise, most of the complexity lies in the differing threading models of ParavirtualizedGraphics.framework, which uses libdispatch and internal locks, versus QEMU, which heavily uses the BQL, especially during memory-mapped device I/O. Great care has therefore been taken to prevent deadlocks by never calling into PVG methods while holding the BQL, and similarly never acquiring the BQL in a callback from PVG. Different strategies have been used (libdispatch, blocking and non-blocking BHs, RCU, etc.) depending on the specific requirements at each framework entry and exit point. Signed-off-by: Phil Dennis-Jordan Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Message-ID: <20241223221645.29911-3-phil@philjordan.eu> [PMD: Re-ordered imported headers, style fixups] Signed-off-by: Philippe Mathieu-Daudé --- meson.build | 4 + hw/display/apple-gfx.h | 63 +++ hw/display/Kconfig | 9 + hw/display/apple-gfx-mmio.m | 278 +++++++++++++ hw/display/apple-gfx.m | 783 ++++++++++++++++++++++++++++++++++++ hw/display/meson.build | 6 + hw/display/trace-events | 28 ++ 7 files changed, 1171 insertions(+) create mode 100644 hw/display/apple-gfx.h create mode 100644 hw/display/apple-gfx-mmio.m create mode 100644 hw/display/apple-gfx.m diff --git a/meson.build b/meson.build index f4109cd3cae..e62251c7ca3 100644 --- a/meson.build +++ b/meson.build @@ -817,6 +817,8 @@ socket = [] version_res = [] coref = [] iokit = [] +pvg = not_found +metal = [] emulator_link_args = [] midl = not_found widl = not_found @@ -838,6 +840,8 @@ elif host_os == 'darwin' coref = dependency('appleframeworks', modules: 'CoreFoundation') iokit = dependency('appleframeworks', modules: 'IOKit', required: false) host_dsosuf = '.dylib' + pvg = dependency('appleframeworks', modules: 'ParavirtualizedGraphics') + metal = dependency('appleframeworks', modules: 'Metal') elif host_os == 'sunos' socket = [cc.find_library('socket'), cc.find_library('nsl'), diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h new file mode 100644 index 00000000000..4cd4163f223 --- /dev/null +++ b/hw/display/apple-gfx.h @@ -0,0 +1,63 @@ +/* + * Data structures and functions shared between variants of the macOS + * ParavirtualizedGraphics.framework based apple-gfx display adapter. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_APPLE_GFX_H +#define QEMU_APPLE_GFX_H + +#include "qemu/queue.h" +#include "exec/memory.h" +#include "hw/qdev-properties.h" +#include "ui/surface.h" + +#define TYPE_APPLE_GFX_MMIO "apple-gfx-mmio" + +@class PGDeviceDescriptor; +@protocol PGDevice; +@protocol PGDisplay; +@protocol MTLDevice; +@protocol MTLTexture; +@protocol MTLCommandQueue; + +typedef QTAILQ_HEAD(, PGTask_s) PGTaskList; + +typedef struct AppleGFXState { + /* Initialised on init/realize() */ + MemoryRegion iomem_gfx; + id pgdev; + id pgdisp; + QemuConsole *con; + id mtl; + id mtl_queue; + + /* List `tasks` is protected by task_mutex */ + QemuMutex task_mutex; + PGTaskList tasks; + + /* Mutable state (BQL protected) */ + QEMUCursor *cursor; + DisplaySurface *surface; + id texture; + int8_t pending_frames; /* # guest frames in the rendering pipeline */ + bool gfx_update_requested; /* QEMU display system wants a new frame */ + bool new_frame_ready; /* Guest has rendered a frame, ready to be used */ + bool using_managed_texture_storage; + uint32_t rendering_frame_width; + uint32_t rendering_frame_height; + + /* Mutable state (atomic) */ + bool cursor_show; +} AppleGFXState; + +void apple_gfx_common_init(Object *obj, AppleGFXState *s, const char* obj_name); +bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, + PGDeviceDescriptor *desc, Error **errp); +void *apple_gfx_host_ptr_for_gpa_range(uint64_t guest_physical, + uint64_t length, bool read_only, + MemoryRegion **mapping_in_region); + +#endif + diff --git a/hw/display/Kconfig b/hw/display/Kconfig index 2250c740078..6a9b7b19ada 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -140,3 +140,12 @@ config XLNX_DISPLAYPORT config DM163 bool + +config MAC_PVG + bool + default y + +config MAC_PVG_MMIO + bool + depends on MAC_PVG && AARCH64 + diff --git a/hw/display/apple-gfx-mmio.m b/hw/display/apple-gfx-mmio.m new file mode 100644 index 00000000000..5a489d2d44f --- /dev/null +++ b/hw/display/apple-gfx-mmio.m @@ -0,0 +1,278 @@ +/* + * QEMU Apple ParavirtualizedGraphics.framework device, MMIO (arm64) variant + * + * Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * ParavirtualizedGraphics.framework is a set of libraries that macOS provides + * which implements 3d graphics passthrough to the host as well as a + * proprietary guest communication channel to drive it. This device model + * implements support to drive that library from within QEMU as an MMIO-based + * system device for macOS on arm64 VMs. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "block/aio-wait.h" +#include "hw/sysbus.h" +#include "hw/irq.h" +#include "apple-gfx.h" +#include "trace.h" + +#import + +OBJECT_DECLARE_SIMPLE_TYPE(AppleGFXMMIOState, APPLE_GFX_MMIO) + +/* + * ParavirtualizedGraphics.Framework only ships header files for the PCI + * variant which does not include IOSFC descriptors and host devices. We add + * their definitions here so that we can also work with the ARM version. + */ +typedef bool(^IOSFCRaiseInterrupt)(uint32_t vector); +typedef bool(^IOSFCUnmapMemory)(void *, void *, void *, void *, void *, void *); +typedef bool(^IOSFCMapMemory)(uint64_t phys, uint64_t len, bool ro, void **va, + void *, void *); + +@interface PGDeviceDescriptor (IOSurfaceMapper) +@property (readwrite, nonatomic) bool usingIOSurfaceMapper; +@end + +@interface PGIOSurfaceHostDeviceDescriptor : NSObject +-(PGIOSurfaceHostDeviceDescriptor *)init; +@property (readwrite, nonatomic, copy, nullable) IOSFCMapMemory mapMemory; +@property (readwrite, nonatomic, copy, nullable) IOSFCUnmapMemory unmapMemory; +@property (readwrite, nonatomic, copy, nullable) IOSFCRaiseInterrupt raiseInterrupt; +@end + +@interface PGIOSurfaceHostDevice : NSObject +-(instancetype)initWithDescriptor:(PGIOSurfaceHostDeviceDescriptor *)desc; +-(uint32_t)mmioReadAtOffset:(size_t)offset; +-(void)mmioWriteAtOffset:(size_t)offset value:(uint32_t)value; +@end + +struct AppleGFXMapSurfaceMemoryJob; +struct AppleGFXMMIOState { + SysBusDevice parent_obj; + + AppleGFXState common; + + qemu_irq irq_gfx; + qemu_irq irq_iosfc; + MemoryRegion iomem_iosfc; + PGIOSurfaceHostDevice *pgiosfc; +}; + +typedef struct AppleGFXMMIOJob { + AppleGFXMMIOState *state; + uint64_t offset; + uint64_t value; + bool completed; +} AppleGFXMMIOJob; + +static void iosfc_do_read(void *opaque) +{ + AppleGFXMMIOJob *job = opaque; + job->value = [job->state->pgiosfc mmioReadAtOffset:job->offset]; + qatomic_set(&job->completed, true); + aio_wait_kick(); +} + +static uint64_t iosfc_read(void *opaque, hwaddr offset, unsigned size) +{ + AppleGFXMMIOJob job = { + .state = opaque, + .offset = offset, + .completed = false, + }; + dispatch_queue_t queue = + dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + + dispatch_async_f(queue, &job, iosfc_do_read); + AIO_WAIT_WHILE(NULL, !qatomic_read(&job.completed)); + + trace_apple_gfx_mmio_iosfc_read(offset, job.value); + return job.value; +} + +static void iosfc_do_write(void *opaque) +{ + AppleGFXMMIOJob *job = opaque; + [job->state->pgiosfc mmioWriteAtOffset:job->offset value:job->value]; + qatomic_set(&job->completed, true); + aio_wait_kick(); +} + +static void iosfc_write(void *opaque, hwaddr offset, uint64_t val, + unsigned size) +{ + AppleGFXMMIOJob job = { + .state = opaque, + .offset = offset, + .value = val, + .completed = false, + }; + dispatch_queue_t queue = + dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + + dispatch_async_f(queue, &job, iosfc_do_write); + AIO_WAIT_WHILE(NULL, !qatomic_read(&job.completed)); + + trace_apple_gfx_mmio_iosfc_write(offset, val); +} + +static const MemoryRegionOps apple_iosfc_ops = { + .read = iosfc_read, + .write = iosfc_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 8, + }, + .impl = { + .min_access_size = 4, + .max_access_size = 8, + }, +}; + +static void raise_irq_bh(void *opaque) +{ + qemu_irq *irq = opaque; + + qemu_irq_pulse(*irq); +} + +static void *apple_gfx_mmio_map_surface_memory(uint64_t guest_physical_address, + uint64_t length, bool read_only) +{ + void *mem; + MemoryRegion *region = NULL; + + RCU_READ_LOCK_GUARD(); + mem = apple_gfx_host_ptr_for_gpa_range(guest_physical_address, + length, read_only, ®ion); + if (mem) { + memory_region_ref(region); + } + return mem; +} + +static bool apple_gfx_mmio_unmap_surface_memory(void *ptr) +{ + MemoryRegion *region; + ram_addr_t offset = 0; + + RCU_READ_LOCK_GUARD(); + region = memory_region_from_host(ptr, &offset); + if (!region) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: memory at %p to be unmapped not found.\n", + __func__, ptr); + return false; + } + + trace_apple_gfx_iosfc_unmap_memory_region(ptr, region); + memory_region_unref(region); + return true; +} + +static PGIOSurfaceHostDevice *apple_gfx_prepare_iosurface_host_device( + AppleGFXMMIOState *s) +{ + PGIOSurfaceHostDeviceDescriptor *iosfc_desc = + [PGIOSurfaceHostDeviceDescriptor new]; + PGIOSurfaceHostDevice *iosfc_host_dev; + + iosfc_desc.mapMemory = + ^bool(uint64_t phys, uint64_t len, bool ro, void **va, void *e, void *f) { + *va = apple_gfx_mmio_map_surface_memory(phys, len, ro); + + trace_apple_gfx_iosfc_map_memory(phys, len, ro, va, e, f, *va); + + return *va != NULL; + }; + + iosfc_desc.unmapMemory = + ^bool(void *va, void *b, void *c, void *d, void *e, void *f) { + return apple_gfx_mmio_unmap_surface_memory(va); + }; + + iosfc_desc.raiseInterrupt = ^bool(uint32_t vector) { + trace_apple_gfx_iosfc_raise_irq(vector); + aio_bh_schedule_oneshot(qemu_get_aio_context(), + raise_irq_bh, &s->irq_iosfc); + return true; + }; + + iosfc_host_dev = + [[PGIOSurfaceHostDevice alloc] initWithDescriptor:iosfc_desc]; + [iosfc_desc release]; + return iosfc_host_dev; +} + +static void apple_gfx_mmio_realize(DeviceState *dev, Error **errp) +{ + @autoreleasepool { + AppleGFXMMIOState *s = APPLE_GFX_MMIO(dev); + PGDeviceDescriptor *desc = [PGDeviceDescriptor new]; + + desc.raiseInterrupt = ^(uint32_t vector) { + trace_apple_gfx_raise_irq(vector); + aio_bh_schedule_oneshot(qemu_get_aio_context(), + raise_irq_bh, &s->irq_gfx); + }; + + desc.usingIOSurfaceMapper = true; + s->pgiosfc = apple_gfx_prepare_iosurface_host_device(s); + + if (!apple_gfx_common_realize(&s->common, dev, desc, errp)) { + [s->pgiosfc release]; + s->pgiosfc = nil; + } + + [desc release]; + desc = nil; + } +} + +static void apple_gfx_mmio_init(Object *obj) +{ + AppleGFXMMIOState *s = APPLE_GFX_MMIO(obj); + + apple_gfx_common_init(obj, &s->common, TYPE_APPLE_GFX_MMIO); + + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->common.iomem_gfx); + memory_region_init_io(&s->iomem_iosfc, obj, &apple_iosfc_ops, s, + TYPE_APPLE_GFX_MMIO, 0x10000); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem_iosfc); + sysbus_init_irq(SYS_BUS_DEVICE(s), &s->irq_gfx); + sysbus_init_irq(SYS_BUS_DEVICE(s), &s->irq_iosfc); +} + +static void apple_gfx_mmio_reset(Object *obj, ResetType type) +{ + AppleGFXMMIOState *s = APPLE_GFX_MMIO(obj); + [s->common.pgdev reset]; +} + + +static void apple_gfx_mmio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); + + rc->phases.hold = apple_gfx_mmio_reset; + dc->hotpluggable = false; + dc->realize = apple_gfx_mmio_realize; +} + +static const TypeInfo apple_gfx_mmio_types[] = { + { + .name = TYPE_APPLE_GFX_MMIO, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(AppleGFXMMIOState), + .class_init = apple_gfx_mmio_class_init, + .instance_init = apple_gfx_mmio_init, + } +}; +DEFINE_TYPES(apple_gfx_mmio_types) diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m new file mode 100644 index 00000000000..59299e339d4 --- /dev/null +++ b/hw/display/apple-gfx.m @@ -0,0 +1,783 @@ +/* + * QEMU Apple ParavirtualizedGraphics.framework device + * + * Copyright © 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * ParavirtualizedGraphics.framework is a set of libraries that macOS provides + * which implements 3d graphics passthrough to the host as well as a + * proprietary guest communication channel to drive it. This device model + * implements support to drive that library from within QEMU. + */ + +#include "qemu/osdep.h" +#include "qemu/lockable.h" +#include "qemu/cutils.h" +#include "qemu/log.h" +#include "qapi/visitor.h" +#include "qapi/error.h" +#include "block/aio-wait.h" +#include "exec/address-spaces.h" +#include "system/dma.h" +#include "migration/blocker.h" +#include "ui/console.h" +#include "apple-gfx.h" +#include "trace.h" + +#include +#include +#include + +#import + +static const PGDisplayCoord_t apple_gfx_modes[] = { + { .x = 1440, .y = 1080 }, + { .x = 1280, .y = 1024 }, +}; + +static Error *apple_gfx_mig_blocker; +static uint32_t next_pgdisplay_serial_num = 1; + +static dispatch_queue_t get_background_queue(void) +{ + return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); +} + +/* ------ PGTask and task operations: new/destroy/map/unmap ------ */ + +/* + * This implements the type declared in + * which is opaque from the framework's point of view. It is used in callbacks + * in the form of its typedef PGTask_t, which also already exists in the + * framework headers. + * + * A "task" in PVG terminology represents a host-virtual contiguous address + * range which is reserved in a large chunk on task creation. The mapMemory + * callback then requests ranges of guest system memory (identified by their + * GPA) to be mapped into subranges of this reserved address space. + * This type of operation isn't well-supported by QEMU's memory subsystem, + * but it is fortunately trivial to achieve with Darwin's mach_vm_remap() call, + * which allows us to refer to the same backing memory via multiple virtual + * address ranges. The Mach VM APIs are therefore used throughout for managing + * task memory. + */ +struct PGTask_s { + QTAILQ_ENTRY(PGTask_s) node; + AppleGFXState *s; + mach_vm_address_t address; + uint64_t len; + /* + * All unique MemoryRegions for which a mapping has been created in in this + * task, and on which we have thus called memory_region_ref(). There are + * usually very few regions of system RAM in total, so we expect this array + * to be very short. Therefore, no need for sorting or fancy search + * algorithms, linear search will do. + * Protected by AppleGFXState's task_mutex. + */ + GPtrArray *mapped_regions; +}; + +static PGTask_t *apple_gfx_new_task(AppleGFXState *s, uint64_t len) +{ + mach_vm_address_t task_mem; + PGTask_t *task; + kern_return_t r; + + r = mach_vm_allocate(mach_task_self(), &task_mem, len, VM_FLAGS_ANYWHERE); + if (r != KERN_SUCCESS) { + return NULL; + } + + task = g_new0(PGTask_t, 1); + task->s = s; + task->address = task_mem; + task->len = len; + task->mapped_regions = g_ptr_array_sized_new(2 /* Usually enough */); + + QEMU_LOCK_GUARD(&s->task_mutex); + QTAILQ_INSERT_TAIL(&s->tasks, task, node); + + return task; +} + +static void apple_gfx_destroy_task(AppleGFXState *s, PGTask_t *task) +{ + GPtrArray *regions = task->mapped_regions; + MemoryRegion *region; + size_t i; + + for (i = 0; i < regions->len; ++i) { + region = g_ptr_array_index(regions, i); + memory_region_unref(region); + } + g_ptr_array_unref(regions); + + mach_vm_deallocate(mach_task_self(), task->address, task->len); + + QEMU_LOCK_GUARD(&s->task_mutex); + QTAILQ_REMOVE(&s->tasks, task, node); + g_free(task); +} + +void *apple_gfx_host_ptr_for_gpa_range(uint64_t guest_physical, + uint64_t length, bool read_only, + MemoryRegion **mapping_in_region) +{ + MemoryRegion *ram_region; + char *host_ptr; + hwaddr ram_region_offset = 0; + hwaddr ram_region_length = length; + + ram_region = address_space_translate(&address_space_memory, + guest_physical, + &ram_region_offset, + &ram_region_length, !read_only, + MEMTXATTRS_UNSPECIFIED); + + if (!ram_region || ram_region_length < length || + !memory_access_is_direct(ram_region, !read_only)) { + return NULL; + } + + host_ptr = memory_region_get_ram_ptr(ram_region); + if (!host_ptr) { + return NULL; + } + host_ptr += ram_region_offset; + *mapping_in_region = ram_region; + return host_ptr; +} + +static bool apple_gfx_task_map_memory(AppleGFXState *s, PGTask_t *task, + uint64_t virtual_offset, + PGPhysicalMemoryRange_t *ranges, + uint32_t range_count, bool read_only) +{ + kern_return_t r; + void *source_ptr; + mach_vm_address_t target; + vm_prot_t cur_protection, max_protection; + bool success = true; + MemoryRegion *region; + + RCU_READ_LOCK_GUARD(); + QEMU_LOCK_GUARD(&s->task_mutex); + + trace_apple_gfx_map_memory(task, range_count, virtual_offset, read_only); + for (int i = 0; i < range_count; i++) { + PGPhysicalMemoryRange_t *range = &ranges[i]; + + target = task->address + virtual_offset; + virtual_offset += range->physicalLength; + + trace_apple_gfx_map_memory_range(i, range->physicalAddress, + range->physicalLength); + + region = NULL; + source_ptr = apple_gfx_host_ptr_for_gpa_range(range->physicalAddress, + range->physicalLength, + read_only, ®ion); + if (!source_ptr) { + success = false; + continue; + } + + if (!g_ptr_array_find(task->mapped_regions, region, NULL)) { + g_ptr_array_add(task->mapped_regions, region); + memory_region_ref(region); + } + + cur_protection = 0; + max_protection = 0; + /* Map guest RAM at range->physicalAddress into PG task memory range */ + r = mach_vm_remap(mach_task_self(), + &target, range->physicalLength, vm_page_size - 1, + VM_FLAGS_FIXED | VM_FLAGS_OVERWRITE, + mach_task_self(), (mach_vm_address_t)source_ptr, + false /* shared mapping, no copy */, + &cur_protection, &max_protection, + VM_INHERIT_COPY); + trace_apple_gfx_remap(r, source_ptr, target); + g_assert(r == KERN_SUCCESS); + } + + return success; +} + +static void apple_gfx_task_unmap_memory(AppleGFXState *s, PGTask_t *task, + uint64_t virtual_offset, uint64_t length) +{ + kern_return_t r; + mach_vm_address_t range_address; + + trace_apple_gfx_unmap_memory(task, virtual_offset, length); + + /* + * Replace task memory range with fresh 0 pages, undoing the mapping + * from guest RAM. + */ + range_address = task->address + virtual_offset; + r = mach_vm_allocate(mach_task_self(), &range_address, length, + VM_FLAGS_FIXED | VM_FLAGS_OVERWRITE); + g_assert(r == KERN_SUCCESS); +} + +/* ------ Rendering and frame management ------ */ + +static void apple_gfx_render_frame_completed_bh(void *opaque); + +static void apple_gfx_render_new_frame(AppleGFXState *s) +{ + bool managed_texture = s->using_managed_texture_storage; + uint32_t width = surface_width(s->surface); + uint32_t height = surface_height(s->surface); + MTLRegion region = MTLRegionMake2D(0, 0, width, height); + id command_buffer = [s->mtl_queue commandBuffer]; + id texture = s->texture; + + assert(bql_locked()); + [texture retain]; + [command_buffer retain]; + + s->rendering_frame_width = width; + s->rendering_frame_height = height; + + dispatch_async(get_background_queue(), ^{ + /* + * This is not safe to call from the BQL/BH due to PVG-internal locks + * causing deadlocks. + */ + bool r = [s->pgdisp encodeCurrentFrameToCommandBuffer:command_buffer + texture:texture + region:region]; + if (!r) { + [texture release]; + [command_buffer release]; + qemu_log_mask(LOG_GUEST_ERROR, + "%s: encodeCurrentFrameToCommandBuffer:texture:region: " + "failed\n", __func__); + bql_lock(); + --s->pending_frames; + if (s->pending_frames > 0) { + apple_gfx_render_new_frame(s); + } + bql_unlock(); + return; + } + + if (managed_texture) { + /* "Managed" textures exist in both VRAM and RAM and must be synced. */ + id blit = [command_buffer blitCommandEncoder]; + [blit synchronizeResource:texture]; + [blit endEncoding]; + } + [texture release]; + [command_buffer addCompletedHandler: + ^(id cb) + { + aio_bh_schedule_oneshot(qemu_get_aio_context(), + apple_gfx_render_frame_completed_bh, s); + }]; + [command_buffer commit]; + [command_buffer release]; + }); +} + +static void copy_mtl_texture_to_surface_mem(id texture, void *vram) +{ + /* + * TODO: Skip this entirely on a pure Metal or headless/guest-only + * rendering path, else use a blit command encoder? Needs careful + * (double?) buffering design. + */ + size_t width = texture.width, height = texture.height; + MTLRegion region = MTLRegionMake2D(0, 0, width, height); + [texture getBytes:vram + bytesPerRow:(width * 4) + bytesPerImage:(width * height * 4) + fromRegion:region + mipmapLevel:0 + slice:0]; +} + +static void apple_gfx_render_frame_completed_bh(void *opaque) +{ + AppleGFXState *s = opaque; + + @autoreleasepool { + --s->pending_frames; + assert(s->pending_frames >= 0); + + /* Only update display if mode hasn't changed since we started rendering. */ + if (s->rendering_frame_width == surface_width(s->surface) && + s->rendering_frame_height == surface_height(s->surface)) { + copy_mtl_texture_to_surface_mem(s->texture, surface_data(s->surface)); + if (s->gfx_update_requested) { + s->gfx_update_requested = false; + dpy_gfx_update_full(s->con); + graphic_hw_update_done(s->con); + s->new_frame_ready = false; + } else { + s->new_frame_ready = true; + } + } + if (s->pending_frames > 0) { + apple_gfx_render_new_frame(s); + } + } +} + +static void apple_gfx_fb_update_display(void *opaque) +{ + AppleGFXState *s = opaque; + + assert(bql_locked()); + if (s->new_frame_ready) { + dpy_gfx_update_full(s->con); + s->new_frame_ready = false; + graphic_hw_update_done(s->con); + } else if (s->pending_frames > 0) { + s->gfx_update_requested = true; + } else { + graphic_hw_update_done(s->con); + } +} + +static const GraphicHwOps apple_gfx_fb_ops = { + .gfx_update = apple_gfx_fb_update_display, + .gfx_update_async = true, +}; + +/* ------ Mouse cursor and display mode setting ------ */ + +static void set_mode(AppleGFXState *s, uint32_t width, uint32_t height) +{ + MTLTextureDescriptor *textureDescriptor; + + if (s->surface && + width == surface_width(s->surface) && + height == surface_height(s->surface)) { + return; + } + + [s->texture release]; + + s->surface = qemu_create_displaysurface(width, height); + + @autoreleasepool { + textureDescriptor = + [MTLTextureDescriptor + texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm + width:width + height:height + mipmapped:NO]; + textureDescriptor.usage = s->pgdisp.minimumTextureUsage; + s->texture = [s->mtl newTextureWithDescriptor:textureDescriptor]; + s->using_managed_texture_storage = + (s->texture.storageMode == MTLStorageModeManaged); + } + + dpy_gfx_replace_surface(s->con, s->surface); +} + +static void update_cursor(AppleGFXState *s) +{ + assert(bql_locked()); + dpy_mouse_set(s->con, s->pgdisp.cursorPosition.x, + s->pgdisp.cursorPosition.y, qatomic_read(&s->cursor_show)); +} + +static void update_cursor_bh(void *opaque) +{ + AppleGFXState *s = opaque; + update_cursor(s); +} + +typedef struct AppleGFXSetCursorGlyphJob { + AppleGFXState *s; + NSBitmapImageRep *glyph; + PGDisplayCoord_t hotspot; +} AppleGFXSetCursorGlyphJob; + +static void set_cursor_glyph(void *opaque) +{ + AppleGFXSetCursorGlyphJob *job = opaque; + AppleGFXState *s = job->s; + NSBitmapImageRep *glyph = job->glyph; + uint32_t bpp = glyph.bitsPerPixel; + size_t width = glyph.pixelsWide; + size_t height = glyph.pixelsHigh; + size_t padding_bytes_per_row = glyph.bytesPerRow - width * 4; + const uint8_t* px_data = glyph.bitmapData; + + trace_apple_gfx_cursor_set(bpp, width, height); + + if (s->cursor) { + cursor_unref(s->cursor); + s->cursor = NULL; + } + + if (bpp == 32) { /* Shouldn't be anything else, but just to be safe... */ + s->cursor = cursor_alloc(width, height); + s->cursor->hot_x = job->hotspot.x; + s->cursor->hot_y = job->hotspot.y; + + uint32_t *dest_px = s->cursor->data; + + for (size_t y = 0; y < height; ++y) { + for (size_t x = 0; x < width; ++x) { + /* + * NSBitmapImageRep's red & blue channels are swapped + * compared to QEMUCursor's. + */ + *dest_px = + (px_data[0] << 16u) | + (px_data[1] << 8u) | + (px_data[2] << 0u) | + (px_data[3] << 24u); + ++dest_px; + px_data += 4; + } + px_data += padding_bytes_per_row; + } + dpy_cursor_define(s->con, s->cursor); + update_cursor(s); + } + [glyph release]; + + g_free(job); +} + +/* ------ DMA (device reading system memory) ------ */ + +typedef struct AppleGFXReadMemoryJob { + QemuSemaphore sem; + hwaddr physical_address; + uint64_t length; + void *dst; + bool success; +} AppleGFXReadMemoryJob; + +static void apple_gfx_do_read_memory(void *opaque) +{ + AppleGFXReadMemoryJob *job = opaque; + MemTxResult r; + + r = dma_memory_read(&address_space_memory, job->physical_address, + job->dst, job->length, MEMTXATTRS_UNSPECIFIED); + job->success = (r == MEMTX_OK); + + qemu_sem_post(&job->sem); +} + +static bool apple_gfx_read_memory(AppleGFXState *s, hwaddr physical_address, + uint64_t length, void *dst) +{ + AppleGFXReadMemoryJob job = { + .physical_address = physical_address, .length = length, .dst = dst + }; + + trace_apple_gfx_read_memory(physical_address, length, dst); + + /* Performing DMA requires BQL, so do it in a BH. */ + qemu_sem_init(&job.sem, 0); + aio_bh_schedule_oneshot(qemu_get_aio_context(), + apple_gfx_do_read_memory, &job); + qemu_sem_wait(&job.sem); + qemu_sem_destroy(&job.sem); + return job.success; +} + +/* ------ Memory-mapped device I/O operations ------ */ + +typedef struct AppleGFXIOJob { + AppleGFXState *state; + uint64_t offset; + uint64_t value; + bool completed; +} AppleGFXIOJob; + +static void apple_gfx_do_read(void *opaque) +{ + AppleGFXIOJob *job = opaque; + job->value = [job->state->pgdev mmioReadAtOffset:job->offset]; + qatomic_set(&job->completed, true); + aio_wait_kick(); +} + +static uint64_t apple_gfx_read(void *opaque, hwaddr offset, unsigned size) +{ + AppleGFXIOJob job = { + .state = opaque, + .offset = offset, + .completed = false, + }; + dispatch_queue_t queue = get_background_queue(); + + dispatch_async_f(queue, &job, apple_gfx_do_read); + AIO_WAIT_WHILE(NULL, !qatomic_read(&job.completed)); + + trace_apple_gfx_read(offset, job.value); + return job.value; +} + +static void apple_gfx_do_write(void *opaque) +{ + AppleGFXIOJob *job = opaque; + [job->state->pgdev mmioWriteAtOffset:job->offset value:job->value]; + qatomic_set(&job->completed, true); + aio_wait_kick(); +} + +static void apple_gfx_write(void *opaque, hwaddr offset, uint64_t val, + unsigned size) +{ + /* + * The methods mmioReadAtOffset: and especially mmioWriteAtOffset: can + * trigger synchronous operations on other dispatch queues, which in turn + * may call back out on one or more of the callback blocks. For this reason, + * and as we are holding the BQL, we invoke the I/O methods on a pool + * thread and handle AIO tasks while we wait. Any work in the callbacks + * requiring the BQL will in turn schedule BHs which this thread will + * process while waiting. + */ + AppleGFXIOJob job = { + .state = opaque, + .offset = offset, + .value = val, + .completed = false, + }; + dispatch_queue_t queue = get_background_queue(); + + dispatch_async_f(queue, &job, apple_gfx_do_write); + AIO_WAIT_WHILE(NULL, !qatomic_read(&job.completed)); + + trace_apple_gfx_write(offset, val); +} + +static const MemoryRegionOps apple_gfx_ops = { + .read = apple_gfx_read, + .write = apple_gfx_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 8, + }, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, +}; + +static size_t apple_gfx_get_default_mmio_range_size(void) +{ + size_t mmio_range_size; + @autoreleasepool { + PGDeviceDescriptor *desc = [PGDeviceDescriptor new]; + mmio_range_size = desc.mmioLength; + [desc release]; + } + return mmio_range_size; +} + +/* ------ Initialisation and startup ------ */ + +void apple_gfx_common_init(Object *obj, AppleGFXState *s, const char* obj_name) +{ + size_t mmio_range_size = apple_gfx_get_default_mmio_range_size(); + + trace_apple_gfx_common_init(obj_name, mmio_range_size); + memory_region_init_io(&s->iomem_gfx, obj, &apple_gfx_ops, s, obj_name, + mmio_range_size); + + /* TODO: PVG framework supports serialising device state: integrate it! */ +} + +static void apple_gfx_register_task_mapping_handlers(AppleGFXState *s, + PGDeviceDescriptor *desc) +{ + desc.createTask = ^(uint64_t vmSize, void * _Nullable * _Nonnull baseAddress) { + PGTask_t *task = apple_gfx_new_task(s, vmSize); + *baseAddress = (void *)task->address; + trace_apple_gfx_create_task(vmSize, *baseAddress); + return task; + }; + + desc.destroyTask = ^(PGTask_t * _Nonnull task) { + trace_apple_gfx_destroy_task(task, task->mapped_regions->len); + + apple_gfx_destroy_task(s, task); + }; + + desc.mapMemory = ^bool(PGTask_t * _Nonnull task, uint32_t range_count, + uint64_t virtual_offset, bool read_only, + PGPhysicalMemoryRange_t * _Nonnull ranges) { + return apple_gfx_task_map_memory(s, task, virtual_offset, + ranges, range_count, read_only); + }; + + desc.unmapMemory = ^bool(PGTask_t * _Nonnull task, uint64_t virtual_offset, + uint64_t length) { + apple_gfx_task_unmap_memory(s, task, virtual_offset, length); + return true; + }; + + desc.readMemory = ^bool(uint64_t physical_address, uint64_t length, + void * _Nonnull dst) { + return apple_gfx_read_memory(s, physical_address, length, dst); + }; +} + +static void new_frame_handler_bh(void *opaque) +{ + AppleGFXState *s = opaque; + + /* Drop frames if guest gets too far ahead. */ + if (s->pending_frames >= 2) { + return; + } + ++s->pending_frames; + if (s->pending_frames > 1) { + return; + } + + @autoreleasepool { + apple_gfx_render_new_frame(s); + } +} + +static PGDisplayDescriptor *apple_gfx_prepare_display_descriptor(AppleGFXState *s) +{ + PGDisplayDescriptor *disp_desc = [PGDisplayDescriptor new]; + + disp_desc.name = @"QEMU display"; + disp_desc.sizeInMillimeters = NSMakeSize(400., 300.); /* A 20" display */ + disp_desc.queue = dispatch_get_main_queue(); + disp_desc.newFrameEventHandler = ^(void) { + trace_apple_gfx_new_frame(); + aio_bh_schedule_oneshot(qemu_get_aio_context(), new_frame_handler_bh, s); + }; + disp_desc.modeChangeHandler = ^(PGDisplayCoord_t sizeInPixels, + OSType pixelFormat) { + trace_apple_gfx_mode_change(sizeInPixels.x, sizeInPixels.y); + + BQL_LOCK_GUARD(); + set_mode(s, sizeInPixels.x, sizeInPixels.y); + }; + disp_desc.cursorGlyphHandler = ^(NSBitmapImageRep *glyph, + PGDisplayCoord_t hotspot) { + AppleGFXSetCursorGlyphJob *job = g_malloc0(sizeof(*job)); + job->s = s; + job->glyph = glyph; + job->hotspot = hotspot; + [glyph retain]; + aio_bh_schedule_oneshot(qemu_get_aio_context(), + set_cursor_glyph, job); + }; + disp_desc.cursorShowHandler = ^(BOOL show) { + trace_apple_gfx_cursor_show(show); + qatomic_set(&s->cursor_show, show); + aio_bh_schedule_oneshot(qemu_get_aio_context(), + update_cursor_bh, s); + }; + disp_desc.cursorMoveHandler = ^(void) { + trace_apple_gfx_cursor_move(); + aio_bh_schedule_oneshot(qemu_get_aio_context(), + update_cursor_bh, s); + }; + + return disp_desc; +} + +static NSArray* apple_gfx_prepare_display_mode_array(void) +{ + PGDisplayMode *modes[ARRAY_SIZE(apple_gfx_modes)]; + NSArray* mode_array; + int i; + + for (i = 0; i < ARRAY_SIZE(apple_gfx_modes); i++) { + modes[i] = + [[PGDisplayMode alloc] initWithSizeInPixels:apple_gfx_modes[i] refreshRateInHz:60.]; + } + + mode_array = [NSArray arrayWithObjects:modes count:ARRAY_SIZE(apple_gfx_modes)]; + + for (i = 0; i < ARRAY_SIZE(apple_gfx_modes); i++) { + [modes[i] release]; + modes[i] = nil; + } + + return mode_array; +} + +static id copy_suitable_metal_device(void) +{ + id dev = nil; + NSArray> *devs = MTLCopyAllDevices(); + + /* Prefer a unified memory GPU. Failing that, pick a non-removable GPU. */ + for (size_t i = 0; i < devs.count; ++i) { + if (devs[i].hasUnifiedMemory) { + dev = devs[i]; + break; + } + if (!devs[i].removable) { + dev = devs[i]; + } + } + + if (dev != nil) { + [dev retain]; + } else { + dev = MTLCreateSystemDefaultDevice(); + } + [devs release]; + + return dev; +} + +bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, + PGDeviceDescriptor *desc, Error **errp) +{ + PGDisplayDescriptor *disp_desc; + + if (apple_gfx_mig_blocker == NULL) { + error_setg(&apple_gfx_mig_blocker, + "Migration state blocked by apple-gfx display device"); + if (migrate_add_blocker(&apple_gfx_mig_blocker, errp) < 0) { + return false; + } + } + + qemu_mutex_init(&s->task_mutex); + QTAILQ_INIT(&s->tasks); + s->mtl = copy_suitable_metal_device(); + s->mtl_queue = [s->mtl newCommandQueue]; + + desc.device = s->mtl; + + apple_gfx_register_task_mapping_handlers(s, desc); + + s->cursor_show = true; + + s->pgdev = PGNewDeviceWithDescriptor(desc); + + disp_desc = apple_gfx_prepare_display_descriptor(s); + /* + * Although the framework does, this integration currently does not support + * multiple virtual displays connected to a single PV graphics device. + * It is however possible to create + * more than one instance of the device, each with one display. The macOS + * guest will ignore these displays if they share the same serial number, + * so ensure each instance gets a unique one. + */ + s->pgdisp = [s->pgdev newDisplayWithDescriptor:disp_desc + port:0 + serialNum:next_pgdisplay_serial_num++]; + [disp_desc release]; + s->pgdisp.modeList = apple_gfx_prepare_display_mode_array(); + + s->con = graphic_console_init(dev, 0, &apple_gfx_fb_ops, s); + return true; +} diff --git a/hw/display/meson.build b/hw/display/meson.build index 20a94973fa2..cf9e6dd35d2 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -61,6 +61,12 @@ system_ss.add(when: 'CONFIG_ARTIST', if_true: files('artist.c')) system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_dbg.c'), pixman]) +if host_os == 'darwin' + system_ss.add(when: 'CONFIG_MAC_PVG', if_true: [files('apple-gfx.m'), pvg, metal]) + if cpu == 'aarch64' + system_ss.add(when: 'CONFIG_MAC_PVG_MMIO', if_true: [files('apple-gfx-mmio.m'), pvg, metal]) + endif +endif if config_all_devices.has_key('CONFIG_VIRTIO_GPU') virtio_gpu_ss = ss.source_set() diff --git a/hw/display/trace-events b/hw/display/trace-events index d26d663f963..a50e4eea0c0 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -194,3 +194,31 @@ dm163_bits_ppi(unsigned dest_width) "dest_width : %u" dm163_leds(int led, uint32_t value) "led %d: 0x%x" dm163_channels(int channel, uint8_t value) "channel %d: 0x%x" dm163_refresh_rate(uint32_t rr) "refresh rate %d" + +# apple-gfx.m +apple_gfx_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 +apple_gfx_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 +apple_gfx_create_task(uint32_t vm_size, void *va) "vm_size=0x%x base_addr=%p" +apple_gfx_destroy_task(void *task, unsigned int num_mapped_regions) "task=%p, task->mapped_regions->len=%u" +apple_gfx_map_memory(void *task, uint32_t range_count, uint64_t virtual_offset, uint32_t read_only) "task=%p range_count=0x%x virtual_offset=0x%"PRIx64" read_only=%d" +apple_gfx_map_memory_range(uint32_t i, uint64_t phys_addr, uint64_t phys_len) "[%d] phys_addr=0x%"PRIx64" phys_len=0x%"PRIx64 +apple_gfx_remap(uint64_t retval, void *source_ptr, uint64_t target) "retval=%"PRId64" source=%p target=0x%"PRIx64 +apple_gfx_unmap_memory(void *task, uint64_t virtual_offset, uint64_t length) "task=%p virtual_offset=0x%"PRIx64" length=0x%"PRIx64 +apple_gfx_read_memory(uint64_t phys_address, uint64_t length, void *dst) "phys_addr=0x%"PRIx64" length=0x%"PRIx64" dest=%p" +apple_gfx_raise_irq(uint32_t vector) "vector=0x%x" +apple_gfx_new_frame(void) "" +apple_gfx_mode_change(uint64_t x, uint64_t y) "x=%"PRId64" y=%"PRId64 +apple_gfx_cursor_set(uint32_t bpp, uint64_t width, uint64_t height) "bpp=%d width=%"PRId64" height=0x%"PRId64 +apple_gfx_cursor_show(uint32_t show) "show=%d" +apple_gfx_cursor_move(void) "" +apple_gfx_common_init(const char *device_name, size_t mmio_size) "device: %s; MMIO size: %zu bytes" + +# apple-gfx-mmio.m +apple_gfx_mmio_iosfc_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 +apple_gfx_mmio_iosfc_write(uint64_t offset, uint64_t val) "offset=0x%"PRIx64" val=0x%"PRIx64 +apple_gfx_iosfc_map_memory(uint64_t phys, uint64_t len, uint32_t ro, void *va, void *e, void *f, void* va_result) "phys=0x%"PRIx64" len=0x%"PRIx64" ro=%d va=%p e=%p f=%p -> *va=%p" +apple_gfx_iosfc_map_memory_new_region(size_t i, void *region, uint64_t start, uint64_t end) "index=%zu, region=%p, 0x%"PRIx64"-0x%"PRIx64 +apple_gfx_iosfc_unmap_memory(void *a, void *b, void *c, void *d, void *e, void *f) "a=%p b=%p c=%p d=%p e=%p f=%p" +apple_gfx_iosfc_unmap_memory_region(void* mem, void *region) "unmapping @ %p from memory region %p" +apple_gfx_iosfc_raise_irq(uint32_t vector) "vector=0x%x" + From patchwork Tue Dec 31 20:22:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854421 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090120wrq; Tue, 31 Dec 2024 12:25:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUzgJxdMolQpHZgXvZ0mdFN+qDN2A6AvaVr0doGsXRBDRoCdgi4rsNYMr04zmd0YCf8mQF58A==@linaro.org X-Google-Smtp-Source: AGHT+IE5R7R3yRbhi8FAyF/LPgzPDyUM1oc6QZ+n/gaA7jX7rhYnn4in6NGbf2UUZf1iYuX73rMZ X-Received: by 2002:a05:620a:459f:b0:7b6:dc74:82ac with SMTP id af79cd13be357-7b9ba6efademr6700940485a.1.1735676758051; Tue, 31 Dec 2024 12:25:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676758; cv=none; d=google.com; s=arc-20240605; b=U4Qdlyya4oA+3a0ctRWA4wzUkTfqhuSI4alhVxfps85PRapItxwmhsZz/jcPEKXNyx 4iGHvk6YofOe9K1wLxId96GLyNEv4bkoDu0Jtxq+dJTOwKvF6rgJWSANwmfLXwsTUUO6 3pDy6tVVpAxYxc448e9S129OqCd7+7MHYSaZl0ZAe15pa5in8YXBeg4M2YMhKHuu0Oyd pC+Wx8K+Bi3fT0l5ndoUCB5tfPog7WSD41n/Uj2hE/acIBvIC16oGwMDLkttTnFbPHWK NnZbxccWceDWVXV23ARy5HnPuKaUK++YwEPHVSbtnOGXgYaA3aPbqRDAYHN7GgZvQEJT Ao+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Z03rwhPNrlyAf9OxibhkB1UzMsuJ/4hpuze5g8H61yY=; fh=tyn3H0ySGZ/3GeTr+63AnxEBt54onnjIpRgEvvPl10Q=; b=SknRsJV1gIAH0NoFmWo6GmE43YJ2g/snBSQAXcsveZFA7ZDbD0zXOu0j8CJXsfX6vh BKmKAmzX2k4rLuMDOnz6uHIip/EeSqj7lM/iikNk8hqFjkMVeBsbwEmJKLBYzF5Z7zRi Ek10gzc0DHAiGjT8QBm1kAhmmcFVIYMimWbND5YFuhPn99kafwPOPZGlNB/3X5aXyxTy 2/0wack+y37YTsBCXU7VYhJp5SEeDnOybh9BA95HAJ378hIrzNlweUQBD3KsZlnWbQHi GyOml/paieWJGTfCYIv/atrI+tSXCSKPNgy2oddbwi1c7JJ0EJ4JnZUcEYRCWt/ds7G9 4DNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S9R9z30/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac5303d0si3074203985a.637.2024.12.31.12.25.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:25:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S9R9z30/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSinE-0000VH-R5; Tue, 31 Dec 2024 15:24:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSinB-0008PT-Bx for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:41 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSin6-00010p-4b for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:41 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4368a293339so63312925e9.3 for ; Tue, 31 Dec 2024 12:24:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676674; x=1736281474; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z03rwhPNrlyAf9OxibhkB1UzMsuJ/4hpuze5g8H61yY=; b=S9R9z30/LCGtmkhyiMk3NruXJTkOZUD6QrUIwhLP08XoIbKb1n1rjcwBQ+IiQtNUo6 2BTj2h6/XzJqWN6VKHvTHHhVVrmPfyiHdIhznOiMfzks1cvyn/+Ja0WwDc3WFjTQucOj 6EcinhLl9JvnjMzOPoi/CuE2Pt4yXc0aEpkJCmawyMN0CmfD4I4CBdpOMBoKOjhTLbFK UW19eVvzCCq35HIMdCHnWJrk5boMOMBGjK7ESv9mrF0NXGlmQc1GnfLwchHripXFNlpN 53y2vh/RZ7hld+TlB98F1LbuolO/vAprUw6oJfZgC2TkzCrCMNg/AXtuGYYBNwsejJx7 9pxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676674; x=1736281474; 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=Z03rwhPNrlyAf9OxibhkB1UzMsuJ/4hpuze5g8H61yY=; b=kiafVyI5ou7X4wjagBikg+TfLnFxUXVqN/Flxm1oWvRL/ajNp9pOzQL9pXuA1Nm688 WJlJgqD6nS1x3SEUvtVss4yRlXvBVaIwCwwg7owQUiARJL8v4w/fIRBdwZagHnZC2wF0 9bXkWN/UCykFPXMJYBF0bvtk+bCElZI/VApUbIYO8/fbauXLyWuQ0UxZvAxUT9c0I5Cv dcV1eB5d0/ZjMwgnycGXhsxuqyU84I3hkrEpxv/3Qk71qowH65+GZ2t2h7LYIrpKf8IO emIAP7bSUSt/PEItmzEvALYW+WhMMm6MJjMGlpGySZEv0eFC05BQbxT4V9DUS34LbE8M qB8A== X-Gm-Message-State: AOJu0Yz6kBOfMwdZrzV5T8L+P99NjtsfC4luFwKNlnQfg4QfmvtkX5cl 6zmfcRDnYlqVuQf9kzCPxmWYu3rCFS5AnCIWw7w2BMhlLuF1zAYY6+RTIDrMEXhMBDZE6dM0zhV L9bA= X-Gm-Gg: ASbGncs24yKfOBOCKg3Q47ZnV3ZpIClkIv0fnhZsKIvrAPTuqXrodWUh4N2Y1Jefrfh TwLdG4gr3h2GkXOmlnFZyBS3d946pW4O1+ukZ/nmet7ZB+/y8xF94Q2O/2CQYup6UcKOBP4Gl4n OtgcGPwbfXEtU/g6ie5okt7RcfYtIRZHh1NcKnVXD+J5P3EfxmObg0lOWcyWxm5sMxalke3neBH +4PnUPeceQj78/wBB1qCOJ4re9ouLg8SdDOxgFyopN8uHlcqlbWAnOymZW1+bbM+uEPFMceVzev 3m/7qh6YzHfIzeGPluKINwQGV3uhQHk= X-Received: by 2002:a05:600c:1d07:b0:435:192:63fb with SMTP id 5b1f17b1804b1-4366854bf0cmr364112245e9.3.1735676674275; Tue, 31 Dec 2024 12:24:34 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4367086e40esm363320485e9.30.2024.12.31.12.24.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:33 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 25/29] hw/display/apple-gfx: Adds PCI implementation Date: Tue, 31 Dec 2024 21:22:24 +0100 Message-ID: <20241231202228.28819-26-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Phil Dennis-Jordan This change wires up the PCI variant of the paravirtualised graphics device, mainly useful for x86-64 macOS guests, implemented by macOS's ParavirtualizedGraphics.framework. It builds on code shared with the vmapple/mmio variant of the PVG device. Signed-off-by: Phil Dennis-Jordan Reviewed-by: Akihiko Odaki Message-ID: <20241223221645.29911-4-phil@philjordan.eu> Signed-off-by: Philippe Mathieu-Daudé --- hw/display/apple-gfx.h | 1 + hw/display/Kconfig | 4 + hw/display/apple-gfx-pci.m | 151 +++++++++++++++++++++++++++++++++++++ hw/display/meson.build | 1 + 4 files changed, 157 insertions(+) create mode 100644 hw/display/apple-gfx-pci.m diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h index 4cd4163f223..6c74209b361 100644 --- a/hw/display/apple-gfx.h +++ b/hw/display/apple-gfx.h @@ -14,6 +14,7 @@ #include "ui/surface.h" #define TYPE_APPLE_GFX_MMIO "apple-gfx-mmio" +#define TYPE_APPLE_GFX_PCI "apple-gfx-pci" @class PGDeviceDescriptor; @protocol PGDevice; diff --git a/hw/display/Kconfig b/hw/display/Kconfig index 6a9b7b19ada..2b53dfd7d26 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -149,3 +149,7 @@ config MAC_PVG_MMIO bool depends on MAC_PVG && AARCH64 +config MAC_PVG_PCI + bool + depends on MAC_PVG && PCI + default y if PCI_DEVICES diff --git a/hw/display/apple-gfx-pci.m b/hw/display/apple-gfx-pci.m new file mode 100644 index 00000000000..35a3c7a7ce6 --- /dev/null +++ b/hw/display/apple-gfx-pci.m @@ -0,0 +1,151 @@ +/* + * QEMU Apple ParavirtualizedGraphics.framework device, PCI variant + * + * Copyright © 2023-2024 Phil Dennis-Jordan + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * ParavirtualizedGraphics.framework is a set of libraries that macOS provides + * which implements 3d graphics passthrough to the host as well as a + * proprietary guest communication channel to drive it. This device model + * implements support to drive that library from within QEMU as a PCI device + * aimed primarily at x86-64 macOS VMs. + */ + +#include "qemu/osdep.h" +#include "hw/pci/pci_device.h" +#include "hw/pci/msi.h" +#include "apple-gfx.h" +#include "trace.h" + +#import + +OBJECT_DECLARE_SIMPLE_TYPE(AppleGFXPCIState, APPLE_GFX_PCI) + +struct AppleGFXPCIState { + PCIDevice parent_obj; + + AppleGFXState common; +}; + +static const char *apple_gfx_pci_option_rom_path = NULL; + +static void apple_gfx_init_option_rom_path(void) +{ + NSURL *option_rom_url = PGCopyOptionROMURL(); + const char *option_rom_path = option_rom_url.fileSystemRepresentation; + apple_gfx_pci_option_rom_path = g_strdup(option_rom_path); + [option_rom_url release]; +} + +static void apple_gfx_pci_init(Object *obj) +{ + AppleGFXPCIState *s = APPLE_GFX_PCI(obj); + + if (!apple_gfx_pci_option_rom_path) { + /* + * The following is done on device not class init to avoid running + * ObjC code before fork() in -daemonize mode. + */ + PCIDeviceClass *pci = PCI_DEVICE_CLASS(object_get_class(obj)); + apple_gfx_init_option_rom_path(); + pci->romfile = apple_gfx_pci_option_rom_path; + } + + apple_gfx_common_init(obj, &s->common, TYPE_APPLE_GFX_PCI); +} + +typedef struct AppleGFXPCIInterruptJob { + PCIDevice *device; + uint32_t vector; +} AppleGFXPCIInterruptJob; + +static void apple_gfx_pci_raise_interrupt(void *opaque) +{ + AppleGFXPCIInterruptJob *job = opaque; + + if (msi_enabled(job->device)) { + msi_notify(job->device, job->vector); + } + g_free(job); +} + +static void apple_gfx_pci_interrupt(PCIDevice *dev, uint32_t vector) +{ + AppleGFXPCIInterruptJob *job; + + trace_apple_gfx_raise_irq(vector); + job = g_malloc0(sizeof(*job)); + job->device = dev; + job->vector = vector; + aio_bh_schedule_oneshot(qemu_get_aio_context(), + apple_gfx_pci_raise_interrupt, job); +} + +static void apple_gfx_pci_realize(PCIDevice *dev, Error **errp) +{ + AppleGFXPCIState *s = APPLE_GFX_PCI(dev); + int ret; + + pci_register_bar(dev, PG_PCI_BAR_MMIO, + PCI_BASE_ADDRESS_SPACE_MEMORY, &s->common.iomem_gfx); + + ret = msi_init(dev, 0x0 /* config offset; 0 = find space */, + PG_PCI_MAX_MSI_VECTORS, true /* msi64bit */, + false /* msi_per_vector_mask */, errp); + if (ret != 0) { + return; + } + + @autoreleasepool { + PGDeviceDescriptor *desc = [PGDeviceDescriptor new]; + desc.raiseInterrupt = ^(uint32_t vector) { + apple_gfx_pci_interrupt(dev, vector); + }; + + apple_gfx_common_realize(&s->common, DEVICE(dev), desc, errp); + [desc release]; + desc = nil; + } +} + +static void apple_gfx_pci_reset(Object *obj, ResetType type) +{ + AppleGFXPCIState *s = APPLE_GFX_PCI(obj); + [s->common.pgdev reset]; +} + +static void apple_gfx_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *pci = PCI_DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); + + rc->phases.hold = apple_gfx_pci_reset; + dc->desc = "macOS Paravirtualized Graphics PCI Display Controller"; + dc->hotpluggable = false; + set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); + + pci->vendor_id = PG_PCI_VENDOR_ID; + pci->device_id = PG_PCI_DEVICE_ID; + pci->class_id = PCI_CLASS_DISPLAY_OTHER; + pci->realize = apple_gfx_pci_realize; + + /* TODO: Property for setting mode list */ +} + +static const TypeInfo apple_gfx_pci_types[] = { + { + .name = TYPE_APPLE_GFX_PCI, + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(AppleGFXPCIState), + .class_init = apple_gfx_pci_class_init, + .instance_init = apple_gfx_pci_init, + .interfaces = (InterfaceInfo[]) { + { INTERFACE_PCIE_DEVICE }, + { }, + }, + } +}; +DEFINE_TYPES(apple_gfx_pci_types) + diff --git a/hw/display/meson.build b/hw/display/meson.build index cf9e6dd35d2..94f4f05d36f 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -63,6 +63,7 @@ system_ss.add(when: 'CONFIG_ATI_VGA', if_true: [files('ati.c', 'ati_2d.c', 'ati_ if host_os == 'darwin' system_ss.add(when: 'CONFIG_MAC_PVG', if_true: [files('apple-gfx.m'), pvg, metal]) + system_ss.add(when: 'CONFIG_MAC_PVG_PCI', if_true: [files('apple-gfx-pci.m'), pvg, metal]) if cpu == 'aarch64' system_ss.add(when: 'CONFIG_MAC_PVG_MMIO', if_true: [files('apple-gfx-mmio.m'), pvg, metal]) endif From patchwork Tue Dec 31 20:22:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854416 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7089860wrq; Tue, 31 Dec 2024 12:25:04 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWlTN7TaWj57k2IyD3vD1wyfMyEOqrEQOQXY3c3kEipRF36HEtpxX5mezo4pjucCLsC2SMgbw==@linaro.org X-Google-Smtp-Source: AGHT+IG7Au59BrVXY9vH2UjAyEUFxAN2b5j2RKczEjoam2L4I/2/LuqF5xk5/wcd0QuFLhpKqhb6 X-Received: by 2002:ac8:5a16:0:b0:466:ab8f:8972 with SMTP id d75a77b69052e-46a4a8b868cmr650519221cf.3.1735676704695; Tue, 31 Dec 2024 12:25:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676704; cv=none; d=google.com; s=arc-20240605; b=JnB7oNsKYhHkbtKUOcoJRW2qHB1343OcJUOEfVabjAQadG0nWIIAFY7fzQ9bPyJaKw IPZqCIzMAbPO64uDqKjCed/BEoWW1DWNPzP0x9LtWRLnKHceOKoI9WjP8Mw4azWKa/VS Cfo0htY1d2jFu6IvUHpk4xmqQEk05WKGtQymeGwrrIsX0MJFh/S+ctlB313Jme1skwfh VEuLZ1kJAKdqsRnqOOHHajwyIDD5b+HL7gURgIvZybRlORWqySA1Kz5mWy5+VQ46eWUd IsHQZHtB+wZChinPsvfuv3j7sU7Qn1PwVuNzUEh+Orz9jilzbNrZJgNYrGJPtcB9hdJp f6BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7v8hmM8w7uYM6AENFnStcDP4Ll55lmP1xAMZVKQOAoc=; fh=tyn3H0ySGZ/3GeTr+63AnxEBt54onnjIpRgEvvPl10Q=; b=QBpfozrudpG8HOjjmqynxeOVEkO8pz+9uduKH5ueZZEvRg6ZEHdTvDBd5wXbBaSkTv AwxYJmlz5OnGdMr3utbT7leaVCEE5wWLVr7cXTyTCNXrgDZB4CNMeYrBIg4E+uePH1Ht NOUlTUNlxVnPb9RHUxPagzPCsXF8Dj5C1D01UjQB3IcDT+VG0NdmQ8ncg69MEAuR2UYV R23PCJFV/8J8iE1wR4ts0IGJ0MfraguHsD7ivDYw9eznp0QMgjMp2+8I2aRIzz515Tnr 576TWGCxXHoJcbNKRZvzZ1iX5XF+rI/a0g7MMlRHSbCUv7Sg8CuxntEDV3ZA/Sj7OVJt 11sw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iiImqmNT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3ec02e46si320196991cf.647.2024.12.31.12.25.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:25:04 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iiImqmNT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSinN-0001Sb-6w; Tue, 31 Dec 2024 15:24:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSinJ-00012c-57 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:50 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSinC-00011I-Vc for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:48 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-385e3621518so4864461f8f.1 for ; Tue, 31 Dec 2024 12:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676679; x=1736281479; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7v8hmM8w7uYM6AENFnStcDP4Ll55lmP1xAMZVKQOAoc=; b=iiImqmNTh6CL0v8w8RQNzLoRVxmOs6jXcspSHRvXWuQhAqK7i19sDUZ8p2zI9Y9WP1 QhKc/48LvTh6PzdND1Y3v2SdAZyRHtkAoTJ2SyyelkpDxiRvo/ddTwleQTepA9bwFXZb +UYGCm2hl8AXxlS2t/poNol2gC7PRofyIKOjvOqwP1JhZpR4RUGUc5V6dzwqTal57mrE 8CVy1IiNsnv/kBIHDbmR8fIBG2csvI4KngRqeKWNKBywmWV1EIuIKOCOVEVM7dmS5xjl BnkB6anbZWkwBeOXN1dco5eZABMpoSRXX10IoFG+ZfXVHLPYqHQqicmXAydQfSV+HpJL hSZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676679; x=1736281479; 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=7v8hmM8w7uYM6AENFnStcDP4Ll55lmP1xAMZVKQOAoc=; b=KhpFV2iip8B1Dd/gG6PR1VkLAPzXi4kAs/64oCn4XUG7gNQA1EDp+MBkr8/fGuDKRX ZHxZkIZTibhpIHCVV48MTBGq8WWLbHGwBp/MIJ87TRtUnGVsftw2eglylQl5OQYK7ZZW eBglNCTEuGyRhk6qFGoI8S8ltfiY1Yvv+v/QLkgEHnnCS5rPwl6Wq/7QnGBd7qWyLA2B /0IcXymZaimz9W4W4UgGbFzmUohI9Wu8yipIxipERxpdJ+795PPhN5QLSlQFSusSRtD3 xAocMb1ZfUMIcnf7XIMo1vigrpbZK1MdNd+05Mjn3KfMdpb6XjvAOxziH5/FyHPTqCD+ pWIw== X-Gm-Message-State: AOJu0Ywzqf2n56EwkoAwoyebY8Xg+JfRZSgWdTsFlhUNQmcaB4rd/GnU VXMbKjc9RLB0TKOEHL0oOIeNy/couABcpxEBL1/goJu6Z0zJWzSqw5v7BXs5g0PFdh34ErNifCU 51w0= X-Gm-Gg: ASbGncsLzIZiOiDOf6KfahYeQqI5NMPUAJjUa+BcE1IZ7qnH908jLFqvPpSFt3Y6J8x w2jjdEhTRlMJiB++FqcBbuydIp+VGqwWGtzMkl327DC9Ds/TRGoM9ienBr4wafcXWItVz+OawDs o09atPUk5eD3AO7e8io8wmhvW/HbzlRljomXW688bENB+LXbqSktpCQz0DZ1MPsmfFNGWazTce5 Mgi9sJgvhKcRu4yWXC07GfcKFDFHLuHmlqSgjb0QVja5WcwWrx9Z5+uby8JHKRMtvaEu0pj5Dvl 76usv3KlP8K3yd7avftP7LhdTJXaigQ= X-Received: by 2002:a05:6000:480b:b0:385:fb34:d585 with SMTP id ffacd0b85a97d-38a221fa418mr34117327f8f.34.1735676678880; Tue, 31 Dec 2024 12:24:38 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436611ea47asm397952225e9.4.2024.12.31.12.24.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:38 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 26/29] hw/display/apple-gfx: Adds configurable mode list Date: Tue, 31 Dec 2024 21:22:25 +0100 Message-ID: <20241231202228.28819-27-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Phil Dennis-Jordan This change adds a property 'display_modes' on the graphics device which permits specifying a list of display modes. (screen resolution and refresh rate) The property is an array of a custom type to make the syntax slightly less awkward to use, for example: -device '{"driver":"apple-gfx-pci", "display-modes":["1920x1080@60", "3840x2160@60"]}' Signed-off-by: Phil Dennis-Jordan Reviewed-by: Akihiko Odaki Tested-by: Akihiko Odaki Message-ID: <20241223221645.29911-5-phil@philjordan.eu> Signed-off-by: Philippe Mathieu-Daudé --- hw/display/apple-gfx.h | 10 +++ hw/display/apple-gfx-mmio.m | 7 ++ hw/display/apple-gfx-pci.m | 8 ++- hw/display/apple-gfx.m | 130 +++++++++++++++++++++++++++++++----- hw/display/trace-events | 2 + 5 files changed, 139 insertions(+), 18 deletions(-) diff --git a/hw/display/apple-gfx.h b/hw/display/apple-gfx.h index 6c74209b361..3900cdbabbb 100644 --- a/hw/display/apple-gfx.h +++ b/hw/display/apple-gfx.h @@ -25,6 +25,12 @@ typedef QTAILQ_HEAD(, PGTask_s) PGTaskList; +typedef struct AppleGFXDisplayMode { + uint16_t width_px; + uint16_t height_px; + uint16_t refresh_rate_hz; +} AppleGFXDisplayMode; + typedef struct AppleGFXState { /* Initialised on init/realize() */ MemoryRegion iomem_gfx; @@ -33,6 +39,8 @@ typedef struct AppleGFXState { QemuConsole *con; id mtl; id mtl_queue; + AppleGFXDisplayMode *display_modes; + uint32_t num_display_modes; /* List `tasks` is protected by task_mutex */ QemuMutex task_mutex; @@ -60,5 +68,7 @@ void *apple_gfx_host_ptr_for_gpa_range(uint64_t guest_physical, uint64_t length, bool read_only, MemoryRegion **mapping_in_region); +extern const PropertyInfo qdev_prop_apple_gfx_display_mode; + #endif diff --git a/hw/display/apple-gfx-mmio.m b/hw/display/apple-gfx-mmio.m index 5a489d2d44f..b2e0e7a30fa 100644 --- a/hw/display/apple-gfx-mmio.m +++ b/hw/display/apple-gfx-mmio.m @@ -255,6 +255,11 @@ static void apple_gfx_mmio_reset(Object *obj, ResetType type) [s->common.pgdev reset]; } +static const Property apple_gfx_mmio_properties[] = { + DEFINE_PROP_ARRAY("display-modes", AppleGFXMMIOState, + common.num_display_modes, common.display_modes, + qdev_prop_apple_gfx_display_mode, AppleGFXDisplayMode), +}; static void apple_gfx_mmio_class_init(ObjectClass *klass, void *data) { @@ -264,6 +269,8 @@ static void apple_gfx_mmio_class_init(ObjectClass *klass, void *data) rc->phases.hold = apple_gfx_mmio_reset; dc->hotpluggable = false; dc->realize = apple_gfx_mmio_realize; + + device_class_set_props(dc, apple_gfx_mmio_properties); } static const TypeInfo apple_gfx_mmio_types[] = { diff --git a/hw/display/apple-gfx-pci.m b/hw/display/apple-gfx-pci.m index 35a3c7a7ce6..b939bb9b233 100644 --- a/hw/display/apple-gfx-pci.m +++ b/hw/display/apple-gfx-pci.m @@ -115,6 +115,12 @@ static void apple_gfx_pci_reset(Object *obj, ResetType type) [s->common.pgdev reset]; } +static const Property apple_gfx_pci_properties[] = { + DEFINE_PROP_ARRAY("display-modes", AppleGFXPCIState, + common.num_display_modes, common.display_modes, + qdev_prop_apple_gfx_display_mode, AppleGFXDisplayMode), +}; + static void apple_gfx_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -131,7 +137,7 @@ static void apple_gfx_pci_class_init(ObjectClass *klass, void *data) pci->class_id = PCI_CLASS_DISPLAY_OTHER; pci->realize = apple_gfx_pci_realize; - /* TODO: Property for setting mode list */ + device_class_set_props(dc, apple_gfx_pci_properties); } static const TypeInfo apple_gfx_pci_types[] = { diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m index 59299e339d4..aa1455b6295 100644 --- a/hw/display/apple-gfx.m +++ b/hw/display/apple-gfx.m @@ -31,9 +31,10 @@ #import -static const PGDisplayCoord_t apple_gfx_modes[] = { - { .x = 1440, .y = 1080 }, - { .x = 1280, .y = 1024 }, +static const AppleGFXDisplayMode apple_gfx_default_modes[] = { + { 1920, 1080, 60 }, + { 1440, 1080, 60 }, + { 1280, 1024, 60 }, }; static Error *apple_gfx_mig_blocker; @@ -690,22 +691,23 @@ static void new_frame_handler_bh(void *opaque) return disp_desc; } -static NSArray* apple_gfx_prepare_display_mode_array(void) +static NSArray *apple_gfx_create_display_mode_array( + const AppleGFXDisplayMode display_modes[], uint32_t display_mode_count) { - PGDisplayMode *modes[ARRAY_SIZE(apple_gfx_modes)]; - NSArray* mode_array; - int i; + PGDisplayMode *mode_obj; + NSMutableArray *mode_array = + [[NSMutableArray alloc] initWithCapacity:display_mode_count]; - for (i = 0; i < ARRAY_SIZE(apple_gfx_modes); i++) { - modes[i] = - [[PGDisplayMode alloc] initWithSizeInPixels:apple_gfx_modes[i] refreshRateInHz:60.]; - } + for (unsigned i = 0; i < display_mode_count; i++) { + const AppleGFXDisplayMode *mode = &display_modes[i]; + trace_apple_gfx_display_mode(i, mode->width_px, mode->height_px); + PGDisplayCoord_t mode_size = { mode->width_px, mode->height_px }; - mode_array = [NSArray arrayWithObjects:modes count:ARRAY_SIZE(apple_gfx_modes)]; - - for (i = 0; i < ARRAY_SIZE(apple_gfx_modes); i++) { - [modes[i] release]; - modes[i] = nil; + mode_obj = + [[PGDisplayMode alloc] initWithSizeInPixels:mode_size + refreshRateInHz:mode->refresh_rate_hz]; + [mode_array addObject:mode_obj]; + [mode_obj release]; } return mode_array; @@ -741,6 +743,9 @@ bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, PGDeviceDescriptor *desc, Error **errp) { PGDisplayDescriptor *disp_desc; + const AppleGFXDisplayMode *display_modes = apple_gfx_default_modes; + uint32_t num_display_modes = ARRAY_SIZE(apple_gfx_default_modes); + NSArray *mode_array; if (apple_gfx_mig_blocker == NULL) { error_setg(&apple_gfx_mig_blocker, @@ -776,8 +781,99 @@ bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, port:0 serialNum:next_pgdisplay_serial_num++]; [disp_desc release]; - s->pgdisp.modeList = apple_gfx_prepare_display_mode_array(); + + if (s->display_modes != NULL && s->num_display_modes > 0) { + trace_apple_gfx_common_realize_modes_property(s->num_display_modes); + display_modes = s->display_modes; + num_display_modes = s->num_display_modes; + } + s->pgdisp.modeList = mode_array = + apple_gfx_create_display_mode_array(display_modes, num_display_modes); + [mode_array release]; s->con = graphic_console_init(dev, 0, &apple_gfx_fb_ops, s); return true; } + +/* ------ Display mode list device property ------ */ + +static void apple_gfx_get_display_mode(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + AppleGFXDisplayMode *mode = object_field_prop_ptr(obj, prop); + /* 3 uint16s (max 5 digits) + 2 separator characters + nul. */ + char buffer[5 * 3 + 2 + 1]; + char *pos = buffer; + + int rc = snprintf(buffer, sizeof(buffer), + "%"PRIu16"x%"PRIu16"@%"PRIu16, + mode->width_px, mode->height_px, + mode->refresh_rate_hz); + assert(rc < sizeof(buffer)); + + visit_type_str(v, name, &pos, errp); +} + +static void apple_gfx_set_display_mode(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + Property *prop = opaque; + AppleGFXDisplayMode *mode = object_field_prop_ptr(obj, prop); + const char *endptr; + g_autofree char *str = NULL; + int ret; + int val; + + if (!visit_type_str(v, name, &str, errp)) { + return; + } + + endptr = str; + + ret = qemu_strtoi(endptr, &endptr, 10, &val); + if (ret || val > UINT16_MAX || val <= 0) { + error_setg(errp, "width in '%s' must be a decimal integer number" + " of pixels in the range 1..65535", name); + return; + } + mode->width_px = val; + if (*endptr != 'x') { + goto separator_error; + } + + ret = qemu_strtoi(endptr + 1, &endptr, 10, &val); + if (ret || val > UINT16_MAX || val <= 0) { + error_setg(errp, "height in '%s' must be a decimal integer number" + " of pixels in the range 1..65535", name); + return; + } + mode->height_px = val; + if (*endptr != '@') { + goto separator_error; + } + + ret = qemu_strtoi(endptr + 1, &endptr, 10, &val); + if (ret || val > UINT16_MAX || val <= 0) { + error_setg(errp, "refresh rate in '%s'" + " must be a positive decimal integer (Hertz)", name); + return; + } + mode->refresh_rate_hz = val; + return; + +separator_error: + error_setg(errp, + "Each display mode takes the format 'x@'"); +} + +const PropertyInfo qdev_prop_apple_gfx_display_mode = { + .name = "display_mode", + .description = + "Display mode in pixels and Hertz, as x@ " + "Example: 3840x2160@60", + .get = apple_gfx_get_display_mode, + .set = apple_gfx_set_display_mode, +}; diff --git a/hw/display/trace-events b/hw/display/trace-events index a50e4eea0c0..52786e6e184 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -212,6 +212,8 @@ apple_gfx_cursor_set(uint32_t bpp, uint64_t width, uint64_t height) "bpp=%d widt apple_gfx_cursor_show(uint32_t show) "show=%d" apple_gfx_cursor_move(void) "" apple_gfx_common_init(const char *device_name, size_t mmio_size) "device: %s; MMIO size: %zu bytes" +apple_gfx_common_realize_modes_property(uint32_t num_modes) "using %u modes supplied by 'display-modes' device property" +apple_gfx_display_mode(uint32_t mode_idx, uint16_t width_px, uint16_t height_px) "mode %2"PRIu32": %4"PRIu16"x%4"PRIu16 # apple-gfx-mmio.m apple_gfx_mmio_iosfc_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" res=0x%"PRIx64 From patchwork Tue Dec 31 20:22:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854425 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090346wrq; Tue, 31 Dec 2024 12:26:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXRe6OsUVR7zie85bwKYPwIbUG6xtL5LDXqYaHeYmwNtRtORw/jkygV7vND771Fzd0vFtFsAA==@linaro.org X-Google-Smtp-Source: AGHT+IHk+WOG/90t1uWh0JiyDDXa/k+2KUmteNJXWIUut44rg6t0LnYn3Y2Shy1LSYE2AfIIHme5 X-Received: by 2002:a05:6214:e48:b0:6d8:95c9:af2b with SMTP id 6a1803df08f44-6dd2339ff71mr615769006d6.35.1735676804196; Tue, 31 Dec 2024 12:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676804; cv=none; d=google.com; s=arc-20240605; b=d/88pPCW02lTq+QEozQ0fzkZHXdGAhAmkiVQ8HJ5pECSK0K47fFCrxSRV93UPPK3Oj ylup62pngHMQKuAqiUXQXLV16tyeDKGqXZIZnI8uX/B4JWVC+7vBA8SpQbI2gjxcXGZM HLc2ffCx1qc6mbXaMApzaLPKg5H++VrXe4jOotS+bXTVjjDOv7tWSFXj2oNlTV/lvlX4 1Q2ZO8MI4QdgkiEEZyzHg+zSmaJTa2FFlIaJlDyKB5K0KEdR33OfUqNKvsRElnuC+R/3 aez0sRPQUhwtsi1T0KmPaL7spk6wHFStqaNUF1XjUyut9jzOKXs46DdygUd541Utws4X e3ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kYhhix/9PVscVBbQFIH04IFrmOJJ4Qi4bOjmujehVDo=; fh=MV21/qroXpcfdSaNRGn3TYkVC1OkcaRWkUBqZrCAeec=; b=Al9TFXvVLH6ByDh45s3NYHbbmxSFMP0DENh3gT9ZZi+RgZ7l5IRyDZQYA30ry9XFmi WUKYoSVyVvbZipelIbmJ7rk42xyOjKWd/BdLAWhw2KCbn2nYyTrBPG6uqJ4OP3yoC/G7 33pGac0Vx1Z5/IHLX+xCyu8wePHPeAw1Cv4ejSo51OqLn8hCz57SO9B3ZhASkztbeLYK bdDz3yUt6R1vu1XT+dFE/jChQ1QJ33YQr2WgiFx+LwGsoBGqLxVV+6eRD7cDgIraPXKL cxogAvGYAOouy2YlZvKa6pVhC6MHd7ds5Fr8XQ8O3D7MpB1CQ1o8dbOh1oORvEQeFegB q5Pg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jnLNRf42; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18233698si303756646d6.220.2024.12.31.12.26.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:26:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jnLNRf42; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSinR-0001mX-3p; Tue, 31 Dec 2024 15:24:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSinK-0001Bw-L2 for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:50 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSinG-00011k-1f for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:49 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-43618283d48so75091835e9.1 for ; Tue, 31 Dec 2024 12:24:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676683; x=1736281483; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kYhhix/9PVscVBbQFIH04IFrmOJJ4Qi4bOjmujehVDo=; b=jnLNRf42L517PD/EkOg2vVWwQgeUoUnXveTfBP9eLcpraDScT3Jtd7tV3Mdrwq1ffr 5xX5h0P6xpcwCTl9nRYWuYvpIFqMuhi+aJ8CpXr6q2FTtpmwg9wbwdyl8NUVp0iRxFUG wtQEzIxv+5ndPW5wk7zyGA/x4jHBaXH98K+HykvWp3eCT6WCTPzMsbzsaDliCItGanc7 AIKHD79zB7rPbH1EUK48iGMtE9OroNaFD9rXqtTMhGTi77kRUMXzoXMEph7Y9fubMxb2 o/wgmHlp0/1ckY1o6nMcOz7mVL8epcrZBFLUbSx8QexsV7BM2JD3F2PYQN9v59UK3NOU PO3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676683; x=1736281483; 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=kYhhix/9PVscVBbQFIH04IFrmOJJ4Qi4bOjmujehVDo=; b=oMFFzzHZl+LzprGuSvMdY0Lugf2rQI+s1pLRzCl2ctc3rVHJi06qCNSVMBrLObiD4M 7fbpGbpdeuXQiL4SvGQDb/FXDJRUvUVHmjZcvfgmmdzp3u0TDDLv/rDzNSOPmSolR77t iagAlO9x/+ehOozWMbzj2iD4yTNIt8Bar+6FLcmJa5bPNCqobKA/yYfLOtGuoB6VrX8T b4uPhKAlphEfGon7OYUnn6LnM1UhDUQugEe6qqeogh3cpymGGdWGkH2hsAeI5BPxry+1 uSQpi8bkC2ffSRNoTamOcOR3fhQ+yXV/QHwquIoOlGWhnPBznT+cjsP9BquUuYK8ksJv 5meg== X-Gm-Message-State: AOJu0Yydt0JyvwiXJ9KDbdhGiraunRsOqDdK1iiDZFQXpFz8EYjrHljM phL3drL5XDoa7zjK0S9AYnkZcQhI8L5n/JnNMsMQEh0Fl/g89BdqlElPxXBcbf6IM/zFG4ZaZR6 ywVQ= X-Gm-Gg: ASbGnctn4Qfp9facwDUXbyq+P13z5EOdYVrGGlDVBPE4h6FwmYu471eDo0HO48BvVqf 8tzpRv1zu61jmbaYB9RRRjW6LkidB7gz8NYHZkPzgGZyeJrkZlF9Ibogoia1c6SNpOB08OB/xo+ 6aIUJfBBqybMuMxS2jw/zlczqPR9b5YZi+EiIZUPSuuVOQz04QqKfsPf/RI8sRSwT0T/16BOsmH RBHItawFUp/pkeScYtxw4oa6kCXu9n8r10kKvHeSc0spVkcX79AYQmGa1vcmNMKSJ3v7+DRDtcz ny3CmLmfglrMdKTWp7Ik8W33kuVnwBE= X-Received: by 2002:a05:600c:3b23:b0:434:9499:9e87 with SMTP id 5b1f17b1804b1-43668b5e194mr296086495e9.25.1735676683417; Tue, 31 Dec 2024 12:24:43 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436611ea3d5sm402023665e9.5.2024.12.31.12.24.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Phil Dennis-Jordan , Roman Bolshakov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 27/29] MAINTAINERS: Add myself as maintainer for apple-gfx, reviewer for HVF Date: Tue, 31 Dec 2024 21:22:26 +0100 Message-ID: <20241231202228.28819-28-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Phil Dennis-Jordan I'm happy to take responsibility for the macOS PV graphics code. As HVF patches don't seem to get much attention at the moment, I'm also adding myself as designated reviewer for HVF and x86 HVF to try and improve that. Signed-off-by: Phil Dennis-Jordan Reviewed-by: Roman Bolshakov Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20241223221645.29911-6-phil@philjordan.eu> Signed-off-by: Philippe Mathieu-Daudé --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 38a290e9c2c..2101b512175 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -509,6 +509,7 @@ F: target/arm/hvf/ X86 HVF CPUs M: Cameron Esfahani M: Roman Bolshakov +R: Phil Dennis-Jordan W: https://wiki.qemu.org/Features/HVF S: Maintained F: target/i386/hvf/ @@ -516,6 +517,7 @@ F: target/i386/hvf/ HVF M: Cameron Esfahani M: Roman Bolshakov +R: Phil Dennis-Jordan W: https://wiki.qemu.org/Features/HVF S: Maintained F: accel/hvf/ @@ -2631,6 +2633,11 @@ F: hw/display/edid* F: include/hw/display/edid.h F: qemu-edid.c +macOS PV Graphics (apple-gfx) +M: Phil Dennis-Jordan +S: Maintained +F: hw/display/apple-gfx* + PIIX4 South Bridge (i82371AB) M: Hervé Poussineau M: Philippe Mathieu-Daudé From patchwork Tue Dec 31 20:22:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854422 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090185wrq; Tue, 31 Dec 2024 12:26:13 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX7DFUirg2TkgNyH0rGJHJZOwwl8WaIqzTI3M5PhSX6/GLNalkGNw9ecpdFxD1KE8qwIF64gQ==@linaro.org X-Google-Smtp-Source: AGHT+IHOUhFw0Fky2z19PGslssiIfy1aUs7ICiF8JjHixVZkZkQowdm841WkayTv5qNiAdWuDWRN X-Received: by 2002:ac8:5751:0:b0:465:3a62:a8f9 with SMTP id d75a77b69052e-46a4a9a436dmr795939031cf.50.1735676772792; Tue, 31 Dec 2024 12:26:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676772; cv=none; d=google.com; s=arc-20240605; b=N9WUcCGhTTeZX4khMSw7UFu4pVOVkLf76k8SRX8x4qkeZ65CZyF99ltDrOmN4RWjI0 UPrJCuG0dW89V5cSzZ/Uu+iuIS3wRDBvC52kT5NLeT7czYl07wwweNozaXQOcScIz7Rs fEGZj/Vtj/uHnrXa5H2axEGC3tnqw5g8va0AVKFipmyCPpuLdxjhn1oDz6G6L0F+QhM+ WkJudOjtFXOzlkLSuSwVZsrx6OMA/3Yx0xSGsUQs2Uj4512eevFrnF6L/trwdD8zh5qa KmLSuClPFj7WlQEGbcQ2eUpJCJGs2M2vMvuj2JAon5Zz69eiCgeHr862WxYvwy8g3uJg tEEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AloPmLUtJIdEn3N27rO6zDqGnD5UcjWX7RRR5V1X2ow=; fh=uFXjJShbbTDTIBTXW3Ai8PxnDc+PR8dmclHLaPJ+IPE=; b=WxBn8oheutjneXNIeph5px07gKH07WM14aW7YCETATHIaDtNsytCW0dzvSGYveZQyi kqwxaNdWKw2ONNHzQG83SA62NB457+xh0+YBb98sUt0SbZajnO0mkhSqtLzivquci9Ya ASTfrhiAytUkA+H0r+DXPsbCadegndVUkC6dyK0SkYYp9MO+YzpDjjAT7eTUCN2yw3V4 8aQbayf+Y6+JZQU0KIi92b8EiIFETpgoqMNqS206pE//1+kNJ0WoYUXeaihORG/AfQQG afcOkaFjS08wROfrBDOXERuxx28G7v52ukCaRFD0A5TOk1CAvrM8wv9pBqBq1VA09P74 Gi8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=snu2RYw0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46a3e6ad683si330064571cf.195.2024.12.31.12.26.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:26:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=snu2RYw0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSini-00026J-Bl; Tue, 31 Dec 2024 15:25:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSinO-0001jP-Qw for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:55 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSinL-00012U-Oc for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:24:54 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4361f796586so106901725e9.3 for ; Tue, 31 Dec 2024 12:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676688; x=1736281488; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AloPmLUtJIdEn3N27rO6zDqGnD5UcjWX7RRR5V1X2ow=; b=snu2RYw09AfV61WBEZGxUx/cihUsE4gekL+Zmxfic+lEOcMxuwKRJbrUuXQNVYRang vXfDRIOUUiR3gN2gmDLEjEm+rL/cPfxSVZOr0mKwsdUYS+Qs2rEy6wTmAzmyVF8oZkZm GOsTZklIktlU2ATK2blJeyobb/yc2IvOzhY3u0i55cyNv19ym0qyadrduRviIGgQL17d bj4FQwD8X8kUKvhkV4t9lXPG6fIGE5hHckCUkw9cQ69oenY6s6bgjB9cDqvMJdP8vivS uBJlGHTrPaz7cL9VfwgKJgyADqTQo8KSfa8Zr+Y6lTI4KZXQ4R8JFNeC/LFgC8LCqsBb qYcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676688; x=1736281488; 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=AloPmLUtJIdEn3N27rO6zDqGnD5UcjWX7RRR5V1X2ow=; b=hOlw3MK1mRs9mYKMzVJQgOWs+qxSes6dhqtOZLASCVdKiDxqwEHiTzugu7ffEWfTGk tgZ7s64f8IiwY4w/wWbKbjn6b6tuVz12nlleyiEx53XLu/5cDsNqNUvKAEbsDDbbvhky Rt1v6t5GFHxOWOqNWt9JX9O6z2KIYvT7L6FbSZ/SGPCRIueaSDDjxP6QlKnc4LvsPM38 phmlU9Dc5tGwDIs0WMAkyHcSMnVGWF06Hwe9VWx4TNwnSjQ1c789KLypLWvDmAd+c3CT 9Sro9vscQVU77L+jjX665JyrYSKF35tbN6F7V5r9PoAJFCpi+YiR7oOPM/cLXV2vDxd3 XB3g== X-Gm-Message-State: AOJu0Yyx0tP2deqyk+bD+BxbEIyQw750KLFHD3IutUFfsfHwDDWfpF/g +NuYmfDFVLrw4OclPQIpQBqDpaMIVkGxaOcOgFGR0aZ5e34ZZmfCZR9ATG3xJ7X5dbdw9mtGDa9 A3U8= X-Gm-Gg: ASbGncvxjdxmru6Qo67coUU/kA/3cvtlHwRApe9h6UygiyEnKOO8WWN8AwnejOr1H+k Sq6g/mopeQtUjhU2BRDH1TTHyiQFA24IV9zvYJLRsV88bLJVduaURJqSYlqlDTXABNSI+xlBrXK IeFFAqocLQlRYc21/AA5b2QAuapCJEICIw4agySzBDjUEMUGqwH9CAmZteD8dcWaVGFeDbtCZ8H 6UvseRePlfYWSttD2k970KkDvDjICwM0HTHjG4sDBg1Jd3Ya4l/HaNw2KHlvIQfXyzP7h64twFs u6dzGGaSJmKdbjaSDDc6UJiBAlqXi1I= X-Received: by 2002:a05:600c:4f95:b0:428:d31:ef25 with SMTP id 5b1f17b1804b1-4366854c111mr370799555e9.12.1735676687957; Tue, 31 Dec 2024 12:24:47 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b119ccsm431476045e9.24.2024.12.31.12.24.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:47 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: William Hooper , Phil Dennis-Jordan , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 28/29] net/vmnet: Pad short Ethernet frames Date: Tue, 31 Dec 2024 21:22:27 +0100 Message-ID: <20241231202228.28819-29-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: William Hooper At least on macOS 12.7.2, vmnet doesn't pad Ethernet frames, such as the host's ARP replies, to the minimum size (60 bytes before the frame check sequence) defined in IEEE Std 802.3-2022, so guests' Ethernet device drivers may drop them with "frame too short" errors. This patch calls eth_pad_short_frame() to add padding, as in net/tap.c and net/slirp.c. Thanks to Bin Meng, Philippe Mathieu-Daudé, and Phil Dennis-Jordan for reviewing earlier versions. Signed-off-by: William Hooper Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2058 Reviewed-by: Phil Dennis-Jordan Message-ID: <20241102205653.30476-1-wsh@wshooper.org> Signed-off-by: Philippe Mathieu-Daudé --- net/vmnet-common.m | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/net/vmnet-common.m b/net/vmnet-common.m index dba5b5bab13..54d900ba679 100644 --- a/net/vmnet-common.m +++ b/net/vmnet-common.m @@ -18,6 +18,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "system/runstate.h" +#include "net/eth.h" #include #include @@ -147,10 +148,26 @@ static int vmnet_read_packets(VmnetState *s) */ static void vmnet_write_packets_to_qemu(VmnetState *s) { + uint8_t *pkt; + size_t pktsz; + uint8_t min_pkt[ETH_ZLEN]; + size_t min_pktsz; + ssize_t size; + while (s->packets_send_current_pos < s->packets_send_end_pos) { - ssize_t size = qemu_send_packet_async(&s->nc, - s->iov_buf[s->packets_send_current_pos].iov_base, - s->packets_buf[s->packets_send_current_pos].vm_pkt_size, + pkt = s->iov_buf[s->packets_send_current_pos].iov_base; + pktsz = s->packets_buf[s->packets_send_current_pos].vm_pkt_size; + + if (net_peer_needs_padding(&s->nc)) { + min_pktsz = sizeof(min_pkt); + + if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pktsz)) { + pkt = min_pkt; + pktsz = min_pktsz; + } + } + + size = qemu_send_packet_async(&s->nc, pkt, pktsz, vmnet_send_completed); if (size == 0) { From patchwork Tue Dec 31 20:22:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854424 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7090306wrq; Tue, 31 Dec 2024 12:26:35 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX2EwPginBQFIGZDgcvkS+fVxpwC+IN/SwLmmJkJqRXDWEahlajR+a4l4X3HB9gz0jkrzrRqQ==@linaro.org X-Google-Smtp-Source: AGHT+IFXzysZyH3ncCSq05x6ZOofFIdEsx+PMTR17ZzLEQnCcEKcoMwsDQwzeGBhYBiSXOf4rSYQ X-Received: by 2002:a05:620a:d87:b0:7b6:d632:37be with SMTP id af79cd13be357-7b9ba7030f6mr6744584085a.4.1735676795076; Tue, 31 Dec 2024 12:26:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735676795; cv=none; d=google.com; s=arc-20240605; b=BLal2IkAnaf9MHrhsOCHQFrXi1JUCHlDa70K2cIxuNoGWpWhfZKrndj93gr2vLHdiC F7JqEyg3pWcpEJ4lZwnD1dexIGfW/PeVJA5z8jiUBnQ2OfGrW0laVPEvxKV+w6h+zNLh NFdpDkNQ9sl4aQo3lIx6MuRb9MzGxj74FdfVFfRy/tQ58batneo3FyMYvgHQ5SjmpxQ4 QtoAgEdLesqiM+sVNZ1r7m0ItYi6NQFD430i5hZ+XgvU94/vzxmgPu9gXphtb2dZOye0 v4GOxk/dIKG6vU41LNJcYKT7nNSCmZ5rJCNt7PW0Q3fZtjNb2FUcyctK9xtnZO4cogHH lPVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uTSP6NjIVoPRvTo3NrDC/CEb4C93RSiNfhEoUzld/gc=; fh=0YaeOFMHf5oh/GYEwSKwJ6rfU3OOC1PV+1N0eDscNYo=; b=R4eoJpDF7o9cLi9Phxjco2Rg903/NZHKuQKi1rEo5ZQmjiY1In34+UqsyYkz56WwQB TVzd+b/80IFC9adEcrFOSuvC5JnQROmNWfFCDasnzqVP7qh++Pm07fHhXq94Y+ePitSx 6sFPvIFYvlUb5khGrCr4gtKnI/J5JYBf1ITF1BGdo811CxGNnGTB0+MK8007ciXwamFB 1yI1astLuqb9avbfo+VBJdm4p1r5Kej8/1q0lx42bA5OvOpEG8rT0xptzVeMLVydJ7Yr XjahC7mkBZ2dVBo8LKBkuVB6F7M0lPwQ7Y/YqYNdHyu+a60MSGLp12CBNq8TOW/lHoc4 P1pw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eatyQC9R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac47876esi3020180285a.349.2024.12.31.12.26.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 12:26:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eatyQC9R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSinz-0002s2-VB; Tue, 31 Dec 2024 15:25:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSinU-00022x-NA for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:25:04 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSinP-00013e-9d for qemu-devel@nongnu.org; Tue, 31 Dec 2024 15:25:00 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3862b40a6e0so5703483f8f.0 for ; Tue, 31 Dec 2024 12:24:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735676693; x=1736281493; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uTSP6NjIVoPRvTo3NrDC/CEb4C93RSiNfhEoUzld/gc=; b=eatyQC9R9q8LniTPPfelaNasXQyUn9FvlX30TU0mVAlUGVUsMw8fBd7hXl79QEjSAN t12vg+TRSgrHRZ8PA/2wUsZCd93mjsb/NLNTfIlgf7OdZGwFQWIdcbxb+teFjyjSGL1a gGewi5UjUmP0v0SbxoAjdnw93lcTnYpd2xDwMOsFbvtAfPpgeCN0er3JAfsJtY66Tyav jEGTJsQp08aU039ba0B+ZV8Gv8o2wtDAuvb056pTGs+lqm6TDcGrId0X1NGwB+IhXwfE MH03LqZgYSxuNpkyeuoiw9pNLZW3nWALPeJM3ORom6wGBNXSMD+NGV7IWHX3BxOcc9rG 3L4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735676693; x=1736281493; 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=uTSP6NjIVoPRvTo3NrDC/CEb4C93RSiNfhEoUzld/gc=; b=a1rOfcqBy+i0Ar+pyMYycrlOZ4q5lZ3NahW8ZWlUJFJZM9JMUmeFXZj7ExUs7144f1 NS0cz/DqpQYRtoTaDdaAgdhpB9CE6nSQTKSJTpEA1zSd50KbdqpAgCBq5MyloGMtyWN8 Db8TMUk1/TNTRoHxr6eQ2aiWEuNs9+9IJIPTro+Dn9om3eQm+uTLwDCuDeycuQJtS/e8 sSX1p341XvaUxeydRfFIknajDt1YdKvHE6becAZaKRp25kXbrfqp17AwMBbyTz5AJN+O 6LctKnTuCXcdtJZg9e6kyag+K/me9qi4syeUZHjG20AMqIG/fo2xk2+KUAL15JY+T1JT IsAA== X-Gm-Message-State: AOJu0YzIG2fMqx3PWX8ylrZ2BHEMqUHQy4qCW4G/Rp768xXPJn6XE5FZ UFb5JDZ3nZP+/lCYPlaTm7UYnex8CY+XPPXcuFgCkW0tcDfeuTDQGa4zGIfSXvYj3qlhMMsjZAz 36+o= X-Gm-Gg: ASbGnct/PapmqFB5pv6k3u72epDSNeJFjHrR+3OWgMn7FT90AntaAMQZGIr8O047/Wm PtUKA6gW+vgyXAvcKr5GSWcOKmxeTvxFSZ0qVs1OV5M2W1zJRAlWmGOsKdPxvtY5T6JmWpBdSPT zlptdZwSd0Gat8/lxMqdBM8ksu5kp5E5Ioo4q9LSuSv5lw3bKbihdvlXhjFQykAHFW188My/eqN /i07opF1kS+bVEfsB0+wFziSltaDdLC95gUI4fYOW/gOZqa3AYfjRuOYlWyUNbMjKE+i4gNTsCE Zx49xqOj6tne5/+Shva8XRO1Z70RAxY= X-Received: by 2002:adf:ab49:0:b0:38a:5ce8:df51 with SMTP id ffacd0b85a97d-38a5ce8dfb8mr2609028f8f.2.1735676693219; Tue, 31 Dec 2024 12:24:53 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436611ea42esm404643215e9.9.2024.12.31.12.24.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 12:24:52 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hyman Huang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 29/29] hw/display/qxl: Do not use C99 // comments Date: Tue, 31 Dec 2024 21:22:28 +0100 Message-ID: <20241231202228.28819-30-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231202228.28819-1-philmd@linaro.org> References: <20241231202228.28819-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Hyman Huang Do not use C99 // comments to fix the checkpatch.pl error Signed-off-by: Hyman Huang Reviewed-by: Philippe Mathieu-Daudé Message-ID: <7d287eaf00e0b52b600431efd350b15a0b5b3544.1734633496.git.yong.huang@smartx.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/display/qxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index f54a15e7404..2efdc77e613 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -50,7 +50,7 @@ #undef ALIGN #define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1)) -#define PIXEL_SIZE 0.2936875 //1280x1024 is 14.8" x 11.9" +#define PIXEL_SIZE 0.2936875 /* 1280x1024 is 14.8" x 11.9" */ #define QXL_MODE(_x, _y, _b, _o) \ { .x_res = _x, \