From patchwork Mon Mar 11 19:12:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 779425 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp1689645wrt; Mon, 11 Mar 2024 12:20:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXXfvpVuC5/bBjBehnJWZUfB3Va09jmkusxS75rdUrzlhZsPB1NQq3GTEVM07J8tPcZk7aE0OK6yeIAK+E37Kwv X-Google-Smtp-Source: AGHT+IF3FZ0juF7QNEyLXkyxFo2dBtVeF0qY8ItYI/aT99QOHlM0ODelntLpm/Nz/avQgXe7g17i X-Received: by 2002:a05:620a:44d6:b0:788:2357:604e with SMTP id y22-20020a05620a44d600b007882357604emr15323971qkp.3.1710184835036; Mon, 11 Mar 2024 12:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710184835; cv=none; d=google.com; s=arc-20160816; b=Y+1sPjFmood6RDlQu9XokFbhCAdOxI23TeGYmuz66BXoRv+Aa3gztuosjFhjUASP7h Hi0nlF6U5C4dLspCCUsWDTEPeHC39ujn9WwXwEyc6l4M9LZOnEskdaC4KBDQrR3nxXZ4 2Z/7R25AYdeC6h5JjjFopwUYNN2BH5C9ulNBZ28xia3lxrnRjD+QfXo7GQ8NhRVgLVlx bTaLoiNb1WdveW20+4CcHPhdP6lX52crYYeZhAPs01cuT09FmclSYetd5keVu+8z8zTl HZ+6G9Ht3JrEmbvqmTQHpKJduMIejDVqro5LE/IDflIHh9SwRNl985D/bmNMfiboJFkr XN9Q== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xdS6BQ4zGUSaBLNVAflAeEIqw3hx2MqgTFA3HutXwAc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=xM/G+1EbTkN5ttnJccYzAD1afgs3trVUnoaOn5N6w31lMRMQNxt7Ms9lpp+HX5fssc 7XhRbWrtIkG83BlRbAYGGiCTqm1NJrBC8VPeOduQLGDJ2nKcL7Hzruc0bN+0oGwYx4YF /alImLCZURCBVZnlV72WvUwHFnE/BnoElHPOiwrooJ0mIMdWWzuoYvLrUMlDJIfbPKjM mQC6oCaFL61BmEhRn1TkNcADO5cbfCotDKokJIO+kSCb3qWa9UochATFA6jELuDnoCTb Uq0ZSKHojp40j5Y9kLxYyxA7y9KmJCbyrYKPDdHtZU4iBizf9Z4xkBhmcSzWXw93xsq/ mpQg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bk9RdLGq; 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 h13-20020a05620a10ad00b00783577b7501si5962647qkk.357.2024.03.11.12.20.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2024 12:20:35 -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=Bk9RdLGq; 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 1rjl6k-0004j7-Tf; Mon, 11 Mar 2024 15:14:51 -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 1rjl4w-0003OP-OF for qemu-devel@nongnu.org; Mon, 11 Mar 2024 15:13:02 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rjl4u-0000NG-30 for qemu-devel@nongnu.org; Mon, 11 Mar 2024 15:12:53 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-41332865abfso401455e9.2 for ; Mon, 11 Mar 2024 12:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710184369; x=1710789169; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xdS6BQ4zGUSaBLNVAflAeEIqw3hx2MqgTFA3HutXwAc=; b=Bk9RdLGqNjvuwE5QOLlO7CTtzqxxhcBDPVnFcjRR8UnwOPKOkiv2nehlyIZTuenP6N XSJ2Lf8zhJztfk/C1lzQjRL7Zqmumqm1Cn/0WFBxa5ShExlMQ9uTP240jGDFC5aoqlIG 6Sad2Uhbdkk/MAh0KE4zVgxbekCc5ulG8LkZRpSFK/2RpcvIvhbZWuwkRh4MZyaFJhA0 LGuYRWW+YOUOIc0HfJO4xega5IJAHYOemwXzNPhcgiNGQFLfzuOKfVjwg60AfnL9SSdG Vq6+0f4JiBPbtvjdmYA7oN2h4jkyXYg3Fou+KRoYPMSnhX3YL0HEKhCK3IuM5ox0Uu5k iFog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710184369; x=1710789169; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xdS6BQ4zGUSaBLNVAflAeEIqw3hx2MqgTFA3HutXwAc=; b=deYfCLABo+acZTRUWKXRxFoGHEEO+ImCHMfquhEzSmPOQQo3mp56WZwW1b+i/izNbh 6wYCnNLsL4/gMucyNvIzTz34kpj39sv5f/AiMdItw22bQCfGNfNzeZK9LDTG6FiYJzo5 6x6y6h0PGwOARoL+J+7ITq+SCPoj878/0YKazi3R0Yc/ANM/Kxefo6MZ2mKXspfDPZPb Tyh2RndcXZqv8iaCqkpHOYvURaZB5YM1zt4lUum/L5QvBS4wQG7igmPX2p0wPYP4Ki0R BSFjxU9b6Uo+TS3Taou08gBs6LWo/VjWmylHjhaKcFS6DHxYVgkjZZM26uQV04JvAUoB kSdw== X-Gm-Message-State: AOJu0Yys7jufSwSh2cSSDQ3bf6VzkfNpVqDsCClCstTYf2NxMVXFSZB5 +Tutq2ASsobmEeAW8m9pt1k2J9w/Jnt7vRAE5JWHBlnokDh6ke1Qr2l4xIGtIKT4oQhP9Bp5omU n X-Received: by 2002:a05:600c:1990:b0:413:21ea:968e with SMTP id t16-20020a05600c199000b0041321ea968emr5900386wmq.41.1710184369667; Mon, 11 Mar 2024 12:12:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t10-20020a05600c450a00b004131388d948sm14425266wmo.0.2024.03.11.12.12.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 12:12:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/20] contrib/elf2dmp: Use rol64() to decode Date: Mon, 11 Mar 2024 19:12:36 +0000 Message-Id: <20240311191241.4177990-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240311191241.4177990-1-peter.maydell@linaro.org> References: <20240311191241.4177990-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki rol64() is roubust against too large shift values and fixes UBSan warnings. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell Tested-by: Viktor Prutyanov Reviewed-by: Philippe Mathieu-Daudé Message-id: 20240307-elf2dmp-v4-14-4f324ad4d99d@daynix.com Signed-off-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 32dc8bac6a3..d046a72ae67 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -6,6 +6,7 @@ */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "err.h" #include "addrspace.h" @@ -47,11 +48,6 @@ static const uint64_t SharedUserData = 0xfffff78000000000; s ? printf(#s" = 0x%016"PRIx64"\n", s) :\ eprintf("Failed to resolve "#s"\n"), s) -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, size_t size, uint64_t block; block = src[i]; - block = rol(block ^ kwn, (uint8_t)kwn); + block = rol64(block ^ kwn, kwn); block = __builtin_bswap64(block ^ kdbe) ^ kwa; dst[i] = block; }