From nobody Wed May 15 20:12:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611750951; cv=none; d=zohomail.com; s=zohoarc; b=bAKANoW8BExi43MgRGNf1y2niHxlRwoJhswDf9APH2DO9meOqHyinwRSubvaVqPBZBT0mK3/M4V5Qpo4Lmnnq0YIKr39NGvRTkzizcWKCN2hKZc2jvumOeeZlIQS5wOk1YMHcaggL3QOd+/3796wh031VA0+cOtmFuYjU8Id60Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611750951; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=9b7+76XwkQ9p5h7GqrjOzqELJ7HNUGqvrd8hw0p8D84=; b=D+HhDwgqsgead1TRWQwCKf3adL/O8OALdJSHSeeD9yTYkpifGsZ+6bFUwdcuIDr0qFsST6Mz76aJ7dhn9kQHoIX3KSxSvja+MI4rAiaH/hwVL7Suu0GI0SIhGhsLKbzoyDyRt9imU/N1ahvW+RrK9LzSoX6ZOxBeuPtolfoAQdo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611750950946631.0341804898218; Wed, 27 Jan 2021 04:35:50 -0800 (PST) Received: from localhost ([::1]:32772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4k33-0001aV-Ja for importer@patchew.org; Wed, 27 Jan 2021 07:35:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4k29-00016Z-HM for qemu-devel@nongnu.org; Wed, 27 Jan 2021 07:34:53 -0500 Received: from mail.weilnetz.de ([37.120.169.71]:46216 helo=mail.v2201612906741603.powersrv.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4k27-0007gy-7Z for qemu-devel@nongnu.org; Wed, 27 Jan 2021 07:34:53 -0500 Received: from qemu.weilnetz.de (qemu.weilnetz.de [188.68.58.204]) by mail.v2201612906741603.powersrv.de (Postfix) with ESMTP id 1FE92DA14B2; Wed, 27 Jan 2021 13:34:49 +0100 (CET) Received: by qemu.weilnetz.de (Postfix, from userid 1000) id 07004460C81; Wed, 27 Jan 2021 13:34:49 +0100 (CET) From: Stefan Weil To: Richard Henderson Subject: [PATCH v2] tcg/tci: Fix some unaligned memory accesses Date: Wed, 27 Jan 2021 13:34:46 +0100 Message-Id: <20210127123446.2037721-1-sw@weilnetz.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=37.120.169.71; envelope-from=stefan@weilnetz.de; helo=mail.v2201612906741603.powersrv.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Weil , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Stefan Weil --- v2: Use inline functions from qemu/bswap.h instead of memcpy as suggested b= y Richard. tcg/tci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 42354d8ebb..ddbb259e1d 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -166,7 +166,11 @@ static uint64_t tci_uint64(uint32_t high, uint32_t low) /* Read constant (native size) from bytecode. */ static tcg_target_ulong tci_read_i(const uint8_t **tb_ptr) { - tcg_target_ulong value =3D *(const tcg_target_ulong *)(*tb_ptr); +#if TCG_TARGET_REG_BITS =3D=3D 32 + tcg_target_ulong value =3D ldl_he_p(*tb_ptr); +#elif TCG_TARGET_REG_BITS =3D=3D 64 + tcg_target_ulong value =3D ldq_he_p(*tb_ptr); +#endif *tb_ptr +=3D sizeof(value); return value; } @@ -174,7 +178,7 @@ static tcg_target_ulong tci_read_i(const uint8_t **tb_p= tr) /* Read unsigned constant (32 bit) from bytecode. */ static uint32_t tci_read_i32(const uint8_t **tb_ptr) { - uint32_t value =3D *(const uint32_t *)(*tb_ptr); + uint32_t value =3D ldl_he_p(*tb_ptr); *tb_ptr +=3D sizeof(value); return value; } @@ -182,7 +186,7 @@ static uint32_t tci_read_i32(const uint8_t **tb_ptr) /* Read signed constant (32 bit) from bytecode. */ static int32_t tci_read_s32(const uint8_t **tb_ptr) { - int32_t value =3D *(const int32_t *)(*tb_ptr); + int32_t value =3D ldl_he_p(*tb_ptr); *tb_ptr +=3D sizeof(value); return value; } @@ -191,7 +195,7 @@ static int32_t tci_read_s32(const uint8_t **tb_ptr) /* Read constant (64 bit) from bytecode. */ static uint64_t tci_read_i64(const uint8_t **tb_ptr) { - uint64_t value =3D *(const uint64_t *)(*tb_ptr); + uint64_t value =3D ldq_he_p(*tb_ptr); *tb_ptr +=3D sizeof(value); return value; } @@ -1129,7 +1133,7 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchSt= ate *env, /* QEMU specific operations. */ =20 case INDEX_op_exit_tb: - ret =3D *(uint64_t *)tb_ptr; + ret =3D ldq_he_p(tb_ptr); goto exit; break; case INDEX_op_goto_tb: --=20 2.29.2