From patchwork Mon Nov 25 14:05: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: 845317 Delivered-To: patch@linaro.org Received: by 2002:a5d:688e:0:b0:382:43a8:7b94 with SMTP id h14csp1197390wru; Mon, 25 Nov 2024 06:07:31 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXfw7gPCZMXXw+7qh/mraN5tLdes2sL0qMel8MqNKdSwUlkUIIGSt7AB0941fLfkJNvXPt6Gg==@linaro.org X-Google-Smtp-Source: AGHT+IHCiT/IC8kADmBf9s2sjDHuKLEFpJ5LNcs84dJKktAuH4uLmvouH9FhW7PNiI3QvSN6MUn5 X-Received: by 2002:a05:6000:2cf:b0:382:5010:c8c9 with SMTP id ffacd0b85a97d-38260bcaf0amr9336030f8f.41.1732543650814; Mon, 25 Nov 2024 06:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732543650; cv=none; d=google.com; s=arc-20240605; b=Y6p3refCf+qt1tvt0u5y6oy6+CNCacKd38Y9OWf/yHcsgEmrrGSy+5PXqSHTUUhtqx URv03Ej/wp3HTeq8rgMZTd4N+6kygFDMxVy9Cokbr8MjzJo4fL2f88Zk7QlC1WqXO3dQ tjlAxj+9l9GWxVAlQ6BgO6VlfeZO10nx1lZIIy5G8b46rBR24kJZyQn5xImoFAY101Bn 3vMrK23j3ouV1EQORvaxJ3K7N5aE/jHS6OvMrqI/95OTewPUucn9bhaJvMInMHxru0iw mjdrhrU/bSyrO8TunqWe07KdvlEbJ74XKUVHx33Ja0jGfopU1F+TX2xVFzCGY1SSR18E L93g== 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=bzQt7LYQ0+9fV8zZopMVzvqsJnnAOoFEcI7W3eeHOtg=; fh=01MTBs686u0z/v+1HBxc617dy4wgnTfT5lmRb9hvZO0=; b=JmcLDK2AcNxr0R+lv5eUoaAjXzYx9FCMV6IQINTHK+oEres1rDMLxViU6uQ14kRj1a GYDMzojOkg9xROWFZqtgOwZdLpoPpPSpl2G7+kCFjk8ClTCt79tnDQ4+jjOl8dBgoU+y ZGVqdemTsp7yRy3nayvRHCWGVg0bYuprnbKVCze4aYm3DKOdnoJUNQ2banKB20aE9Z1M YEVGynTe1Q++DTP+B9Yo1yNXzw7R3RoSLIZbEmO//KfZ1rotLh8brgfE20DGXakVFDYY +/omjxLY+V5CDhvhRy62Zwnv6nknfxDEn13hEeQFVG+7Kz1bktrOGksMtgehL2kmsjuy jo8A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bug7QNop; 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 ffacd0b85a97d-385be98a0d7si249687f8f.361.2024.11.25.06.07.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Nov 2024 06:07:30 -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=bug7QNop; 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 1tFZjT-00026g-Vx; Mon, 25 Nov 2024 09:06: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 1tFZjS-00025Q-Bp for qemu-devel@nongnu.org; Mon, 25 Nov 2024 09:06:30 -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 1tFZjJ-0006YG-FD for qemu-devel@nongnu.org; Mon, 25 Nov 2024 09:06:26 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3823eb7ba72so3038220f8f.0 for ; Mon, 25 Nov 2024 06:06:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732543579; x=1733148379; 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=bzQt7LYQ0+9fV8zZopMVzvqsJnnAOoFEcI7W3eeHOtg=; b=bug7QNopQ/aUzl6OsovFq2Z4orsEwFxEisewcRiZHc6IRI5VgBt8zAPYMk9EI5X3XM 3iZ3pdlNdFvst8PmysalErnlvBtDo49AtI2hna9sDwkurup1o1HbvnbDH+VAyqJMSgAS wvQHfQpFkbicOgsjyaq+NQUAiXIstUnE5czgTsVDorkrNe2GGGylkwf833Ylj7KzPCn4 FJeLXRjE/kZdBWAJD1ORwZ9LtLCnXeS8a8U2k3gvNBR13pu6EUJWn3jIg5t4uVejmvyk sCIYIQOknZvW805BlpRVF41sWjlwZMurqKbEIbzRDmd1v7MIFp7WzGsOw0+oGPRLWbKR UgaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732543579; x=1733148379; 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=bzQt7LYQ0+9fV8zZopMVzvqsJnnAOoFEcI7W3eeHOtg=; b=SF6c0nMFjQdwY+7zIe7ELBWB/WFczH2UG76ILeyHRlVU5ZrHvlA6YJrrm2ND2HlzdQ JtcdgeBFqXBwe9sBBVs3/x2TUtYPZY/7oR/9lOkNGFI4qyxAzXulGZvy1MTwAnpSUbzs z7QEwluqXmiCX3wc88TanUKoWSqLPJ6eQhZiZookR+W7dZDE8kq5LKxGSCJPQTvLlBNp +EUloECXPYKTZrYsGaDkA0PFJGGOl9RbOOKIUMnuQqRBp253v2Co9zeCYyPnaZdNQINf GHxsYMkW8GEV/j1lwE1dgRZRgg1qoUxai9t37viOVRio+Kh6d/474Lw/dDRBU0rMupZg hPuQ== X-Gm-Message-State: AOJu0Yy07OzF2/djxyV9k6AC7HQwzW7TfmV5KlFiAhUOgEeleJHCZ+xL 4yA9P5lkAWwyPH2WD4CZFoHDEI1PmGwPPwsnMkE86xeSSnERXZ7ZDMoSb79Rv/uAAWR9EVaKjxI X X-Gm-Gg: ASbGncuOIduQ29X4OJcaGZqMn8AsZvypY2WKduyv2gTIymlcO8zS0IVmMDi4kt4Krie OJXieb8/jTWoKDJYMKHLLNieNP8Vv7isYRCUIR0/Y3Am30O4pvtI9EBMb/7uIhaUniGk0xJrNiz OZgRjfaAy4vLD1ZRLU/5XPCWEFdY0SwYlTdMAPUdPZQEjuvrC46oPYEAu+OCFA2zMsuiAXp/Kj5 18awXs8FHHEuNYYS/xR9A8PmiGgJ8sAdknIl7aKF93tDBEVAemkUoqW0SWnvsXsXurAs/ph X-Received: by 2002:a05:6000:2102:b0:382:3419:46e6 with SMTP id ffacd0b85a97d-38260be1efcmr8856441f8f.52.1732543568479; Mon, 25 Nov 2024 06:06:08 -0800 (PST) Received: from localhost.localdomain ([176.176.170.239]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fbedf40sm10338059f8f.98.2024.11.25.06.06.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 25 Nov 2024 06:06:07 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , Marcin Juszkiewicz , Bin Meng , Alistair Francis , Harsh Prateek Bora , Zhao Liu , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Liu Zhiwei , Palmer Dabbelt , Marcel Apfelbaum , qemu-arm@nongnu.org, "Michael S. Tsirkin" , Nicholas Piggin , Leif Lindholm , Peter Maydell , qemu-riscv@nongnu.org, Weiwei Li , Radoslaw Biernacki , Thomas Huth , Yanan Wang , Eduardo Habkost , qemu-ppc@nongnu.org Subject: [PATCH-for-10.0 1/8] hw/pci/pci_bus: Introduce PCIBusFlags::PCI_BUS_IO_ADDR0_ALLOWED Date: Mon, 25 Nov 2024 15:05:28 +0100 Message-ID: <20241125140535.4526-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241125140535.4526-1-philmd@linaro.org> References: <20241125140535.4526-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=unavailable 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 Some machines need PCI buses to allow access at BAR0. Introduce the PCI_BUS_IO_ADDR0_ALLOWED flag and the pci_bus_allows_io_addr0_access() helper, so machines can set this flag during creation, similarly to how they do with the PCI_BUS_EXTENDED_CONFIG_SPACE flag. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci_bus.h | 6 ++++++ hw/pci/pci.c | 1 + 2 files changed, 7 insertions(+) diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index 2261312546..5c8b0d2887 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -26,6 +26,7 @@ enum PCIBusFlags { PCI_BUS_EXTENDED_CONFIG_SPACE = 0x0002, /* This is a CXL Type BUS */ PCI_BUS_CXL = 0x0004, + PCI_BUS_IO_ADDR0_ALLOWED = 0x0008, }; #define PCI_NO_PASID UINT32_MAX @@ -72,4 +73,9 @@ static inline bool pci_bus_allows_extended_config_space(PCIBus *bus) return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE); } +static inline bool pci_bus_allows_io_addr0_access(PCIBus *bus) +{ + return !!(bus->flags & PCI_BUS_IO_ADDR0_ALLOWED); +} + #endif /* QEMU_PCI_BUS_H */ diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 1416ae202c..de3f93646f 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1475,6 +1475,7 @@ pcibus_t pci_bar_address(PCIDevice *d, MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); bool allow_0_address = mc->pci_allow_0_address; + allow_0_address |= pci_bus_allows_io_addr0_access(pci_get_bus(d)); if (type & PCI_BASE_ADDRESS_SPACE_IO) { if (!(cmd & PCI_COMMAND_IO)) { return PCI_BAR_UNMAPPED;