From patchwork Fri Oct 4 16:21:12 2024 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: 832735 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp864042wra; Fri, 4 Oct 2024 09:22:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQKzgw5T1M9GYjA5P2LshzxuK/+2o7pOUyYhHARnf25erXISmK3xDzO/cu/qSSvPKfmUJr+Q==@linaro.org X-Google-Smtp-Source: AGHT+IFVAPVtBtbO52j/4cJrmbEdx8EaCkBJTAE1Z4BNnxlYJ2/hWzjmAZDYUoWsZ/WICByxqY1K X-Received: by 2002:ad4:5d4f:0:b0:6cb:2e49:a743 with SMTP id 6a1803df08f44-6cb902f2191mr132675996d6.24.1728058972144; Fri, 04 Oct 2024 09:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728058972; cv=none; d=google.com; s=arc-20240605; b=ipXJJn36O2wuxUFIs5Z2PV+oQUHNaVwjA5RqnxElHIiJlVPaxialUdwpcHIhLByW3s xKx1ei0hIvQ6/dp2BT41/yVGLGBmOplVT5YJHHN1UAPddhvymytuOi/qTivm/UwbSF5C +nB3OU8vf61dCWQJdJFiEA5u0eEctdTY5OP35ilPq3AjNMQhBo847Y9adwZgAtkVLxNm G6zmWkCxfa/FdIe3vEJ+/iOkCvf/xrzd8Sx06gI5FmlYu1UpOYnTN+xbmj7MVNEOEJba LIdmePGZToCl2Ij8iHVx6EuA9GlYK27T3jFpZ1LonDznxrUSD7kPl0MNyeBp8pwojpfb 493g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=ar5l4AIEpN89iIriQ1A0Rg6FdJgoGAMAWx9ArtF1/do=; fh=IxtCl+9ZHUzZoUVl4S7ob8DSiOMwUZ6EKD3En8tt6Ik=; b=AtxHiNNKi3Kj85cj/gR0L6UEZJezimfLybeYDTGwmx0hdjca4neNNFvaLguLWNQZqv jCsv/eAKEvR0/98o6NJb7pADAsuvyA3sSYQE/oswz7Z/Mk0/+8xCwyVZFkeTnNCEoj2v n7N13z5Hygm1ucB5UOMqT76STGtFtQdDW5D77Dup5kSsvZpyNfo7VXmgBScGW2NIGs2D lP4RIBocH+AbjIv7pnzcwXc9MswSg5W+fj12T/3MtlngAUAo4FHeEjASs++3OGPoGeqm DRPEXWtRE5YxwRbuMDAQrPfcQmRibUFWOShs9Eyf0caeFOQlABMxyHFOoauUlKgnimPk BIbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ytp0wzKT; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6cba4772eabsi1230686d6.419.2024.10.04.09.22.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Oct 2024 09:22:52 -0700 (PDT) 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=Ytp0wzKT; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swl4K-0004Ek-S4; Fri, 04 Oct 2024 12:22:17 -0400 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 1swl4G-00049L-0Q for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:22:13 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1swl4D-0004Jv-Im for qemu-devel@nongnu.org; Fri, 04 Oct 2024 12:22:11 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2facf00b0c7so30379521fa.1 for ; Fri, 04 Oct 2024 09:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728058927; x=1728663727; darn=nongnu.org; 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=ar5l4AIEpN89iIriQ1A0Rg6FdJgoGAMAWx9ArtF1/do=; b=Ytp0wzKTkW8NIPEum3ch5BKTIUseSEEti4EBj3Va0PjPyzOXXJoBPmz/aCffQCD0kA 9AUmpDDjj30sz3pDRGZWur0HZtaSt5J4HRvZZOvR+oog+v/tgvFbvdXKhi7N6/fA3W5B B32ke9DsYjLwb1GtCMDtnM08oo1cpf8xGqMRmgGicKna3Y6nWbzEpBGfePAT2wsECryq VsEmgIngAoDDO+dbUYA2WWBzT3GrLK8OnlZpctUYcZWmnkNq+eeUSNqUqWvt3J/g98I+ mXgHCcPOHMPgy114mnh6X/Wy1wBB10iKff14hQEw/46i2FQJZZUkyGeh81kMfIFjrwCb CYVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728058927; x=1728663727; 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=ar5l4AIEpN89iIriQ1A0Rg6FdJgoGAMAWx9ArtF1/do=; b=ZxGYrk2bQrMr8ZD7nJ4CgKZNxeTvTJ6j58FixD/HH92/evIBRBsTx7S6UHc15CLDbO +TSPHMYZa7khAYaYk25g3ynW1LxEYcjA5X9Up6TwaqHgpPBuX9bz7VjMSORFx/mF05XL hnS/Mz/SbKiO1stnrXt6gnJdlHFq0GC8z4axKNyN7hTbpGtTWgmudmAL+gCWboTV0B1O po0LEB85lVTs4z/FExY8uTJbNTWspvN8Lt6USvObqUtjHsAxgrF5wZ0DdFeofS07w5Vb zXZJ/HYDk85Txjvpk9S523Xj3vFM9vREJsvUh6w7Q1vXd8Wl9qpNqCi9WveraFcUyGHv JUrA== X-Gm-Message-State: AOJu0YywSJUg5sxywsJ/JjthjhGf/MrBr2zZOGcRtL3rRbzL+TFzrCWG SguuPsPA2a4N3lO9CCZK0IzzIrMoogJdChIKaftKblOSubMy0DN4e+3cO5+hcO0/31A4dRQ8DPY R4SlkvOBv X-Received: by 2002:a2e:b8c9:0:b0:2fa:cf2c:479a with SMTP id 38308e7fff4ca-2faf39f9266mr9732401fa.24.1728058927479; Fri, 04 Oct 2024 09:22:07 -0700 (PDT) Received: from localhost.localdomain ([91.223.100.208]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2faf9b33027sm161171fa.115.2024.10.04.09.21.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Oct 2024 09:22:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Aurelien Jarno , Eduardo Habkost , Yanan Wang , "Edgar E. Iglesias" , qemu-ppc@nongnu.org, Marcel Apfelbaum , Aleksandar Rikalo , Daniel Henrique Barboza , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , Nicholas Piggin , qemu-arm@nongnu.org, Zhao Liu , Peter Maydell , Jiaxun Yang Subject: [PATCH 2/8] hw/core/cpu: Introduce CPUClass::is_big_endian() handler Date: Fri, 4 Oct 2024 13:21:12 -0300 Message-ID: <20241004162118.84570-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241004162118.84570-1-philmd@linaro.org> References: <20241004162118.84570-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philmd@linaro.org; helo=mail-lj1-x22d.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 Introduce the CPUClass::is_big_endian() handler and its common default. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/core/cpu.h | 3 ++- hw/core/cpu-common.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 04e9ad49968..22ef7a44e86 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -150,6 +150,7 @@ struct CPUClass { ObjectClass *(*class_by_name)(const char *cpu_model); void (*parse_features)(const char *typename, char *str, Error **errp); + bool (*is_big_endian)(CPUState *cpu); bool (*has_work)(CPUState *cpu); int (*mmu_index)(CPUState *cpu, bool ifetch); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, @@ -749,7 +750,7 @@ int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs); */ bool cpu_virtio_is_big_endian(CPUState *cpu); -#endif /* CONFIG_USER_ONLY */ +#endif /* !CONFIG_USER_ONLY */ /** * cpu_list_add: diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 7982ecd39a5..aa5ea9761e4 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -26,6 +26,7 @@ #include "qemu/main-loop.h" #include "exec/log.h" #include "exec/gdbstub.h" +#include "exec/tswap.h" #include "sysemu/tcg.h" #include "hw/boards.h" #include "hw/qdev-properties.h" @@ -138,6 +139,11 @@ static void cpu_common_reset_hold(Object *obj, ResetType type) cpu_exec_reset_hold(cpu); } +static bool cpu_common_is_big_endian(CPUState *cs) +{ + return target_words_bigendian(); +} + static bool cpu_common_has_work(CPUState *cs) { return false; @@ -306,6 +312,7 @@ static void cpu_common_class_init(ObjectClass *klass, void *data) k->parse_features = cpu_common_parse_features; k->get_arch_id = cpu_common_get_arch_id; + k->is_big_endian = cpu_common_is_big_endian; k->has_work = cpu_common_has_work; k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register;