From patchwork Mon Dec 12 23:05:13 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: 633244 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2770095pvb; Mon, 12 Dec 2022 15:07:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf6dWWcMhYVdJ3Mt/S5N//mxyKupe9WlvNdXMJZzE0TfmsfSxzJrK+D69a0qdrMYoLU5JLEh X-Received: by 2002:a0c:fac8:0:b0:4c7:49b:f6da with SMTP id p8-20020a0cfac8000000b004c7049bf6damr21247983qvo.1.1670886431761; Mon, 12 Dec 2022 15:07:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670886431; cv=none; d=google.com; s=arc-20160816; b=vBPyiUdO54VLhhhP2JWRS2I1En3f4UVnkhbU3s4TyTVxhJQw4mW5WtqFhstI/Wl/fC RQfi2KW47Qkl03PknAmiUtnUt8m8cKQBwLOldCky0TeVADJydDHsr6EmsjRBmdLDUKXi UgETzW3mOSB/mPSI2rLTarR5t80d8E61FJtFY4iw91KNhZ5rnDkJOcRV7N02QfJQvTrK SNZ1nSqIDXQMtbbarWWz0S33SAUXxQXdLxJQc5+NQ9RPExwmlEBT7LsZmQmD6U71CfSi bmN7qcjUkF5eGvSGFSfHGSIPkImeJ4TQ35brkiBuXNyHbKfYUIKehda4UpN6H2aVZgBs c5eA== 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=PAyoKSmpc73U7mUWxcH2rj9U96WCObqWKu1vwMAguEE=; b=D5KAExUBe+XHz1hZ+TSsid3cszW/vucNeORxKcr/lyiPZmjncmj+uiRTgniRVeH0fN JiEalm6HxmDL8sEr0Ks129yY1b417PprrDw9gy3Ocir1WHHkKZkwTItXl2sJ/zRb4KXj xczlubORfNx2VL1Ghnaos0MxGnCfWT45U91HsGBrBz3KeAUciAlRiaTYVZ9WibOpgmHw NbwicX1n3ybbtYH1f2GhwMglAxivpxMZU7hN7Lx1wwuEKd9Kr81Z6iM0WS851oa+XoC2 DgF9v6VZhRWP9myQ45foW0JmpZ2qsUvz6zzKgPE0zmgsWRNBdfKWe+/sUuiQg/wnOmQM lIkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M7hh+zs9; 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 q6-20020a05621419e600b004dde51a6f61si3001106qvc.371.2022.12.12.15.07.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Dec 2022 15:07:11 -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=M7hh+zs9; 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 1p4rs1-0007DX-BU; Mon, 12 Dec 2022 18:06:01 -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 1p4rry-0007CR-Nu for qemu-devel@nongnu.org; Mon, 12 Dec 2022 18:05:58 -0500 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p4rrw-0004L2-M6 for qemu-devel@nongnu.org; Mon, 12 Dec 2022 18:05:58 -0500 Received: by mail-ej1-x631.google.com with SMTP id fc4so32145965ejc.12 for ; Mon, 12 Dec 2022 15:05:55 -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=PAyoKSmpc73U7mUWxcH2rj9U96WCObqWKu1vwMAguEE=; b=M7hh+zs9v02qZwg/pfWXdnWzzvrZNH2j/X6uglqm0f5Mbry+iVIX5OAQfhJI42Qjy2 ITmNkWMigM6d0d2iEBI47GUCIblbtTFYGstxi+HcH/FjoRrsy6/RqEXyDkGjGZ6opeLQ 5xcvsqk0bwJA0+EGM7wVyForB5chbxCrhPuckOYUDd1luK5fkpfrYzSEAQ9E9c0XPt7u sxs3Sb0bONTpdLOXVYtlb5K6pbfTQnomhL6iAEcCiAGkBfIyu30JKsjjAUlsD3O5vZ2z 8P1qu8sBUx4JwCZAyS5gCy3M/K/+S2KBac+gnpsNBb8JLoWf+VA9l+ZotRqMBI+2IUyV XBPw== 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=PAyoKSmpc73U7mUWxcH2rj9U96WCObqWKu1vwMAguEE=; b=xj/gJ6EW6z9PK5b+pkkdmvAruLpJUJjbHkeKDvSim3Jrhndps6vxvasL/R+RcvlBjt Vi6ttymXMNgjTCsWGD5PuGuWOxHtt0SwLwmLd9tbcnrD4+H2Cp1lFFj0NYx7rthmv8Xk XL1oWKOrptQetWXb7OD0FNLLdHqgxYWyZJe7+lK5DCBGDOUXaqYjbG5INZwBAcilRsaI 3djxmFFZoFEOE8NIUGIV+ZIc67i7uloR9iQ/Ac4FmPXPphkuypl+6Qy6yQQcpGCvLf0C D2SJG0NJ9LqcAFgenqPSlWXg/XMVpHD9HEAWdcPXxqcoxJxr/CaW2SFj1a8dQ+nyb9iY 8dbg== X-Gm-Message-State: ANoB5pmwvNmFdQkrEgh+WVPCBtuYUcWIwSqUBCdesrBZ30+6dsU0ni+I AYtMmX4ka7BxiSOplcpHSAgEvBI1cM2ysaPMjh8= X-Received: by 2002:a17:906:fa14:b0:7c0:c5b3:cb49 with SMTP id lo20-20020a170906fa1400b007c0c5b3cb49mr13813017ejb.31.1670886353931; Mon, 12 Dec 2022 15:05:53 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id l2-20020a1709063d2200b0077a8fa8ba55sm3793229ejf.210.2022.12.12.15.05.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 12 Dec 2022 15:05:53 -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 06/10] hw/virtio: Cache access_is_big_endian value in VirtIODevice state Date: Tue, 13 Dec 2022 00:05:13 +0100 Message-Id: <20221212230517.28872-7-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::631; envelope-from=philmd@linaro.org; helo=mail-ej1-x631.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 The device endianness doesn't change during runtime. Cache it in the VirtIODevice state. Signed-off-by: Philippe Mathieu-Daudé --- RFC: I'm not sure virtio_init() is the correct place to add this check. We want to initialize this field once the features are negociated. --- hw/virtio/virtio.c | 1 + include/hw/virtio/virtio.h | 1 + 2 files changed, 2 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 09b1a0e3d9..dbb1fe33f7 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3193,6 +3193,7 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size) vdev->vmstate = qdev_add_vm_change_state_handler(DEVICE(vdev), virtio_vmstate_change, vdev); vdev->device_endian = virtio_default_endian(); + vdev->access_is_big_endian = virtio_access_is_big_endian(vdev); vdev->use_guest_notifier_mask = true; } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index acfd4df125..5f28e51e93 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -130,6 +130,7 @@ struct VirtIODevice bool vhost_started; VMChangeStateEntry *vmstate; char *bus_name; + bool access_is_big_endian; uint8_t device_endian; bool use_guest_notifier_mask; AddressSpace *dma_as;