From patchwork Thu Dec 22 21:55:43 2022 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: 635952 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp125709pvb; Thu, 22 Dec 2022 13:56:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXvbZeAAMatZ+14jK7Dov+Y3tXDGMdhyWPxJcBgSPuLngiPPS06J2n51akCGGcUh4FTXLHk5 X-Received: by 2002:ac8:6a0e:0:b0:3a9:86c6:e27b with SMTP id t14-20020ac86a0e000000b003a986c6e27bmr7905601qtr.28.1671746195600; Thu, 22 Dec 2022 13:56:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671746195; cv=none; d=google.com; s=arc-20160816; b=vZ5XSZpTbBsbjTwHSgxNpunhcC4+ZFRjtTmufrY+a8Do+vcti0+jq04rj17iDZvSmh ODHfyEuo/i20oO+JDAV3lb9g1wVsHjmvNKT2N/AYERbN9PsnfaVAvv8exvzZ3Z0A6MjX gWBGQuF3GUM5poL5fVfqKej6aw5kHQtBjrs4g1QBRz1GGVfCKAYqhp5aRcejPE416oYZ WBQnNpIjyDeiEtmFJlYy2Vn69ZR2N6Sj9tgGSqHU0aJwEk9yLWgsG7Y8ognsx69MgmBX SUczSIQi9IVO/ENFcci7Gkn7cuViY+E6sG6FmlhScpQuMhroFkDXgDqVYRBbicWwJa3z 89sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=U6OB+osXLSH5rsjdTEcuOpIx3EZfV0y8ZIYPN7oPYLs=; b=LEu4NvOUAvpSVtISvICqGQR9GvxxKYBbH2nFgrEDUH6f3u5i7FNa9GanUTBjLFxisq 61b6azGa8KFy49vsdRXZYUaIaxX2iIw0sE195L09ZjIEQcrjXoxH+cBokVXG6ERoaWBf Zu654XYUXJSSRd1Zgw4eiElRx0yigG+78dX6Qmvb6rSwDD2abXZdg1nvXJ9ycAGeRnd7 4xSzYEdLA+k+Sy2RXrMrj1ZTNRpsghT0Y2UtcP3y/xD5E0WRckVnasLJwGsc0t+rOJSG JgFkITlxPu2eM4fJPwCTlG6ZcEa3XwBqZHxieK8SikuXb+1X9Hp13pcbt7MVK6ytkfRJ nVhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eaeT8tDS; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u8-20020a05622a17c800b003a7fe306dd5si670592qtk.330.2022.12.22.13.56.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Dec 2022 13:56:35 -0800 (PST) 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=eaeT8tDS; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8TXp-0005z2-4G; Thu, 22 Dec 2022 16:56:05 -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 1p8TXl-0005yh-6z for qemu-devel@nongnu.org; Thu, 22 Dec 2022 16:56:02 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p8TXj-00078l-Lg for qemu-devel@nongnu.org; Thu, 22 Dec 2022 16:56:00 -0500 Received: by mail-ej1-x633.google.com with SMTP id bj12so7882865ejb.13 for ; Thu, 22 Dec 2022 13:55:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=U6OB+osXLSH5rsjdTEcuOpIx3EZfV0y8ZIYPN7oPYLs=; b=eaeT8tDS+rX486vZ7f3STK14HEPWH473aA+yQ6v64ROApXywLkMdephJuFtzYeMOil 73uNmukHZ07xyH8ihzU4vEVudZI7IqjGCS8p+soaXE3tDj6SwZeiR1KEkbl3bBA48QgC DtKZsvmZknHiE8Zjsqt+LzETRhsQO5LNVpinMF98Ecuttdm3gkMZy/KKpRUveEc5XLhJ TjTjwbrevMhKBy9ZzRkRb/U01o9mixi2t8uCVVn5E0VrSSBVV/bw3crFkS9+AHPH27dN ATICZKtfHoTjTD/G/Am+2Gu+kb2tAWdB9xTdFvBvVqrO+tq9u+zSycKpLdY+b51emBLT UEng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U6OB+osXLSH5rsjdTEcuOpIx3EZfV0y8ZIYPN7oPYLs=; b=XkaSwX7/I2NcaoNQRwrxTKTDnelwCBC3Uz96fNhYEbB72MCprsKrdou41+2nV6qX3q mKFfT6mpEoUwi4AkTHHdUA4tL+cJ+OyVP7csUk+MWofD9QJBVhwwc4OdkC0xCxmMNt6W imTO8o/XwIxey12jVu3i2fjxPCVmd9Ht07HAQLbJwfaR3kdEi8m5dncNpR6ws4vwL6sZ 9QRc7bXl1n8ac7CVL3uV9GV9wGARGXpPwBTnUsgmVX0JQcVnAF4DH6hkFv/2NwAv3yJO dbxdF+I+PFdg5TcXY4aMvLCnFrTYuyBxnJQu/+sdXsilBduBgDFS4RHEuYmkgiO4k70v jq1w== X-Gm-Message-State: AFqh2kpGO7cx/0HRQ+4Daaa2tpWAGBE8Mm9ilMK2lrQN9/suQz18z00I LazG0jHfZwtraQA33S8zeqXF/wagW8T/tyIPFKw= X-Received: by 2002:a17:907:d045:b0:7c1:5464:3360 with SMTP id vb5-20020a170907d04500b007c154643360mr7931510ejc.65.1671746157387; Thu, 22 Dec 2022 13:55:57 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id e15-20020a170906314f00b007c07909eb9asm677945eje.1.2022.12.22.13.55.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 22 Dec 2022 13:55:56 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrew Jeffery , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Igor Mitsyanko , Joel Stanley , Havard Skinnemoen , Peter Maydell , "Edgar E. Iglesias" , =?utf-8?q?C=C3=A9dric_Le_Go?= =?utf-8?q?ater?= , Alistair Francis , qemu-arm@nongnu.org, Tyrone Ting Subject: [PATCH 0/6] hw/arm: Fix smpboot[] on big-endian hosts and remove tswap32() Date: Thu, 22 Dec 2022 22:55:43 +0100 Message-Id: <20221222215549.86872-1-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.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 ARM CPUs fetch instructions in little-endian. smpboot[] encoded instructions are written in little-endian. We call tswap32() on the array. tswap32 function swap a 32-bit value if the target endianness doesn't match the host one. Otherwise it is a NOP. * On a little-endian host, the array is stored as it. tswap32() is a NOP, and the vCPU fetches the instructions as it, in little-endian. * On a big-endian host, the array is stored as it. tswap32() swap the instructions to little-endian, and the vCPU fetches the instructions as it, in little-endian. Using tswap() on system emulation is a bit odd: while the target particularities might change the system emulation, the host ones (such its endianness) shouldn't interfere. We can simplify by using const_le32() to always store the instructions in the array in little-endian, removing the need for the dubious tswap(). Two boards which weren't swapping (aspeed and raspi) are fixed. Tested running ARM avocado tests on x86_64 and s390x. Philippe Mathieu-Daudé (6): hw/arm/aspeed: Fix smpboot[] on big-endian hosts hw/arm/raspi: Fix smpboot[] on big-endian hosts hw/arm/exynos4210: Remove tswap32() calls and constify smpboot[] hw/arm/npcm7xx: Remove tswap32() calls and constify smpboot[] hw/arm/xilinx_zynq: Remove tswap32() calls and constify smpboot[] hw/arm/boot: Remove tswap32() calls and constify board_setup_blob[] hw/arm/aspeed.c | 28 ++++++++++++------------ hw/arm/boot.c | 52 +++++++++++++++++++------------------------- hw/arm/exynos4210.c | 48 ++++++++++++++++++---------------------- hw/arm/npcm7xx.c | 49 +++++++++++++++++------------------------ hw/arm/raspi.c | 46 +++++++++++++++++++-------------------- hw/arm/xilinx_zynq.c | 27 ++++++++++------------- 6 files changed, 112 insertions(+), 138 deletions(-) Reviewed-by: Richard Henderson