From nobody Tue Feb 10 04:16:08 2026 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=1621363143; cv=none; d=zohomail.com; s=zohoarc; b=K8wMRCrJ3YglqFhizPzPYTDKvcrOthk+55UEkFz1ANEMpM6JJVTm1B3dNo8+DhwnpxcC6VZccsz3p2JGM+9b7zUdaCzTu5VASSlnUf66n7VhN08UW2zGQSFJwBfF53GqKlPN0IeCmBkK/w5NoDe3bWkq8ZgYudKYCII/AeR8cng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621363143; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=F5bc/fLR7X3lBPxXh2gaq/EPG/Hnjmqk5I/R/ixg5NU=; b=iAKEm9iTad+sfw09OmNL+KjsiTKAEKDgNyuJRzx6XYyP1BPf7oz/DFf2RuLm8Q9JM/d6rASY1rC+y1+tGZJdTFy+HuJNt7XRwMgAamqC1ZQxfI30mG2s41wNmLQ1I1GR/XXLnvcPGudQa8vKu+dA6HO1o/wgOzY20r58iVY7vw8= 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 1621363143487697.973752526033; Tue, 18 May 2021 11:39:03 -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-233--JWUwLHIPXCkW9nh5ahUkA-1; Tue, 18 May 2021 14:38:59 -0400 Received: by mail-ej1-f72.google.com with SMTP id i8-20020a1709068508b02903d75f46b7aeso2401013ejx.18 for ; Tue, 18 May 2021 11:38:59 -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 e6sm1738171ejd.31.2021.05.18.11.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 11:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621363142; 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=F5bc/fLR7X3lBPxXh2gaq/EPG/Hnjmqk5I/R/ixg5NU=; b=Sw2zPk+pJDH5XQZyRIAFkVI7sKcnPAIpdQgQ6V72LJdohLkYJ0MAGvet5XPQd0a/+19vuX 8ji5CObNo7izCvU+htfRbJO2o7vRZfU8dTxHRLWi4yUYFXmIB8Rg7GJ6CAua4BaTxfKhwh QyMonXd9iRlU6Tv3f5h6royMHw/RHE0= X-MC-Unique: -JWUwLHIPXCkW9nh5ahUkA-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=F5bc/fLR7X3lBPxXh2gaq/EPG/Hnjmqk5I/R/ixg5NU=; b=V4DGMe+HthQIZnxZle5dJ/Vi4d0f8MwYJd/j9gQFjhyuGOFo9zTMKXHPhzYhwT3rDC KuoRVWhoEdbLZ9PqTpyPk81w9lB/ASrNvPxrYr6zbtJLcgJQYJ6yGIvi9rnYiFjjjgrT VPkeUW6J4qClv7kS5Oc+YFS3lQ0psyqxMCfgeN90zGzSOzfR2JKqKJ4CLCs6bpHfzSPX Ri2G4WFAKMLMLbMhxsjljqSzs6c3MXTukpyARuDo93isu6Cm0gxavG2YoZX2N4GLKddn vgFZtUNQr1VzTf1Wze22ALxxlny1C2j/IBHFS9ygiud+kw38vBMXx6ANgBnW41fjR6DM I7HA== X-Gm-Message-State: AOAM533U7lPhF6JoIUzbmpbkfUWpXqpP8UCwGuWbdH4Nm6QSNetVybxc cMY3F/XhrbLhyw+O3mv6uMeRKJBIfcuIkqbxzULI1yOSFA1IHGL8MQI1cGVEYEQsWj41UWf3MRi 5y+UHt52BnOQbiw== X-Received: by 2002:a17:906:a84e:: with SMTP id dx14mr7342960ejb.220.1621363138342; Tue, 18 May 2021 11:38:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUTZdzy85UcK5H0rImGDWfRk2nVcwF4b1HLgbSJFPlecoiwU8vAYSzL/WE4QBrgOza/mkmiQ== X-Received: by 2002:a17:906:a84e:: with SMTP id dx14mr7342949ejb.220.1621363138172; Tue, 18 May 2021 11:38:58 -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?= , Stefan Hajnoczi Subject: [RFC PATCH 24/25] hw/virtio: Add methods for aligned pointer access Date: Tue, 18 May 2021 20:36:54 +0200 Message-Id: <20210518183655.1711377-25-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) Suggested-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/virtio/virtio-access.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-a= ccess.h index ae66bbd74f9..5b20f004e12 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -66,6 +66,16 @@ static inline rtype virtio_ld ## size ## _phys_cached(Vi= rtIODevice *vdev,\ return ld ## size ## _be_phys_cached(cache, pa);\ }\ return ld ## size ## _le_phys_cached(cache, pa);\ +}\ +static inline rtype virtio_ld ## size ## _phys_cached_aligned(\ + VirtIODevice *vdev,\ + MemoryRegionCache *c= ache,\ + hwaddr pa)\ +{\ + if (virtio_access_is_big_endian(vdev)) {\ + return ld ## size ## _be_phys_cached_aligned(cache, pa);\ + }\ + return ld ## size ## _le_phys_cached_aligned(cache, pa);\ } =20 #define VIRTIO_ST_CONVERT(size, vtype)\ @@ -98,6 +108,17 @@ static inline void virtio_st ## size ## _phys_cached(Vi= rtIODevice *vdev,\ } else {\ st ## size ## _le_phys_cached(cache, pa, value);\ }\ +}\ +static inline void virtio_st ## size ## _phys_cached_aligned(\ + VirtIODevice *vdev,\ + MemoryRegionCache *ca= che,\ + hwaddr pa, vtype valu= e)\ +{\ + if (virtio_access_is_big_endian(vdev)) {\ + st ## size ## _be_phys_cached_aligned(cache, pa, value);\ + } else {\ + st ## size ## _le_phys_cached_aligned(cache, pa, value);\ + }\ } =20 #define VIRTIO_LDST_CONVERT(size, rtype, vtype)\ --=20 2.26.3