From patchwork Tue Apr 25 07:45:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 676813 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2562852wrs; Tue, 25 Apr 2023 00:50:40 -0700 (PDT) X-Google-Smtp-Source: AKy350bcmoj5oGvdRM0Vr3tpK4blC8+IMN9TFCAXg3Sudd+0W3s/6c6geODtu1oxyGcM4fAPyWi+ X-Received: by 2002:ac8:5bc4:0:b0:3ef:983:f4fd with SMTP id b4-20020ac85bc4000000b003ef0983f4fdmr27851087qtb.53.1682409039814; Tue, 25 Apr 2023 00:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682409039; cv=none; d=google.com; s=arc-20160816; b=GoL25CZbVQ447rUd5329Bpci9vZSX8qWba3yaI4ujQAItCIlGio1Y1U1ocMt0k81lc nz4OWalV6YW7ttn9yyg2LLAAf5thB006BvHm9DIPEUO5NHshTbswEmdyn6xnamxQhB8Y +qf+qXuxPPhYnZS2VPmLJNwaTLXOsDN+J8I89wy/S2sMxDF3sPyI2hhzMHWTvINTooo3 Nl3Q10fSBp7AUMPHMMtB7CnEMCBx6YzlTqY5RDjHOgLetyvO7c6ViY0pehxVYkVVNqn7 G/bu+JuOap5j6jBLSLRr/mg1vxG1XZua6I60QmuvbgDj86ardvXPcVJKUXKVKyM4W+af Oarg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=r7X86YUKsr6DaUP9RJPAougsaucvvbmX812GyuJi0kM=; b=PQ91IyoI+2kp0MsNcbyIOJzEX0PqtYeTrt5VY1rZFnyAE3SQQ/oqxvtMsTcBHHx1xd 9Kf+u+IrmZBD4URzQRK0ddjAKgHwQH2ubNFseTZmm/JQS1aSzVQMw7zmRRWRPMnXCO8+ 6vcnjuRzymE/W9J0iEOAYU4VnL0LPr/f3Jf7jI9nWJQxurWU73oCp0q4py6GO97kRatH 5deu6PkS9lGlLP1n7tzUU9h2opYbG52sLo0Kj7A45pRZrtORgXR4Gja0LK7tunE4e0cB a3Ej/uDreyvmykXDDY1MzaxkDIMWKbK3UkLIXPF3cPXBF81JdJ9fqQl696kL2P+hvIED /Pmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gbcIxVgZ; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w5-20020a05620a424500b00746aaaf86f1si8448678qko.321.2023.04.25.00.50.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Apr 2023 00:50:39 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=gbcIxVgZ; 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=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prDMo-0007Ny-Uk; Tue, 25 Apr 2023 03:45:39 -0400 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 1prDMn-0007Fw-HJ for qemu-devel@nongnu.org; Tue, 25 Apr 2023 03:45:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prDMl-0006lE-ML for qemu-devel@nongnu.org; Tue, 25 Apr 2023 03:45:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682408735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r7X86YUKsr6DaUP9RJPAougsaucvvbmX812GyuJi0kM=; b=gbcIxVgZWHXosipeOyL3fhF2tO+Y6QXyCa+n+3+O3rVVtVcey4daSCRoWCo5lzwSlkVQqN BavxFElXjLcNyP3iT7jeGVwMoFLFSHKQas02NLv895+3BMs6tEcUeC8mSoChZrUQLWuP3e 3Sx2OCWlMqxy8TxID+wLTYMiRng3TDY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-gKkS6dKZP8yiVutB25p1Tg-1; Tue, 25 Apr 2023 03:45:33 -0400 X-MC-Unique: gKkS6dKZP8yiVutB25p1Tg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-2ffee43dac5so1939023f8f.2 for ; Tue, 25 Apr 2023 00:45:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682408731; x=1685000731; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=r7X86YUKsr6DaUP9RJPAougsaucvvbmX812GyuJi0kM=; b=he4Z+k0wmDXb/UVLk67cRWXJmTP8vwt8zkpTLDGTWdgR3OhqC/pC2qkvWlIxhcaQSz buiPiPTgsY431LpcdQ/xMuPCa0jc7clt8E9niuxsYYlKd5uVa1o7hFPhHo6EuC+qRIVS xFbv2j9tKztrVurjKWriDrmaQbINHbrpENEq/3y6VG1eXxBPyolcrPjMoj093WjT0sR/ jYC6AQT66tbPc0f7+nonyHik7LEfFOsYTJWjjWxzHmEDhpaQ3yuP/DiQc7V8upgtM1Ao KP0MPJnkS+ZqbNbauxxg6P/jIzqG8+ZmGe2Exh+0RpNUYEea+MtH+Qa0rPldhcc1GT4G NZhw== X-Gm-Message-State: AAQBX9e5sMTfM+fu43gWS0ZIRfJfqG84E4luQiJdsVsQcCrntvrfXH9h 1L18Twa1bSYTSVMrZVZO4jhXDwBZBqGkIFi8/CA8oo8IFEgltox+PYPYy/uXHGHHFaPLX7MdPZF LmzLMu2cjdpTQ6dxKy57ApxAePjQxiFjrCvEEMLrbJpNfKS1QNXaYMu9Q8emBBm/c+E0U X-Received: by 2002:a5d:570b:0:b0:2fb:11ec:f2a1 with SMTP id a11-20020a5d570b000000b002fb11ecf2a1mr10403978wrv.20.1682408731216; Tue, 25 Apr 2023 00:45:31 -0700 (PDT) X-Received: by 2002:a5d:570b:0:b0:2fb:11ec:f2a1 with SMTP id a11-20020a5d570b000000b002fb11ecf2a1mr10403957wrv.20.1682408730883; Tue, 25 Apr 2023 00:45:30 -0700 (PDT) Received: from redhat.com ([2.55.61.39]) by smtp.gmail.com with ESMTPSA id b9-20020adfee89000000b002f777345d21sm12391227wro.95.2023.04.25.00.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 00:45:30 -0700 (PDT) Date: Tue, 25 Apr 2023 03:45:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?q?Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 12/31] hw/i386/amd_iommu: Move capab_offset from AMDVIState to AMDVIPCIState Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.171, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: Philippe Mathieu-Daudé The 'PCI capability offset' is a *PCI* notion. Since AMDVIPCIState inherits PCIDevice and hold PCI-related fields, move capab_offset from AMDVIState to AMDVIPCIState. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20230313153031.86107-5-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 2 +- hw/i386/acpi-build.c | 2 +- hw/i386/amd_iommu.c | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 5eccaad790..1c0cb54bd4 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -308,6 +308,7 @@ typedef struct AMDVIAddressSpace AMDVIAddressSpace; /* functions to steal PCI config space */ typedef struct AMDVIPCIState { PCIDevice dev; /* The PCI device itself */ + uint32_t capab_offset; /* capability offset pointer */ } AMDVIPCIState; struct AMDVIState { @@ -315,7 +316,6 @@ struct AMDVIState { AMDVIPCIState pci; /* IOMMU PCI device */ uint32_t version; - uint32_t capab_offset; /* capability offset pointer */ uint64_t mmio_addr; diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a27bc33956..7f211e1f48 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2399,7 +2399,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, object_property_get_int(OBJECT(&s->pci), "addr", &error_abort), 2); /* Capability offset */ - build_append_int_noprefix(table_data, s->capab_offset, 2); + build_append_int_noprefix(table_data, s->pci.capab_offset, 2); /* IOMMU base address */ build_append_int_noprefix(table_data, s->mmio.addr, 8); /* PCI Segment Group */ diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 19f57e6318..9f6622e11f 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1516,15 +1516,15 @@ static void amdvi_init(AMDVIState *s) pci_config_set_class(s->pci.dev.config, 0x0806); /* reset AMDVI specific capabilities, all r/o */ - pci_set_long(s->pci.dev.config + s->capab_offset, AMDVI_CAPAB_FEATURES); - pci_set_long(s->pci.dev.config + s->capab_offset + AMDVI_CAPAB_BAR_LOW, + pci_set_long(s->pci.dev.config + s->pci.capab_offset, AMDVI_CAPAB_FEATURES); + pci_set_long(s->pci.dev.config + s->pci.capab_offset + AMDVI_CAPAB_BAR_LOW, AMDVI_BASE_ADDR & ~(0xffff0000)); - pci_set_long(s->pci.dev.config + s->capab_offset + AMDVI_CAPAB_BAR_HIGH, + pci_set_long(s->pci.dev.config + s->pci.capab_offset + AMDVI_CAPAB_BAR_HIGH, (AMDVI_BASE_ADDR & ~(0xffff)) >> 16); - pci_set_long(s->pci.dev.config + s->capab_offset + AMDVI_CAPAB_RANGE, + pci_set_long(s->pci.dev.config + s->pci.capab_offset + AMDVI_CAPAB_RANGE, 0xff000000); - pci_set_long(s->pci.dev.config + s->capab_offset + AMDVI_CAPAB_MISC, 0); - pci_set_long(s->pci.dev.config + s->capab_offset + AMDVI_CAPAB_MISC, + pci_set_long(s->pci.dev.config + s->pci.capab_offset + AMDVI_CAPAB_MISC, 0); + pci_set_long(s->pci.dev.config + s->pci.capab_offset + AMDVI_CAPAB_MISC, AMDVI_MAX_PH_ADDR | AMDVI_MAX_GVA_ADDR | AMDVI_MAX_VA_ADDR); } @@ -1557,7 +1557,7 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) if (ret < 0) { return; } - s->capab_offset = ret; + s->pci.capab_offset = ret; ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_MSI, 0, AMDVI_CAPAB_REG_SIZE, errp);