From patchwork Mon Dec 12 23:05:14 2022 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: 633247 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2771019pvb; Mon, 12 Dec 2022 15:08:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf4cxfzuunxj0rvDs0uIcXWzF2So/8sGKavtDhvebs2kmYWkoC63f0mcFBG01g91sYE6T56Y X-Received: by 2002:ac8:707:0:b0:3a6:930b:b3b1 with SMTP id g7-20020ac80707000000b003a6930bb3b1mr1303351qth.20.1670886534637; Mon, 12 Dec 2022 15:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670886534; cv=none; d=google.com; s=arc-20160816; b=DlvrAAczv2njXuhl2KbaOxWsab5KEUWGXQ+uWaXNekMhMspK7snS61+c5GhNWg97se QFZ3btlowkWSsVJ0f9hiYpUa93oEHkCZ3D+QWWm2AjmeKd1deTO/IP6z7vP9Oo3kihUH xYey++jOTPCRtSK7EM0WVevnQe9C1GE8gxBzFj5Sl63mwGruJq896mVsxY2+HH6IhSZj uykE8E/p1e7rqn0sAJMIyRKKliCquId93hlm2k07zqn5YNTdPMn9AecCq6Lpz2T8xKhr sc5YNrbI1q+lCySGDDwfg3m0EHXzDU7tQ7ZVYR5qn5lnL6sCJvZSn6xr3aY/Y3iThYT7 /K7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LuyI/hgCA8EM+7WspIU6SYJTlNy9W44FIcpLaj/BLMk=; b=zkKII/D6U2DTIAUtAtGNaNocT1HKhXviYDDYYrT/tb8IXHusl/1hlGNklFN9qRqJNh dufWlEOqSadHYUXEr07vSR2u6MB0ZvgFPfJ14AJQpCcXY2Q2VWUe5IbCl81cWD+/gOS9 bwa5KjGg8OqpT1lTUjoLUZmfSO4d8tW8IxYni+F++10+ttZlKl/QYmv9QHBwAvEl1dQI IzW8t82bE31a9JXn1Qwb63pdGc8ZmJkhCALjoPqALtLkhI5rWL9nI53ypbk0wwG7CKAH iItcrgHEM97fFwZoQdWRxWvd4R+PAiXWCBx2/KHpE0ZgR6Syk2apSy6wTSfY0Wvnc9HZ uF/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xeebUGjK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id de36-20020a05620a372400b006bb9cfda390si5398229qkb.31.2022.12.12.15.08.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Dec 2022 15:08:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xeebUGjK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4rs5-0007Fh-K5; Mon, 12 Dec 2022 18:06:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4rs3-0007F0-SC for qemu-devel@nongnu.org; Mon, 12 Dec 2022 18:06:03 -0500 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p4rs1-0004Lt-Tw for qemu-devel@nongnu.org; Mon, 12 Dec 2022 18:06:03 -0500 Received: by mail-ed1-x52c.google.com with SMTP id f7so15329180edc.6 for ; Mon, 12 Dec 2022 15:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LuyI/hgCA8EM+7WspIU6SYJTlNy9W44FIcpLaj/BLMk=; b=xeebUGjK8gqr5qRD7aoTsKYNlKsMrbb4Ta+r/ttugk7SZEnjozOtWzySkFbCgmXXhs 25iYdEC3WsqJyQzOO6004MAe0ynZn/TnShy3BgD+lxy7hWD5Jp+En3/DM4Edi1oxmp/7 YdEodpfq98G8aBil4QYWbou5tQRHFstgpaqY/twJArWKTKO4o8dx8P/Io2hVwNFYKyne Ji1L71Qnlvz1UbE94Xf9u7Yuk01o52d1JLD4MxaRgrqgDoT/XuFkmbd0hwVrixK83z6I pdWNmZqPBLuwrXkW2P7e2eYXaxRh78HM8rhApukLIcZ42bYnTDMw+GXMRyllhTwGQI/x GowQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LuyI/hgCA8EM+7WspIU6SYJTlNy9W44FIcpLaj/BLMk=; b=MckdxbjXy5K/Imzl2hKIGVFSpUuoLz0jKU8Uti5tPF8GVfuJ0LGu5w0z25ZSMG8GEm FpZlyqzpm4uiS6uWbHJUWqk/kyWSKJBGKPjHhYMg31aKIFVLLImScF+GdIW9LmUy3DLd hnEd645JL0SlYJkOj1kJaIDxV9m9U40uKNzMkeIcMmO7eX1n271Mpa4s6MtE8e2gatbY srd+1K4+JThWVTORCqY9flpWLG/6bb2waZmDgS6+EHkVmXJdD9Z3Z1J39y6hRs7VxZ8O I1NM3IqtXBaTNIs1Z66HfbBgH55eJ/KalMuNgBaOrEth7HtkabuNCLnm9neI9bC9BE3k /uxQ== X-Gm-Message-State: ANoB5pklUDnJS/ARakAwHVPZ6cyZfM+tVhmh+DEpeKGbslLkjc1P/RPZ 06o1uBZ+EN6jtyROimZ71OtlxrQz0io9iFFXXG4= X-Received: by 2002:a05:6402:1002:b0:467:9384:a7aa with SMTP id c2-20020a056402100200b004679384a7aamr16552007edu.15.1670886360465; Mon, 12 Dec 2022 15:06:00 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id ch17-20020a0564021bd100b0046c2eee21a2sm4258946edb.11.2022.12.12.15.05.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 12 Dec 2022 15:06:00 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Thomas Huth Cc: Greg Kurz , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org, Paolo Bonzini , "Michael S. Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , Jason Wang , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Christian Schoenebeck , Hanna Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-8.0 07/10] hw/virtio: Directly access cached VirtIODevice::access_is_big_endian Date: Tue, 13 Dec 2022 00:05:14 +0100 Message-Id: <20221212230517.28872-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212230517.28872-1-philmd@linaro.org> References: <20221212230517.28872-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=philmd@linaro.org; helo=mail-ed1-x52c.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since the device endianness doesn't change at runtime, use the cached value instead of evaluating it on each call. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/virtio/virtio-access.h | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/include/hw/virtio/virtio-access.h b/include/hw/virtio/virtio-access.h index 07aae69042..985f39fe16 100644 --- a/include/hw/virtio/virtio-access.h +++ b/include/hw/virtio/virtio-access.h @@ -43,7 +43,7 @@ static inline uint16_t virtio_lduw_phys(VirtIODevice *vdev, hwaddr pa) { AddressSpace *dma_as = vdev->dma_as; - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return lduw_be_phys(dma_as, pa); } return lduw_le_phys(dma_as, pa); @@ -53,7 +53,7 @@ static inline uint32_t virtio_ldl_phys(VirtIODevice *vdev, hwaddr pa) { AddressSpace *dma_as = vdev->dma_as; - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return ldl_be_phys(dma_as, pa); } return ldl_le_phys(dma_as, pa); @@ -63,7 +63,7 @@ static inline uint64_t virtio_ldq_phys(VirtIODevice *vdev, hwaddr pa) { AddressSpace *dma_as = vdev->dma_as; - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return ldq_be_phys(dma_as, pa); } return ldq_le_phys(dma_as, pa); @@ -74,7 +74,7 @@ static inline void virtio_stw_phys(VirtIODevice *vdev, hwaddr pa, { AddressSpace *dma_as = vdev->dma_as; - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { stw_be_phys(dma_as, pa, value); } else { stw_le_phys(dma_as, pa, value); @@ -86,7 +86,7 @@ static inline void virtio_stl_phys(VirtIODevice *vdev, hwaddr pa, { AddressSpace *dma_as = vdev->dma_as; - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { stl_be_phys(dma_as, pa, value); } else { stl_le_phys(dma_as, pa, value); @@ -95,7 +95,7 @@ static inline void virtio_stl_phys(VirtIODevice *vdev, hwaddr pa, static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { stw_be_p(ptr, v); } else { stw_le_p(ptr, v); @@ -104,7 +104,7 @@ static inline void virtio_stw_p(VirtIODevice *vdev, void *ptr, uint16_t v) static inline void virtio_stl_p(VirtIODevice *vdev, void *ptr, uint32_t v) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { stl_be_p(ptr, v); } else { stl_le_p(ptr, v); @@ -113,7 +113,7 @@ static inline void virtio_stl_p(VirtIODevice *vdev, void *ptr, uint32_t v) static inline void virtio_stq_p(VirtIODevice *vdev, void *ptr, uint64_t v) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { stq_be_p(ptr, v); } else { stq_le_p(ptr, v); @@ -122,7 +122,7 @@ static inline void virtio_stq_p(VirtIODevice *vdev, void *ptr, uint64_t v) static inline int virtio_lduw_p(VirtIODevice *vdev, const void *ptr) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return lduw_be_p(ptr); } else { return lduw_le_p(ptr); @@ -131,7 +131,7 @@ static inline int virtio_lduw_p(VirtIODevice *vdev, const void *ptr) static inline int virtio_ldl_p(VirtIODevice *vdev, const void *ptr) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return ldl_be_p(ptr); } else { return ldl_le_p(ptr); @@ -140,7 +140,7 @@ static inline int virtio_ldl_p(VirtIODevice *vdev, const void *ptr) static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return ldq_be_p(ptr); } else { return ldq_le_p(ptr); @@ -150,9 +150,9 @@ static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr) static inline uint16_t virtio_tswap16(VirtIODevice *vdev, uint16_t s) { #if HOST_BIG_ENDIAN - return virtio_access_is_big_endian(vdev) ? s : bswap16(s); + return vdev->access_is_big_endian ? s : bswap16(s); #else - return virtio_access_is_big_endian(vdev) ? bswap16(s) : s; + return vdev->access_is_big_endian ? bswap16(s) : s; #endif } @@ -160,7 +160,7 @@ static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev, MemoryRegionCache *cache, hwaddr pa) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return lduw_be_phys_cached(cache, pa); } return lduw_le_phys_cached(cache, pa); @@ -170,7 +170,7 @@ static inline uint32_t virtio_ldl_phys_cached(VirtIODevice *vdev, MemoryRegionCache *cache, hwaddr pa) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return ldl_be_phys_cached(cache, pa); } return ldl_le_phys_cached(cache, pa); @@ -180,7 +180,7 @@ static inline uint64_t virtio_ldq_phys_cached(VirtIODevice *vdev, MemoryRegionCache *cache, hwaddr pa) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { return ldq_be_phys_cached(cache, pa); } return ldq_le_phys_cached(cache, pa); @@ -190,7 +190,7 @@ static inline void virtio_stw_phys_cached(VirtIODevice *vdev, MemoryRegionCache *cache, hwaddr pa, uint16_t value) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { stw_be_phys_cached(cache, pa, value); } else { stw_le_phys_cached(cache, pa, value); @@ -201,7 +201,7 @@ static inline void virtio_stl_phys_cached(VirtIODevice *vdev, MemoryRegionCache *cache, hwaddr pa, uint32_t value) { - if (virtio_access_is_big_endian(vdev)) { + if (vdev->access_is_big_endian) { stl_be_phys_cached(cache, pa, value); } else { stl_le_phys_cached(cache, pa, value); @@ -216,9 +216,9 @@ static inline void virtio_tswap16s(VirtIODevice *vdev, uint16_t *s) static inline uint32_t virtio_tswap32(VirtIODevice *vdev, uint32_t s) { #if HOST_BIG_ENDIAN - return virtio_access_is_big_endian(vdev) ? s : bswap32(s); + return vdev->access_is_big_endian ? s : bswap32(s); #else - return virtio_access_is_big_endian(vdev) ? bswap32(s) : s; + return vdev->access_is_big_endian ? bswap32(s) : s; #endif } @@ -230,9 +230,9 @@ static inline void virtio_tswap32s(VirtIODevice *vdev, uint32_t *s) static inline uint64_t virtio_tswap64(VirtIODevice *vdev, uint64_t s) { #if HOST_BIG_ENDIAN - return virtio_access_is_big_endian(vdev) ? s : bswap64(s); + return vdev->access_is_big_endian ? s : bswap64(s); #else - return virtio_access_is_big_endian(vdev) ? bswap64(s) : s; + return vdev->access_is_big_endian ? bswap64(s) : s; #endif }