From patchwork Thu Sep 3 11:08:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F107AC433E2 for ; Thu, 3 Sep 2020 11:11:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB0C8206EB for ; Thu, 3 Sep 2020 11:11:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VWbYzox3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB0C8206EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDn9Q-000517-PQ for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 07:11:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDn6q-0007oJ-79 for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:08:52 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:60761 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kDn6o-0005mN-O3 for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:08:51 -0400 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= 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-277-3v5moL5JONiKpnISUgZACg-1; Thu, 03 Sep 2020 07:08:48 -0400 X-MC-Unique: 3v5moL5JONiKpnISUgZACg-1 Received: by mail-wm1-f69.google.com with SMTP id b73so854590wmb.0 for ; Thu, 03 Sep 2020 04:08:48 -0700 (PDT) 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=RhpLWwDPeIhOtM1SBIx6Trn0eHZiR1dFwR2GlPjehQ4NilWp/RwpTGzqDaldnqixlm nHkuE8A4gC7ERMtuAxl9lVS8+GAQDVGiMzbd+AHt9vMSB5+gr1JeeR6KTFw+HnPGEMxq UleDGS/dhCY0pcaIxrBX54kofMuR3a1OFze4pUnC+EuF1OTufZuzRNujN1eF1U9Z0M4X 9ztSGTvHc+NdacF5N92/bOGjr5M1QyCcR2SiEYXJdiLpfffKMWuJ5evTYscGCRcPxccy OV4PHL4iM2a3XZDTEMmE6NTGmyYG2CMEzPq5TxpeONnx8uEPphw2qw4ASufxUprC/INp 6DIA== X-Gm-Message-State: AOAM530iks84CzcEmiZZNoBaaMdlcxM10Utu49NdYLeLbApqeWgjOfgB zvTDX7Vm9XngpwA05rckifL01LSsp+ZO4FGSC38BPlE42rw1fQuBGFarcWRZmQH//7+jK1ueBuu yvAD94xVZiJVLtqo= X-Received: by 2002:a05:600c:210c:: with SMTP id u12mr2040147wml.185.1599131327268; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 00:24:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Eduardo Habkost , "Edgar E . Iglesias" , qemu-block@nongnu.org, Li Qiang , "Emilio G . Cota" , Peter Chubb , Joel Stanley , Richard Henderson , Laszlo Ersek , Robert Foley , Alistair Francis , Richard Henderson , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefan Hajnoczi , John Snow , David Gibson , Tony Nguyen , Prasad J Pandit , Alexander Bulekov , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-ppc@nongnu.org, Klaus Jensen , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- 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 *dev) 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_UNSPECIFIED); } 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, DMADirection 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 == DMA_DIRECTION_FROM_DEVICE, - MEMTXATTRS_UNSPECIFIED); + attrs); } static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr, From patchwork Thu Sep 3 11:08:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274698 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AF43C433E9 for ; Thu, 3 Sep 2020 11:13:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 58603206EB for ; Thu, 3 Sep 2020 11:13:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Wpe1eQoI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58603206EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDnB3-0007cX-Dx for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 07:13:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDn6x-00086u-4w for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:08:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kDn6v-0005oK-4a for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:08:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131336; 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=Wpe1eQoIHEu7dTKs1rcgYcJt2GJojIuGGZII551eRHkzVtoizo8FN0QusQ5ZjQsu0KhGZO PoSTYs3jmUM2+Ux0zHzNFq1CxE5HRr8YSBXMPy0FbzOynVwl4AVBHP2cHBe7+GoLgYhEtZ YjzaQb5V3H7c2io05i54N23gAiq+oAE= 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-91-EnqphyunOeWvorZhqSidlQ-1; Thu, 03 Sep 2020 07:08:54 -0400 X-MC-Unique: EnqphyunOeWvorZhqSidlQ-1 Received: by mail-wm1-f70.google.com with SMTP id b14so848214wmj.3 for ; Thu, 03 Sep 2020 04:08:54 -0700 (PDT) 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=Dp5QmAXqL/mc1Y9utVEoaXHCS8aPE+/qaJhyEV7s1xDBliYbJ+BdrzbcHGAifGXPpY 13kNhevTHn2eaD4SJh89JzDOLAd5q+/kBJldH4SCqbKArYvrTc6kKNFJrlx66lImxOj2 qwkIwVdlJ4Hvgwnp7IOzWEClwKjjnN65R+9AiFt+MjzbidvPEXRZBWmcdw5fML9LHp0Q xqgMFZRB+690bxzi1zTvhQXgCsYJQ6CFQxs/NXZ0WchsN6LMuW0vGBCQI1ddr1D4F6ni 8QITvPMmSWZZRJRbc8I/WOGftW1OTIXvnDhGfvsQk7Q+ly+bFcLMLyT7sMkahKRDHYNG CpaQ== X-Gm-Message-State: AOAM530ralr1NMDHE2Ncn9csKbvQmfr1bWSfcTsaIoL0PPcO+dXB5a6D 36TwqEYr6wnL+7k8FX8Cio+DyP5MTNWrLrAtU4O7qB9aIM7U038aogibdkRsDp7vMzq5SUla+mi cUFQaFaAfHykVga8= X-Received: by 2002:adf:ec45:: with SMTP id w5mr1930582wrn.357.1599131333635; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 01:47:17 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Eduardo Habkost , "Edgar E . Iglesias" , qemu-block@nongnu.org, Li Qiang , "Emilio G . Cota" , Peter Chubb , Joel Stanley , Richard Henderson , Laszlo Ersek , Robert Foley , Alistair Francis , Richard Henderson , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefan Hajnoczi , John Snow , David Gibson , Tony Nguyen , Prasad J Pandit , Alexander Bulekov , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-ppc@nongnu.org, Klaus Jensen , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- 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 *dev, 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) != 0) ? + return (dma_memory_set(&dev->as, taddr, + c, size, MEMTXATTRS_UNSPECIFIED) != 0) ? H_DEST_PARM : H_SUCCESS; } 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, dma_addr_t addr, DMA_DIRECTION_FROM_DEVICE); } -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); 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 @@ /* #define DEBUG_IOMMU */ -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); @@ -30,8 +31,7 @@ int dma_memory_set(AddressSpace *as, dma_addr_t addr, uint8_t c, dma_addr_t len) memset(fillbuf, c, FILLBUF_SIZE); while (len > 0) { l = len < FILLBUF_SIZE ? len : FILLBUF_SIZE; - error |= address_space_write(as, addr, MEMTXATTRS_UNSPECIFIED, - fillbuf, l); + error |= address_space_write(as, addr, attrs, fillbuf, l); len -= l; addr += 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 |= FW_CFG_DMA_CTL_ERROR; } } From patchwork Thu Sep 3 11:08:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D53AFC433E2 for ; Thu, 3 Sep 2020 11:10:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F1E7206EB for ; Thu, 3 Sep 2020 11:10:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YGI4DY76" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F1E7206EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDn8V-0002dA-JI for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 07:10:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDn73-0008O4-VT for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:09:06 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:33858 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kDn71-0005pe-FI for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:09:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131342; 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=YGI4DY762GNDVysu1xauKV8EmU09E4Meoo/UFXaxmE71ah00uJTdUnT8XnPE2pxVn3IKeT KWv+cwjkg3Tp9u6re5BSVL/7NzZ3LYLwlxFM201WCbwEQp6vqHObLiWJTAbPY2OUuOimyF 77C/laYMwqOnbXdR7fbKfI9VWSZJOM4= 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-43-oKTlDOANM_-xqn2af-4jPQ-1; Thu, 03 Sep 2020 07:09:01 -0400 X-MC-Unique: oKTlDOANM_-xqn2af-4jPQ-1 Received: by mail-wr1-f70.google.com with SMTP id b8so960229wrr.2 for ; Thu, 03 Sep 2020 04:09:01 -0700 (PDT) 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=egxlEMdYWjhURtRgF678Ca3/YaHLqD6vOGd0zsOqmc8NIaKMpSqzHIL5m68GHwYTt6 COI0eol+8jVpmuEA2dsROUUIlL4fUVaBbBhtTXAk14gDS7u2nMGxKdTQxf8v19fbC+xh YGs/dIFkKXKvXz0DFXEzZp7H+1xj/vT56ADvKyPryiUnu6svgG8IBXfIb7Se7dcxGn7R sgoIu+Q8B9CJCgk4DTIJ20aXZV4TdpaCA8ihExJII50L/VYTrK4qt60dgKzr483mwS1P Z/wUvZv1xPULZ8ezhYGTalHGYG4DAffo+he6E4/eP8UUuUh7mnhD+WzZIiOoJ6HYCiZk txSg== X-Gm-Message-State: AOAM533cxhZ2U1hR5fLkk1pCFSvHA3meTPK1TsuCPAxUd7y49FGk+1WV 56zXI9zEwIk5X3EGicvl5yAoCUBE2tDVHb34lPyMjeKa/l6KB/lHR9jI2R/qGoz9nNVnB2FRnLW pGQUYM853avQCags= X-Received: by 2002:adf:e9c1:: with SMTP id l1mr1912999wrn.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 04:23:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Eduardo Habkost , "Edgar E . Iglesias" , qemu-block@nongnu.org, Li Qiang , "Emilio G . Cota" , Peter Chubb , Joel Stanley , Richard Henderson , Laszlo Ersek , Robert Foley , Alistair Francis , Richard Henderson , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefan Hajnoczi , John Snow , David Gibson , Tony Nguyen , Prasad J Pandit , Alexander Bulekov , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-ppc@nongnu.org, Klaus Jensen , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- 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, 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 == DMA_DIRECTION_FROM_DEVICE); } static inline int dma_memory_read_relaxed(AddressSpace *as, dma_addr_t addr, void *buf, dma_addr_t len) { - return dma_memory_rw_relaxed(as, addr, buf, len, DMA_DIRECTION_TO_DEVICE); + return dma_memory_rw_relaxed(as, addr, buf, len, + DMA_DIRECTION_TO_DEVICE, + MEMTXATTRS_UNSPECIFIED); } static inline int dma_memory_write_relaxed(AddressSpace *as, dma_addr_t addr, 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); } 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_addr_t addr, { dma_barrier(as, dir); - return dma_memory_rw_relaxed(as, addr, buf, len, dir); + return dma_memory_rw_relaxed(as, addr, buf, len, dir, + MEMTXATTRS_UNSPECIFIED); } static inline int dma_memory_read(AddressSpace *as, dma_addr_t addr, From patchwork Thu Sep 3 11:08:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B018C433E2 for ; Thu, 3 Sep 2020 11:14:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 041F0206EB for ; Thu, 3 Sep 2020 11:14:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ivRY8BgZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 041F0206EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDnCW-0001gB-3T for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 07:14:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDn7S-0000xw-VG for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:09:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21126) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kDn7Q-0005wW-3C for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:09:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131367; 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=ivRY8BgZ+ti9tJmlZ67Wli1N7as/5EAOtR0woudnf7uy4Cx8/g1COXeAjehJReyhERMUVC Zw2pH4CyfBZ2+OG+p9obuFzRaRq1E0S253swZNeP8WoVbaU9vaNfyfi5OUIJuLc6FK6drL bOiIHs44T1DUZyoWh3VUcBY+vJ/CHxI= 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-237-eVd1i5OjNdCLA2B_KwkohQ-1; Thu, 03 Sep 2020 07:09:26 -0400 X-MC-Unique: eVd1i5OjNdCLA2B_KwkohQ-1 Received: by mail-wm1-f69.google.com with SMTP id m125so840318wmm.7 for ; Thu, 03 Sep 2020 04:09:26 -0700 (PDT) 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=nAVVo+0ruIW8xFMP6/daoE1Z77/cOBreIKYS+w/mY+NgPoNQQWzkxPs04tIQ2l3vz1 849hR5UUZ55dy920YqqYgrWvfeDL1haeVjJL50Woxv0yYVM8oSSaj7kjNSaX23EtKb5H IRJyXZo0UyXTzTkk6vFuId8J50pbWstzJaa9mBw8aQWAoNT+kN6qY+NwSUViZijB3xG5 v6shD02N/5rO4YyDfrqZ1gH3pUzL1yQW0vtPsMxjQMGMtJ8vzsoBEod+PbGmrE9tFo9t D6MrJJ8uDPz2ex0RV1fhDC8i/wwqywx3vvzgz8pfUk3qjIqJlI70rwNWHkFmWZkEp5em 5Rkg== X-Gm-Message-State: AOAM531LhKlIEc/CN3ShREA8xT32voFkX1LmLyHZy5QuxIYlG24Xklfi X2eAH9prvhScMVlCclrHSP4rtFJM3aUd4bNZDgi0fTR/037Jo7m3NHnfwFAtLQTwDXWv666msRd e0ussoT5lybj5tK8= X-Received: by 2002:a1c:96c5:: with SMTP id y188mr2031717wmd.72.1599131364949; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 01:47:17 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Eduardo Habkost , "Edgar E . Iglesias" , qemu-block@nongnu.org, Li Qiang , "Emilio G . Cota" , Peter Chubb , Joel Stanley , Richard Henderson , Laszlo Ersek , Robert Foley , Alistair Francis , Richard Henderson , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefan Hajnoczi , John Snow , David Gibson , Tony Nguyen , Prasad J Pandit , Alexander Bulekov , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-ppc@nongnu.org, Klaus Jensen , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- 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. Regexes for git grep - ``\`` + - ``\`` + - ``\`` ``pci_dma_*`` and ``{ld,st}*_pci_dma`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From patchwork Thu Sep 3 11:08:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274696 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C11BFC433E2 for ; Thu, 3 Sep 2020 11:16:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 625AE20716 for ; Thu, 3 Sep 2020 11:16:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AfdwSg4L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 625AE20716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDnDr-0003RV-B8 for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 07:16:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDn7b-00019E-U7 for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:09:40 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:24830 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kDn7Y-0005xl-Sl for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:09:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131376; 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=AfdwSg4L9/1aZPUdLS3q2SseN7UwcmiEmAitQUv2lJvgWf7DiEcUnBw3hxNNcUzDbGJhD9 dT2243AlxGXEbp3+DPZQixIKkPHJtglddq4UdYhpSjbFoS3JECiFZHsE6omyxL1DfA8Epd 5ptpj3gHUpm+3mp6xU3v9kjALz4NMJI= 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-569-v1Ijf-BANZKZHxDDBlhZEA-1; Thu, 03 Sep 2020 07:09:32 -0400 X-MC-Unique: v1Ijf-BANZKZHxDDBlhZEA-1 Received: by mail-wr1-f70.google.com with SMTP id m7so935313wrb.20 for ; Thu, 03 Sep 2020 04:09:32 -0700 (PDT) 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=ZcK44wvIgsn2G0HHpo0V4U/WK1mtV6sQWhu3a1ljQcvf9eLbn4nbf4lPEYOkVIjKLm 5uQgWLaeNywpDJQ+IJtLsGO7IMEtzO9kqkf6yu0ZpMyhYzwU6xaVqgMMgtIKStgyZlmF eNoxX9GIV1aZ1LKViLudnsfC8teL4DKtyXW0uVYCRtZXnyo4TnlAJPF+RcbgpUAt39lg 6slGyitVpEhg3I8xjixPmjfTFGf6TmnkqY6KLJt7Eembq4wsUGxzpZ4hX4aWE5+tXxq5 PjXraWpd3MVnRshC9u3IjToT0c0uwBwTuwp3TH9rqtMcEH+QjSvU/pGzOkGDoz9sDAxr 1/BQ== X-Gm-Message-State: AOAM533cuop9Orrfu/3y030Z7KIQx4VcnGky+5gQ28SPZyu4Pvz0LTqt OomDC2Ha6UbTk1fRA6rjvkUFvO4rnhd+OUMmZ+TsyCKcNnk9K370dDYMrI6HBG2SgApKSxxEDPa duBIoMJtH7p216rQ= X-Received: by 2002:adf:9125:: with SMTP id j34mr2033735wrj.157.1599131371188; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 04:23:49 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Eduardo Habkost , "Edgar E . Iglesias" , qemu-block@nongnu.org, Li Qiang , "Emilio G . Cota" , Peter Chubb , Joel Stanley , Richard Henderson , Laszlo Ersek , Robert Foley , Alistair Francis , Richard Henderson , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefan Hajnoczi , John Snow , David Gibson , Tony Nguyen , Prasad J Pandit , Alexander Bulekov , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-ppc@nongnu.org, Klaus Jensen , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- 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_addr_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 val) \ { \ - st##_s##_dma(pci_get_address_space(dev), addr, val); \ + st##_s##_dma(pci_get_address_space(dev), addr, val, \ + MEMTXATTRS_UNSPECIFIED); \ } 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 *dev, uint64_t taddr, H_DEST_PARM : H_SUCCESS; } -#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)) int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq); 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, #define DEFINE_LDST_DMA(_lname, _sname, _bits, _end) \ static inline uint##_bits##_t ld##_lname##_##_end##_dma(AddressSpace *as, \ - dma_addr_t addr) \ + dma_addr_t addr, \ + MemTxAttrs attrs) \ { \ uint##_bits##_t val; \ - dma_memory_read(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFIED); \ + 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 = cpu_to_##_end##_bits(val); \ - dma_memory_write(as, addr, &val, (_bits) / 8, MEMTXATTRS_UNSPECIFIED); \ + dma_memory_write(as, addr, &val, (_bits) / 8, attrs); \ } -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; - dma_memory_read(as, addr, &val, 1, MEMTXATTRS_UNSPECIFIED); + dma_memory_read(as, addr, &val, 1, attrs); return val; } -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); } 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 *xive, uint32_t type, /* Get the page size of the indirect table. */ vsd_addr = vsd & VSD_ADDRESS_MASK; - vsd = ldq_be_dma(&address_space_memory, vsd_addr); + vsd = ldq_be_dma(&address_space_memory, vsd_addr, MEMTXATTRS_UNSPECIFIED); if (!(vsd & VSD_ADDRESS_MASK)) { #ifdef XIVE_DEBUG @@ -194,7 +194,8 @@ static uint64_t pnv_xive_vst_addr_indirect(PnvXive *xive, uint32_t type, /* Load the VSD we are looking for, if not already done */ if (vsd_idx) { vsd_addr = vsd_addr + vsd_idx * XIVE_VSD_SIZE; - vsd = ldq_be_dma(&address_space_memory, vsd_addr); + vsd = ldq_be_dma(&address_space_memory, vsd_addr, + MEMTXATTRS_UNSPECIFIED); 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) /* Get the page size of the indirect table. */ vsd_addr = vsd & VSD_ADDRESS_MASK; - vsd = ldq_be_dma(&address_space_memory, vsd_addr); + vsd = ldq_be_dma(&address_space_memory, vsd_addr, MEMTXATTRS_UNSPECIFIED); 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; } @@ -444,7 +444,7 @@ static void fw_cfg_dma_transfer(FWCfgState *s) } stl_be_dma(s->dma_as, dma_addr + offsetof(FWCfgDmaAccess, control), - dma.control); + dma.control, MEMTXATTRS_UNSPECIFIED); trace_fw_cfg_read(s, 0); } From patchwork Thu Sep 3 11:08:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 274695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA778C43461 for ; Thu, 3 Sep 2020 11:17:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81E052071B for ; Thu, 3 Sep 2020 11:17:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RsySzsPs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81E052071B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDnFQ-0005wN-Kg for qemu-devel@archiver.kernel.org; Thu, 03 Sep 2020 07:17:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDn7q-0001R0-Uj for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:09:54 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51387 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kDn7o-00060V-D9 for qemu-devel@nongnu.org; Thu, 03 Sep 2020 07:09:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599131391; 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=RsySzsPsh2kvq7nkD+jX+Er/fgawngwtQlGJTComtHoWAKMxZbTtVoCI+AyPk7sfjn7lk3 TiN5KktQpjL5fo7KUxP+aAUaVkInUFKmrC3hmaH8gmmmqUtByrrVZqnvFOD5+5pugiKfgm lE43lwsbzfSuJDCyOfvytjejGSWUQhQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-528-PePNy95GPcqEXhlxmqkwoQ-1; Thu, 03 Sep 2020 07:09:50 -0400 X-MC-Unique: PePNy95GPcqEXhlxmqkwoQ-1 Received: by mail-wm1-f71.google.com with SMTP id c186so836259wmd.9 for ; Thu, 03 Sep 2020 04:09:50 -0700 (PDT) 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=nkPwc6Dsf5DSeM3y6HU/5NtswfGCZ4SIEc4XqWuWeNfQEbT1fFQ7D0k5RlwKRBmxuU ueUXpJ2qEetWNULvvatsQhkwfA4sS+HQQd9y4k69kC3Vj6ja8Xf74DNoeDsa/asVHMD7 V9QUva2tZRMBPwaEPT5vBFXhA8R36lcv+JZr3iuJsdNu1kSniagzL4YuSjS6j8KfdYzc OOPm9KlkdXKH/aq52CIs8FOsXlR2Y/3JRXhygnyBsSseuaWoiSDD1JcShTfXywALPwvI qEfwFmkYfa1ufuoGHjmUkTPBq1//aGalBnAsF0BZqV+Asx5ppSPT9rPkDNXzQJ25vvO+ JRBw== X-Gm-Message-State: AOAM530Ut2N9V6Ms780kFOrTJyVqArUWvrR9brGfdBdYNdjEL9mqX6Hp H8r/1fVfBEOx7wj/okRMoCPUh8S70mw2SVUI+jpF48xBWsbW0DoAdqTjaxnuXkXNZlw8EX0A3uP TyDSWqCVh8hVNVaM= X-Received: by 2002:a1c:f003:: with SMTP id a3mr1951210wmb.170.1599131388986; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/03 01:58:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "Michael S. Tsirkin" , Jason Wang , Mark Cave-Ayland , Peter Xu , Gerd Hoffmann , "Edgar E. Iglesias" , Eduardo Habkost , "Edgar E . Iglesias" , qemu-block@nongnu.org, Li Qiang , "Emilio G . Cota" , Peter Chubb , Joel Stanley , Richard Henderson , Laszlo Ersek , Robert Foley , Alistair Francis , Richard Henderson , Beniamino Galvani , Eric Auger , qemu-arm@nongnu.org, Jan Kiszka , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefan Hajnoczi , John Snow , David Gibson , Tony Nguyen , Prasad J Pandit , Alexander Bulekov , Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Emanuele Giuseppe Esposito , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-ppc@nongnu.org, Klaus Jensen , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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(AddressSpace *, dma_addr_t, void *, dma_addr_t, DMADirection, MemTxAttrs): Assertion `dir == 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=0x7fffddd3ca28, addr=4064, buf=0x7fffffff7780, len=16, dir=DMA_DIRECTION_FROM_DEVICE, attrs=...) at /home/phil/source/qemu/include/sysemu/dma.h:111 #5 0x0000555557b487e0 in pci_dma_rw (dev=0x7fffddd3c800, addr=4064, buf=0x7fffffff7780, len=16, dir=DMA_DIRECTION_FROM_DEVICE) at /home/phil/source/qemu/include/hw/pci/pci.h:791 #6 0x0000555557b47373 in pci_dma_write (dev=0x7fffddd3c800, addr=4064, buf=0x7fffffff7780, len=16) at /home/phil/source/qemu/include/hw/pci/pci.h:804 #7 0x0000555557b340b4 in e1000e_write_packet_to_guest (core=0x7fffddd3f4e0, pkt=0x61100006c740, rxr=0x7fffffff7cf0, rss_info=0x7fffffff7d10) at hw/net/e1000e_core.c:1609 #8 0x0000555557b30739 in e1000e_receive_iov (core=0x7fffddd3f4e0, iov=0x619000060e80, iovcnt=4) at hw/net/e1000e_core.c:1709 #9 0x00005555576e2069 in e1000e_nc_receive_iov (nc=0x61400000a060, iov=0x619000060e80, iovcnt=4) at hw/net/e1000e.c:213 #10 0x00005555572a3c34 in net_tx_pkt_sendv (pkt=0x631000028800, nc=0x61400000a060, iov=0x619000060e80, iov_cnt=4) at hw/net/net_tx_pkt.c:556 #11 0x00005555572a23e2 in net_tx_pkt_send (pkt=0x631000028800, nc=0x61400000a060) at hw/net/net_tx_pkt.c:633 #12 0x00005555572a4c67 in net_tx_pkt_send_loopback (pkt=0x631000028800, nc=0x61400000a060) at hw/net/net_tx_pkt.c:646 #13 0x0000555557b70b05 in e1000e_tx_pkt_send (core=0x7fffddd3f4e0, tx=0x7fffddd5f748, queue_index=0) at hw/net/e1000e_core.c:664 #14 0x0000555557b6eab8 in e1000e_process_tx_desc (core=0x7fffddd3f4e0, tx=0x7fffddd5f748, dp=0x7fffffff8680, queue_index=0) at hw/net/e1000e_core.c:743 #15 0x0000555557b6d65d in e1000e_start_xmit (core=0x7fffddd3f4e0, txr=0x7fffffff88a0) at hw/net/e1000e_core.c:934 #16 0x0000555557b5ea38 in e1000e_set_tctl (core=0x7fffddd3f4e0, index=256, val=255) at hw/net/e1000e_core.c:2431 #17 0x0000555557b369ef in e1000e_core_write (core=0x7fffddd3f4e0, addr=1027, val=255, size=4) at hw/net/e1000e_core.c:3265 #18 0x00005555576de3be in e1000e_mmio_write (opaque=0x7fffddd3c800, addr=1027, val=255, size=4) at hw/net/e1000e.c:109 #19 0x0000555558e6b789 in memory_region_write_accessor (mr=0x7fffddd3f110, addr=1027, value=0x7fffffff8eb0, size=4, shift=0, mask=4294967295, attrs=...) at softmmu/memory.c:483 #20 0x0000555558e6b05b in access_with_adjusted_size (addr=1027, value=0x7fffffff8eb0, size=1, access_size_min=4, access_size_max=4, access_fn= 0x555558e6b120 , mr=0x7fffddd3f110, attrs=...) at softmmu/memory.c:544 #21 0x0000555558e69776 in memory_region_dispatch_write (mr=0x7fffddd3f110, addr=1027, data=255, op=MO_8, attrs=...) at softmmu/memory.c:1465 #22 0x0000555558f60462 in flatview_write_continue (fv=0x60600003f9e0, addr=3775005699, attrs=..., ptr=0x6020000e3710, len=1, addr1=1027, l=1, mr=0x7fffddd3f110) at exec.c:3176 #23 0x0000555558f4e38b in flatview_write (fv=0x60600003f9e0, addr=3775005699, attrs=..., buf=0x6020000e3710, len=1) at exec.c:3220 #24 0x0000555558f4dd4f in address_space_write (as=0x60800000baa0, addr=3775005699, attrs=..., buf=0x6020000e3710, len=1) at exec.c:3315 #25 0x000055555916b3e0 in qtest_process_command (chr=0x55555c03f300 , words=0x604000058150) at softmmu/qtest.c:567 #26 0x000055555915f7f2 in qtest_process_inbuf (chr=0x55555c03f300 , inbuf=0x6190000200e0) at softmmu/qtest.c:710 Signed-off-by: Philippe Mathieu-Daudé --- 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_addr_t addr, void *buf, dma_addr_t len, DMADirection dir, MemTxAttrs attrs) { + assert(dir == DMA_DIRECTION_TO_DEVICE || attrs.direct_access); + dma_barrier(as, dir); return dma_memory_rw_relaxed(as, addr, buf, len, dir, attrs);