From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131324; cv=none; d=zohomail.com; s=zohoarc; b=Yk7Q3QeiG53O5s5mZF44SJFKIgUZpTpCLIaGfwnay/od1ElD5uw72pi9O/4fjGAueycUz3lCosEIc1TlC7iMPI9kdhFT8BKY+PNS0/Xm7ZKdYHJht6FSC3i+AbU3kC9Byp4O2xeUI5K2IESS8DbHnv/BAoCFTjKFqZtTtWyxSu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131324; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=TrCc5tJ7tNpb4UHqNYewv5YRJY1ciA4UDwcY4eIZ444=; b=faiCB7QY8vhuaZhWEoDkZaT5xi4aPqZWklHLQiSVyVX4dIG/Gj/9h+9VlgIBjoVrq7+KdgG6CTgqm6BqRFqcSFL8ai3KrV/3PGxkGcL0kVw/pdv6Q9/drQESsSpI336XbXJ/uRdYdoPzuarsOR+OPrM8K4JIzS0Z6JGBtH3XR1s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1599131324668770.6221390391224; Thu, 3 Sep 2020 04:08:44 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-426-IIAxf2CXP_a96LPTxpzCFQ-1; Thu, 03 Sep 2020 07:08:42 -0400 Received: by mail-wm1-f72.google.com with SMTP id q7so840599wmc.6 for ; Thu, 03 Sep 2020 04:08:42 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id t203sm3782107wmg.43.2020.09.03.04.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131323; 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=TrCc5tJ7tNpb4UHqNYewv5YRJY1ciA4UDwcY4eIZ444=; b=PiU8lLn+Ky+hTxYXbezYrZfMrNWeDp3Amtt4HQI+5fWpHKfnS6UF/nDRrjMxNFkWeR3AA0 2bhlaYUUOcNUVwE/J+ZZyl6apxE9uQTqAvYgUWFEje+yiVF/hTgO42w/MFo+6/uHVYLgF4 aBCjdgni69I3NsKAjDljfW8YOrchIN8= X-MC-Unique: IIAxf2CXP_a96LPTxpzCFQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TrCc5tJ7tNpb4UHqNYewv5YRJY1ciA4UDwcY4eIZ444=; b=YX4Je2qhPt5H2qEZFgiF44MKejN/VdxICaNOYfHel4CpW/g1tRExUoN5wHEWHbLUxQ M+PFY32GQHMUbbSSar2wex2hRyEaiGia/yAEW5CN/CbLUPP0LPh3n6hVJcvSGuXiiFMv TMsIe3Gp8EdOps9w/dch0Kme0YOZ0S1hPASwzfNP6LlN0UfeOHTgL1JUO3bPmC41Iyzp NP9Ab7mX2ZjLevrIEbzJnxBDjZy6SAcvP4ORCo7BD6N6lS9IUfjeCTuGWugk+1GHAq50 Yd5ZjXN2tdOWWPbBAcPyKWl54OmKJZJac0ekDNREd82kCvu8XTriJPkmgUOj5DrkUNfa cZpQ== X-Gm-Message-State: AOAM532VaHYruIvx5aGphMygW+qGnsy2o6IaSMUvvWcrdEAzBNHYnFBU j1UCF476xF0e+tEJ/it/Y38hA3Y9v0WWasIGb6vb7hrYreHM6kpOdU+G2oerwe+NsC3JZgsGuFw fUa7ev/m6Brg7lQ== X-Received: by 2002:adf:ef45:: with SMTP id c5mr1787484wrp.37.1599131321244; Thu, 03 Sep 2020 04:08:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1nDVtyj2C5ereY9H7VxhNf1/u/J+QL0uGJVVe99wm6AacViHBWUkekx13e+NQGBdcWUEh9g== X-Received: by 2002:adf:ef45:: with SMTP id c5mr1787437wrp.37.1599131321081; Thu, 03 Sep 2020 04:08:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson , Keith Busch Subject: [PATCH 01/12] pci: pass along the return value of dma_memory_rw Date: Thu, 3 Sep 2020 13:08:20 +0200 Message-Id: <20200903110831.353476-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Klaus Jensen Some might actually care about the return value of dma_memory_rw. So let us pass it along instead of ignoring it. There are no existing users of the return value, so this patch should be safe. Signed-off-by: Klaus Jensen Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Acked-by: Keith Busch Message-Id: <20191011070141.188713-2-its@irrelevant.dk> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/pci/pci.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 4ca7258b5b7..896cef9ad47 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -788,8 +788,7 @@ static inline AddressSpace *pci_get_address_space(PCIDe= vice *dev) static inline int pci_dma_rw(PCIDevice *dev, dma_addr_t addr, void *buf, dma_addr_t len, DMADirection dir) { - dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir); - return 0; + return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir); } =20 static inline int pci_dma_read(PCIDevice *dev, dma_addr_t addr, --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131331; cv=none; d=zohomail.com; s=zohoarc; b=djS28Syiimz8R5dfDPuqfa6eQMTt5Lcac7/T8GnsdiPVLEjxNDD+Z+Qf7O40GYSV5BaKvOC/ivROK0ZjSjHIgxohOfOGGFI4M7i1tfRe4HXQ6n+NMS7Sp5Z3M759P5XvHAMHuknWvRJyEWcVQchBr/NbiOeJ+iNeUj/sXapTk1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131331; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nruMQlHxT2HZJRXPESpouaZWFiIsjV8XHOgEIt8o5lI=; b=Sw9MuOGEIuwCyHTzm764yfQl2pgmjTnYlyhguyyiECkjqQwNvQ0ZQSMk+9sRRz2+g2RvH4oJ0+/OVHVTus2huYDLNUJgUxPW7cGlfeEj1fbtGYgm91sKMOYCwXGbnH36XmaWy+jpMek+FHyqGDKuQH8A8Uns4zMeRBLWBgo8g/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1599131331510828.5154751616079; Thu, 3 Sep 2020 04:08:51 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-492-Eu-GRY9jMPGfCJnmMLRlUA-1; Thu, 03 Sep 2020 07:08:48 -0400 Received: by mail-wr1-f72.google.com with SMTP id j2so947877wrr.14 for ; Thu, 03 Sep 2020 04:08:48 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id a85sm4028592wmd.26.2020.09.03.04.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:08:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131330; 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=nruMQlHxT2HZJRXPESpouaZWFiIsjV8XHOgEIt8o5lI=; b=VWbYzox3QjKA9jJ+O6GjdFzIELQ2SoyDG26lHSs/qg4AGo+RnTBGkQ7fgBetAFVU9y8X7b kUvZJ1NT/wJI56i3otaHxrGE4Q2dwPZnNTfEF7+8kxP8bvydbCEeby0JnuSXhpd7FNhWtG l0Iqb4RT6+p2HHlkCdeTnTHQm0B4mME= X-MC-Unique: Eu-GRY9jMPGfCJnmMLRlUA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nruMQlHxT2HZJRXPESpouaZWFiIsjV8XHOgEIt8o5lI=; b=PYzI6jh/64UcnNi3cb1L19m0bTEF2YTXrU8d3ippwjWDQTpgkmzh0CoGx0GIrCOS5p 5rh1bHH5xW1KKfmRtaAIwmxkP1ihxOHGg3sjHOxqptKmcmPcBMby9w6bI00K8QddCmbt PYCyu8WvCb7eptfSjgH0E8hZx7/HCaW0h1Za9f7zm9/W6mnLKGS3Dxanb0C7RYsFQi08 bFPGcWZxgNBQT689H2MEdqUTBkEqcSPzJ4avsCjPTNvwk7wkjV/LOMk+SFih3aw85f4H 5qxalEFLHbr6JMGgFZM5VTr0zej0hOlcSIfDggLnwt9glkHs7sETw4ZyMnu6p9gq8/5c kKwA== X-Gm-Message-State: AOAM533inB1iH74SCJCoiCr1IdKqIbSNjueZAofEbFh0aN25WP6NIu1G l1DjFwDjwMTd1r4LTjy7VEcyiTVD88y+3lDoQzI6CUTrS79IFOT7BA4U0kZE13OifHI88gHRmmM d9UgX+OIfM+5EZg== X-Received: by 2002:a05:600c:210c:: with SMTP id u12mr2040111wml.185.1599131327122; Thu, 03 Sep 2020 04:08:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGrtr7MQ758xmiWfsJmkkStZSQEHC0Q3qRpEOKJcrFtHv0snS8g3uYtQy/OAXbkKyFEnYdGw== X-Received: by 2002:a05:600c:210c:: with SMTP id u12mr2040078wml.185.1599131326964; Thu, 03 Sep 2020 04:08:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [PATCH 02/12] dma: Let dma_memory_valid() take MemTxAttrs argument Date: Thu, 3 Sep 2020 13:08:21 +0200 Message-Id: <20200903110831.353476-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/ppc/spapr_vio.h | 2 +- include/sysemu/dma.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index bed7df60e35..f134f6cf574 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -96,7 +96,7 @@ static inline void spapr_vio_irq_pulse(SpaprVioDevice *de= v) static inline bool spapr_vio_dma_valid(SpaprVioDevice *dev, uint64_t taddr, uint32_t size, DMADirection dir) { - return dma_memory_valid(&dev->as, taddr, size, dir); + return dma_memory_valid(&dev->as, taddr, size, dir, MEMTXATTRS_UNSPECI= FIED); } =20 static inline int spapr_vio_dma_read(SpaprVioDevice *dev, uint64_t taddr, diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 80c5bc3e02d..fe3999dba59 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -73,11 +73,11 @@ static inline void dma_barrier(AddressSpace *as, DMADir= ection dir) * dma_memory_{read,write}() and check for errors */ static inline bool dma_memory_valid(AddressSpace *as, dma_addr_t addr, dma_addr_t len, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { return address_space_access_valid(as, addr, len, dir =3D=3D DMA_DIRECTION_FROM_DEVICE, - MEMTXATTRS_UNSPECIFIED); + attrs); } =20 static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131339; cv=none; d=zohomail.com; s=zohoarc; b=K7xnTijOusIv7SdOXgTTUU2HeEd8QtaaDvBd7+V7DUoq30bJiemr1AJmuthiohT9VbhFKYFWx0LpT6UqBLrlYXfY5Ss0N30lN7jypMQeDCWLVmO5AQHr9cQPgTMKQoQnFOczvLYoqDa2SC9vTj3bcjTkXlwn2FpIIRs/SPwgdbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131339; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=lI0QOKOjsBIQPb4JR9+p08dzOczCwGubAvEgxznc7/Q=; b=kLVR1aBHdivtmIZs4NgwluJjlJkvbnVHhjDW8IuO8c34UEz2GDkQTIJ6sJlP/FkGn1mQxsCuZdYbdaQFHBORtSmug7fr2g0xe/umYPgcjly0o7cLWaVNCGl9JYOip+Uu1MG2FM4bu0wzejGdoob8zZfTZJkdzu0p40cWM8NLpnM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1599131339163701.0896890694937; Thu, 3 Sep 2020 04:08:59 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-227-M8KiX_4_PYacTqD6l6XHeQ-1; Thu, 03 Sep 2020 07:08:56 -0400 Received: by mail-wm1-f69.google.com with SMTP id a5so842428wmj.5 for ; Thu, 03 Sep 2020 04:08:55 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id t4sm3818792wre.30.2020.09.03.04.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131338; 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=lI0QOKOjsBIQPb4JR9+p08dzOczCwGubAvEgxznc7/Q=; b=bx3bZeD3DMZcM8jQz/VcD+6Ybu2XztmXliSYSAZYQG0t+XjGVQ1Gi4MUbxS82/hlLlA8lY gm5DBos4XTftYr3zaS377YlTXaX6gkEyAbB39GyVJjFQhdedEBJRloxtHutPJrohZMAnWX 0QzmIj4IV9mi4OB6cA0knqNUDzEK1MA= X-MC-Unique: M8KiX_4_PYacTqD6l6XHeQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lI0QOKOjsBIQPb4JR9+p08dzOczCwGubAvEgxznc7/Q=; b=YAYyDmcp9O7eMws7fhonjkKZt/GqkC7k5dmkCMZRKfT7rLjA1RxVyGmpn3bQI/GdpC a/L7jUikky6yxntqfCg4K3pn4Dl1nG34Jd8i2Xhgl+UBKsxztzoG+Wkr8+LWxxC2742Y j7LnhHRuyyKcAkWwhgxkJpK3Ubnkly/V4jY4of06zKDpQoDNwo37U4gI6hT/3pS31EEh tnslu6Z2Kel9mEyU3WMnppoIQjv8LRazZKUOXexB9oKpb5XZhSp6r/SnNi6YxacPdNuO QQSaezS4tZJxOkVAlRiHE5NR9u5wwyY5lf0atljKCbh/OAWfAbG45TCmM8M07A44jM/f zT1g== X-Gm-Message-State: AOAM533vmsyIzQjJejObY6EZ827R4d7eH6CvRuRgJAskRqZSCSwc3Mf0 1aRdS180/cf+9p9yMXkAvYLhS2KanDkewot8NE8eav7MRAnlNKVmQE2r6DkkiWxdoIpJ3f9A0kw Pri0afsgspG8HZw== X-Received: by 2002:adf:ec45:: with SMTP id w5mr1930581wrn.357.1599131333634; Thu, 03 Sep 2020 04:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaXFm4w5Ohr2LN1cJuuhu1+mwP3obhIRDWIm7OWCaGpOEFgAjMzMv//oNv4qxMSNAwt007WA== X-Received: by 2002:adf:ec45:: with SMTP id w5mr1930521wrn.357.1599131333398; Thu, 03 Sep 2020 04:08:53 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [PATCH 03/12] dma: Let dma_memory_set() take MemTxAttrs argument Date: Thu, 3 Sep 2020 13:08:22 +0200 Message-Id: <20200903110831.353476-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/ppc/spapr_vio.h | 3 ++- include/sysemu/dma.h | 3 ++- dma-helpers.c | 6 +++--- hw/nvram/fw_cfg.c | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index f134f6cf574..6e5c0840248 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -116,7 +116,8 @@ static inline int spapr_vio_dma_write(SpaprVioDevice *d= ev, uint64_t taddr, static inline int spapr_vio_dma_set(SpaprVioDevice *dev, uint64_t taddr, uint8_t c, uint32_t size) { - return (dma_memory_set(&dev->as, taddr, c, size) !=3D 0) ? + return (dma_memory_set(&dev->as, taddr, + c, size, MEMTXATTRS_UNSPECIFIED) !=3D 0) ? H_DEST_PARM : H_SUCCESS; } =20 diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index fe3999dba59..34f957cc278 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -123,7 +123,8 @@ static inline int dma_memory_write(AddressSpace *as, dm= a_addr_t addr, DMA_DIRECTION_FROM_DEVICE); } =20 -int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_= t len); +int dma_memory_set(AddressSpace *as, dma_addr_t addr, + uint8_t c, dma_addr_t len, MemTxAttrs attrs); =20 static inline void *dma_memory_map(AddressSpace *as, dma_addr_t addr, dma_addr_t *len, diff --git a/dma-helpers.c b/dma-helpers.c index 41ef24a63b6..49d66716469 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -18,7 +18,8 @@ =20 /* #define DEBUG_IOMMU */ =20 -int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_= t len) +int dma_memory_set(AddressSpace *as, dma_addr_t addr, + uint8_t c, dma_addr_t len, MemTxAttrs attrs) { dma_barrier(as, DMA_DIRECTION_FROM_DEVICE); =20 @@ -30,8 +31,7 @@ int dma_memory_set(AddressSpace *as, dma_addr_t addr, uin= t8_t c, dma_addr_t len) memset(fillbuf, c, FILLBUF_SIZE); while (len > 0) { l =3D len < FILLBUF_SIZE ? len : FILLBUF_SIZE; - error |=3D address_space_write(as, addr, MEMTXATTRS_UNSPECIFIED, - fillbuf, l); + error |=3D address_space_write(as, addr, attrs, fillbuf, l); len -=3D l; addr +=3D l; } diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index f3a4728288e..a15de06a10c 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -397,7 +397,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) * tested before. */ if (read) { - if (dma_memory_set(s->dma_as, dma.address, 0, len)) { + if (dma_memory_set(s->dma_as, dma.address, 0, len, + MEMTXATTRS_UNSPECIFIED)) { dma.control |=3D FW_CFG_DMA_CTL_ERROR; } } --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131344; cv=none; d=zohomail.com; s=zohoarc; b=f0xtC2rBS6kybZSAc+icu7igxbIEnontre7Q1dMeEnd0cHk+d+HGLxFZagvYwCbM4tiFk/rlgRQKJ2RkcKU5xJ88KKziEiKkqHQ6FYZziE3mXPFqSYX8tM0uStSug2/90CEf8sRqqc05/XnaOy9Q5GiWFZzmoHnYSE728VeXWV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131344; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=j+CTPuGUnIINTsaPCLli+OHIjRAwlTE0OOiFGbSRLLI=; b=hU2ReHz6jd082kJXPKCa6K2GmbUU2IaEl9o17LF5LQPMldT2UJ0SckAdnzuiCknGUTWlm3bX5RREGbZpLfUn2r0H9ekgcXahC6x7raXaazxA9D0PSdKo5a+RE0iYL83DbcBN6su13IwNxXeJ/DEtdG5TI0CYp1eoa/TDz6/qUqo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1599131344438523.429771502828; Thu, 3 Sep 2020 04:09:04 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-CQ79t4dKOZW6MlMC3q7-Fg-1; Thu, 03 Sep 2020 07:09:02 -0400 Received: by mail-wr1-f70.google.com with SMTP id r16so936615wrm.18 for ; Thu, 03 Sep 2020 04:09:02 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id q18sm3863193wre.78.2020.09.03.04.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131343; 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=j+CTPuGUnIINTsaPCLli+OHIjRAwlTE0OOiFGbSRLLI=; b=YxWBR1BxpR5i/VFV/EqTY1MROyv2oMAGdcs/TLnwUloO3GkY1UZ3AOMLmfawV9d3MHfDJ0 nav942DQbfPp+o0Eo11uunglCqoXBKz6/xol7Iu1DZmEzVD1yBz4IR97qBHbp48/c/pNGC HMSWFCzoUIav+B87DF3zGQ/qARSDc+U= X-MC-Unique: CQ79t4dKOZW6MlMC3q7-Fg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j+CTPuGUnIINTsaPCLli+OHIjRAwlTE0OOiFGbSRLLI=; b=R7kPAZxV7boMwxgS9MQJnbCgMa6bswViHHov2eIS2JN+h4sezq4KLowE0QBvDsLxxR CjG9CaMHpgvN5c7yxpU4nQwT2bYiAg0Hppme9sV+MF2G4QFRfzmcj64d7vIHkU0lm644 vHH9tpW1i0mVHnecqEhuhGBEa+iAhqH+/YpFvGh16qfJNxIPP8wsYFjtQHyscx2ZKyGF GTaR8mE82da/F+o0m7O+JJ6ZHDN7zwhGH64uTyXh/CU1F7Il4/PDOtT8CnjOrLtMq9v6 eu1Qvx3Jlwk8YrLpu4ZQAx/xS7Emt3TGoNPibQWz7AogzyIi7jAESyqGYrZzN/n92CRk rOMg== X-Gm-Message-State: AOAM531HoQvUo1wDCI9FssbZ5SWexDoRUOeIzSKS9/GfCzRy+GIcyXfA tleV5XI7ZPH1KgiUh0QZSjUAQT2vEywBttPgw86Jner2GGcPmIi0IaKZMkqUUdqJoE8pz/3F5MQ XfwNag0NHZSZh2A== X-Received: by 2002:adf:e9c1:: with SMTP id l1mr1912997wrn.68.1599131339764; Thu, 03 Sep 2020 04:08:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNjVckWeZj1Fks7WkDAmCdI4aYyZe18yH1B95ng9F9Ur0Iayl4PU3nMhc55IyTVorvdu0rOQ== X-Received: by 2002:adf:e9c1:: with SMTP id l1mr1912961wrn.68.1599131339616; Thu, 03 Sep 2020 04:08:59 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [PATCH 04/12] dma: Let dma_memory_rw_relaxed() take MemTxAttrs argument Date: Thu, 3 Sep 2020 13:08:23 +0200 Message-Id: <20200903110831.353476-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/sysemu/dma.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 34f957cc278..6068323e48f 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -82,23 +82,26 @@ static inline bool dma_memory_valid(AddressSpace *as, =20 static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, void *buf, dma_addr_t len, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { - return (bool)address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED, + return (bool)address_space_rw(as, addr, attrs, buf, len, dir =3D=3D DMA_DIRECTION_FROM_= DEVICE); } =20 static inline int dma_memory_read_relaxed(AddressSpace *as, dma_addr_t add= r, void *buf, dma_addr_t len) { - return dma_memory_rw_relaxed(as, addr, buf, len, DMA_DIRECTION_TO_DEVI= CE); + return dma_memory_rw_relaxed(as, addr, buf, len, + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); } =20 static inline int dma_memory_write_relaxed(AddressSpace *as, dma_addr_t ad= dr, const void *buf, dma_addr_t len) { return dma_memory_rw_relaxed(as, addr, (void *)buf, len, - DMA_DIRECTION_FROM_DEVICE); + DMA_DIRECTION_FROM_DEVICE, + MEMTXATTRS_UNSPECIFIED); } =20 static inline int dma_memory_rw(AddressSpace *as, dma_addr_t addr, @@ -107,7 +110,8 @@ static inline int dma_memory_rw(AddressSpace *as, dma_a= ddr_t addr, { dma_barrier(as, dir); =20 - return dma_memory_rw_relaxed(as, addr, buf, len, dir); + return dma_memory_rw_relaxed(as, addr, buf, len, dir, + MEMTXATTRS_UNSPECIFIED); } =20 static inline int dma_memory_read(AddressSpace *as, dma_addr_t addr, --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131350; cv=none; d=zohomail.com; s=zohoarc; b=MToij6KzF1rh+y4WtT0osDtBM6pTI1+X64le1uN+yMS3sw6+2rIXd9OVKvt6sfVVGHhY7fZBWPVmS2x2c9T5mY6aCQyh+w4HKhGNGOhkjv3wE4MocqoJAs4s/lp8xUHczSJtNE+4Q2JjNB0KOnFjLRa4fnef0TDklc2Bdn0VjMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131350; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=m9Kq6ilZXw1SgPGwv65dwwD+++f09k8wejmCLHdwFqM=; b=L+zjiCv0uXIMD99qybxos94v7BipOm6qYIUDj8Shd4k6RXV8ZF1TqdxodH61URjJYbSzKKQyrxruBwLUjW/KhzQSZ+TkoTEkkV4b7urqXrFoIg1ZOYQUOh04t2gCKEFMTq8kaYHniZOL9pppbbzh/LL+IjhJMzZn+97jnVwZhEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1599131350283852.7926625395804; Thu, 3 Sep 2020 04:09:10 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-_6ZDuBnQPdSUn8Jt7svsCQ-1; Thu, 03 Sep 2020 07:09:08 -0400 Received: by mail-wm1-f69.google.com with SMTP id a5so842607wmj.5 for ; Thu, 03 Sep 2020 04:09:08 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id 197sm3869799wme.10.2020.09.03.04.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131349; 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=m9Kq6ilZXw1SgPGwv65dwwD+++f09k8wejmCLHdwFqM=; b=X1DlM0leHQa0SnLCCRZ4hpof+5PuaDmZvN3H6ay8tPkLXNfMUBAK0QPC3OpGpXFQ8xjY5/ NPuYar07E3rCboyeWlrrGjgjS2tO3hw0MHumBkJC7ZXQD55p2bji9GomYfKk3prfRK9Ml6 gzeyUj/JW9KsBQ23ak/EyvZm0KF6mlE= X-MC-Unique: _6ZDuBnQPdSUn8Jt7svsCQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m9Kq6ilZXw1SgPGwv65dwwD+++f09k8wejmCLHdwFqM=; b=Ockkkc+A/OOLbwS6qSeWhtKup5T57qpbc79MP3cJlieFsn6ewJJ33AFiGypAmWRRyb v9vtGLBMnjd0Fq+/jFRWh4vvSPUKdW5yEKX8HklWgS4S5HOvrKrNAbL7K+Kf8DOO1+E5 pSq9HaL+Xs/bck0oEVLLLCns4jda00Z7RX/w2mEuSB+LXkqNlDKlO2r97eLxLHFqySPn /EFHBunkzgvsv79/qaa7ACcQms4VJ1uPmI5buZTxeLdFRvDIHBeeetnF8a4Fipq960HQ 1aK05FZqwYUhoUI1WHpvCOTtINAy5881jFcVpedEpk4yvZwFcyJIMR71ZiGlznWhc0cB D+gQ== X-Gm-Message-State: AOAM532yjeWcMAvJJDj6Lk6awr0TjuP2Z/nSjge9VAiQVr+qDrd3yTHT a29a/C/bRL00KBDj14YdrtuptWiaB/uM4vLjZrpOWZZT/NmtSRd9z6MbF0a4/HlP3Lnc7tQiTsI 9viYIHtNCz0LJHg== X-Received: by 2002:a1c:9d83:: with SMTP id g125mr1863586wme.41.1599131346004; Thu, 03 Sep 2020 04:09:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRiHbWxFDviE7nR+1lhmyRzMAOuU0bX6QwqWVwsRP0tHrsP4Qu+Qmf+kIz2nRAdDXj/BgKgA== X-Received: by 2002:a1c:9d83:: with SMTP id g125mr1863549wme.41.1599131345807; Thu, 03 Sep 2020 04:09:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [PATCH 05/12] dma: Let dma_memory_rw() take MemTxAttrs argument Date: Thu, 3 Sep 2020 13:08:24 +0200 Message-Id: <20200903110831.353476-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/pci/pci.h | 3 ++- include/sysemu/dma.h | 10 +++++----- dma-helpers.c | 3 ++- hw/intc/spapr_xive.c | 3 ++- hw/usb/hcd-ohci.c | 10 ++++++---- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 896cef9ad47..0c3217e019c 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -788,7 +788,8 @@ static inline AddressSpace *pci_get_address_space(PCIDe= vice *dev) static inline int pci_dma_rw(PCIDevice *dev, dma_addr_t addr, void *buf, dma_addr_t len, DMADirection dir) { - return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, dir); + return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, + dir, MEMTXATTRS_UNSPECIFIED); } =20 static inline int pci_dma_read(PCIDevice *dev, dma_addr_t addr, diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 6068323e48f..f03edeab173 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -106,25 +106,25 @@ static inline int dma_memory_write_relaxed(AddressSpa= ce *as, dma_addr_t addr, =20 static inline int dma_memory_rw(AddressSpace *as, dma_addr_t addr, void *buf, dma_addr_t len, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { dma_barrier(as, dir); =20 - return dma_memory_rw_relaxed(as, addr, buf, len, dir, - MEMTXATTRS_UNSPECIFIED); + return dma_memory_rw_relaxed(as, addr, buf, len, dir, attrs); } =20 static inline int dma_memory_read(AddressSpace *as, dma_addr_t addr, void *buf, dma_addr_t len) { - return dma_memory_rw(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE); + return dma_memory_rw(as, addr, buf, len, + DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED); } =20 static inline int dma_memory_write(AddressSpace *as, dma_addr_t addr, const void *buf, dma_addr_t len) { return dma_memory_rw(as, addr, (void *)buf, len, - DMA_DIRECTION_FROM_DEVICE); + DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED= ); } =20 int dma_memory_set(AddressSpace *as, dma_addr_t addr, diff --git a/dma-helpers.c b/dma-helpers.c index 49d66716469..50473bb1996 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -305,7 +305,8 @@ static uint64_t dma_buf_rw(uint8_t *ptr, int32_t len, Q= EMUSGList *sg, while (len > 0) { ScatterGatherEntry entry =3D sg->sg[sg_cur_index++]; int32_t xfer =3D MIN(len, entry.len); - dma_memory_rw(sg->as, entry.base, ptr, xfer, dir); + dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, + MEMTXATTRS_UNSPECIFIED); ptr +=3D xfer; len -=3D xfer; resid -=3D xfer; diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 4bd0d606ba1..dbf73a8bf47 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -1666,7 +1666,8 @@ static target_ulong h_int_esb(PowerPCCPU *cpu, mmio_addr =3D xive->vc_base + xive_source_esb_mgmt(xsrc, lisn) + o= ffset; =20 if (dma_memory_rw(&address_space_memory, mmio_addr, &data, 8, - (flags & SPAPR_XIVE_ESB_STORE))) { + (flags & SPAPR_XIVE_ESB_STORE), + MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "XIVE: failed to access ESB @0x= %" HWADDR_PRIx "\n", mmio_addr); return H_HARDWARE; diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 1e6e85e86a8..bac1adf439c 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -586,7 +586,8 @@ static int ohci_copy_td(OHCIState *ohci, struct ohci_td= *td, if (n > len) n =3D len; =20 - if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, n, dir)) { + if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, + n, dir, MEMTXATTRS_UNSPECIFIED)) { return -1; } if (n =3D=3D len) { @@ -595,7 +596,7 @@ static int ohci_copy_td(OHCIState *ohci, struct ohci_td= *td, ptr =3D td->be & ~0xfffu; buf +=3D n; if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, - len - n, dir)) { + len - n, dir, MEMTXATTRS_UNSPECIFIED)) { return -1; } return 0; @@ -613,7 +614,8 @@ static int ohci_copy_iso_td(OHCIState *ohci, if (n > len) n =3D len; =20 - if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, n, dir)) { + if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, + n, dir, MEMTXATTRS_UNSPECIFIED)) { return -1; } if (n =3D=3D len) { @@ -622,7 +624,7 @@ static int ohci_copy_iso_td(OHCIState *ohci, ptr =3D end_addr & ~0xfffu; buf +=3D n; if (dma_memory_rw(ohci->as, ptr + ohci->localmem_base, buf, - len - n, dir)) { + len - n, dir, MEMTXATTRS_UNSPECIFIED)) { return -1; } return 0; --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131360; cv=none; d=zohomail.com; s=zohoarc; b=J2SirHkTYKv20Cj2ue6h5gMgtrndZd1CdKcQdeCgMBwwM3BkOdaEYa8UjeQ86hVwcUNi2R6fq9xnG2/+/f0gNpnFjXKLmYI88b7MODTWi3rV0sBeJuBu2MGd7SmqTSUHv8VvCPZ2KmeYVLedQN/OpIdp7L9+fcwJK8dGT0a8cPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131360; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=KfWm4HscWObDDzR80VqiAjUworVILp5Zcbw9UTPR0fg=; b=YuyZuQJ2k1rE4jH7Icrwj2krZSO3SjQpTKMLX2v39C8eEnUcuylI2lCyxk3Lr2hffKaoh54sSBfAH/xAXmzjWjZSky9Zs42llESH9BwDiAX0G7At3U8YZhCSgxea9v8LZ3LnzeDUk3rlutD8+OZXWsrw3m177LKJ5sBuHlS5YWQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 15991313600511017.6086575370351; Thu, 3 Sep 2020 04:09:20 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-77-Mo0aSnOXPzCp04-lyu5Qhw-1; Thu, 03 Sep 2020 07:09:15 -0400 Received: by mail-wr1-f70.google.com with SMTP id 33so945057wrk.12 for ; Thu, 03 Sep 2020 04:09:15 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id s67sm2133808wmf.38.2020.09.03.04.09.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131359; 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=KfWm4HscWObDDzR80VqiAjUworVILp5Zcbw9UTPR0fg=; b=U810+jryXxqS/9yFSsUdl5SOi52sjEOcmHEZyX3EztluUDYNMiAnrfZgZXSDytJQ0A1dAh AxZv9avMi/pC5TeB7bdB0+2rDkxtgfToPddOY3E4IzrOlLuWiOMWqyyGXf8qEoWVXrBUpo 0rOqsJ5WihIpSiGYtxAPIWq+DJVtQ2s= X-MC-Unique: Mo0aSnOXPzCp04-lyu5Qhw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KfWm4HscWObDDzR80VqiAjUworVILp5Zcbw9UTPR0fg=; b=tE1AGXzpDp3t2e3k5y4cR7n9iwKrX/VPQ0CNpNHZi98qVucXqGQZPDCY49gb0zIljF 5vAAsEMijm6pS8cgpkDgXoQZrGrs91pHuVQjbjPPUfBQNCbpePvieMjCoJX/MaJTHdRV qItclqUjUgd6sshAb6gmMrgPZDnkVSgbVamNYZXdZIhsSM2YSnez4AYWsKM2rgpWVdco WgdrDK6LXeZKpzvKr3xSfYiCM4pW+Pr7zXQT2PrPaPndSK/u2b7ZlF+kY2gc3IFOrdFU YUe8DsGZ0egbTfxjbLb6h43ykm4prO5n0rAuAo2J9J1174uRiEvQKirexHTbkb05L6AB sKcA== X-Gm-Message-State: AOAM530rGnZ22h7DqJZxdVuKXiiujJk2DKjzWD67NK0lUgsI7TW8O9Wb iNdhohDy3hI8N4bkfnxE5DuQOnKS7sUVRKhWEcvwyCXxe8Y1E0uiHyWG9qdveZmrDnnovBv/Hn7 sHSIfise3/mzDmA== X-Received: by 2002:a1c:2dcb:: with SMTP id t194mr1870462wmt.94.1599131353048; Thu, 03 Sep 2020 04:09:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkYqAuPNt62IpZ2CSOgERCZhLz7o5grvi0XoI7rqizD+yevaakOi6BYxFzunKn3753euzCdA== X-Received: by 2002:a1c:2dcb:: with SMTP id t194mr1870367wmt.94.1599131352391; Thu, 03 Sep 2020 04:09:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [PATCH 06/12] dma: Let dma_memory_read/write() take MemTxAttrs argument Date: Thu, 3 Sep 2020 13:08:25 +0200 Message-Id: <20200903110831.353476-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Patch created mechanically using spatch with this script: @@ expression E1, E2, E3, E4; @@ ( - dma_memory_read(E1, E2, E3, E4) + dma_memory_read(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED) | - dma_memory_write(E1, E2, E3, E4) + dma_memory_write(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED) ) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/ppc/spapr_vio.h | 6 ++++-- include/sysemu/dma.h | 18 ++++++++++-------- hw/arm/musicpal.c | 13 +++++++------ hw/arm/smmu-common.c | 3 ++- hw/arm/smmuv3.c | 14 +++++++++----- hw/core/generic-loader.c | 3 ++- hw/dma/pl330.c | 12 ++++++++---- hw/dma/sparc32_dma.c | 16 ++++++++++------ hw/dma/xlnx-zynq-devcfg.c | 6 ++++-- hw/dma/xlnx_dpdma.c | 10 ++++++---- hw/i386/amd_iommu.c | 16 +++++++++------- hw/i386/intel_iommu.c | 28 +++++++++++++++++----------- hw/ide/macio.c | 2 +- hw/intc/xive.c | 7 ++++--- hw/misc/bcm2835_property.c | 3 ++- hw/misc/macio/mac_dbdma.c | 10 ++++++---- hw/net/allwinner-sun8i-emac.c | 21 ++++++++++++++------- hw/net/ftgmac100.c | 25 ++++++++++++++++--------- hw/net/imx_fec.c | 32 ++++++++++++++++++++------------ hw/nvram/fw_cfg.c | 9 ++++++--- hw/pci-host/pnv_phb3.c | 5 +++-- hw/pci-host/pnv_phb3_msi.c | 9 ++++++--- hw/pci-host/pnv_phb4.c | 7 ++++--- hw/sd/allwinner-sdhost.c | 14 ++++++++------ hw/sd/sdhci.c | 35 ++++++++++++++++++++++------------- hw/usb/hcd-dwc2.c | 8 ++++---- hw/usb/hcd-ehci.c | 6 ++++-- hw/usb/hcd-ohci.c | 18 +++++++++++------- 28 files changed, 219 insertions(+), 137 deletions(-) diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 6e5c0840248..8168f4fc5a5 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -102,14 +102,16 @@ static inline bool spapr_vio_dma_valid(SpaprVioDevice= *dev, uint64_t taddr, static inline int spapr_vio_dma_read(SpaprVioDevice *dev, uint64_t taddr, void *buf, uint32_t size) { - return (dma_memory_read(&dev->as, taddr, buf, size) !=3D 0) ? + return (dma_memory_read(&dev->as, taddr, + buf, size, MEMTXATTRS_UNSPECIFIED) !=3D 0) ? H_DEST_PARM : H_SUCCESS; } =20 static inline int spapr_vio_dma_write(SpaprVioDevice *dev, uint64_t taddr, const void *buf, uint32_t size) { - return (dma_memory_write(&dev->as, taddr, buf, size) !=3D 0) ? + return (dma_memory_write(&dev->as, taddr, + buf, size, MEMTXATTRS_UNSPECIFIED) !=3D 0) ? H_DEST_PARM : H_SUCCESS; } =20 diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index f03edeab173..f0880b79e74 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -114,17 +114,19 @@ static inline int dma_memory_rw(AddressSpace *as, dma= _addr_t addr, } =20 static inline int dma_memory_read(AddressSpace *as, dma_addr_t addr, - void *buf, dma_addr_t len) + void *buf, dma_addr_t len, + MemTxAttrs attrs) { return dma_memory_rw(as, addr, buf, len, - DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED); + DMA_DIRECTION_TO_DEVICE, attrs); } =20 static inline int dma_memory_write(AddressSpace *as, dma_addr_t addr, - const void *buf, dma_addr_t len) + const void *buf, dma_addr_t len, + MemTxAttrs attrs) { return dma_memory_rw(as, addr, (void *)buf, len, - DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED= ); + DMA_DIRECTION_FROM_DEVICE, attrs); } =20 int dma_memory_set(AddressSpace *as, dma_addr_t addr, @@ -156,7 +158,7 @@ static inline void dma_memory_unmap(AddressSpace *as, dma_addr_t add= r) \ { \ uint##_bits##_t val; \ - dma_memory_read(as, addr, &val, (_bits) / 8); \ + dma_memory_read(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFIE= D); \ return _end##_bits##_to_cpu(val); \ } \ static inline void st##_sname##_##_end##_dma(AddressSpace *as, \ @@ -164,20 +166,20 @@ static inline void dma_memory_unmap(AddressSpace *as, uint##_bits##_t val) \ { \ val =3D cpu_to_##_end##_bits(val); \ - dma_memory_write(as, addr, &val, (_bits) / 8); \ + dma_memory_write(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFI= ED); \ } =20 static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr) { uint8_t val; =20 - dma_memory_read(as, addr, &val, 1); + dma_memory_read(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); return val; } =20 static inline void stb_dma(AddressSpace *as, dma_addr_t addr, uint8_t val) { - dma_memory_write(as, addr, &val, 1); + dma_memory_write(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); } =20 DEFINE_LDST_DMA(uw, w, 16, le); diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index f2f4fc02649..5d9959e8ddd 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -187,13 +187,13 @@ static void eth_rx_desc_put(AddressSpace *dma_as, uin= t32_t addr, cpu_to_le16s(&desc->buffer_size); cpu_to_le32s(&desc->buffer); cpu_to_le32s(&desc->next); - dma_memory_write(dma_as, addr, desc, sizeof(*desc)); + dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECI= FIED); } =20 static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr, mv88w8618_rx_desc *desc) { - dma_memory_read(dma_as, addr, desc, sizeof(*desc)); + dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIF= IED); le32_to_cpus(&desc->cmdstat); le16_to_cpus(&desc->bytes); le16_to_cpus(&desc->buffer_size); @@ -217,7 +217,7 @@ static ssize_t eth_receive(NetClientState *nc, const ui= nt8_t *buf, size_t size) eth_rx_desc_get(&s->dma_as, desc_addr, &desc); if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >=3D si= ze) { dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header, - buf, size); + buf, size, MEMTXATTRS_UNSPECIFIED); desc.bytes =3D size + s->vlan_header; desc.cmdstat &=3D ~MP_ETH_RX_OWN; s->cur_rx[i] =3D desc.next; @@ -243,13 +243,13 @@ static void eth_tx_desc_put(AddressSpace *dma_as, uin= t32_t addr, cpu_to_le16s(&desc->bytes); cpu_to_le32s(&desc->buffer); cpu_to_le32s(&desc->next); - dma_memory_write(dma_as, addr, desc, sizeof(*desc)); + dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECI= FIED); } =20 static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr, mv88w8618_tx_desc *desc) { - dma_memory_read(dma_as, addr, desc, sizeof(*desc)); + dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIF= IED); le32_to_cpus(&desc->cmdstat); le16_to_cpus(&desc->res); le16_to_cpus(&desc->bytes); @@ -271,7 +271,8 @@ static void eth_send(mv88w8618_eth_state *s, int queue_= index) if (desc.cmdstat & MP_ETH_TX_OWN) { len =3D desc.bytes; if (len < 2048) { - dma_memory_read(&s->dma_as, desc.buffer, buf, len); + dma_memory_read(&s->dma_as, desc.buffer, buf, len, + MEMTXATTRS_UNSPECIFIED); qemu_send_packet(qemu_get_queue(s->nic), buf, len); } desc.cmdstat &=3D ~MP_ETH_TX_OWN; diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 3838db13952..f42ee237204 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -188,7 +188,8 @@ static int get_pte(dma_addr_t baseaddr, uint32_t index,= uint64_t *pte, dma_addr_t addr =3D baseaddr + index * sizeof(*pte); =20 /* TODO: guarantee 64-bit single-copy atomicity */ - ret =3D dma_memory_read(&address_space_memory, addr, pte, sizeof(*pte)= ); + ret =3D dma_memory_read(&address_space_memory, addr, pte, sizeof(*pte), + MEMTXATTRS_UNSPECIFIED); =20 if (ret !=3D MEMTX_OK) { info->type =3D SMMU_PTW_ERR_WALK_EABT; diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 0122700e725..71d0eea2af1 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -101,7 +101,8 @@ static inline MemTxResult queue_read(SMMUQueue *q, void= *data) { dma_addr_t addr =3D Q_CONS_ENTRY(q); =20 - return dma_memory_read(&address_space_memory, addr, data, q->entry_siz= e); + return dma_memory_read(&address_space_memory, addr, data, q->entry_siz= e, + MEMTXATTRS_UNSPECIFIED); } =20 static MemTxResult queue_write(SMMUQueue *q, void *data) @@ -109,7 +110,8 @@ static MemTxResult queue_write(SMMUQueue *q, void *data) dma_addr_t addr =3D Q_PROD_ENTRY(q); MemTxResult ret; =20 - ret =3D dma_memory_write(&address_space_memory, addr, data, q->entry_s= ize); + ret =3D dma_memory_write(&address_space_memory, addr, data, q->entry_s= ize, + MEMTXATTRS_UNSPECIFIED); if (ret !=3D MEMTX_OK) { return ret; } @@ -283,7 +285,8 @@ static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr= , STE *buf, =20 trace_smmuv3_get_ste(addr); /* TODO: guarantee 64-bit single-copy atomicity */ - ret =3D dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf)= ); + ret =3D dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf), + MEMTXATTRS_UNSPECIFIED); if (ret !=3D MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "Cannot fetch pte at address=3D0x%"PRIx64"\n", addr); @@ -304,7 +307,8 @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32= _t ssid, =20 trace_smmuv3_get_cd(addr); /* TODO: guarantee 64-bit single-copy atomicity */ - ret =3D dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf)= ); + ret =3D dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf), + MEMTXATTRS_UNSPECIFIED); if (ret !=3D MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "Cannot fetch pte at address=3D0x%"PRIx64"\n", addr); @@ -409,7 +413,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, = STE *ste, l1ptr =3D (dma_addr_t)(strtab_base + l1_ste_offset * sizeof(l1std)= ); /* TODO: guarantee 64-bit single-copy atomicity */ ret =3D dma_memory_read(&address_space_memory, l1ptr, &l1std, - sizeof(l1std)); + sizeof(l1std), MEMTXATTRS_UNSPECIFIED); if (ret !=3D MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "Could not read L1PTR at 0X%"PRIx64"\n", l1ptr); diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index a242c076f69..ba48ebae993 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -57,7 +57,8 @@ static void generic_loader_reset(void *opaque) =20 if (s->data_len) { assert(s->data_len < sizeof(s->data)); - dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len); + dma_memory_write(s->cpu->as, s->addr, &s->data, s->data_len, + MEMTXATTRS_UNSPECIFIED); } } =20 diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c index 0bd63a43f50..0361524c067 100644 --- a/hw/dma/pl330.c +++ b/hw/dma/pl330.c @@ -1107,7 +1107,8 @@ static inline const PL330InsnDesc *pl330_fetch_insn(P= L330Chan *ch) uint8_t opcode; int i; =20 - dma_memory_read(&address_space_memory, ch->pc, &opcode, 1); + dma_memory_read(&address_space_memory, ch->pc, &opcode, 1, + MEMTXATTRS_UNSPECIFIED); for (i =3D 0; insn_desc[i].size; i++) { if ((opcode & insn_desc[i].opmask) =3D=3D insn_desc[i].opcode) { return &insn_desc[i]; @@ -1121,7 +1122,8 @@ static inline void pl330_exec_insn(PL330Chan *ch, con= st PL330InsnDesc *insn) uint8_t buf[PL330_INSN_MAXSIZE]; =20 assert(insn->size <=3D PL330_INSN_MAXSIZE); - dma_memory_read(&address_space_memory, ch->pc, buf, insn->size); + dma_memory_read(&address_space_memory, ch->pc, buf, insn->size, + MEMTXATTRS_UNSPECIFIED); insn->exec(ch, buf[0], &buf[1], insn->size - 1); } =20 @@ -1185,7 +1187,8 @@ static int pl330_exec_cycle(PL330Chan *channel) if (q !=3D NULL && q->len <=3D pl330_fifo_num_free(&s->fifo)) { int len =3D q->len - (q->addr & (q->len - 1)); =20 - dma_memory_read(&address_space_memory, q->addr, buf, len); + dma_memory_read(&address_space_memory, q->addr, buf, len, + MEMTXATTRS_UNSPECIFIED); trace_pl330_exec_cycle(q->addr, len); if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { pl330_hexdump(buf, len); @@ -1216,7 +1219,8 @@ static int pl330_exec_cycle(PL330Chan *channel) fifo_res =3D pl330_fifo_get(&s->fifo, buf, len, q->tag); } if (fifo_res =3D=3D PL330_FIFO_OK || q->z) { - dma_memory_write(&address_space_memory, q->addr, buf, len); + dma_memory_write(&address_space_memory, q->addr, buf, len, + MEMTXATTRS_UNSPECIFIED); trace_pl330_exec_cycle(q->addr, len); if (trace_event_get_state_backends(TRACE_PL330_HEXDUMP)) { pl330_hexdump(buf, len); diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index bcd1626fbd5..00c22232ceb 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -81,11 +81,11 @@ void ledma_memory_read(void *opaque, hwaddr addr, addr |=3D s->dmaregs[3]; trace_ledma_memory_read(addr, len); if (do_bswap) { - dma_memory_read(&is->iommu_as, addr, buf, len); + dma_memory_read(&is->iommu_as, addr, buf, len, MEMTXATTRS_UNSPECIF= IED); } else { addr &=3D ~1; len &=3D ~1; - dma_memory_read(&is->iommu_as, addr, buf, len); + dma_memory_read(&is->iommu_as, addr, buf, len, MEMTXATTRS_UNSPECIF= IED); for(i =3D 0; i < len; i +=3D 2) { bswap16s((uint16_t *)(buf + i)); } @@ -103,7 +103,8 @@ void ledma_memory_write(void *opaque, hwaddr addr, addr |=3D s->dmaregs[3]; trace_ledma_memory_write(addr, len); if (do_bswap) { - dma_memory_write(&is->iommu_as, addr, buf, len); + dma_memory_write(&is->iommu_as, addr, buf, len, + MEMTXATTRS_UNSPECIFIED); } else { addr &=3D ~1; len &=3D ~1; @@ -114,7 +115,8 @@ void ledma_memory_write(void *opaque, hwaddr addr, for(i =3D 0; i < l; i +=3D 2) { tmp_buf[i >> 1] =3D bswap16(*(uint16_t *)(buf + i)); } - dma_memory_write(&is->iommu_as, addr, tmp_buf, l); + dma_memory_write(&is->iommu_as, addr, tmp_buf, l, + MEMTXATTRS_UNSPECIFIED); len -=3D l; buf +=3D l; addr +=3D l; @@ -148,7 +150,8 @@ void espdma_memory_read(void *opaque, uint8_t *buf, int= len) IOMMUState *is =3D (IOMMUState *)s->iommu; =20 trace_espdma_memory_read(s->dmaregs[1], len); - dma_memory_read(&is->iommu_as, s->dmaregs[1], buf, len); + dma_memory_read(&is->iommu_as, s->dmaregs[1], buf, len, + MEMTXATTRS_UNSPECIFIED); s->dmaregs[1] +=3D len; } =20 @@ -158,7 +161,8 @@ void espdma_memory_write(void *opaque, uint8_t *buf, in= t len) IOMMUState *is =3D (IOMMUState *)s->iommu; =20 trace_espdma_memory_write(s->dmaregs[1], len); - dma_memory_write(&is->iommu_as, s->dmaregs[1], buf, len); + dma_memory_write(&is->iommu_as, s->dmaregs[1], buf, len, + MEMTXATTRS_UNSPECIFIED); s->dmaregs[1] +=3D len; } =20 diff --git a/hw/dma/xlnx-zynq-devcfg.c b/hw/dma/xlnx-zynq-devcfg.c index e33112b6f0e..f5ad1a0d22c 100644 --- a/hw/dma/xlnx-zynq-devcfg.c +++ b/hw/dma/xlnx-zynq-devcfg.c @@ -161,12 +161,14 @@ static void xlnx_zynq_devcfg_dma_go(XlnxZynqDevcfg *s) btt =3D MIN(btt, dmah->dest_len); } DB_PRINT("reading %x bytes from %x\n", btt, dmah->src_addr); - dma_memory_read(&address_space_memory, dmah->src_addr, buf, btt); + dma_memory_read(&address_space_memory, dmah->src_addr, buf, btt, + MEMTXATTRS_UNSPECIFIED); dmah->src_len -=3D btt; dmah->src_addr +=3D btt; if (loopback && (dmah->src_len || dmah->dest_len)) { DB_PRINT("writing %x bytes from %x\n", btt, dmah->dest_addr); - dma_memory_write(&address_space_memory, dmah->dest_addr, buf, = btt); + dma_memory_write(&address_space_memory, dmah->dest_addr, buf, = btt, + MEMTXATTRS_UNSPECIFIED); dmah->dest_len -=3D btt; dmah->dest_addr +=3D btt; } diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c index b40c897de2c..321f30a6535 100644 --- a/hw/dma/xlnx_dpdma.c +++ b/hw/dma/xlnx_dpdma.c @@ -652,7 +652,7 @@ size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, ui= nt8_t channel, } =20 if (dma_memory_read(&address_space_memory, desc_addr, &desc, - sizeof(DPDMADescriptor))) { + sizeof(DPDMADescriptor), MEMTXATTRS_UNSPECIFIE= D)) { s->registers[DPDMA_EISR] |=3D ((1 << 1) << channel); xlnx_dpdma_update_irq(s); s->operation_finished[channel] =3D true; @@ -708,7 +708,8 @@ size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, ui= nt8_t channel, if (dma_memory_read(&address_space_memory, source_addr[0], &s->data[channel][ptr], - line_size)) { + line_size, + MEMTXATTRS_UNSPECIFIED)) { s->registers[DPDMA_ISR] |=3D ((1 << 12) << channel= ); xlnx_dpdma_update_irq(s); DPRINTF("Can't get data.\n"); @@ -736,7 +737,8 @@ size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, ui= nt8_t channel, if (dma_memory_read(&address_space_memory, source_addr[frag], &(s->data[channel][ptr]), - fragment_len)) { + fragment_len, + MEMTXATTRS_UNSPECIFIED)) { s->registers[DPDMA_ISR] |=3D ((1 << 12) << channel= ); xlnx_dpdma_update_irq(s); DPRINTF("Can't get data.\n"); @@ -754,7 +756,7 @@ size_t xlnx_dpdma_start_operation(XlnxDPDMAState *s, ui= nt8_t channel, DPRINTF("update the descriptor with the done flag set.\n"); xlnx_dpdma_desc_set_done(&desc); dma_memory_write(&address_space_memory, desc_addr, &desc, - sizeof(DPDMADescriptor)); + sizeof(DPDMADescriptor), MEMTXATTRS_UNSPECIFI= ED); } =20 if (xlnx_dpdma_desc_completion_interrupt(&desc)) { diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 74a93a5d93f..3c2a1a61db5 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -181,7 +181,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *ev= t) } =20 if (dma_memory_write(&address_space_memory, s->evtlog + s->evtlog_tail, - evt, AMDVI_EVENT_LEN)) { + evt, AMDVI_EVENT_LEN, MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_evntlog_fail(s->evtlog, s->evtlog_tail); } =20 @@ -376,7 +376,8 @@ static void amdvi_completion_wait(AMDVIState *s, uint64= _t *cmd) } if (extract64(cmd[0], 0, 1)) { if (dma_memory_write(&address_space_memory, addr, &data, - AMDVI_COMPLETION_DATA_SIZE)) { + AMDVI_COMPLETION_DATA_SIZE, + MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_completion_wait_fail(addr); } } @@ -502,7 +503,7 @@ static void amdvi_cmdbuf_exec(AMDVIState *s) uint64_t cmd[2]; =20 if (dma_memory_read(&address_space_memory, s->cmdbuf + s->cmdbuf_head, - cmd, AMDVI_COMMAND_SIZE)) { + cmd, AMDVI_COMMAND_SIZE, MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_command_read_fail(s->cmdbuf, s->cmdbuf_head); amdvi_log_command_error(s, s->cmdbuf + s->cmdbuf_head); return; @@ -836,7 +837,7 @@ static bool amdvi_get_dte(AMDVIState *s, int devid, uin= t64_t *entry) uint32_t offset =3D devid * AMDVI_DEVTAB_ENTRY_SIZE; =20 if (dma_memory_read(&address_space_memory, s->devtab + offset, entry, - AMDVI_DEVTAB_ENTRY_SIZE)) { + AMDVI_DEVTAB_ENTRY_SIZE, MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_dte_get_fail(s->devtab, offset); /* log error accessing dte */ amdvi_log_devtab_error(s, devid, s->devtab + offset, 0); @@ -881,7 +882,8 @@ static inline uint64_t amdvi_get_pte_entry(AMDVIState *= s, uint64_t pte_addr, { uint64_t pte; =20 - if (dma_memory_read(&address_space_memory, pte_addr, &pte, sizeof(pte)= )) { + if (dma_memory_read(&address_space_memory, pte_addr, + &pte, sizeof(pte), MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_get_pte_hwerror(pte_addr); amdvi_log_pagetab_error(s, devid, pte_addr, 0); pte =3D 0; @@ -1048,7 +1050,7 @@ static int amdvi_get_irte(AMDVIState *s, MSIMessage *= origin, uint64_t *dte, trace_amdvi_ir_irte(irte_root, offset); =20 if (dma_memory_read(&address_space_memory, irte_root + offset, - irte, sizeof(*irte))) { + irte, sizeof(*irte), MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_ir_err("failed to get irte"); return -AMDVI_IR_GET_IRTE; } @@ -1108,7 +1110,7 @@ static int amdvi_get_irte_ga(AMDVIState *s, MSIMessag= e *origin, uint64_t *dte, trace_amdvi_ir_irte(irte_root, offset); =20 if (dma_memory_read(&address_space_memory, irte_root + offset, - irte, sizeof(*irte))) { + irte, sizeof(*irte), MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_ir_err("failed to get irte_ga"); return -AMDVI_IR_GET_IRTE; } diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 749eb6ad632..8de57dd995e 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -570,7 +570,8 @@ static int vtd_get_root_entry(IntelIOMMUState *s, uint8= _t index, dma_addr_t addr; =20 addr =3D s->root + index * sizeof(*re); - if (dma_memory_read(&address_space_memory, addr, re, sizeof(*re))) { + if (dma_memory_read(&address_space_memory, addr, + re, sizeof(*re), MEMTXATTRS_UNSPECIFIED)) { re->lo =3D 0; return -VTD_FR_ROOT_TABLE_INV; } @@ -603,7 +604,8 @@ static int vtd_get_context_entry_from_root(IntelIOMMUSt= ate *s, } =20 addr =3D addr + index * ce_size; - if (dma_memory_read(&address_space_memory, addr, ce, ce_size)) { + if (dma_memory_read(&address_space_memory, addr, + ce, ce_size, MEMTXATTRS_UNSPECIFIED)) { return -VTD_FR_CONTEXT_TABLE_INV; } =20 @@ -640,8 +642,8 @@ static uint64_t vtd_get_slpte(dma_addr_t base_addr, uin= t32_t index) assert(index < VTD_SL_PT_ENTRY_NR); =20 if (dma_memory_read(&address_space_memory, - base_addr + index * sizeof(slpte), &slpte, - sizeof(slpte))) { + base_addr + index * sizeof(slpte), + &slpte, sizeof(slpte), MEMTXATTRS_UNSPECIFIED)) { slpte =3D (uint64_t)-1; return slpte; } @@ -705,7 +707,8 @@ static int vtd_get_pdire_from_pdir_table(dma_addr_t pas= id_dir_base, index =3D VTD_PASID_DIR_INDEX(pasid); entry_size =3D VTD_PASID_DIR_ENTRY_SIZE; addr =3D pasid_dir_base + index * entry_size; - if (dma_memory_read(&address_space_memory, addr, pdire, entry_size)) { + if (dma_memory_read(&address_space_memory, addr, + pdire, entry_size, MEMTXATTRS_UNSPECIFIED)) { return -VTD_FR_PASID_TABLE_INV; } =20 @@ -729,7 +732,8 @@ static int vtd_get_pe_in_pasid_leaf_table(IntelIOMMUSta= te *s, index =3D VTD_PASID_TABLE_INDEX(pasid); entry_size =3D VTD_PASID_ENTRY_SIZE; addr =3D addr + index * entry_size; - if (dma_memory_read(&address_space_memory, addr, pe, entry_size)) { + if (dma_memory_read(&address_space_memory, addr, + pe, entry_size, MEMTXATTRS_UNSPECIFIED)) { return -VTD_FR_PASID_TABLE_INV; } =20 @@ -2262,7 +2266,8 @@ static bool vtd_get_inv_desc(IntelIOMMUState *s, uint32_t dw =3D s->iq_dw ? 32 : 16; dma_addr_t addr =3D base_addr + offset * dw; =20 - if (dma_memory_read(&address_space_memory, addr, inv_desc, dw)) { + if (dma_memory_read(&address_space_memory, addr, + inv_desc, dw, MEMTXATTRS_UNSPECIFIED)) { error_report_once("Read INV DESC failed."); return false; } @@ -2295,8 +2300,9 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s,= VTDInvDesc *inv_desc) dma_addr_t status_addr =3D inv_desc->hi; trace_vtd_inv_desc_wait_sw(status_addr, status_data); status_data =3D cpu_to_le32(status_data); - if (dma_memory_write(&address_space_memory, status_addr, &status_d= ata, - sizeof(status_data))) { + if (dma_memory_write(&address_space_memory, status_addr, + &status_data, sizeof(status_data), + MEMTXATTRS_UNSPECIFIED)) { trace_vtd_inv_desc_wait_write_fail(inv_desc->hi, inv_desc->lo); return false; } @@ -3106,8 +3112,8 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint1= 6_t index, } =20 addr =3D iommu->intr_root + index * sizeof(*entry); - if (dma_memory_read(&address_space_memory, addr, entry, - sizeof(*entry))) { + if (dma_memory_read(&address_space_memory, addr, + entry, sizeof(*entry), MEMTXATTRS_UNSPECIFIED)) { error_report_once("%s: read failed: ind=3D0x%x addr=3D0x%" PRIx64, __func__, index, addr); return -VTD_FR_IR_ROOT_INVAL; diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 62a599a0751..a93a2b75a85 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -97,7 +97,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int = ret) /* Non-block ATAPI transfer - just copy to RAM */ s->io_buffer_size =3D MIN(s->io_buffer_size, io->len); dma_memory_write(&address_space_memory, io->addr, s->io_buffer, - s->io_buffer_size); + s->io_buffer_size, MEMTXATTRS_UNSPECIFIED); io->len =3D 0; ide_atapi_cmd_ok(s); m->dma_active =3D false; diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 489e6256ef7..8e8618c1ab4 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1236,8 +1236,8 @@ void xive_end_queue_pic_print_info(XiveEND *end, uint= 32_t width, Monitor *mon) uint64_t qaddr =3D qaddr_base + (qindex << 2); uint32_t qdata =3D -1; =20 - if (dma_memory_read(&address_space_memory, qaddr, &qdata, - sizeof(qdata))) { + if (dma_memory_read(&address_space_memory, qaddr, + &qdata, sizeof(qdata), MEMTXATTRS_UNSPECIFIED)= ) { qemu_log_mask(LOG_GUEST_ERROR, "XIVE: failed to read EQ @0x%" HWADDR_PRIx "\n", qaddr); return; @@ -1300,7 +1300,8 @@ static void xive_end_enqueue(XiveEND *end, uint32_t d= ata) uint32_t qdata =3D cpu_to_be32((qgen << 31) | (data & 0x7fffffff)); uint32_t qentries =3D 1 << (qsize + 10); =20 - if (dma_memory_write(&address_space_memory, qaddr, &qdata, sizeof(qdat= a))) { + if (dma_memory_write(&address_space_memory, qaddr, + &qdata, sizeof(qdata), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "XIVE: failed to write END data @0x= %" HWADDR_PRIx "\n", qaddr); return; diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c index 73941bdae97..76ea511d53d 100644 --- a/hw/misc/bcm2835_property.c +++ b/hw/misc/bcm2835_property.c @@ -69,7 +69,8 @@ static void bcm2835_property_mbox_push(BCM2835PropertySta= te *s, uint32_t value) break; case 0x00010003: /* Get board MAC address */ resplen =3D sizeof(s->macaddr.a); - dma_memory_write(&s->dma_as, value + 12, s->macaddr.a, resplen= ); + dma_memory_write(&s->dma_as, value + 12, s->macaddr.a, resplen, + MEMTXATTRS_UNSPECIFIED); break; case 0x00010004: /* Get board serial */ qemu_log_mask(LOG_UNIMP, diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c index e220f1a9277..efcc02609fd 100644 --- a/hw/misc/macio/mac_dbdma.c +++ b/hw/misc/macio/mac_dbdma.c @@ -94,7 +94,7 @@ static void dbdma_cmdptr_load(DBDMA_channel *ch) DBDMA_DPRINTFCH(ch, "dbdma_cmdptr_load 0x%08x\n", ch->regs[DBDMA_CMDPTR_LO]); dma_memory_read(&address_space_memory, ch->regs[DBDMA_CMDPTR_LO], - &ch->current, sizeof(dbdma_cmd)); + &ch->current, sizeof(dbdma_cmd), MEMTXATTRS_UNSPECIFIE= D); } =20 static void dbdma_cmdptr_save(DBDMA_channel *ch) @@ -104,7 +104,7 @@ static void dbdma_cmdptr_save(DBDMA_channel *ch) le16_to_cpu(ch->current.xfer_status), le16_to_cpu(ch->current.res_count)); dma_memory_write(&address_space_memory, ch->regs[DBDMA_CMDPTR_LO], - &ch->current, sizeof(dbdma_cmd)); + &ch->current, sizeof(dbdma_cmd), MEMTXATTRS_UNSPECIFI= ED); } =20 static void kill_channel(DBDMA_channel *ch) @@ -371,7 +371,8 @@ static void load_word(DBDMA_channel *ch, int key, uint3= 2_t addr, return; } =20 - dma_memory_read(&address_space_memory, addr, ¤t->cmd_dep, len); + dma_memory_read(&address_space_memory, addr, ¤t->cmd_dep, len, + MEMTXATTRS_UNSPECIFIED); =20 if (conditional_wait(ch)) goto wait; @@ -403,7 +404,8 @@ static void store_word(DBDMA_channel *ch, int key, uint= 32_t addr, return; } =20 - dma_memory_write(&address_space_memory, addr, ¤t->cmd_dep, len); + dma_memory_write(&address_space_memory, addr, ¤t->cmd_dep, len, + MEMTXATTRS_UNSPECIFIED); =20 if (conditional_wait(ch)) goto wait; diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c index 38d328587e3..5189ad77527 100644 --- a/hw/net/allwinner-sun8i-emac.c +++ b/hw/net/allwinner-sun8i-emac.c @@ -345,7 +345,8 @@ static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iE= macState *s, { uint32_t paddr =3D desc->next; =20 - dma_memory_read(&s->dma_as, paddr, desc, sizeof(*desc)); + dma_memory_read(&s->dma_as, paddr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); =20 if ((desc->status & DESC_STATUS_CTL) && (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >=3D min_size) { @@ -364,7 +365,8 @@ static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEm= acState *s, =20 /* Note that the list is a cycle. Last entry points back to the head. = */ while (desc_addr !=3D 0) { - dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc)); + dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); =20 if ((desc->status & DESC_STATUS_CTL) && (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >=3D min_size) { @@ -397,7 +399,8 @@ static void allwinner_sun8i_emac_flush_desc(AwSun8iEmac= State *s, FrameDescriptor *desc, uint32_t phys_addr) { - dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc)); + dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); } =20 static bool allwinner_sun8i_emac_can_receive(NetClientState *nc) @@ -455,7 +458,8 @@ static ssize_t allwinner_sun8i_emac_receive(NetClientSt= ate *nc, << RX_DESC_STATUS_FRM_LEN_SHIFT; } =20 - dma_memory_write(&s->dma_as, desc.addr, buf, desc_bytes); + dma_memory_write(&s->dma_as, desc.addr, buf, desc_bytes, + MEMTXATTRS_UNSPECIFIED); allwinner_sun8i_emac_flush_desc(s, &desc, s->rx_desc_curr); trace_allwinner_sun8i_emac_receive(s->rx_desc_curr, desc.addr, desc_bytes); @@ -506,7 +510,8 @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacSt= ate *s) desc.status |=3D TX_DESC_STATUS_LENGTH_ERR; break; } - dma_memory_read(&s->dma_as, desc.addr, packet_buf + packet_bytes, = bytes); + dma_memory_read(&s->dma_as, desc.addr, packet_buf + packet_bytes, + bytes, MEMTXATTRS_UNSPECIFIED); packet_bytes +=3D bytes; desc.status &=3D ~DESC_STATUS_CTL; allwinner_sun8i_emac_flush_desc(s, &desc, s->tx_desc_curr); @@ -628,7 +633,8 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque,= hwaddr offset, break; case REG_TX_CUR_BUF: /* Transmit Current Buffer */ if (s->tx_desc_curr !=3D 0) { - dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(des= c)); + dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(des= c), + MEMTXATTRS_UNSPECIFIED); value =3D desc.addr; } else { value =3D 0; @@ -641,7 +647,8 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque,= hwaddr offset, break; case REG_RX_CUR_BUF: /* Receive Current Buffer */ if (s->rx_desc_curr !=3D 0) { - dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(des= c)); + dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(des= c), + MEMTXATTRS_UNSPECIFIED); value =3D desc.addr; } else { value =3D 0; diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c index 5f4b26fc5f3..725aeb65f85 100644 --- a/hw/net/ftgmac100.c +++ b/hw/net/ftgmac100.c @@ -453,7 +453,8 @@ static void do_phy_ctl(FTGMAC100State *s) =20 static int ftgmac100_read_bd(FTGMAC100Desc *bd, dma_addr_t addr) { - if (dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd))) { + if (dma_memory_read(&address_space_memory, addr, + bd, sizeof(*bd), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to read descriptor @ 0x= %" HWADDR_PRIx "\n", __func__, addr); return -1; @@ -473,7 +474,8 @@ static int ftgmac100_write_bd(FTGMAC100Desc *bd, dma_ad= dr_t addr) lebd.des1 =3D cpu_to_le32(bd->des1); lebd.des2 =3D cpu_to_le32(bd->des2); lebd.des3 =3D cpu_to_le32(bd->des3); - if (dma_memory_write(&address_space_memory, addr, &lebd, sizeof(lebd))= ) { + if (dma_memory_write(&address_space_memory, addr, + &lebd, sizeof(lebd), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to write descriptor @ 0= x%" HWADDR_PRIx "\n", __func__, addr); return -1; @@ -514,7 +516,8 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t= tx_ring, len =3D sizeof(s->frame) - frame_size; } =20 - if (dma_memory_read(&address_space_memory, bd.des3, ptr, len)) { + if (dma_memory_read(&address_space_memory, bd.des3, + ptr, len, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to read packet @ 0x= %x\n", __func__, bd.des3); s->isr |=3D FTGMAC100_INT_NO_NPTXBUF; @@ -976,20 +979,24 @@ static ssize_t ftgmac100_receive(NetClientState *nc, = const uint8_t *buf, bd.des1 =3D lduw_be_p(buf + 14) | FTGMAC100_RXDES1_VLANTAG_AVA= IL; =20 if (s->maccr & FTGMAC100_MACCR_RM_VLAN) { - dma_memory_write(&address_space_memory, buf_addr, buf, 12); - dma_memory_write(&address_space_memory, buf_addr + 12, buf= + 16, - buf_len - 16); + dma_memory_write(&address_space_memory, buf_addr, buf, 12, + MEMTXATTRS_UNSPECIFIED); + dma_memory_write(&address_space_memory, buf_addr + 12, + buf + 16, buf_len - 16, + MEMTXATTRS_UNSPECIFIED); } else { - dma_memory_write(&address_space_memory, buf_addr, buf, buf= _len); + dma_memory_write(&address_space_memory, buf_addr, buf, + buf_len, MEMTXATTRS_UNSPECIFIED); } } else { bd.des1 =3D 0; - dma_memory_write(&address_space_memory, buf_addr, buf, buf_len= ); + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len, + MEMTXATTRS_UNSPECIFIED); } buf +=3D buf_len; if (size < 4) { dma_memory_write(&address_space_memory, buf_addr + buf_len, - crc_ptr, 4 - size); + crc_ptr, 4 - size, MEMTXATTRS_UNSPECIFIED); crc_ptr +=3D 4 - size; } =20 diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 2c148040414..ff4c345f09f 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -389,19 +389,22 @@ static void imx_phy_write(IMXFECState *s, int reg, ui= nt32_t val) =20 static void imx_fec_read_bd(IMXFECBufDesc *bd, dma_addr_t addr) { - dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd)); + dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd), + MEMTXATTRS_UNSPECIFIED); =20 trace_imx_fec_read_bd(addr, bd->flags, bd->length, bd->data); } =20 static void imx_fec_write_bd(IMXFECBufDesc *bd, dma_addr_t addr) { - dma_memory_write(&address_space_memory, addr, bd, sizeof(*bd)); + dma_memory_write(&address_space_memory, addr, bd, sizeof(*bd), + MEMTXATTRS_UNSPECIFIED); } =20 static void imx_enet_read_bd(IMXENETBufDesc *bd, dma_addr_t addr) { - dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd)); + dma_memory_read(&address_space_memory, addr, bd, sizeof(*bd), + MEMTXATTRS_UNSPECIFIED); =20 trace_imx_enet_read_bd(addr, bd->flags, bd->length, bd->data, bd->option, bd->status); @@ -409,7 +412,8 @@ static void imx_enet_read_bd(IMXENETBufDesc *bd, dma_ad= dr_t addr) =20 static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr) { - dma_memory_write(&address_space_memory, addr, bd, sizeof(*bd)); + dma_memory_write(&address_space_memory, addr, bd, sizeof(*bd), + MEMTXATTRS_UNSPECIFIED); } =20 static void imx_eth_update(IMXFECState *s) @@ -476,7 +480,8 @@ static void imx_fec_do_tx(IMXFECState *s) len =3D ENET_MAX_FRAME_SIZE - frame_size; s->regs[ENET_EIR] |=3D ENET_INT_BABT; } - dma_memory_read(&address_space_memory, bd.data, ptr, len); + dma_memory_read(&address_space_memory, bd.data, ptr, len, + MEMTXATTRS_UNSPECIFIED); ptr +=3D len; frame_size +=3D len; if (bd.flags & ENET_BD_L) { @@ -557,7 +562,8 @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t ind= ex) len =3D ENET_MAX_FRAME_SIZE - frame_size; s->regs[ENET_EIR] |=3D ENET_INT_BABT; } - dma_memory_read(&address_space_memory, bd.data, ptr, len); + dma_memory_read(&address_space_memory, bd.data, ptr, len, + MEMTXATTRS_UNSPECIFIED); ptr +=3D len; frame_size +=3D len; if (bd.flags & ENET_BD_L) { @@ -1109,11 +1115,12 @@ static ssize_t imx_fec_receive(NetClientState *nc, = const uint8_t *buf, buf_len +=3D size - 4; } buf_addr =3D bd.data; - dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len, + MEMTXATTRS_UNSPECIFIED); buf +=3D buf_len; if (size < 4) { dma_memory_write(&address_space_memory, buf_addr + buf_len, - crc_ptr, 4 - size); + crc_ptr, 4 - size, MEMTXATTRS_UNSPECIFIED); crc_ptr +=3D 4 - size; } bd.flags &=3D ~ENET_BD_E; @@ -1216,8 +1223,8 @@ static ssize_t imx_enet_receive(NetClientState *nc, c= onst uint8_t *buf, */ const uint8_t zeros[2] =3D { 0 }; =20 - dma_memory_write(&address_space_memory, buf_addr, - zeros, sizeof(zeros)); + dma_memory_write(&address_space_memory, buf_addr, zeros, + sizeof(zeros), MEMTXATTRS_UNSPECIFIED); =20 buf_addr +=3D sizeof(zeros); buf_len -=3D sizeof(zeros); @@ -1226,11 +1233,12 @@ static ssize_t imx_enet_receive(NetClientState *nc,= const uint8_t *buf, shift16 =3D false; } =20 - dma_memory_write(&address_space_memory, buf_addr, buf, buf_len); + dma_memory_write(&address_space_memory, buf_addr, buf, buf_len, + MEMTXATTRS_UNSPECIFIED); buf +=3D buf_len; if (size < 4) { dma_memory_write(&address_space_memory, buf_addr + buf_len, - crc_ptr, 4 - size); + crc_ptr, 4 - size, MEMTXATTRS_UNSPECIFIED); crc_ptr +=3D 4 - size; } bd.flags &=3D ~ENET_BD_E; diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index a15de06a10c..877df8752a0 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -355,7 +355,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) dma_addr =3D s->dma_addr; s->dma_addr =3D 0; =20 - if (dma_memory_read(s->dma_as, dma_addr, &dma, sizeof(dma))) { + if (dma_memory_read(s->dma_as, dma_addr, + &dma, sizeof(dma), MEMTXATTRS_UNSPECIFIED)) { stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), FW_CFG_DMA_CTL_ERROR); return; @@ -417,7 +418,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) */ if (read) { if (dma_memory_write(s->dma_as, dma.address, - &e->data[s->cur_offset], len)) { + &e->data[s->cur_offset], len, + MEMTXATTRS_UNSPECIFIED)) { dma.control |=3D FW_CFG_DMA_CTL_ERROR; } } @@ -425,7 +427,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s) if (!e->allow_write || len !=3D dma.length || dma_memory_read(s->dma_as, dma.address, - &e->data[s->cur_offset], len)) { + &e->data[s->cur_offset], len, + MEMTXATTRS_UNSPECIFIED)) { dma.control |=3D FW_CFG_DMA_CTL_ERROR; } else if (e->write_cb) { e->write_cb(e->callback_opaque, s->cur_offset, len); diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c index 82132c12ca9..3e0938e5f4e 100644 --- a/hw/pci-host/pnv_phb3.c +++ b/hw/pci-host/pnv_phb3.c @@ -714,7 +714,8 @@ static bool pnv_phb3_resolve_pe(PnvPhb3DMASpace *ds) bus_num =3D pci_bus_num(ds->bus); addr =3D rtt & PHB_RTT_BASE_ADDRESS_MASK; addr +=3D 2 * ((bus_num << 8) | ds->devfn); - if (dma_memory_read(&address_space_memory, addr, &rte, sizeof(rte))) { + if (dma_memory_read(&address_space_memory, addr, &rte, + sizeof(rte), MEMTXATTRS_UNSPECIFIED)) { phb3_error(ds->phb, "Failed to read RTT entry at 0x%"PRIx64, addr); /* Set error bits ? fence ? ... */ return false; @@ -793,7 +794,7 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds,= hwaddr addr, /* Grab the TCE address */ taddr =3D base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) <<= 3); if (dma_memory_read(&address_space_memory, taddr, &tce, - sizeof(tce))) { + sizeof(tce), MEMTXATTRS_UNSPECIFIED)) { phb3_error(phb, "Failed to read TCE at 0x%"PRIx64, taddr); return; } diff --git a/hw/pci-host/pnv_phb3_msi.c b/hw/pci-host/pnv_phb3_msi.c index 099d2092a2c..8bcbc2cc4f3 100644 --- a/hw/pci-host/pnv_phb3_msi.c +++ b/hw/pci-host/pnv_phb3_msi.c @@ -53,7 +53,8 @@ static bool phb3_msi_read_ive(PnvPHB3 *phb, int srcno, ui= nt64_t *out_ive) return false; } =20 - if (dma_memory_read(&address_space_memory, ive_addr, &ive, sizeof(ive)= )) { + if (dma_memory_read(&address_space_memory, ive_addr, + &ive, sizeof(ive), MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "Failed to read IVE at 0x%" PRIx64, ive_addr); return false; @@ -73,7 +74,8 @@ static void phb3_msi_set_p(Phb3MsiState *msi, int srcno, = uint8_t gen) return; } =20 - if (dma_memory_write(&address_space_memory, ive_addr + 4, &p, 1)) { + if (dma_memory_write(&address_space_memory, ive_addr + 4, + &p, 1, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "Failed to write IVE (set P) at 0x%" PRIx64, ive_add= r); } @@ -89,7 +91,8 @@ static void phb3_msi_set_q(Phb3MsiState *msi, int srcno) return; } =20 - if (dma_memory_write(&address_space_memory, ive_addr + 5, &q, 1)) { + if (dma_memory_write(&address_space_memory, ive_addr + 5, + &q, 1, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(LOG_GUEST_ERROR, "Failed to write IVE (set Q) at 0x%" PRIx64, ive_add= r); } diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 75ad766fe0b..4369a97b9d2 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -889,7 +889,8 @@ static bool pnv_phb4_resolve_pe(PnvPhb4DMASpace *ds) bus_num =3D pci_bus_num(ds->bus); addr =3D rtt & PHB_RTT_BASE_ADDRESS_MASK; addr +=3D 2 * ((bus_num << 8) | ds->devfn); - if (dma_memory_read(&address_space_memory, addr, &rte, sizeof(rte))) { + if (dma_memory_read(&address_space_memory, addr, + &rte, sizeof(rte), MEMTXATTRS_UNSPECIFIED)) { phb_error(ds->phb, "Failed to read RTT entry at 0x%"PRIx64, addr); /* Set error bits ? fence ? ... */ return false; @@ -958,8 +959,8 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds,= hwaddr addr, while ((lev--) >=3D 0) { /* Grab the TCE address */ taddr =3D base | (((addr >> sh) & ((1ul << tbl_shift) - 1)) <<= 3); - if (dma_memory_read(&address_space_memory, taddr, &tce, - sizeof(tce))) { + if (dma_memory_read(&address_space_memory, taddr, + &tce, sizeof(tce), MEMTXATTRS_UNSPECIFIED)= ) { phb_error(ds->phb, "Failed to read TCE at 0x%"PRIx64, tadd= r); return; } diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c index e82afb75eb6..e98956ebb76 100644 --- a/hw/sd/allwinner-sdhost.c +++ b/hw/sd/allwinner-sdhost.c @@ -309,7 +309,8 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostS= tate *s, uint8_t buf[1024]; =20 /* Read descriptor */ - dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc)); + dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); if (desc->size =3D=3D 0) { desc->size =3D klass->max_desc_size; } else if (desc->size > klass->max_desc_size) { @@ -335,23 +336,24 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHos= tState *s, /* Write to SD bus */ if (is_write) { dma_memory_read(&s->dma_as, - (desc->addr & DESC_SIZE_MASK) + num_done, - buf, buf_bytes); + (desc->addr & DESC_SIZE_MASK) + num_done, buf, + buf_bytes, MEMTXATTRS_UNSPECIFIED); sdbus_write_data(&s->sdbus, buf, buf_bytes); =20 /* Read from SD bus */ } else { sdbus_read_data(&s->sdbus, buf, buf_bytes); dma_memory_write(&s->dma_as, - (desc->addr & DESC_SIZE_MASK) + num_done, - buf, buf_bytes); + (desc->addr & DESC_SIZE_MASK) + num_done, buf, + buf_bytes, MEMTXATTRS_UNSPECIFIED); } num_done +=3D buf_bytes; } =20 /* Clear hold flag and flush descriptor */ desc->status &=3D ~DESC_STATUS_HOLD; - dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc)); + dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc), + MEMTXATTRS_UNSPECIFIED); =20 return num_done; } diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 1785d7e1f79..987d76e72ae 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -604,8 +604,8 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState= *s) s->blkcnt--; } } - dma_memory_write(s->dma_as, s->sdmasysad, - &s->fifo_buffer[begin], s->data_count - begin= ); + dma_memory_write(s->dma_as, s->sdmasysad, &s->fifo_buffer[begi= n], + s->data_count - begin, MEMTXATTRS_UNSPECIFIED= ); s->sdmasysad +=3D s->data_count - begin; if (s->data_count =3D=3D block_size) { s->data_count =3D 0; @@ -626,8 +626,8 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState= *s) s->data_count =3D block_size; boundary_count -=3D block_size - begin; } - dma_memory_read(s->dma_as, s->sdmasysad, - &s->fifo_buffer[begin], s->data_count - begin); + dma_memory_read(s->dma_as, s->sdmasysad, &s->fifo_buffer[begin= ], + s->data_count - begin, MEMTXATTRS_UNSPECIFIED); s->sdmasysad +=3D s->data_count - begin; if (s->data_count =3D=3D block_size) { sdbus_write_data(&s->sdbus, s->fifo_buffer, block_size); @@ -659,9 +659,11 @@ static void sdhci_sdma_transfer_single_block(SDHCIStat= e *s) =20 if (s->trnmod & SDHC_TRNS_READ) { sdbus_read_data(&s->sdbus, s->fifo_buffer, datacnt); - dma_memory_write(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt); + dma_memory_write(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt, + MEMTXATTRS_UNSPECIFIED); } else { - dma_memory_read(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt); + dma_memory_read(s->dma_as, s->sdmasysad, s->fifo_buffer, datacnt, + MEMTXATTRS_UNSPECIFIED); sdbus_write_data(&s->sdbus, s->fifo_buffer, datacnt); } s->blkcnt--; @@ -683,7 +685,8 @@ static void get_adma_description(SDHCIState *s, ADMADes= cr *dscr) hwaddr entry_addr =3D (hwaddr)s->admasysaddr; switch (SDHC_DMA_TYPE(s->hostctl1)) { case SDHC_CTRL_ADMA2_32: - dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2)); + dma_memory_read(s->dma_as, entry_addr, &adma2, sizeof(adma2), + MEMTXATTRS_UNSPECIFIED); adma2 =3D le64_to_cpu(adma2); /* The spec does not specify endianness of descriptor table. * We currently assume that it is LE. @@ -694,7 +697,8 @@ static void get_adma_description(SDHCIState *s, ADMADes= cr *dscr) dscr->incr =3D 8; break; case SDHC_CTRL_ADMA1_32: - dma_memory_read(s->dma_as, entry_addr, &adma1, sizeof(adma1)); + dma_memory_read(s->dma_as, entry_addr, &adma1, sizeof(adma1), + MEMTXATTRS_UNSPECIFIED); adma1 =3D le32_to_cpu(adma1); dscr->addr =3D (hwaddr)(adma1 & 0xFFFFF000); dscr->attr =3D (uint8_t)extract32(adma1, 0, 7); @@ -706,10 +710,13 @@ static void get_adma_description(SDHCIState *s, ADMAD= escr *dscr) } break; case SDHC_CTRL_ADMA2_64: - dma_memory_read(s->dma_as, entry_addr, &dscr->attr, 1); - dma_memory_read(s->dma_as, entry_addr + 2, &dscr->length, 2); + dma_memory_read(s->dma_as, entry_addr, &dscr->attr, 1, + MEMTXATTRS_UNSPECIFIED); + dma_memory_read(s->dma_as, entry_addr + 2, &dscr->length, 2, + MEMTXATTRS_UNSPECIFIED); dscr->length =3D le16_to_cpu(dscr->length); - dma_memory_read(s->dma_as, entry_addr + 4, &dscr->addr, 8); + dma_memory_read(s->dma_as, entry_addr + 4, &dscr->addr, 8, + MEMTXATTRS_UNSPECIFIED); dscr->addr =3D le64_to_cpu(dscr->addr); dscr->attr &=3D (uint8_t) ~0xC0; dscr->incr =3D 12; @@ -767,7 +774,8 @@ static void sdhci_do_adma(SDHCIState *s) } dma_memory_write(s->dma_as, dscr.addr, &s->fifo_buffer[begin], - s->data_count - begin); + s->data_count - begin, + MEMTXATTRS_UNSPECIFIED); dscr.addr +=3D s->data_count - begin; if (s->data_count =3D=3D block_size) { s->data_count =3D 0; @@ -791,7 +799,8 @@ static void sdhci_do_adma(SDHCIState *s) } dma_memory_read(s->dma_as, dscr.addr, &s->fifo_buffer[begin], - s->data_count - begin); + s->data_count - begin, + MEMTXATTRS_UNSPECIFIED); dscr.addr +=3D s->data_count - begin; if (s->data_count =3D=3D block_size) { sdbus_write_data(&s->sdbus, s->fifo_buffer, block_= size); diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c index 97688d21bf0..fe684f92b7a 100644 --- a/hw/usb/hcd-dwc2.c +++ b/hw/usb/hcd-dwc2.c @@ -261,8 +261,8 @@ static void dwc2_handle_packet(DWC2State *s, uint32_t d= evadr, USBDevice *dev, =20 if (pid !=3D USB_TOKEN_IN) { trace_usb_dwc2_memory_read(hcdma, tlen); - if (dma_memory_read(&s->dma_as, hcdma, - s->usb_buf[chan], tlen) !=3D MEMTX_OK) { + if (dma_memory_read(&s->dma_as, hcdma, s->usb_buf[chan], tlen, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_read failed= \n", __func__); } @@ -317,8 +317,8 @@ babble: =20 if (pid =3D=3D USB_TOKEN_IN) { trace_usb_dwc2_memory_write(hcdma, actual); - if (dma_memory_write(&s->dma_as, hcdma, s->usb_buf[chan], - actual) !=3D MEMTX_OK) { + if (dma_memory_write(&s->dma_as, hcdma, s->usb_buf[chan], actu= al, + MEMTXATTRS_UNSPECIFIED) !=3D MEMTX_OK) { qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_write faile= d\n", __func__); } diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 2b995443fbf..03ea5279f9b 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -383,7 +383,8 @@ static inline int get_dwords(EHCIState *ehci, uint32_t = addr, } =20 for (i =3D 0; i < num; i++, buf++, addr +=3D sizeof(*buf)) { - dma_memory_read(ehci->as, addr, buf, sizeof(*buf)); + dma_memory_read(ehci->as, addr, buf, sizeof(*buf), + MEMTXATTRS_UNSPECIFIED); *buf =3D le32_to_cpu(*buf); } =20 @@ -405,7 +406,8 @@ static inline int put_dwords(EHCIState *ehci, uint32_t = addr, =20 for (i =3D 0; i < num; i++, buf++, addr +=3D sizeof(*buf)) { uint32_t tmp =3D cpu_to_le32(*buf); - dma_memory_write(ehci->as, addr, &tmp, sizeof(tmp)); + dma_memory_write(ehci->as, addr, &tmp, sizeof(tmp), + MEMTXATTRS_UNSPECIFIED); } =20 return num; diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index bac1adf439c..3df6a141b5f 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -452,7 +452,8 @@ static inline int get_dwords(OHCIState *ohci, addr +=3D ohci->localmem_base; =20 for (i =3D 0; i < num; i++, buf++, addr +=3D sizeof(*buf)) { - if (dma_memory_read(ohci->as, addr, buf, sizeof(*buf))) { + if (dma_memory_read(ohci->as, addr, + buf, sizeof(*buf), MEMTXATTRS_UNSPECIFIED)) { return -1; } *buf =3D le32_to_cpu(*buf); @@ -471,7 +472,8 @@ static inline int put_dwords(OHCIState *ohci, =20 for (i =3D 0; i < num; i++, buf++, addr +=3D sizeof(*buf)) { uint32_t tmp =3D cpu_to_le32(*buf); - if (dma_memory_write(ohci->as, addr, &tmp, sizeof(tmp))) { + if (dma_memory_write(ohci->as, addr, + &tmp, sizeof(tmp), MEMTXATTRS_UNSPECIFIED)) { return -1; } } @@ -488,7 +490,8 @@ static inline int get_words(OHCIState *ohci, addr +=3D ohci->localmem_base; =20 for (i =3D 0; i < num; i++, buf++, addr +=3D sizeof(*buf)) { - if (dma_memory_read(ohci->as, addr, buf, sizeof(*buf))) { + if (dma_memory_read(ohci->as, addr, + buf, sizeof(*buf), MEMTXATTRS_UNSPECIFIED)) { return -1; } *buf =3D le16_to_cpu(*buf); @@ -507,7 +510,8 @@ static inline int put_words(OHCIState *ohci, =20 for (i =3D 0; i < num; i++, buf++, addr +=3D sizeof(*buf)) { uint16_t tmp =3D cpu_to_le16(*buf); - if (dma_memory_write(ohci->as, addr, &tmp, sizeof(tmp))) { + if (dma_memory_write(ohci->as, addr, + &tmp, sizeof(tmp), MEMTXATTRS_UNSPECIFIED)) { return -1; } } @@ -537,8 +541,8 @@ static inline int ohci_read_iso_td(OHCIState *ohci, static inline int ohci_read_hcca(OHCIState *ohci, dma_addr_t addr, struct ohci_hcca *hcca) { - return dma_memory_read(ohci->as, addr + ohci->localmem_base, - hcca, sizeof(*hcca)); + return dma_memory_read(ohci->as, addr + ohci->localmem_base, hcca, + sizeof(*hcca), MEMTXATTRS_UNSPECIFIED); } =20 static inline int ohci_put_ed(OHCIState *ohci, @@ -572,7 +576,7 @@ static inline int ohci_put_hcca(OHCIState *ohci, return dma_memory_write(ohci->as, addr + ohci->localmem_base + HCCA_WRITEBACK_OF= FSET, (char *)hcca + HCCA_WRITEBACK_OFFSET, - HCCA_WRITEBACK_SIZE); + HCCA_WRITEBACK_SIZE, MEMTXATTRS_UNSPECIFIED); } =20 /* Read/Write the contents of a TD from/to main memory. */ --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131364; cv=none; d=zohomail.com; s=zohoarc; b=UPtWKSJoasVE+c8FHrOoGxhcOJU6OXJVf2ddA3ZPYzbqbTtSW3vOjeq1rgxrUXNWniBy5Mk1DrqMa9Kb2+lNJ8ENudRKdo4qY4gjJh3oDJVivWPZOaYGHzIDWnWTpXIIZVkhXMbTDKS1TBJ21mURy1F9ZGnmSxrobxWp6g9AZo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131364; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=NLyuskZ143R3Ct0pzqL+Ie6dafsNnC0aYMFcz8ZBRUs=; b=hDF9YdiyIksF56r9EfwCDRx8iNKxpeAgC/p18tzstlRAcwhodSDLOMnZzx3cV72NDqV2XzTzRj4hpyvXJIAICfeOnHQzX/dBYP1V9yeATa5TKdfLKAwWD+3hPX668pfGJ9dCkZQ0XbpShukwKLKH9hRP4AjqOI/IQn26J1qlo8Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1599131364007296.41026027613725; Thu, 3 Sep 2020 04:09:24 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-ETkGQplYMLisu1gvnjA09Q-1; Thu, 03 Sep 2020 07:09:20 -0400 Received: by mail-wm1-f69.google.com with SMTP id c198so846568wme.5 for ; Thu, 03 Sep 2020 04:09:20 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id b2sm3705778wmh.47.2020.09.03.04.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131362; 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=NLyuskZ143R3Ct0pzqL+Ie6dafsNnC0aYMFcz8ZBRUs=; b=KsW+eMkrrlsiq/TRph3Bp2BlMU8VbEatANtFtd8uayiDsppU7IW90TlDbm9Cp556z4VqEG VIrp3N1C4kWEGohqJnMKQqxZYWJS73pCqBa3mfPfMhPWvNs3PrusB0na6Dl5plDnhRTzlA u2hg9LhlEMre1MptVw6+AoPyzGGSmSo= X-MC-Unique: ETkGQplYMLisu1gvnjA09Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NLyuskZ143R3Ct0pzqL+Ie6dafsNnC0aYMFcz8ZBRUs=; b=FH6DDRAmY2WDs1fVTyyhkQc81zMUfhkrf1e2tdsq7qd9maVmnLBxniPDmp+PNE07d8 2wP1NEVcIdBb5g3PXa9TR1f0aO16E2ojXh+PgU/XJuYRGVVkMCq6lowJ7B3Z4Vo/xLky bYkbg6dVne69G7pWcv9PSTjZcaEJzFBaH31uhU73GBG0hvyzY3KXRQE9eJfqEGEu73so maWrj+JoJP4bFoteSWhl0OND4se234AH5R0+XM6/Y2wJWYGbLGEdsYEcaXvoWNvxiqfD A+9bx4Msgtk2V1i2PlNjWLRdOV2/9k6Zoro5NyC+g6Ne8enaRvBSKWfvjvewaFYSD4MI JbkA== X-Gm-Message-State: AOAM532BRPyvLPRUZb1TtgdxvZ0oC216OBRNpe2my9XkSFUPEgcyUn/K CgaGPfZwDPsDsiw0rXCMxd2NauIIrvkr5URGejUvhuCUf5483YUF1Cg41CqfkdeD0Rv2xxUAaAz 6AkKMIeydUDZ5Ew== X-Received: by 2002:adf:c983:: with SMTP id f3mr1866724wrh.348.1599131358935; Thu, 03 Sep 2020 04:09:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypkCQ6H6y1ceFbQJjJEbMrPi5iaUBHSOSve6wgsWGZQv8a6VBkqjOdsBURxD8OhLXqPyfb7Q== X-Received: by 2002:adf:c983:: with SMTP id f3mr1866690wrh.348.1599131358709; Thu, 03 Sep 2020 04:09:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [PATCH 07/12] dma: Let dma_memory_map() take MemTxAttrs argument Date: Thu, 3 Sep 2020 13:08:26 +0200 Message-Id: <20200903110831.353476-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Patch created mechanically using spatch with this script: @@ expression E1, E2, E3, E4; @@ - dma_memory_map(E1, E2, E3, E4) + dma_memory_map(E1, E2, E3, E4, MEMTXATTRS_UNSPECIFIED) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/pci/pci.h | 3 ++- include/sysemu/dma.h | 4 ++-- dma-helpers.c | 3 ++- hw/display/virtio-gpu.c | 8 ++++++-- hw/hyperv/vmbus.c | 8 +++++--- hw/ide/ahci.c | 9 ++++++--- hw/usb/libhw.c | 3 ++- hw/virtio/virtio.c | 6 ++++-- 8 files changed, 29 insertions(+), 15 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 0c3217e019c..a221dfb3b08 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -831,7 +831,8 @@ static inline void *pci_dma_map(PCIDevice *dev, dma_add= r_t addr, { void *buf; =20 - buf =3D dma_memory_map(pci_get_address_space(dev), addr, plen, dir); + buf =3D dma_memory_map(pci_get_address_space(dev), addr, plen, dir, + MEMTXATTRS_UNSPECIFIED); return buf; } =20 diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index f0880b79e74..9d0e145d76f 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -134,13 +134,13 @@ int dma_memory_set(AddressSpace *as, dma_addr_t addr, =20 static inline void *dma_memory_map(AddressSpace *as, dma_addr_t addr, dma_addr_t *len, - DMADirection dir) + DMADirection dir, MemTxAttrs attrs) { hwaddr xlen =3D *len; void *p; =20 p =3D address_space_map(as, addr, &xlen, dir =3D=3D DMA_DIRECTION_FROM= _DEVICE, - MEMTXATTRS_UNSPECIFIED); + attrs); *len =3D xlen; return p; } diff --git a/dma-helpers.c b/dma-helpers.c index 50473bb1996..dfac123680b 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -143,7 +143,8 @@ static void dma_blk_cb(void *opaque, int ret) while (dbs->sg_cur_index < dbs->sg->nsg) { cur_addr =3D dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byt= e; cur_len =3D dbs->sg->sg[dbs->sg_cur_index].len - dbs->sg_cur_byte; - mem =3D dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir); + mem =3D dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir, + MEMTXATTRS_UNSPECIFIED); /* * Make reads deterministic in icount mode. Windows sometimes issu= es * disk read requests with overlapping SGs. It leads diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5f0dd7c1500..be7f5cdee46 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -648,7 +648,9 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, hwaddr len =3D l; (*iov)[i].iov_len =3D l; (*iov)[i].iov_base =3D dma_memory_map(VIRTIO_DEVICE(g)->dma_as, - a, &len, DMA_DIRECTION_TO_DEVI= CE); + a, &len, + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (addr) { (*addr)[i] =3D a; } @@ -1049,7 +1051,9 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, hwaddr len =3D res->iov[i].iov_len; res->iov[i].iov_base =3D dma_memory_map(VIRTIO_DEVICE(g)->dma_as, - res->addrs[i], &len, DMA_DIRECTION_TO_DEVIC= E); + res->addrs[i], &len, + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); =20 if (!res->iov[i].iov_base || len !=3D res->iov[i].iov_len) { /* Clean up the half-a-mapping we just created... */ diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c index 75af6b83dde..56621d72e5b 100644 --- a/hw/hyperv/vmbus.c +++ b/hw/hyperv/vmbus.c @@ -372,7 +372,8 @@ static ssize_t gpadl_iter_io(GpadlIter *iter, void *buf= , uint32_t len) =20 maddr =3D (iter->gpadl->gfns[idx] << TARGET_PAGE_BITS) | off_i= n_page; =20 - iter->map =3D dma_memory_map(iter->as, maddr, &mlen, iter->dir= ); + iter->map =3D dma_memory_map(iter->as, maddr, &mlen, iter->dir, + MEMTXATTRS_UNSPECIFIED); if (mlen !=3D pgleft) { dma_memory_unmap(iter->as, iter->map, mlen, iter->dir, 0); iter->map =3D NULL; @@ -488,7 +489,8 @@ int vmbus_map_sgl(VMBusChanReq *req, DMADirection dir, = struct iovec *iov, goto err; } =20 - iov[ret_cnt].iov_base =3D dma_memory_map(sgl->as, a, &l, dir); + iov[ret_cnt].iov_base =3D dma_memory_map(sgl->as, a, &l, dir, + MEMTXATTRS_UNSPECIFIED); if (!l) { ret =3D -EFAULT; goto err; @@ -564,7 +566,7 @@ static vmbus_ring_buffer *ringbuf_map_hdr(VMBusRingBufC= ommon *ringbuf) dma_addr_t mlen =3D sizeof(*rb); =20 rb =3D dma_memory_map(ringbuf->as, ringbuf->rb_addr, &mlen, - DMA_DIRECTION_FROM_DEVICE); + DMA_DIRECTION_FROM_DEVICE, MEMTXATTRS_UNSPECIFIED); if (mlen !=3D sizeof(*rb)) { dma_memory_unmap(ringbuf->as, rb, mlen, DMA_DIRECTION_FROM_DEVICE, 0); diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index b696c6291a3..fe1a4e2b1a2 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -249,7 +249,8 @@ static void map_page(AddressSpace *as, uint8_t **ptr, u= int64_t addr, dma_memory_unmap(as, *ptr, len, DMA_DIRECTION_FROM_DEVICE, len); } =20 - *ptr =3D dma_memory_map(as, addr, &len, DMA_DIRECTION_FROM_DEVICE); + *ptr =3D dma_memory_map(as, addr, &len, DMA_DIRECTION_FROM_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (len < wanted) { dma_memory_unmap(as, *ptr, len, DMA_DIRECTION_FROM_DEVICE, len); *ptr =3D NULL; @@ -938,7 +939,8 @@ static int ahci_populate_sglist(AHCIDevice *ad, QEMUSGL= ist *sglist, =20 /* map PRDT */ if (!(prdt =3D dma_memory_map(ad->hba->as, prdt_addr, &prdt_len, - DMA_DIRECTION_TO_DEVICE))){ + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED))) { trace_ahci_populate_sglist_no_map(ad->hba, ad->port_no); return -1; } @@ -1299,7 +1301,8 @@ static int handle_cmd(AHCIState *s, int port, uint8_t= slot) tbl_addr =3D le64_to_cpu(cmd->tbl_addr); cmd_len =3D 0x80; cmd_fis =3D dma_memory_map(s->as, tbl_addr, &cmd_len, - DMA_DIRECTION_FROM_DEVICE); + DMA_DIRECTION_FROM_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (!cmd_fis) { trace_handle_cmd_badfis(s, port); return -1; diff --git a/hw/usb/libhw.c b/hw/usb/libhw.c index 9c33a1640f7..f350eae443d 100644 --- a/hw/usb/libhw.c +++ b/hw/usb/libhw.c @@ -36,7 +36,8 @@ int usb_packet_map(USBPacket *p, QEMUSGList *sgl) =20 while (len) { dma_addr_t xlen =3D len; - mem =3D dma_memory_map(sgl->as, base, &xlen, dir); + mem =3D dma_memory_map(sgl->as, base, &xlen, dir, + MEMTXATTRS_UNSPECIFIED); if (!mem) { goto err; } diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e9830252176..c951131ba39 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1320,7 +1320,8 @@ static bool virtqueue_map_desc(VirtIODevice *vdev, un= signed int *p_num_sg, iov[num_sg].iov_base =3D dma_memory_map(vdev->dma_as, pa, &len, is_write ? DMA_DIRECTION_FROM_DEVICE : - DMA_DIRECTION_TO_DEVICE); + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (!iov[num_sg].iov_base) { virtio_error(vdev, "virtio: bogus descriptor or out of resourc= es"); goto out; @@ -1369,7 +1370,8 @@ static void virtqueue_map_iovec(VirtIODevice *vdev, s= truct iovec *sg, sg[i].iov_base =3D dma_memory_map(vdev->dma_as, addr[i], &len, is_write ? DMA_DIRECTION_FROM_DEVICE : - DMA_DIRECTION_TO_DEVICE); + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); if (!sg[i].iov_base) { error_report("virtio: error trying to map MMIO memory"); exit(1); --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131370; cv=none; d=zohomail.com; s=zohoarc; b=Io9B+2lUKBUnummKZ7c4bGrAnu9iJFaiH1EJHOY74EV1rvXTrG6OqVEuvd2IWiciUFT0cS4KK9QBM4I9ttbGK8mmORxxUy6mCLatv95UL1j8UwoVa2MtvDDVqN2uGS8Ov8vM8eM2qPfPnaenUZuOu7QFIXBE2SFclq5czqBqgWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131370; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=QoQLqcCGXTEq/TAmIUw2m4awB0M5QrT2MRC6GDSSjNM=; b=MLOxGgixyDVYb8LnZyfHC19Jc3VSTpUdkpUYrPBuQMh2BlEcwkMj+opjXQRzXd/i50/adGIRUJhg6hoMe7nQcV+GijxmTXHTQ7q4j/v2PZps4oXrCoL0LhniWSVInR+saGXNwBeKIlNUh4jRuvhoACRxAKmofiai9h2jj1/+8es= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1599131370232119.15306548436422; Thu, 3 Sep 2020 04:09:30 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-b_jqP8xKM_ykWJpx72ZUuw-1; Thu, 03 Sep 2020 07:09:26 -0400 Received: by mail-wm1-f70.google.com with SMTP id x6so843661wmb.6 for ; Thu, 03 Sep 2020 04:09:25 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id h6sm3675054wmb.22.2020.09.03.04.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131369; 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=QoQLqcCGXTEq/TAmIUw2m4awB0M5QrT2MRC6GDSSjNM=; b=PJ1+gAHqSsR37f12/n1YOmgSyDzlJLsD3XEg6KKtbQ//7vkTaTUcdV8hgH3nwBigGbwjM0 Me/M+GovSAVL/56IOfVCHqUm0gdBnKW2xMGcx6AnoH+Hog2ug9U0Wcj7byym19dquTLkNp RDgU8eFH90kI5niB6TqYv2J2u449P+4= X-MC-Unique: b_jqP8xKM_ykWJpx72ZUuw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QoQLqcCGXTEq/TAmIUw2m4awB0M5QrT2MRC6GDSSjNM=; b=ZOTtLfH6Q3ezCQC/sYUUfnSoRYxfUuh2wYsS6kc+KpAHmYhJ+c2lQV9xCg8wgIRpep +/yMnxpYIQW/qZQ0fdUw/rSQdc9ihU21ilzISPjta3ZkBSgjrp5bbJ9tQOD+BHVbD2lG vj8OtUXVst89Y8NctiTOoqCy7QjlNWsaQN2WRTUvUpQj3pvHs4ZDFXfd4ePfCh4VoFzR yR2k+MCYpWuauhfto7c015qCGk/TBvLTzo0PIIKvRGtXrQWR0AnWNk8ZTR6BeaS65IC/ wHmAf8oOBHXSNF7ohUdaxkrLQfoD4QIzF7j9xPT2RncMhgec7DIz2OY35+e6RWSgj3K/ n+Ew== X-Gm-Message-State: AOAM533hFQXoeZes4DLhq7obXvkOhhmKviARvdYo06c63N0VX7BqVYDR dnfj+mpB2+yfvKN29JFgRw1oTYRiu36RZsyycJeeYUnOYQZRxZwYKt6VkEybutMAUm0AJ35LQ6A OCFpnKragh5WqPQ== X-Received: by 2002:a1c:96c5:: with SMTP id y188mr2031722wmd.72.1599131364950; Thu, 03 Sep 2020 04:09:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaSU7iRONFARcRVCRaU47oXkeaP1W8IN/jSQZtdmBcceRd3LDSad+4MzXAb9YBpYg9kk+eLA== X-Received: by 2002:a1c:96c5:: with SMTP id y188mr2031677wmd.72.1599131364785; Thu, 03 Sep 2020 04:09:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [PATCH 08/12] docs/devel/loads-stores: Add regexp for DMA functions Date: Thu, 3 Sep 2020 13:08:27 +0200 Message-Id: <20200903110831.353476-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/loads-stores.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst index 9a944ef1af6..5b20f907e4d 100644 --- a/docs/devel/loads-stores.rst +++ b/docs/devel/loads-stores.rst @@ -477,6 +477,8 @@ make sure our existing code is doing things correctly. =20 Regexes for git grep - ``\`` + - ``\`` + - ``\`` =20 ``pci_dma_*`` and ``{ld,st}*_pci_dma`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131375; cv=none; d=zohomail.com; s=zohoarc; b=IBbxTbj+u1a0CCMPH7cQLm7kT2h5AbU1Ft5EAps9ubul67aXnEU2eU7ByXtDkk0qhGA6AkPxzSxVbHJyvjom1rqpwDYRGlH3eeHPew7I2alOePDrJj4z0MxZobFK+laYSlupZsmIUQn2bZxX42uAZnhCJ0AgonRDKNjTOwK7HCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131375; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ttIhFvQJ3Qx5h4aB9uiVRWifVpzA075lQL1qUnB3ii8=; b=DOTYMAo35hF7GIKYRp3TpzPqpxB3VTwiQLytxOqF/5lD91BwiR56AA+vYqYuruDLnCXPiTGbQlsnCaRrJ662yo9B22RTyTeeEagFZR9pDytrSzZrv9w/jG8Wykm69vkNnXlQr+UWBVGd/nBdAF5sLTqscxWzleB57wnoDSSvQUc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1599131375921250.15617393670118; Thu, 3 Sep 2020 04:09:35 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-pdnKmmb6M16Neb8vXeSKMw-1; Thu, 03 Sep 2020 07:09:33 -0400 Received: by mail-wr1-f72.google.com with SMTP id m7so935345wrb.20 for ; Thu, 03 Sep 2020 04:09:33 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id n124sm3826996wmn.29.2020.09.03.04.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131375; 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=ttIhFvQJ3Qx5h4aB9uiVRWifVpzA075lQL1qUnB3ii8=; b=PwKhwdKYp8EyksRNtzcUhqHcwUjkji/M17eIE2EkZVzzy5m7/DGuVmKpHixv34ZW9EmFZ6 injlhapbt+EXw6/cgBNYyRHn7TycWmOdsR2CQEhNTf6A7CxrgEyhoCs8J4EvBso+0mktiX F6z08mOSTVd3872oPWKCi0SDNvzZhhI= X-MC-Unique: pdnKmmb6M16Neb8vXeSKMw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ttIhFvQJ3Qx5h4aB9uiVRWifVpzA075lQL1qUnB3ii8=; b=Cn1U+wk0MUM1HcpKsPEg1QxtK+8ivyJ8o3U5AeINNN61zods5chzQ0TJYochz9F74X nXUBQQBOS+WhOvksD8e4SBXToelZOdVAyfuB4L3UMajH8FgHU3Yj+WU/PQgkB+fsFe99 9T/MFt+zHTV9HOCBVymSX/vQrdomMuucawNy+3907zw/vRqDlIcr495hFRpVrIC7PYAS NBDquMreaJ0/8l2W2ASGSDfeP8UNFQdsHNqwEncZ7mBL3Hy2qIaVX8TD9LQpsPliih2a ctXeU3hcE5sbPpGaU5v0WGXzKnP9QHiKOkxYrF+zqqo6oq7MAMhNLhDXG9W8D33f+fNj 2ieg== X-Gm-Message-State: AOAM530tqgw1wiFPmXHkCA0yq23EEn1FZ7Gjlc4eIaDmp9ZICJzssRu8 AYA/x9Z7US/IiyaBSdW7lPwt4/WXMryR7SLZUIXqmXwgKp2kzkPmeFD5KMTYBR/FrZ9M5MO5Ahi xTnEpes4kt9stbA== X-Received: by 2002:adf:9125:: with SMTP id j34mr2033737wrj.157.1599131371189; Thu, 03 Sep 2020 04:09:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJe3yX5MvaWSQke6o2y/dh9IKY1D2GnYhS9htoIeRd5BMp4R28WHRNudL8Dzq7tg2W9d8KRA== X-Received: by 2002:adf:9125:: with SMTP id j34mr2033681wrj.157.1599131370911; Thu, 03 Sep 2020 04:09:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [PATCH 09/12] dma: Let load/store DMA functions take MemTxAttrs argument Date: Thu, 3 Sep 2020 13:08:28 +0200 Message-Id: <20200903110831.353476-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/pci/pci.h | 6 ++++-- include/hw/ppc/spapr_vio.h | 15 ++++++++++----- include/sysemu/dma.h | 20 ++++++++++++-------- hw/intc/pnv_xive.c | 7 ++++--- hw/nvram/fw_cfg.c | 4 ++-- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index a221dfb3b08..8f901e6c289 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -808,12 +808,14 @@ static inline int pci_dma_write(PCIDevice *dev, dma_a= ddr_t addr, static inline uint##_bits##_t ld##_l##_pci_dma(PCIDevice *dev, \ dma_addr_t addr) \ { \ - return ld##_l##_dma(pci_get_address_space(dev), addr); \ + return ld##_l##_dma(pci_get_address_space(dev), addr, \ + MEMTXATTRS_UNSPECIFIED); \ } \ static inline void st##_s##_pci_dma(PCIDevice *dev, \ dma_addr_t addr, uint##_bits##_t v= al) \ { \ - st##_s##_dma(pci_get_address_space(dev), addr, val); \ + st##_s##_dma(pci_get_address_space(dev), addr, val, \ + MEMTXATTRS_UNSPECIFIED); \ } =20 PCI_DMA_DEFINE_LDST(ub, b, 8); diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 8168f4fc5a5..e4db1aa7662 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -123,11 +123,16 @@ static inline int spapr_vio_dma_set(SpaprVioDevice *d= ev, uint64_t taddr, H_DEST_PARM : H_SUCCESS; } =20 -#define vio_stb(_dev, _addr, _val) (stb_dma(&(_dev)->as, (_addr), (_val))) -#define vio_sth(_dev, _addr, _val) (stw_be_dma(&(_dev)->as, (_addr), (_val= ))) -#define vio_stl(_dev, _addr, _val) (stl_be_dma(&(_dev)->as, (_addr), (_val= ))) -#define vio_stq(_dev, _addr, _val) (stq_be_dma(&(_dev)->as, (_addr), (_val= ))) -#define vio_ldq(_dev, _addr) (ldq_be_dma(&(_dev)->as, (_addr))) +#define vio_stb(_dev, _addr, _val) (stb_dma(&(_dev)->as, (_addr), (_val), \ + MEMTXATTRS_UNSPECIFIED)) +#define vio_sth(_dev, _addr, _val) (stw_be_dma(&(_dev)->as, (_addr), (_val= ), \ + MEMTXATTRS_UNSPECIFIED)) +#define vio_stl(_dev, _addr, _val) (stl_be_dma(&(_dev)->as, (_addr), (_val= ), \ + MEMTXATTRS_UNSPECIFIED)) +#define vio_stq(_dev, _addr, _val) (stq_be_dma(&(_dev)->as, (_addr), (_val= ), \ + MEMTXATTRS_UNSPECIFIED)) +#define vio_ldq(_dev, _addr) (ldq_be_dma(&(_dev)->as, (_addr), \ + MEMTXATTRS_UNSPECIFIED)) =20 int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq); =20 diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 9d0e145d76f..8a7dbf0b0f3 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -155,31 +155,35 @@ static inline void dma_memory_unmap(AddressSpace *as, =20 #define DEFINE_LDST_DMA(_lname, _sname, _bits, _end) \ static inline uint##_bits##_t ld##_lname##_##_end##_dma(AddressSpace *= as, \ - dma_addr_t add= r) \ + dma_addr_t add= r, \ + MemTxAttrs att= rs) \ { \ uint##_bits##_t val; \ - dma_memory_read(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFIE= D); \ + dma_memory_read(as, addr, &val, (_bits) / 8, attrs); \ return _end##_bits##_to_cpu(val); \ } \ static inline void st##_sname##_##_end##_dma(AddressSpace *as, \ dma_addr_t addr, \ - uint##_bits##_t val) \ + uint##_bits##_t val, \ + MemTxAttrs attrs) \ { \ val =3D cpu_to_##_end##_bits(val); \ - dma_memory_write(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFI= ED); \ + dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ } =20 -static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr) +static inline uint8_t ldub_dma(AddressSpace *as, dma_addr_t addr, + MemTxAttrs attrs) { uint8_t val; =20 - dma_memory_read(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); + dma_memory_read(as, addr, &val, 1, attrs); return val; } =20 -static inline void stb_dma(AddressSpace *as, dma_addr_t addr, uint8_t val) +static inline void stb_dma(AddressSpace *as, dma_addr_t addr, uint8_t val, + MemTxAttrs attrs) { - dma_memory_write(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); + dma_memory_write(as, addr, &val, 1, attrs); } =20 DEFINE_LDST_DMA(uw, w, 16, le); diff --git a/hw/intc/pnv_xive.c b/hw/intc/pnv_xive.c index 5f69626b3a8..3d7d6e0ca4a 100644 --- a/hw/intc/pnv_xive.c +++ b/hw/intc/pnv_xive.c @@ -171,7 +171,7 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xiv= e, uint32_t type, =20 /* Get the page size of the indirect table. */ vsd_addr =3D vsd & VSD_ADDRESS_MASK; - vsd =3D ldq_be_dma(&address_space_memory, vsd_addr); + vsd =3D ldq_be_dma(&address_space_memory, vsd_addr, MEMTXATTRS_UNSPECI= FIED); =20 if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG @@ -194,7 +194,8 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xiv= e, uint32_t type, /* Load the VSD we are looking for, if not already done */ if (vsd_idx) { vsd_addr =3D vsd_addr + vsd_idx * XIVE_VSD_SIZE; - vsd =3D ldq_be_dma(&address_space_memory, vsd_addr); + vsd =3D ldq_be_dma(&address_space_memory, vsd_addr, + MEMTXATTRS_UNSPECIFIED); =20 if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG @@ -541,7 +542,7 @@ static uint64_t pnv_xive_vst_per_subpage(PnvXive *xive,= uint32_t type) =20 /* Get the page size of the indirect table. */ vsd_addr =3D vsd & VSD_ADDRESS_MASK; - vsd =3D ldq_be_dma(&address_space_memory, vsd_addr); + vsd =3D ldq_be_dma(&address_space_memory, vsd_addr, MEMTXATTRS_UNSPECI= FIED); =20 if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 877df8752a0..b8a936bd04a 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -358,7 +358,7 @@ static void fw_cfg_dma_transfer(FWCfgState *s) if (dma_memory_read(s->dma_as, dma_addr, &dma, sizeof(dma), MEMTXATTRS_UNSPECIFIED)) { stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), - FW_CFG_DMA_CTL_ERROR); + FW_CFG_DMA_CTL_ERROR, MEMTXATTRS_UNSPECIFIED); return; } =20 @@ -444,7 +444,7 @@ static void fw_cfg_dma_transfer(FWCfgState *s) } =20 stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), - dma.control); + dma.control, MEMTXATTRS_UNSPECIFIED); =20 trace_fw_cfg_read(s, 0); } --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131380; cv=none; d=zohomail.com; s=zohoarc; b=GqhsCqBQCGXtRVMIjHVdFUdwgNzHps1jURYz6dC0vyS0JKhMFUdf+rqYfgvOZrK1BlD6A1/3a7dwuSr2uhAzgxHSP0qjFJ3boo/5FX8OOvgNqEQ20O1n1s+dsk9T8PxbkG0SK6cnhicpaId+r3ahda/Z4TKnPA4lzsGSrZJNPLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131380; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=6vKwxcBB1Jm47jSnzS0OZNKGx56lCbflcLgkBcmGpYU=; b=ABL0HtroPif/rbAR+D2EqBMfRM8NAffttTGkGf7fbFKMDnd7sj9EoEYTfdZDqXTGs7y2PT4jbdlr5+HFXmxhbeZVLiXgTUIXBooz+mjBnnPNszvlZ8JNlSu/4ANP62EILPcOeMTiULlBpUgRN+7QdJxJuLRL9WTKNmHdLtJAtMU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1599131380431620.0572843610375; Thu, 3 Sep 2020 04:09:40 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-I-7YxIvKMLCSBWdoDjkKjg-1; Thu, 03 Sep 2020 07:09:38 -0400 Received: by mail-wm1-f69.google.com with SMTP id x81so840321wmg.8 for ; Thu, 03 Sep 2020 04:09:38 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id h6sm3675958wmb.22.2020.09.03.04.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131379; 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=6vKwxcBB1Jm47jSnzS0OZNKGx56lCbflcLgkBcmGpYU=; b=c7CutQ7aLjyLcx3mrx4DS914Wtbj5iihfz3Gj1bBraM2YQPEVjxo7sTICrxCKLv5C1A21u gM4SJLpnkJ2WpyfBuX0eLojWX/hHv3MFRAk//mMV23h6dgUFMZKkflie8VUCdE0jFF0dW2 CWTok/+kdQQ8b+3cEOT12nrKn9lnY4Y= X-MC-Unique: I-7YxIvKMLCSBWdoDjkKjg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6vKwxcBB1Jm47jSnzS0OZNKGx56lCbflcLgkBcmGpYU=; b=N80BiyK8wm4ZussLX8UkVT1lWAIWtv4VHMBmc+GlfheYk8QchVqM9mDeahf4Gvw82y ZQVmoslLhQxAf7YfsDv4eLogM++z+uIxKWLuhmRaW+XUqJebaMINKL11pHQ2fjylFAs4 jqIDY40cpwc5+de0nAH8Swc81brDA7tIQsnCB9yq8SI0MjGyqGyUTJ1FMQys4HBgHB0P f5S99P/oydPaGCD/O+BovHIKPSNYwLK7djhQNTTk2rfDXJLepAELh8y7wHUy7Gr7fOqd rPWA2ErWIziZhNG0klKC6Rtuce9aHU3JQu6J+nog0Tb3GSTnB8AyRQMU/xthjD1nUP/M uong== X-Gm-Message-State: AOAM5337jUPf6DzPxvXtIT8g8jVRYALIHthFosHjJlcCnpVVaRZbdTi9 z84t/Xt+pZaNoJLaM50nADrBdSrWTD15TypoqR873ax9H9oo7ZD0QuTfxa7PVZzkVy/Tl+EmhaO f6AsLTw6XRzrofA== X-Received: by 2002:adf:f7d0:: with SMTP id a16mr1759239wrq.381.1599131377060; Thu, 03 Sep 2020 04:09:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9ZzABMZHs/OnZtQQCj7u3oB9peViXkexZzHsdyPbqqnttBSyzIq0Xp6JVHBCMLGPo6NUwEw== X-Received: by 2002:adf:f7d0:: with SMTP id a16mr1759190wrq.381.1599131376857; Thu, 03 Sep 2020 04:09:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [RFC PATCH 10/12] exec/memattrs: Introduce MemTxAttrs::direct_access field Date: Thu, 3 Sep 2020 13:08:29 +0200 Message-Id: <20200903110831.353476-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Add the 'direct_access' bit to the memory attributes to restrict bus master access to ROM/RAM. Have read/write accessors return MEMTX_BUS_ERROR if an access is restricted and the region is not ROM/RAM ('direct'). Add corresponding trace events. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/exec/memattrs.h | 3 +++ exec.c | 8 ++++++++ trace-events | 1 + 3 files changed, 12 insertions(+) diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index 95f2d20d55b..c27cf639a96 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -35,6 +35,8 @@ typedef struct MemTxAttrs { unsigned int secure:1; /* Memory access is usermode (unprivileged) */ unsigned int user:1; + /* Bus master restricted to ROM/RAM slaves */ + unsigned int direct_access:1; /* Requester ID (for MSI for example) */ unsigned int requester_id:16; /* Invert endianness for this page */ @@ -66,6 +68,7 @@ typedef struct MemTxAttrs { #define MEMTX_OK 0 #define MEMTX_ERROR (1U << 0) /* device returned an error */ #define MEMTX_DECODE_ERROR (1U << 1) /* nothing at that address */ +#define MEMTX_BUS_ERROR (1U << 2) /* bus returned an error */ typedef uint32_t MemTxResult; =20 #endif diff --git a/exec.c b/exec.c index 7683afb6a8e..e6185eb04de 100644 --- a/exec.c +++ b/exec.c @@ -3213,6 +3213,10 @@ static MemTxResult flatview_write(FlatView *fv, hwad= dr addr, MemTxAttrs attrs, =20 l =3D len; mr =3D flatview_translate(fv, addr, &addr1, &l, true, attrs); + if (attrs.direct_access && !memory_access_is_direct(mr, true)) { + trace_memory_access_illegal(true, addr, len, mr->name); + return MEMTX_BUS_ERROR; + } result =3D flatview_write_continue(fv, addr, attrs, buf, len, addr1, l, mr); =20 @@ -3275,6 +3279,10 @@ static MemTxResult flatview_read(FlatView *fv, hwadd= r addr, =20 l =3D len; mr =3D flatview_translate(fv, addr, &addr1, &l, false, attrs); + if (attrs.direct_access && !memory_access_is_direct(mr, false)) { + trace_memory_access_illegal(false, addr, len, mr->name); + return MEMTX_BUS_ERROR; + } return flatview_read_continue(fv, addr, attrs, buf, len, addr1, l, mr); } diff --git a/trace-events b/trace-events index 42107ebc697..931896735b1 100644 --- a/trace-events +++ b/trace-events @@ -54,6 +54,7 @@ find_ram_offset_loop(uint64_t size, uint64_t candidate, u= int64_t offset, uint64_ ram_block_discard_range(const char *rbname, void *hva, size_t length, bool= need_madvise, bool need_fallocate, int ret) "%s@%p + 0x%zx: madvise: %d fa= llocate: %d ret: %d" memory_notdirty_write_access(uint64_t vaddr, uint64_t ram_addr, unsigned s= ize) "0x%" PRIx64 " ram_addr 0x%" PRIx64 " size %u" memory_notdirty_set_dirty(uint64_t vaddr) "0x%" PRIx64 +memory_access_illegal(bool is_write, uint64_t addr, uint64_t len, const ch= ar *mr_name) "is_write:%u addr:0x%08" PRIx64 " size:0x%04" PRIx64 " region:= '%s'" =20 # memory.c memory_region_ops_read(int cpu_index, void *mr, uint64_t addr, uint64_t va= lue, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64" size %= u" --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131389; cv=none; d=zohomail.com; s=zohoarc; b=jdJYK30Ztni0jp/gCwWazBN84eOK2ycUcl0AwSIdGey9noSIdJn1uRg2+9lxIIWoOWJNPsshp4tdyzy8UkVjvPu3uVkNIGqG9BS3sw/wV+JHLckubgA0G6T6yt6p+Rdxjme8KPS4mI8v55I8qIEFmL4hv6hbUF/aV6PS6NErPls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Gfc0vh/hSxUgj/nHXInlGH3QJr0Hadg3+ww1zXZjK0w=; b=RLvhd+OKB3tge9J5gPPVVfw25ZDHDJCUKIYTwGuFa9pSId+Ipoz+6SxXRaK5tGdJ1xVyEltvcUeaj/Kipq0lwwxyDKxkAyAqR6rZcsAn34kMXF8PCe02EuuhSUuWMkZ5OArMRW/5mvY3sE677b5pzXf2+xUq45l0JWj0sc8Wlb8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1599131389318862.8953139758501; Thu, 3 Sep 2020 04:09:49 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-Jdf9lz2-Nyi_C9Yh5764qw-1; Thu, 03 Sep 2020 07:09:44 -0400 Received: by mail-wm1-f69.google.com with SMTP id a7so854550wmc.2 for ; Thu, 03 Sep 2020 04:09:44 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id z13sm3820908wro.97.2020.09.03.04.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131388; 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=Gfc0vh/hSxUgj/nHXInlGH3QJr0Hadg3+ww1zXZjK0w=; b=UKpe9sK8U3RUHZqdpXNqXB4rCXrncs31Su5LskFZuaklFP58EOqfSz06TUsDj8vnGis3Xt nPvrJ/0V39wrd8LVFi5JFeo09w8z+whs1G3s02p2cAfUH6SltRPjMGwSZr26xdSnJB10aN oqYebD4A7XYgdV5WS4hH/8uRf8fupHQ= X-MC-Unique: Jdf9lz2-Nyi_C9Yh5764qw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gfc0vh/hSxUgj/nHXInlGH3QJr0Hadg3+ww1zXZjK0w=; b=KubkfzrMGiGzI+4F/MlNe4LCkkSsxRZdEr5PY8QQKv/Y4QAL5j9aZU23D2KEEmPl3J vBAHfSGp3pyYgSzhC6hLitdw88mGiwBqmWNNrb9Gl9d2nECn+TC3OctUo17kHA1T98ds v7I7Ch1iX7Ljk0hDlbquvy6ghF6/m0gFgwViu4/V/N5Lic7AgfZkjz3b0si8DFxHZXCV 2i50wmA7hkE4BN3IlC0oX70VdcjhqEbNXiWcC0sHZepCFr2XFf61Rquz8pBsyepMGvKg EsFZ3cz13XVGdAwfYNsQKc9izLcLU3IqArxNLxp5qb5d703ONgRGSKU6i3OMpehue4lG StuQ== X-Gm-Message-State: AOAM5303ZXK/5NSJpqKdjYVezGs6n9APWeMMF2EJcv2LEbBQOiI9giD6 zSvpRI9+YgTKHHo2AaHnbgntB5pGEwCHBOls24BxgG5pCJ4FivnAdADtVOBolMP5N3IqYCoaG5L tTriXbBQ462M5dA== X-Received: by 2002:a1c:4c06:: with SMTP id z6mr1916146wmf.40.1599131383033; Thu, 03 Sep 2020 04:09:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa1QNXafg0ye14T7uTUb9HQ/dvqWbALHxQzlyRjgumJlibWVrf8ZVOSq1l2j24wGvld+nBug== X-Received: by 2002:a1c:4c06:: with SMTP id z6mr1916113wmf.40.1599131382849; Thu, 03 Sep 2020 04:09:42 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [RFC PATCH 11/12] hw/pci: Only allow PCI slave devices to write to direct memory Date: Thu, 3 Sep 2020 13:08:30 +0200 Message-Id: <20200903110831.353476-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Do not allow PCI slaves to write to indirect memory regions such MMIO. This fixes LP#1886362 and LP#1888606. Example with the former reproducer: $ cat << EOF | \ qemu-system-i386 -M q35,accel=3Dqtest \ -qtest stdio \ -trace memory_access\* \ outl 0xcf8 0x80001010 outl 0xcfc 0xe1020000 outl 0xcf8 0x80001014 outl 0xcf8 0x80001004 outw 0xcfc 0x7 outl 0xcf8 0x800010a2 write 0xe102003b 0x1 0xff write 0xe1020103 0x1e 0xffffff055c5e5c30be4511d084fffffffffffffffffffffff= fffffffffff write 0xe1020420 0x4 0xffffffff write 0xe1020424 0x4 0xffffffff write 0xe102042b 0x1 0xff write 0xe1020430 0x4 0x055c5e5c write 0x5c041 0x1 0x04 write 0x5c042 0x1 0x02 write 0x5c043 0x1 0xe1 write 0x5c048 0x1 0x8a write 0x5c04a 0x1 0x31 write 0x5c04b 0x1 0xff write 0xe1020403 0x1 0xff EOF 562564:memory_access_illegal is_write:1 addr:0xe1020400 size:0x000e regio= n:'e1000e-mmio' 562592:memory_access_illegal is_write:1 addr:0xe102040e size:0x007c regio= n:'e1000e-mmio' 562601:memory_access_illegal is_write:1 addr:0xe102048a size:0x0004 regio= n:'e1000e-mmio' Reported-by: Alexander Bulekov Buglink: https://bugs.launchpad.net/qemu/+bug/1886362 Buglink: https://bugs.launchpad.net/qemu/+bug/1888606 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/pci/pci.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 8f901e6c289..cd97268b3a8 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -788,8 +788,12 @@ static inline AddressSpace *pci_get_address_space(PCID= evice *dev) static inline int pci_dma_rw(PCIDevice *dev, dma_addr_t addr, void *buf, dma_addr_t len, DMADirection dir) { + MemTxAttrs attrs =3D { + .direct_access =3D (dir =3D=3D DMA_DIRECTION_FROM_DEVICE), + .requester_id =3D pci_requester_id(dev), + }; return dma_memory_rw(pci_get_address_space(dev), addr, buf, len, - dir, MEMTXATTRS_UNSPECIFIED); + dir, attrs); } =20 static inline int pci_dma_read(PCIDevice *dev, dma_addr_t addr, @@ -808,14 +812,18 @@ static inline int pci_dma_write(PCIDevice *dev, dma_a= ddr_t addr, static inline uint##_bits##_t ld##_l##_pci_dma(PCIDevice *dev, \ dma_addr_t addr) \ { \ - return ld##_l##_dma(pci_get_address_space(dev), addr, \ - MEMTXATTRS_UNSPECIFIED); \ + MemTxAttrs attrs =3D { \ + .requester_id =3D pci_requester_id(dev), \ + }; \ + return ld##_l##_dma(pci_get_address_space(dev), addr, attrs); \ } \ static inline void st##_s##_pci_dma(PCIDevice *dev, \ dma_addr_t addr, uint##_bits##_t v= al) \ { \ - st##_s##_dma(pci_get_address_space(dev), addr, val, \ - MEMTXATTRS_UNSPECIFIED); \ + MemTxAttrs attrs =3D { \ + .requester_id =3D pci_requester_id(dev), \ + }; \ + st##_s##_dma(pci_get_address_space(dev), addr, val, attrs); \ } =20 PCI_DMA_DEFINE_LDST(ub, b, 8); --=20 2.26.2 From nobody Sun May 19 23:41:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599131393; cv=none; d=zohomail.com; s=zohoarc; b=IDX8g08npEigLTtZ7acEL2ajfM1RGUiFYoS7t346zoRC8fZ+y23UQdzXH+nuKVvUZ+bJ6gNFudHKoyBTmOhdH/SZEXk10Viu154LIH1QsD5s8ghTxjl8nI9IrEVH/WqZSDHgNkSKFxjWl3JAvthKnr/J1FNvVj0tQFFa5dd8ysI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599131393; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=9GnpNx8hKziNiqdzN01AImO2FtSdDZqIBcQzFpkVYA0=; b=mC2OfJNNpuuxRD5EWhVAwDKaBQFXQl2ckK24PF/EoEDOH1TZdrKtYSXIUvxKoQ1J+0TEYaMRURy6NXLfUTRAGiE6jZYAwB4EyZyhuH8MpFkKZair6FNt3rc1UTUY8womkSKYX/ilIWUcUR2KKgMJi92LK8wTiJAvClA8CYtp0NY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1599131393254231.41246106876213; Thu, 3 Sep 2020 04:09:53 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-578-Wp2p8UbFO3WCIdTZmC4vZg-1; Thu, 03 Sep 2020 07:09:51 -0400 Received: by mail-wm1-f69.google.com with SMTP id x6so844026wmb.6 for ; Thu, 03 Sep 2020 04:09:51 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id q3sm3709070wmq.12.2020.09.03.04.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 04:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131392; 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=9GnpNx8hKziNiqdzN01AImO2FtSdDZqIBcQzFpkVYA0=; b=TNDxlO23SAmoDT630w6aRuh6TlsXR98/5QJ3P+aKnR9lhpeN5EoG8l0mG3Pq4wgyUhfnR3 50eWbqWOnOmRz1+Z/K71NwlaBw09aen6LO5iIYC1AEoqOeEx9NHf9KrA7QolMY3CMCbpSa sxFrMA95FE5lq+KuYN09texMvOwz8xQ= X-MC-Unique: Wp2p8UbFO3WCIdTZmC4vZg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9GnpNx8hKziNiqdzN01AImO2FtSdDZqIBcQzFpkVYA0=; b=gojWH40dw0SNjTDhGzTAYBnGFnt4J2dYi25l7ZrA97gARqaFmqNz1s6mp1S47wlXa1 INVif/NqHVIFWNempYqOq7s2z2MO44x4LTTu+Y1hIlJ6rydfy8qRbdGcPuHGXExEymWR iroQpnN9jAIANGu8Jqozwqn+o3YUyoMXVMNsuMWbOghdBMb+VksZMPXBIGF2K7A3fF/S 3Zpbiv3b10UaIXOlnisETZhk4rSZXmk0uEu2aO0KIxIqHa2zX24YXr3F7HridM6i9tUP eyYPB8rfG4GVswFIKLRIPOMDZnkAmN44kZKlVoe/ZPtUpwGWxpKiwsUxN+Q9McvEFzid 5GOQ== X-Gm-Message-State: AOAM533ZEcbsuqJiGWS6LXOWI+k23JlvtzLlZCsONZumXgWwAmvVEgAC KxeQ7/H96dFIPMnFwOqeJcKIk9+ZDDsm8B9SJYFDTJj9BL7BT11GXbg+OHT1HgftnkPJ2kBgJMN 7r7MDIeT8W5/qWQ== X-Received: by 2002:a1c:f003:: with SMTP id a3mr1951201wmb.170.1599131388976; Thu, 03 Sep 2020 04:09:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMrJssg5m9tGdHjZnb9WOYc9LGcKTl/RYUTl+cJMTDL99r9rkDu5mWJzLx75Laz0g6Ll7jVQ== X-Received: by 2002:a1c:f003:: with SMTP id a3mr1951153wmb.170.1599131388703; Thu, 03 Sep 2020 04:09:48 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: John Snow , Gerd Hoffmann , Li Qiang , "Michael S. Tsirkin" , "Edgar E. Iglesias" , Eduardo Habkost , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jan Kiszka , Emanuele Giuseppe Esposito , Eric Auger , Peter Chubb , Beniamino Galvani , Robert Foley , Paolo Bonzini , "Emilio G . Cota" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jason Wang , Andrew Baumann , Laszlo Ersek , Klaus Jensen , Stefan Hajnoczi , Tony Nguyen , Peter Xu , qemu-arm@nongnu.org, Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Andrew Jeffery , Alexander Bulekov , Marcel Apfelbaum , "Edgar E . Iglesias" , Joel Stanley , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , qemu-ppc@nongnu.org, Mark Cave-Ayland , David Gibson , Richard Henderson Subject: [RFC PATCH 12/12] dma: Assert when device writes to indirect memory (such MMIO regions) Date: Thu, 3 Sep 2020 13:08:31 +0200 Message-Id: <20200903110831.353476-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903110831.353476-1-philmd@redhat.com> References: <20200903110831.353476-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Assert DMA accesses are done on direct memory (in particular to catch invalid accesses to MMIO regions). Example with the reproducer from LP#1886362 (see previous commit): qemu-system-i386: include/sysemu/dma.h:111: int dma_memory_rw(AddressSpac= e *, dma_addr_t, void *, dma_addr_t, DMADirection, MemTxAttrs): Assertion `= dir =3D=3D DMA_DIRECTION_TO_DEVICE || attrs.direct_access' failed. (gdb) bt #0 0x00007ffff51d69e5 in raise () at /lib64/libc.so.6 #1 0x00007ffff51bf895 in abort () at /lib64/libc.so.6 #2 0x00007ffff51bf769 in _nl_load_domain.cold () at /lib64/libc.so.6 #3 0x00007ffff51cee76 in annobin_assert.c_end () at /lib64/libc.so.6 #4 0x0000555557b48a94 in dma_memory_rw (as=3D0x7fffddd3ca28, addr=3D4064= , buf=3D0x7fffffff7780, len=3D16, dir=3DDMA_DIRECTION_FROM_DEVICE, attrs=3D= ...) at /home/phil/source/qemu/include/sysemu/dma.h:111 #5 0x0000555557b487e0 in pci_dma_rw (dev=3D0x7fffddd3c800, addr=3D4064, = buf=3D0x7fffffff7780, len=3D16, dir=3DDMA_DIRECTION_FROM_DEVICE) at /home/p= hil/source/qemu/include/hw/pci/pci.h:791 #6 0x0000555557b47373 in pci_dma_write (dev=3D0x7fffddd3c800, addr=3D406= 4, buf=3D0x7fffffff7780, len=3D16) at /home/phil/source/qemu/include/hw/pci= /pci.h:804 #7 0x0000555557b340b4 in e1000e_write_packet_to_guest (core=3D0x7fffddd3= f4e0, pkt=3D0x61100006c740, rxr=3D0x7fffffff7cf0, rss_info=3D0x7fffffff7d10= ) at hw/net/e1000e_core.c:1609 #8 0x0000555557b30739 in e1000e_receive_iov (core=3D0x7fffddd3f4e0, iov= =3D0x619000060e80, iovcnt=3D4) at hw/net/e1000e_core.c:1709 #9 0x00005555576e2069 in e1000e_nc_receive_iov (nc=3D0x61400000a060, iov= =3D0x619000060e80, iovcnt=3D4) at hw/net/e1000e.c:213 #10 0x00005555572a3c34 in net_tx_pkt_sendv (pkt=3D0x631000028800, nc=3D0x= 61400000a060, iov=3D0x619000060e80, iov_cnt=3D4) at hw/net/net_tx_pkt.c:556 #11 0x00005555572a23e2 in net_tx_pkt_send (pkt=3D0x631000028800, nc=3D0x6= 1400000a060) at hw/net/net_tx_pkt.c:633 #12 0x00005555572a4c67 in net_tx_pkt_send_loopback (pkt=3D0x631000028800,= nc=3D0x61400000a060) at hw/net/net_tx_pkt.c:646 #13 0x0000555557b70b05 in e1000e_tx_pkt_send (core=3D0x7fffddd3f4e0, tx= =3D0x7fffddd5f748, queue_index=3D0) at hw/net/e1000e_core.c:664 #14 0x0000555557b6eab8 in e1000e_process_tx_desc (core=3D0x7fffddd3f4e0, = tx=3D0x7fffddd5f748, dp=3D0x7fffffff8680, queue_index=3D0) at hw/net/e1000e= _core.c:743 #15 0x0000555557b6d65d in e1000e_start_xmit (core=3D0x7fffddd3f4e0, txr= =3D0x7fffffff88a0) at hw/net/e1000e_core.c:934 #16 0x0000555557b5ea38 in e1000e_set_tctl (core=3D0x7fffddd3f4e0, index= =3D256, val=3D255) at hw/net/e1000e_core.c:2431 #17 0x0000555557b369ef in e1000e_core_write (core=3D0x7fffddd3f4e0, addr= =3D1027, val=3D255, size=3D4) at hw/net/e1000e_core.c:3265 #18 0x00005555576de3be in e1000e_mmio_write (opaque=3D0x7fffddd3c800, add= r=3D1027, val=3D255, size=3D4) at hw/net/e1000e.c:109 #19 0x0000555558e6b789 in memory_region_write_accessor (mr=3D0x7fffddd3f1= 10, addr=3D1027, value=3D0x7fffffff8eb0, size=3D4, shift=3D0, mask=3D429496= 7295, attrs=3D...) at softmmu/memory.c:483 #20 0x0000555558e6b05b in access_with_adjusted_size (addr=3D1027, value= =3D0x7fffffff8eb0, size=3D1, access_size_min=3D4, access_size_max=3D4, acce= ss_fn=3D 0x555558e6b120 , mr=3D0x7fffddd3f110= , attrs=3D...) at softmmu/memory.c:544 #21 0x0000555558e69776 in memory_region_dispatch_write (mr=3D0x7fffddd3f1= 10, addr=3D1027, data=3D255, op=3DMO_8, attrs=3D...) at softmmu/memory.c:14= 65 #22 0x0000555558f60462 in flatview_write_continue (fv=3D0x60600003f9e0, a= ddr=3D3775005699, attrs=3D..., ptr=3D0x6020000e3710, len=3D1, addr1=3D1027,= l=3D1, mr=3D0x7fffddd3f110) at exec.c:3176 #23 0x0000555558f4e38b in flatview_write (fv=3D0x60600003f9e0, addr=3D377= 5005699, attrs=3D..., buf=3D0x6020000e3710, len=3D1) at exec.c:3220 #24 0x0000555558f4dd4f in address_space_write (as=3D0x60800000baa0, addr= =3D3775005699, attrs=3D..., buf=3D0x6020000e3710, len=3D1) at exec.c:3315 #25 0x000055555916b3e0 in qtest_process_command (chr=3D0x55555c03f300 , words=3D0x604000058150) at softmmu/qtest.c:567 #26 0x000055555915f7f2 in qtest_process_inbuf (chr=3D0x55555c03f300 , inbuf=3D0x6190000200e0) at softmmu/qtest.c:710 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/sysemu/dma.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h index 8a7dbf0b0f3..a4ba9438a56 100644 --- a/include/sysemu/dma.h +++ b/include/sysemu/dma.h @@ -108,6 +108,8 @@ static inline int dma_memory_rw(AddressSpace *as, dma_a= ddr_t addr, void *buf, dma_addr_t len, DMADirection dir, MemTxAttrs attrs) { + assert(dir =3D=3D DMA_DIRECTION_TO_DEVICE || attrs.direct_access); + dma_barrier(as, dir); =20 return dma_memory_rw_relaxed(as, addr, buf, len, dir, attrs); --=20 2.26.2