From patchwork Wed Dec 11 23:03:49 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: 2021735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=A7ymYIDO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Y7rnC186vz1yRC for ; Thu, 12 Dec 2024 10:06:07 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLVkY-0002pe-Md; Wed, 11 Dec 2024 18:04:10 -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 1tLVkW-0002oH-Ho for qemu-ppc@nongnu.org; Wed, 11 Dec 2024 18:04:08 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLVkU-0001rL-Jr for qemu-ppc@nongnu.org; Wed, 11 Dec 2024 18:04:08 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-38633b5dbcfso4471825f8f.2 for ; Wed, 11 Dec 2024 15:04:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733958245; x=1734563045; 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=q84BF+ePAefMMrHK1zEl0KjUdaMQRdy3zhrx62Em4cY=; b=A7ymYIDO5fap9DrW/EBuzh7/yEydEefzdDuEfKHedx5RcI4wSuCV5V55XUhPcIkajG JiUJbLRJR41PR+DwSgdBi047I+zg9ZylSlnR4CtmC8gGmdQjuTKZYKVM8pSEc1qasYmm 5ztNXDuzPcP5k+lkHCmku3wgrOz4gLiKrSrX1PSBNvGsQBrnbjFy7qmreAyPj0qnTOYm yFErLFM7CXFctn9La0dFsOMtiNWKCzrinER09og6FJEoqLDKrI1ZaAMtj8De9WcehdO3 L/M4Xx+iX8xuwNwQDvL2HP0Wt5Wzd+8lKOk31114f2cMJ//cpuwfANBFzIqDdC8zVXnB VL6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733958245; x=1734563045; 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=q84BF+ePAefMMrHK1zEl0KjUdaMQRdy3zhrx62Em4cY=; b=BMngpP2pVX6XXTYYKg4W8lYboHuivvDKCy4+sqxeXLnOsCxqdRELkDEE0/uSlHZ2Yk ToClJqxfO2XP0OmhdzBU4aQnYqP/vp0pRW3CqmRN45Fd91Nn8PV+zPJqgad0Xe3T29be FMqMPVpP26GztkEpRBcBRJIHcD7bls1TI4lMGtVA8OvU/xx6dBk4Ewf+IQwS6Uj7V8K+ 9/zuFyNZUSSdWI96N8xbS3BwudWMAd+iMFzH+w45v10OWTVeEaSfbg1L6+Dv4bRUqOiU agMudpxBUU813egB7pBzpMYBx0Q/1OqMXjy/5UVpXcc6tsY+Zpk/R+BcSgvWCSKMUM3a f6gg== X-Forwarded-Encrypted: i=1; AJvYcCX6cpguU3c4AgH7caQP5LewBmhD7iL819wzWCoI5mf5zIHQJ3a81K5ca+k2BISAS84YlCTo2QHWzw==@nongnu.org X-Gm-Message-State: AOJu0YxIImz9m2B3CYePbN2wDieJAiu+2O6SnSVAvhjEhgwiaTWmSZH0 ycGghobtM+iqqsNa8p+4ZA3KULjKLrYvR7M8ej/T0DN/MNRwF6Bfy5KTfx25mhY= X-Gm-Gg: ASbGncsw070BDSxds1zCCKjS9W/unbM6c8PPvsWTWri/X7W3Z8B8ETdGMdBBQd2xsix Sql3QNS6x2h4Doio5quVNdRws7xfbmq6L0Eo1ElPvtvhKP/SZGFkiE+EJEeUDInEodVMLH8L9eW vHa2PIntZpVa6iMeG8DK5o51Oe3ylWEc6qmZIOVOVfLxpM81OCd/bOs8ASVjUXtQgW/7dY7CoP8 nFmIS9ELDHvGd5RkgNR7CgYKN8pzeIDNb70XFhRTpYlbQgNWxMVRZIwEpXca2xi4Cd2h9t/FhJK xfIEcSbVFNmnSSmLtZgu1HvJP0+2KFaOtQ== X-Google-Smtp-Source: AGHT+IFj4wDYdVTeVwuYH2TKwtEA6LG+06PYKJPO47q/hi6nNnWcScJdwe5EV5X9ap37AMBzXiD+XQ== X-Received: by 2002:a5d:5983:0:b0:386:3903:86eb with SMTP id ffacd0b85a97d-3864ce97148mr3804619f8f.23.1733958245097; Wed, 11 Dec 2024 15:04:05 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38782514dc3sm2279838f8f.67.2024.12.11.15.04.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Dec 2024 15:04:04 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , qemu-ppc@nongnu.org, qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell Subject: [PATCH v2 1/9] target/xtensa: Remove tswap() calls in semihosting simcall() helper Date: Thu, 12 Dec 2024 00:03:49 +0100 Message-ID: <20241211230357.97036-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241211230357.97036-1-philmd@linaro.org> References: <20241211230357.97036-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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-ppc@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-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-ppc-bounces+incoming=patchwork.ozlabs.org@nongnu.org In preparation of heterogeneous emulation where cores with different endianness can run concurrently, we need to remove the tswap() calls -- which use a fixed per-binary endianness. Get the endianness of the CPU accessed using the libisa xtensa_isa_is_big_endian() call and replace the tswap() calls by bswap() ones when necessary. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/xtensa/xtensa-semi.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c index fa21b7e11fc..2ded8e5634e 100644 --- a/target/xtensa/xtensa-semi.c +++ b/target/xtensa/xtensa-semi.c @@ -30,6 +30,7 @@ #include "chardev/char-fe.h" #include "exec/helper-proto.h" #include "semihosting/semihost.h" +#include "semihosting/uaccess.h" #include "qapi/error.h" #include "qemu/log.h" @@ -323,15 +324,12 @@ void HELPER(simcall)(CPUXtensaState *env) uint32_t fd = regs[3]; uint32_t rq = regs[4]; uint32_t target_tv = regs[5]; - uint32_t target_tvv[2]; struct timeval tv = {0}; if (target_tv) { - cpu_memory_rw_debug(cs, target_tv, - (uint8_t *)target_tvv, sizeof(target_tvv), 0); - tv.tv_sec = (int32_t)tswap32(target_tvv[0]); - tv.tv_usec = (int32_t)tswap32(target_tvv[1]); + get_user_u32(tv.tv_sec, target_tv); + get_user_u32(tv.tv_sec, target_tv + 4); } if (fd < 3 && sim_console) { if ((fd == 1 || fd == 2) && rq == SELECT_ONE_WRITE) { @@ -387,11 +385,8 @@ void HELPER(simcall)(CPUXtensaState *env) const char *str = semihosting_get_arg(i); int str_size = strlen(str) + 1; - argptr = tswap32(regs[3] + str_offset); - - cpu_memory_rw_debug(cs, - regs[3] + i * sizeof(uint32_t), - (uint8_t *)&argptr, sizeof(argptr), 1); + put_user_u32(regs[3] + str_offset, + regs[3] + i * sizeof(uint32_t)); cpu_memory_rw_debug(cs, regs[3] + str_offset, (uint8_t *)str, str_size, 1);