From nobody Fri Dec 19 07:15:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1621509010; cv=none; d=zohomail.com; s=zohoarc; b=Ayfzr+8u+/mi1DUhw+IOUpUNtPjZcAOxMBV/Rkuf7vZMvqH99KCbXSyNXfAB50cV9f+3YT/9T8pJrZYeTsqNY+eBlfBRvNddmJoFWn7vpDkIbVc4j8z6CaOvS3hgq4sDvu/+mFZPtA8hyfQA1EhlU6jzl2tgLDMFaVSjQrH2bZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621509010; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=B2sGmsuzq6ssxzUGpyvhj2pP3TABHbW6gQF2vvqdbU8=; b=l5BdCWjs/VQTRVNard+GvLUg6s4LeVoUpYC7w1OcJkuxUj74X2AVi10//4p+21Ph2QxkqeDYgUFL/1yJQEPjN6wCupR+fGcpg2JQVe+9aozon52IAx3VguILmFrzWRZkoJeOmSukrbWWtpxu1Gw7Uw4e3+wZ/GwS76B3hEJeGvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621509010336971.8114157977484; Thu, 20 May 2021 04:10:10 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-528-DAkvujRaNWqkrBZ3QZO_6Q-1; Thu, 20 May 2021 07:10:07 -0400 Received: by mail-wr1-f69.google.com with SMTP id a9-20020adfc4490000b0290112095ca785so3287612wrg.14 for ; Thu, 20 May 2021 04:10:07 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id j18sm2153364wmq.27.2021.05.20.04.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 04:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621509009; 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=B2sGmsuzq6ssxzUGpyvhj2pP3TABHbW6gQF2vvqdbU8=; b=QHS/+nqp4jaZscfdDkjpcglFd2exjY4eLrQl463DHk30M/YDJWR3IbdUc1kGYNV/clgWXu bfS5As62ylIXXrUdJe8SGYu3kCC5D6U4yf29NX1StNDHD3y2bv7+dOMRYKZyeVSa9yADdM HamF2/y1804qjjDCJ6ZCmBVMwkKMa7w= X-MC-Unique: DAkvujRaNWqkrBZ3QZO_6Q-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=B2sGmsuzq6ssxzUGpyvhj2pP3TABHbW6gQF2vvqdbU8=; b=UeVNmLunLnftEUQH9ceRaBTy2bXXRl1vV5obUfYVUBifEpeZZiMwZwGeHSG9DDud27 hPGxtc5REpgzGSHEvtAWVJXeX7UB7XxeNgGqM2Y6RUrNhd88xiGFqs9UpokdOMRqYCKB 7UHcVGGNWcftd77zBxMAJZRhj6HBLI+X5DK/Z30ljywHkQh6+GGPPKHtzgiCULoFBNh6 UAWphr80bNhYG5ukBjmsBDegnqitAQI6M1x7Ty+lTHUjxy1bkpMVH8dJwo0NtZghKtvw F6+Gbb2dz54X5wvUpI2rC6+/fn+tFm2Mve4VjCr3/AKWgTuHVFx1t7+pCRysSbR8XBDY sDaw== X-Gm-Message-State: AOAM530yW15Kl3TQ4tx6iUYgB/QoB9fU7pH/u7jVs+AD04LcmuwsVi7Z FEt2eYwaKkfnXfXtXvjJEulZLW6l4GN+eYnyfnHnggqNcxKb5HumZqXcohr7hoZpz7gIkSFpVPc b59AhgScf6yiPng== X-Received: by 2002:a5d:58d0:: with SMTP id o16mr3688285wrf.420.1621509006516; Thu, 20 May 2021 04:10:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr1jKsgTU7z86XYAXdKX+v2p3GgjdQGU1xnatVqO28ldznpuvEBjfHYdTua9fyxEgVJdXhNg== X-Received: by 2002:a5d:58d0:: with SMTP id o16mr3688266wrf.420.1621509006290; Thu, 20 May 2021 04:10:06 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , Peter Maydell , Peter Xu , Paolo Bonzini , Richard Henderson , Bibo Mao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 10/12] hw/virtio: Extract virtio_lduw_phys_cached_with_attrs() Date: Thu, 20 May 2021 13:09:17 +0200 Message-Id: <20210520110919.2483190-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210520110919.2483190-1-philmd@redhat.com> References: <20210520110919.2483190-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) To be able to specify memory transaction attributes (such the address alignment), extract virtio_lduw_phys_cached_with_attrs() from virtio_lduw_phys_cached(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/virtio/virtio-access.h | 35 +++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-a= ccess.h index ae8c9feffc5..aebf0a088a0 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -156,14 +156,41 @@ static inline uint16_t virtio_tswap16(VirtIODevice *v= dev, uint16_t s) #endif } =20 +/** + * virtio_ld*_phys_cached_with_attrs: load from a VirtIO cached #MemoryReg= ion + * virtio_st*_phys_cached_with_attrs: store to a VirtIO cached #MemoryRegi= on + * + * These functions perform a load or store of the byte, word, + * longword or quad to the specified address. The address is + * a physical address in the VirtIO device AddressSpace, but it must lie w= ithin + * a #MemoryRegion that was mapped with address_space_cache_init. + * + * @vdev: virtio device accessed + * @cache: previously initialized #MemoryRegionCache to be accessed + * @pa: physical address within the address space + * @val: data value, for stores + * @attrs: memory transaction attributes + * @result: location to write the success/failure of the transaction; + * if NULL, this information is discarded + */ + +static inline uint16_t virtio_lduw_phys_cached_with_attrs(VirtIODevice *vd= ev, + MemoryRegionCache *cache, + hwaddr pa, MemTxAttrs attr= s, + MemTxResult *result) +{ + if (virtio_access_is_big_endian(vdev)) { + return address_space_lduw_be_cached(cache, pa, attrs, result); + } + return address_space_lduw_le_cached(cache, pa, attrs, result); +} + static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev, MemoryRegionCache *cache, hwaddr pa) { - if (virtio_access_is_big_endian(vdev)) { - return lduw_be_phys_cached(cache, pa); - } - return lduw_le_phys_cached(cache, pa); + return virtio_lduw_phys_cached_with_attrs(vdev, cache, pa, + MEMTXATTRS_UNSPECIFIED, NULL= ); } =20 static inline uint32_t virtio_ldl_phys_cached(VirtIODevice *vdev, --=20 2.26.3