From nobody Mon Feb 9 17:24:36 2026 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=1621363123; cv=none; d=zohomail.com; s=zohoarc; b=K++YZxFEoz4AHS4yYa87zoWdB8T36sCtKZqYwas9OKn0te2TcP4omef5jLt8W0EgXJq+tom0TIT+9NXPD2fUddbCb2i1meg9lqnLMUuBvyCT/I9jv6fJd5gkbC9FTFHnf27kzAhaCTcdueQOVLxikZ7rfWX8dgsjakvLVWz6PrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621363123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nkQ439nwJVtM0Q48vhAoZUVzUukLms9COugvSIGg64M=; b=V+P7eXDIXzd4pEbQImAOROzqIpFZH00B7KL91/VRqp6DC+ExGF2dAeN38X9QnhTqja9MMT2buED7Jpl3oTrb7XPU4rDtZiW/bY/5PlktLUZc+sGz2f2UfzViGRv1N+pZj6L3SZjabYjQTCRVo4BzV7X/tcdZPOAnc2pdOVXIzzQ= 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 1621363123317849.7661736586648; Tue, 18 May 2021 11:38:43 -0700 (PDT) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-494-Sj_-C0XmMxeaqEWpNRUHFQ-1; Tue, 18 May 2021 14:38:39 -0400 Received: by mail-ej1-f72.google.com with SMTP id p25-20020a1709061419b0290378364a6464so2737298ejc.15 for ; Tue, 18 May 2021 11:38:39 -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 v18sm1602931edc.76.2021.05.18.11.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 11:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621363121; 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=nkQ439nwJVtM0Q48vhAoZUVzUukLms9COugvSIGg64M=; b=HUesh84t2+m3vIsARyiDZPCC+qbpQcr+4KFqFDs+jiWhvp3WBWxoapBtQqa8NtEeTSs3eN huCrWl5p6I16ZZ2h9LPZFUFKtRM/9fjEjonVSxdebL4AiKxKUeI8JsWMddRbYdsMqB0zUP WnsdhscuBtXg/Yi1gC8FqKt4Nffjia0= X-MC-Unique: Sj_-C0XmMxeaqEWpNRUHFQ-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=nkQ439nwJVtM0Q48vhAoZUVzUukLms9COugvSIGg64M=; b=AvfePJ5s3bpjY9bC2hCDRTc0y6UJsp9WEX1yxc/PBkz5Fmoz2XQLgh8B1lrMkSoF2F 1ooe4Nb9MebuDcYcMKnNAlLQKtsMgcvfREby6Q8p3uqpeWTwGW3uoqJEyONZfTKh+bJA 3qAvAn+CfZguBkCU5g9pNsYRBsjeSZXE0PvUqXhC+ERgn3tDaPiljcFI6LTkdWlxp9zp ANa0NqfL/F0pObHlpfnOsTrPcKRAeGDMIGbBFdIt50R76kOMDZIOD8nmQJs2TRsDurJQ iJYpRoi2Ve3FCu/t1Q6mcUg5CT/BcitytfxxvfDFeJenqqYL+oCMvBPoJvCOY7qtWtxS ZYYQ== X-Gm-Message-State: AOAM533nC1GjFq7g6ds5sshpmrCBtmC55Nuh6Uff303Gnivot8vd1YjS FSLScfq8P8DUji7TDufbzWniNcY+I1ULz2+BKWJyykw2Q1VqCU4KblIyYJeJwyrXBHyUWvw3lz6 +jl3ymCwnSZmp6A== X-Received: by 2002:a05:6402:14c2:: with SMTP id f2mr8796478edx.69.1621363118383; Tue, 18 May 2021 11:38:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvQtpgrJ5MmmBPxeO08o3LNXUyat80zCiU7ug+0l7vmM9WYlqOXbTeQWpLp/Pt0nYOPgfZvQ== X-Received: by 2002:a05:6402:14c2:: with SMTP id f2mr8796471edx.69.1621363118255; Tue, 18 May 2021 11:38:38 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Bibo Mao , "Michael S. Tsirkin" , Richard Henderson , Paolo Bonzini , Jiaxun Yang , Peter Xu , Huacai Chen , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH 20/25] hw/virtio: Introduce VIRTIO_ST_CONVERT() macro Date: Tue, 18 May 2021 20:36:50 +0200 Message-Id: <20210518183655.1711377-21-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210518183655.1711377-1-philmd@redhat.com> References: <20210518183655.1711377-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 add more load/store operations, introduce the VIRTIO_ST_CONVERT() macro. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/virtio/virtio-access.h | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-a= ccess.h index 594247f6e35..a86819ef2fe 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -68,6 +68,38 @@ static inline rtype virtio_ld ## size ## _phys_cached(Vi= rtIODevice *vdev,\ return ld ## size ## _le_phys_cached(cache, pa);\ } =20 +#define VIRTIO_ST_CONVERT(size, vtype)\ +static inline void virtio_st## size ## _p(VirtIODevice *vdev,\ + void *ptr, vtype v)\ +{\ + if (virtio_access_is_big_endian(vdev)) {\ + st## size ## _be_p(ptr, v);\ + } else {\ + st## size ## _le_p(ptr, v);\ + }\ +}\ +static inline void virtio_st## size ## _phys(VirtIODevice *vdev,\ + hwaddr pa, vtype value)\ +{\ + AddressSpace *dma_as =3D vdev->dma_as;\ +\ + if (virtio_access_is_big_endian(vdev)) {\ + st## size ## _be_phys(dma_as, pa, value);\ + } else {\ + st## size ## _le_phys(dma_as, pa, value);\ + }\ +}\ +static inline void virtio_st ## size ## _phys_cached(VirtIODevice *vdev,\ + MemoryRegionCache *ca= che,\ + hwaddr pa, vtype valu= e)\ +{\ + if (virtio_access_is_big_endian(vdev)) {\ + st ## size ## _be_phys_cached(cache, pa, value);\ + } else {\ + st ## size ## _le_phys_cached(cache, pa, value);\ + }\ +} + VIRTIO_LD_CONVERT(uw, uint16_t) =20 static inline uint32_t virtio_ldl_phys(VirtIODevice *vdev, hwaddr pa) --=20 2.26.3