From nobody Wed Nov 19 04:32:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.48 as permitted sender) client-ip=209.85.221.48; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f48.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1614357171; cv=none; d=zohomail.com; s=zohoarc; b=RRlGPfXTQ/FRgRtVDI/9NKiQqYQssJApawncdZe+yLQxKKLRNXmOj5pTt0hFqqoZbi3E8ai3Z/WW/JWN6ycJzjRihI4S+eJysUQlXHVdHBMb/hx41QeH8Ey0qfYIo2shfZzZBo8qgA01IFYLLUgb6Sr6lhQ8NeHSFa7Ssyj+Esk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614357171; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=alNnX6GeE8sTwFbIWBvN2VrnGh2+v4nR5yjKLFDEoAw=; b=IqvM0pnFPPoJo0g6nfcXSQBaXPDNg+vyjk9JJBWVPYvFPFpmpRWiZQ3vzXPAEY747KNdpI8fUnT2fFQz0UpF6qDtGTq/lh7RXbEUMYXXaEQ7KGmNZ+F2rKRUMGGc2s0IhqQQTpv1OBC6RbDRE+fKn5ksVlVH8U1BBg9IKXF8F10= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by mx.zohomail.com with SMTPS id 1614357171479536.0616255028609; Fri, 26 Feb 2021 08:32:51 -0800 (PST) Received: by mail-wr1-f48.google.com with SMTP id v15so9175823wrx.4 for ; Fri, 26 Feb 2021 08:32:50 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id k15sm16661875wrn.0.2021.02.26.08.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Feb 2021 08:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=alNnX6GeE8sTwFbIWBvN2VrnGh2+v4nR5yjKLFDEoAw=; b=uyLMHlRDhmj2W3V3ce9VzgPU9r6OpFofbOSN9lX/cs7+Tmdo/xSLuzIAUfNU0EMI4I 23Ze1PKYwLOkQn7eEaZgrTKXetGQprjQrfqOu6co1hwfi1og/IyqrUDIt5QvCk9DdvKT mYhhjzPXto23Dhqs5Pukg9PsRMu4WhzkzF4hjTxLplbu2kkKYTnwOsxCjM4Rpv4NgEOy /mB+EUK2gj5Au/d/Mwuk4AsG0Lj7LlfkFMvmpBcS0eeiCMebZw5VDoDr1F6bdEbKS1Ro 4KOSfzmq2Qi9TvR563kHISpz3tA3QNMs7n0pCw1IcDTwRxE7F9aHdgkpRQt+52QKAyCU w3mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=alNnX6GeE8sTwFbIWBvN2VrnGh2+v4nR5yjKLFDEoAw=; b=G6YxcHXX2US+k4YEhtEx/nURnzzdxgjYZdVXhx1qoltjrtqIM98hsKjClii3Bvy/uh UlsnK1moQ4mPbLHEr7ttbTs03F5X7emmW4CAiJqlU7g7I8taKkm4kHv1s4WcAAeLB8CN yFH4zT3ScIPPTqDklQiVUgAAjxfNFZg+5A61HJQYGRPR55P9hTaBk/oPi1oDLF29W6Iv XeWe5AWbeWx1nHE22qvtmZkElJZsMfTRo5kTCI+qa2DuERd/23AWvqNae2PVB36eZtfu 4/UIYo9KHeJAm2RBhmHB6vGVt5ONpyzPfEYD5AelrFJTz2TAI9STVWJ7G97N0E42Gecp xIEg== X-Gm-Message-State: AOAM531UnbSOmc8iECSLpbhjGlT9xomRrKAyTgowveizCMpkpVMbeiZM +Qt94zr7MZsm+D75Yw6mnyI= X-Google-Smtp-Source: ABdhPJzDkN6tyMjmW6kiH+JF3nWHZrnzVfI10cUhsz+my/NvSxcjCUQIcnL4ukyU+tijzW/+2XMUqA== X-Received: by 2002:a5d:6ca6:: with SMTP id a6mr1465183wra.179.1614357169623; Fri, 26 Feb 2021 08:32:49 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Sarah Harris , Paolo Bonzini , Max Filippov , Yoshinori Sato , qemu-s390x@nongnu.org, Michael Rolnik , qemu-ppc@nongnu.org, Marek Vasut , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alistair Francis , Michael Walle , Guan Xuetao , Laurent Vivier , Anthony Green , Palmer Dabbelt , David Hildenbrand , qemu-riscv@nongnu.org, David Gibson , Peter Maydell , Cornelia Huck , Jiaxun Yang , Richard Henderson , Chris Wulff , "Michael S. Tsirkin" , Aurelien Jarno , Aleksandar Rikalo , Sagar Karandikar , Claudio Fontana , Thomas Huth , Artyom Tarasenko , Greg Kurz , Stafford Horne , Bastian Koppelmann , Mark Cave-Ayland , Marcel Apfelbaum , "Edgar E. Iglesias" Subject: [PATCH 03/16] cpu: Introduce cpu_virtio_is_big_endian() Date: Fri, 26 Feb 2021 17:32:14 +0100 Message-Id: <20210226163227.4097950-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210226163227.4097950-1-f4bug@amsat.org> References: <20210226163227.4097950-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Introduce the cpu_virtio_is_big_endian() generic helper to avoid calling CPUClass internal virtio_is_big_endian() one. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/cpu.h | 9 +++++++++ hw/core/cpu.c | 8 ++++++-- hw/virtio/virtio.c | 4 +--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 2d43f78819f..b12028c3c03 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -602,6 +602,15 @@ hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr ad= dr); */ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs); =20 +/** + * cpu_virtio_is_big_endian: + * @cpu: CPU + + * Returns %true if a CPU which supports runtime configurable endianness + * is currently big-endian. + */ +bool cpu_virtio_is_big_endian(CPUState *cpu); + #endif /* CONFIG_USER_ONLY */ =20 /** diff --git a/hw/core/cpu.c b/hw/core/cpu.c index 4dce35f832f..daaff56a79e 100644 --- a/hw/core/cpu.c +++ b/hw/core/cpu.c @@ -218,8 +218,13 @@ static int cpu_common_gdb_write_register(CPUState *cpu= , uint8_t *buf, int reg) return 0; } =20 -static bool cpu_common_virtio_is_big_endian(CPUState *cpu) +bool cpu_virtio_is_big_endian(CPUState *cpu) { + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (cc->virtio_is_big_endian) { + return cc->virtio_is_big_endian(cpu); + } return target_words_bigendian(); } =20 @@ -438,7 +443,6 @@ static void cpu_class_init(ObjectClass *klass, void *da= ta) k->write_elf64_note =3D cpu_common_write_elf64_note; k->gdb_read_register =3D cpu_common_gdb_read_register; k->gdb_write_register =3D cpu_common_gdb_write_register; - k->virtio_is_big_endian =3D cpu_common_virtio_is_big_endian; set_bit(DEVICE_CATEGORY_CPU, dc->categories); dc->realize =3D cpu_common_realizefn; dc->unrealize =3D cpu_common_unrealizefn; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 1fd1917ca0f..fe6a4be99e4 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1973,9 +1973,7 @@ static enum virtio_device_endian virtio_default_endia= n(void) =20 static enum virtio_device_endian virtio_current_cpu_endian(void) { - CPUClass *cc =3D CPU_GET_CLASS(current_cpu); - - if (cc->virtio_is_big_endian(current_cpu)) { + if (cpu_virtio_is_big_endian(current_cpu)) { return VIRTIO_DEVICE_ENDIAN_BIG; } else { return VIRTIO_DEVICE_ENDIAN_LITTLE; --=20 2.26.2