From nobody Tue Feb 10 06:26:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.51 as permitted sender) client-ip=209.85.221.51; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f51.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1621248737; cv=none; d=zohomail.com; s=zohoarc; b=WMoDRH1EPvHfSQkRu/B19Temfa+hwcaYPoB/nHqOEpq0SczjLVzSF66o2dIhy0S7DShA+966dOIYrtsqdJOHQlIJ9jL9Wxu2+aCGALlFr7s7X1noofSztYPSxCLax5oOv7P0gyuVXu87jL02TqiJdWg/N4CjhLIrSgpA+/ps6hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621248737; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l59dJwJTD3X/0a1ZARal5paaLkpJSadoVLKuikWa47k=; b=iR5uLYIhP9BOy6w09xWIrwGuve66rBOX6qjKZavceaj2HoIgxrqEkutr1hCr8vnYec/0sewAOKBtPpRFD75vlhq0bnWSDE41o3ViaQn1amNeqSFMriBuIw/misP1anOzXXNG3SMvk5lZTbFoneV/dA7E3IZkdYSV1aLrdMJajwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.51 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mx.zohomail.com with SMTPS id 1621248737904818.6654571298059; Mon, 17 May 2021 03:52:17 -0700 (PDT) Received: by mail-wr1-f51.google.com with SMTP id v12so5874552wrq.6 for ; Mon, 17 May 2021 03:52:17 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (31.red-83-51-215.dynamicip.rima-tde.net. [83.51.215.31]) by smtp.gmail.com with ESMTPSA id r11sm10990805wrp.46.2021.05.17.03.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 03:52:15 -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=l59dJwJTD3X/0a1ZARal5paaLkpJSadoVLKuikWa47k=; b=BmVPx1KPaifiuvOXGa4COEASn+9rXlOdAopBowSdJtwknRgiQcWsRx6iGLN9mYPPQT uHS7d7vc9mruNJLK5ObIkZXcvrZXhueYfOSAe4f4BiiQtsCBMXGpsK015mPzxhcGyTsB mEUr9BgajFYNSrUkSX0MfZYl1lwq/EMBZ1Ahp8J4Cgo+U4lLJ32s4doQPK0NEBOMk6zo wujAu1VdHqoYqnCNkbvLKLolfr1A74LBq7rrn2xQFq9yKFC64ioKlVwB95qMEPnFMzTO m4O9Io5oYp1MpkdVLZFfuMy5GlyxNilF2d6uWcJHRuDoOjpCoOWqMBYggSz4R02rOoAY UcqA== 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=l59dJwJTD3X/0a1ZARal5paaLkpJSadoVLKuikWa47k=; b=lEPEPctY0IWgGLLcIa7O1Ia+5DL1fkoH6v2vq/cDOs1U8QwS+zWhk3904jFp2x4PdI xY9ja19xyI+hiyEkrHhlxiEcuhf8gjBNfqdCt4xVg6luQ+ZRB5LbhgJoI36HimnjpphB 9lKEnVgY/KjKdQH6wDNfSJVbwL55GcT4ttdz2XcleF2oO24Hmf2/7smh1DaG9SzkTJs0 tOTuFhefcSzX7U5bAC397QBFEW4WQc2R7PmG6SjzxP13HDqD8CGGnT62+w1Gxn+6gQTK oH/ncYNFsZp83C1eVsMHGvCihsD/0BmKVETuQ4Gv1SRYVliRCryj+P4BagUAJZMFQi8N Fu7Q== X-Gm-Message-State: AOAM533k5kYngtBvfj2UWDXdVAJ00C3/LxhIUwYqY6hiWGp68yag9F9Y TFDi06tJgTz6S/b+GV8liFQ= X-Google-Smtp-Source: ABdhPJxARe1TggM0cO94HPndcxDkxQrW2nLYeEPPxM1+Jit3Tveb4lDVmNgSWlGwaVS9wOSzAhOy2g== X-Received: by 2002:adf:e944:: with SMTP id m4mr31326484wrn.10.1621248736089; Mon, 17 May 2021 03:52:16 -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: qemu-s390x@nongnu.org, Richard Henderson , qemu-arm@nongnu.org, Laurent Vivier , Paolo Bonzini , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7 07/23] cpu: Introduce cpu_virtio_is_big_endian() Date: Mon, 17 May 2021 12:51:24 +0200 Message-Id: <20210517105140.1062037-8-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210517105140.1062037-1-f4bug@amsat.org> References: <20210517105140.1062037-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-common.c | 6 ------ hw/core/cpu-sysemu.c | 10 ++++++++++ hw/virtio/virtio.c | 4 +--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index df495287850..d96ff4dace0 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -610,6 +610,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-common.c b/hw/core/cpu-common.c index ddddf4b10eb..9d73c9a28ca 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -185,11 +185,6 @@ 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) -{ - return target_words_bigendian(); -} - void cpu_dump_state(CPUState *cpu, FILE *f, int flags) { CPUClass *cc =3D CPU_GET_CLASS(cpu); @@ -388,7 +383,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/core/cpu-sysemu.c b/hw/core/cpu-sysemu.c index fe90dde8681..078e1a84a58 100644 --- a/hw/core/cpu-sysemu.c +++ b/hw/core/cpu-sysemu.c @@ -54,6 +54,16 @@ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs) return ret; } =20 +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(); +} + GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) { CPUClass *cc =3D CPU_GET_CLASS(cpu); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e02544b2df7..ab516ac6144 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1972,9 +1972,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