From nobody Tue Nov 26 06:34:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=1709624318; cv=none; d=zohomail.com; s=zohoarc; b=P//sKqkxA1zujUL5vCO1LQeGmZPHak61Jg5c5XAJqGmHvFbs16Y7bf6KDAHDZ3dFAqUJS3NaK3IuQtkCYTUbfZaZKoGQKQOoNMUNbjKnHohvlVvmBEST2P1AIaMcrX8Q0OANTTlOA1WjJFqQGlgocAwdQv8sv+J4EOG/2tq/4W4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709624318; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i3f3HL5yPh+B2f2TWI8nLswxD9Zg3vmdmgIkTXj+uig=; b=cYK06pp219D6aHNpFJrjd2i1qAz7FceqMAQymYvwOONvnQhV4NNzqVnrh+VSM1a0/mZVi37lZKTx3PPF9wgwfwovX13X4HtByQdl+j1jo9KIsBXkb7VQctp0Jc1SgocRwUujBAj/UQd4vJDVTKbS/I96XvTm5hJqMfj0a4JsCdI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 17096243189471017.0113766634944; Mon, 4 Mar 2024 23:38:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhPMw-0006uO-3b; Tue, 05 Mar 2024 02:37:46 -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 1rhPMM-0006Hv-4b for qemu-devel@nongnu.org; Tue, 05 Mar 2024 02:37:13 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0: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 1rhPMI-0005sD-FB for qemu-devel@nongnu.org; Tue, 05 Mar 2024 02:37:09 -0500 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6e56d594b31so245261b3a.1 for ; Mon, 04 Mar 2024 23:36:57 -0800 (PST) Received: from localhost ([157.82.203.206]) by smtp.gmail.com with UTF8SMTPSA id j1-20020a62b601000000b006e64370ace9sm52664pff.195.2024.03.04.23.36.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Mar 2024 23:36:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1709624216; x=1710229016; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=i3f3HL5yPh+B2f2TWI8nLswxD9Zg3vmdmgIkTXj+uig=; b=xhfoaqbupk9Tgn9DBe5/ySIM3GDph7OazMSWGfXpqB3egpEoqNkdPd5mNli4L+SBdU nnJBZ4+I3+WvuJDfoN+754zU/bGErbuT6nqND4Okh8yb6Vu+dtSX0lBr5OGUGd1gG8qa ZpSV3vaEt0AfhtuFg3qOOloCzAETjA0e2GlWDPmx8TzRgjy7ZRhCZ8Ub09o3auOb6iUa tZKDVSRLITIWhrQHYHlmeM9JwJ2HVq64qfl13TK9Cy/2h3U/mixDjrokctUwGs8OpuPN crhpgvYiNCL7yyMICUhMlwkIEX0n2CSZmtCGUmO/3ZPkQmxhQlVDYSxMhUsq7ESmyfm0 r75w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709624216; x=1710229016; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i3f3HL5yPh+B2f2TWI8nLswxD9Zg3vmdmgIkTXj+uig=; b=SD2ODU9Hr0U2MIDfOAW4Y3DhIqQ2SpI2kpwUs9+I12KbSawHQLe/10dAo9o24IR50D uY58u0z2S81lFQhbkKR4hWa7UDU2VvtZXFEUEKRnIADbRuTODraJZd1DNewt10WL1GkY IbAwNFrJWl1tT2lX4WZ+YvL5DJWcuYmqELd34uN+P0kyJWp/427ARCBYHFga/W8qM3TG hQO0Q/O+RQgIYdL3skaqeUjQvqQ0tUfpcED/lLHmOKDECJ9EzlWk+UGVOJrGsPPD1gm+ SSUgpggjHYOIysMQ9/RvDt6J6XHOKmIU1ZVWFJQct9GJEu3sIU3MKfLD32DTAomot7zo juZA== X-Gm-Message-State: AOJu0YwaR+ketQ0OJKFJAOE0Ah5Yy31lKZrNnCO9/e04pvHIhH87Kvv2 mCtnUSCwrLeailJ5GFew+Y6rDb3+9DD1/+Br10xFagua5qcSXLYPy4qkSZ1gfsHcIgPrIYnKIA3 N X-Google-Smtp-Source: AGHT+IHTkLIkjVo41zPM6rMVfI6Pw4doPdq5mpKXgGn0terhyFFQZsUnHkt4nT5wlvNe6ad0kDIHHA== X-Received: by 2002:a05:6a20:748d:b0:1a1:4bec:4841 with SMTP id p13-20020a056a20748d00b001a14bec4841mr1084100pzd.25.1709624216342; Mon, 04 Mar 2024 23:36:56 -0800 (PST) From: Akihiko Odaki Date: Tue, 05 Mar 2024 16:36:26 +0900 Subject: [PATCH v2 09/13] contrib/elf2dmp: Use rol64() to decode MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240305-elf2dmp-v2-9-86ff2163ad32@daynix.com> References: <20240305-elf2dmp-v2-0-86ff2163ad32@daynix.com> In-Reply-To: <20240305-elf2dmp-v2-0-86ff2163ad32@daynix.com> To: Viktor Prutyanov , Peter Maydell Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::430; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x430.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1709624320639100007 rol64() is roubust against too large shift values and fixes UBSan warnings. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- contrib/elf2dmp/main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index 25cf0fdff724..20547fd8f819 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -6,6 +6,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/bitops.h" =20 #include "err.h" #include "addrspace.h" @@ -47,11 +48,6 @@ static const uint64_t SharedUserData =3D 0xfffff78000000= 000; s ? printf(#s" =3D 0x%016"PRIx64"\n", s) :\ eprintf("Failed to resolve "#s"\n"), s) =20 -static uint64_t rol(uint64_t x, uint64_t y) -{ - return (x << y) | (x >> (64 - y)); -} - /* * Decoding algorithm can be found in Volatility project */ @@ -64,7 +60,7 @@ static void kdbg_decode(uint64_t *dst, uint64_t *src, siz= e_t size, uint64_t block; =20 block =3D src[i]; - block =3D rol(block ^ kwn, (uint8_t)kwn); + block =3D rol64(block ^ kwn, kwn); block =3D __builtin_bswap64(block ^ kdbe) ^ kwa; dst[i] =3D block; } --=20 2.44.0