From patchwork Fri Apr 25 15:28:29 2025 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: 884390 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4027148wrs; Fri, 25 Apr 2025 08:34:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV1jLl9CBHqbqZbIBZn8KsCBkFbZWogscoGIYaYDnsQsHw3gQvI9CnMx0gI6I1gc9ZcBzuKbQ==@linaro.org X-Google-Smtp-Source: AGHT+IEPe4Bc6WwdZmmIVb0sYlvz2T58pno71O3i+U5mtxj3IFmQkUOZsYpZOxt3RXBgnbQJlyYA X-Received: by 2002:ac8:5911:0:b0:477:ea0:1b27 with SMTP id d75a77b69052e-4801d049f45mr35949381cf.26.1745595262633; Fri, 25 Apr 2025 08:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745595262; cv=none; d=google.com; s=arc-20240605; b=Eblhcv9MvLAweVQNq55XeVszyKv0yEFmGZje2ynYMEITIfsLaNCzyHzkdVYNASe3d0 SEyI15KLBAYZCnVulHa8/j4S8rr8qwad1J6WYmZzrJzhI1hP/Fror7iYWBVqW3oARlUu Ig5G7slENlOOp9RHBM632N96RcB/VIt6UfX5IIIW7QSPnX0gQoYXbJfPcu1u3lF+N4ih 3+9MD9AjCV7ney8pgme7MDQ4f931NYuCk+tsDRPSB689S1ZJry1m+BJyjwYAa6HmQcXG 37WNgDHdPPB1MjY/EWvz2hmbphY2OdRET0zi+l8/Oul/9gYgsg+fKzjv4k2PFcOlMdD9 vhyw== 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=bURnSPDaVtR9N3EkMoH8bF+JT/oXfM8qcNeiJQnPSHQ=; fh=qtn8prgQtzf5IzCNvLChUZDElvNECP6ej9YfjQeBz3I=; b=hXG8ljE88N2GNV8rb/RGj6ZkMuma/HGYVECylON5hH6WSwO6Ly8667i9exdoQIgdCc boMewvds2KODj43CfP7dinzGYIlbQ01OAacQE0w3nQKyFfZXdzjJvd7zS69rqOTAOKCs Mf4gA53OM5bGxgQyNmxrDzeAMoLHqlzNHP6ZK+7af+AtixYh9AmG6pt9mGVTzpLpRIz1 qRm0Xj0qCU1yhoa34UMMTIJJ4PDl661rN6pQJR4qyWfDjdzF6msG3oMqC2+5j1Bl58Dz rwFK4PmdpDkEfpnL+whftQG2iHfU//9EHAvQfb/uoGkQBsF+1TimkqLMUE0s5HeJb8j3 EiIA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Gmk8p79/"; 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 d75a77b69052e-47ea24b839fsi41837431cf.522.2025.04.25.08.34.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Apr 2025 08:34:22 -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="Gmk8p79/"; 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 1u8L2e-0000cg-5Y; Fri, 25 Apr 2025 11:32:40 -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 1u8L2V-0000H3-Di for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:32:31 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u8L2T-0004Az-JU for qemu-devel@nongnu.org; Fri, 25 Apr 2025 11:32:31 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-43cf58eea0fso10770915e9.0 for ; Fri, 25 Apr 2025 08:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745595147; x=1746199947; 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=bURnSPDaVtR9N3EkMoH8bF+JT/oXfM8qcNeiJQnPSHQ=; b=Gmk8p79/wFZXvWm5TKsFnC0hGD7s5acPn7TMIJYd/0I+/Oe0O6InUJiyEHnyJzY6P9 mL9YD/DX/ipAfcLczDwc1rmFyrJ//gf7gUyfgeJyk12SU9BG9AUUBG13uq82mc7WxNSo j9GRPlFxTfbn4qFa8IAGoSe7tjifbgBTfOKexxlWHsuHcNDPhc9BrAOvB885IZe1gxaa YtMQjqqgGChkIHdOxijMKYN/6AvvOzOmkvVHlSay7CxHPVa3VU76NytrZU7eXldAZLvi YuWeIjNL6zQBHRFir7Hn8nFntikfoGhHAYcy8QBpJLag+haDB/rQiRugI4CfvSMVXUBm lW5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745595147; x=1746199947; 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=bURnSPDaVtR9N3EkMoH8bF+JT/oXfM8qcNeiJQnPSHQ=; b=GlmpFfPt24s+aO0f99R6PBgJFJG8od36i8NKtlu0493CdyMmPA7kYFP3ODGru1XxZU tX2JdrI5+lr729Ft/6Ry/mXWrRa2UbiLkbi0/QVL+Y2tj0HP3YNM2e5SVV/4EGPNsm7z M1FRulvzFuFqAcy/iKierZnL14FQXTpauUiuwXWKtGmf5p/wWt6Cgku0L5mccmRx13kk Xf/o9Wi3PwHgHXGzhhvToojGori8Y6rrSShhgcaHpwUF4HSB6v2Ns2Ze/J1BSNMh5OAn frEAWKoRQ4Uvkz/jo6S0UcyX5qmt023gWL7zIj4v3P8a1kBGJ96144+QTYCqmHOfszj8 88iw== X-Gm-Message-State: AOJu0YwoRqGNozOKInSwirlYPRrQoHOABFNhChkzyoxT0GgHq2sJvt8V 1/UtMIwM1+86WS9Io2rHQbDwh2CxWpytWnY23VrtTfgQm3OM4fZ7nNjl8TsCbVe3tuYjI2Y16Tt E X-Gm-Gg: ASbGncuDkllXJYta+d8p8mKRlmXsK+fR1YHfQipwFPQM2MKlE21oNk8OoK5eTF7NYE0 FDclrK/lKyLz7oQsl4/9hkQRyETG+hgsNZiLi9OOTXyPKkK1FGboDcLaC9kKCusdeyaSghB1cQs 0OUxzjABxfzgXzH9lLyYVfDRodQRnyUmMj5CJvzI46aGL/EhkrcGcFiEnhHC58VRShk9AuqH4hA D38EwYeazNjVIRTCVScUiVbHD1gEdbGJ9ZYqbF70wduEUwPTY3PulHsTfC3BP2sRVPf0kGeYmCI VX9/lpSb9sbpEIGwBAs8BbCP9CegqRBB/wF7xuZ7YKnnPvSvtxHTM3GbDhwawdVXs60bCs16ESm F3FAqRUaR4py5/Nc= X-Received: by 2002:a05:600c:190b:b0:43b:c95f:fd9 with SMTP id 5b1f17b1804b1-440a65ba213mr25134635e9.5.1745595147631; Fri, 25 Apr 2025 08:32:27 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4409d2a0e7esm62693035e9.10.2025.04.25.08.32.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 25 Apr 2025 08:32:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 45/58] accel/kvm: Use target_needs_bswap() Date: Fri, 25 Apr 2025 17:28:29 +0200 Message-ID: <20250425152843.69638-46-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250425152843.69638-1-philmd@linaro.org> References: <20250425152843.69638-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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=ham 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 Check whether we need to swap at runtime using target_needs_bswap(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20250417131004.47205-3-philmd@linaro.org> --- accel/kvm/kvm-all.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b8c68c7819a..278a50690c9 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -33,6 +33,7 @@ #include "system/cpus.h" #include "system/accel-blocker.h" #include "qemu/bswap.h" +#include "exec/tswap.h" #include "system/memory.h" #include "system/ram_addr.h" #include "qemu/event_notifier.h" @@ -1318,21 +1319,22 @@ bool kvm_hwpoisoned_mem(void) static uint32_t adjust_ioeventfd_endianness(uint32_t val, uint32_t size) { -#if HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN - /* The kernel expects ioeventfd values in HOST_BIG_ENDIAN - * endianness, but the memory core hands them in target endianness. - * For example, PPC is always treated as big-endian even if running - * on KVM and on PPC64LE. Correct here. - */ - switch (size) { - case 2: - val = bswap16(val); - break; - case 4: - val = bswap32(val); - break; + if (target_needs_bswap()) { + /* + * The kernel expects ioeventfd values in HOST_BIG_ENDIAN + * endianness, but the memory core hands them in target endianness. + * For example, PPC is always treated as big-endian even if running + * on KVM and on PPC64LE. Correct here, swapping back. + */ + switch (size) { + case 2: + val = bswap16(val); + break; + case 4: + val = bswap32(val); + break; + } } -#endif return val; }