From nobody Wed Nov 5 19:23:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.54 as permitted sender) client-ip=209.85.128.54; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f54.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1619120356; cv=none; d=zohomail.com; s=zohoarc; b=FM4ZEgA2npVTsYkYsLp4+gxnZPtXOA7IMM31W8rZRRKp4R85Yt2pYUiaIoHPWeA6noi1igyM/JO9j4c2ztjinUfpKtwLkYdmBT/V6oNMRg9ByE/KB7xwiqn7fl4kDW9OrYgtVLQFDk3V46nUoFqr2moHgQuCU5X2cSWgHl0y1xw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619120356; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ihV9O9yTVtGcI1ps/jSm4x/bK7fEiTqIiB+cKzqcXs4=; b=SuRM4NDNEkIvw5vVjaK0Ys2N/D9u6yz3muM5vKiwIsTidxwKrEotqHWQWgdVoPB49dOm9hLVN9a5lWcrkmP7ZwpLYH1NZES0VEfDgHVlUatQj2xwA8PGjT0IIevdFwzssZlI+G8jErjxcPlzUhT0gl/pF0hLHsQhasQjUuMhKFs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mx.zohomail.com with SMTPS id 1619120356701169.60361031374134; Thu, 22 Apr 2021 12:39:16 -0700 (PDT) Received: by mail-wm1-f54.google.com with SMTP id w7-20020a1cdf070000b0290125f388fb34so3914425wmg.0 for ; Thu, 22 Apr 2021 12:39:16 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (39.red-81-40-121.staticip.rima-tde.net. [81.40.121.39]) by smtp.gmail.com with ESMTPSA id o17sm5682842wrg.80.2021.04.22.12.39.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 12:39:14 -0700 (PDT) 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=ihV9O9yTVtGcI1ps/jSm4x/bK7fEiTqIiB+cKzqcXs4=; b=XLh+v1gbJMnAVrx29+u1RUDo5tUhYYxSBy6l1s0U6O7qZEM/KKdlbz4jV/1BGaTfRd uGiSDoMbe4iBKYblQlzWcDu0hAB2grjCjmy+jShXDLCC2holF2/R652hR209Wd1Maz85 li38HjWCK1+2W353Y+pmOL5nrfZjFrQ0z/BNVofaJTCeT6/HjG9iMgora6sENHKCGveb kUXi/jIapfO/u2BrqgQgJpotXCSXmt20nhboa7rZ2FRmk9zMJ29h461E4rBBeyBXImzJ TqcbYVVzaTOWbwP+Pcndu1qBPXAusdkPGhsfTNz0XPCU2N25T5vE24gtV3cqaufRC7np lAgg== 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=ihV9O9yTVtGcI1ps/jSm4x/bK7fEiTqIiB+cKzqcXs4=; b=TepfAHfZXtlw3gmbvYeZt+AEeFDl291Vh8yw4KAnEk37pKOxXAdY2YrxddCM2x0JEY aypX2IrvqUux0ojPBcY3C90669un4fnEqG1VLAiYdCT3oTvrLyZmnL2hlLCHp49PLwy0 Q4LoBEAf6PJzQsrZWS3sFW5ftKxQGxkRBdyh0gt6rWmP/pyNOg3y5RsrUp4E90oRe23K hg0645humlForWDiGUha0BOi9g3ne8U4PdfZfmft5Mv/nextmbUp37e+3Oz7RVY78UZY MRxGJs7tHdlY6i2QNA/44pKuMqiBza0y/o5hX4X659+mrk5FBWNzs1QafT4tP7y5t6tj TuzA== X-Gm-Message-State: AOAM533soNpk/3VKF9XtRHo/07nvU0n1YMhzmojC75okddAsceD/L6aO 6oS0f1OaVkAxRHcspsdqmb0= X-Google-Smtp-Source: ABdhPJxTyi8KdiHJnCKLRppZZXL1lNeExXpqj57ApsimvtXIBuG7BXBzsLUg5KhQmlnrRgW8eyz5rA== X-Received: by 2002:a1c:2342:: with SMTP id j63mr350940wmj.109.1619120354873; Thu, 22 Apr 2021 12:39:14 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , qemu-riscv@nongnu.org, Juan Quintela , Peter Maydell , Claudio Fontana , qemu-arm@nongnu.org, Eduardo Habkost , qemu-ppc@nongnu.org, Richard Henderson , Laurent Vivier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , "Michael S. Tsirkin" Subject: [PATCH v6 02/18] cpu: Introduce cpu_virtio_is_big_endian() Date: Thu, 22 Apr 2021 21:38:46 +0200 Message-Id: <20210422193902.2644064-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210422193902.2644064-1-f4bug@amsat.org> References: <20210422193902.2644064-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. Similarly to commit bf7663c4bd8 ("cpu: introduce CPUClass::virtio_is_big_endian()"), we keep 'virtio' in the method name to hint this handler shouldn't be called anywhere but from the virtio code. Reviewed-by: Richard Henderson 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 9338e80aa4b..08af2c383a5 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -604,6 +604,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 07f4e60b309..8a364496fd5 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.3