Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5968380pxu; Wed, 23 Dec 2020 09:46:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyj/92PTWgIdxcUVR7JXjQ12K10SFJCloccvMd1ssq2aSnn1JsrN1WUjpC+m3R5wRzpoZsA X-Received: by 2002:a17:906:a011:: with SMTP id p17mr24635634ejy.30.1608745592088; Wed, 23 Dec 2020 09:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608745592; cv=none; d=google.com; s=arc-20160816; b=Ggn5KbSyn87qHKWMnPJF4e0N1qZy16ahHcM3lSOSueXXYG6VoGfUc8Ew+GpwtWqHyd nllM4BlsbkJ02x90+S9+q3UOX9QIiLlcvkHbkbPG7d2KRy0mjmfhKpcHnXTbMLn3Uvy2 +SPwXQBEqMy3AxNYGsYTmgGAqp8PWn9P5PjruxzJ4gjkUwM7cocRuv/+QFGguysLunnF dVyeisaTL/NoDCdBMgDtgw6Knv3srWKn0zt/1GvuDQHVe1YapVEqQHo8lSa4CMjF3rn9 uOeE1muEYnxc4Tuc10e16TzymmajQW/jZDE2BGi06g6vErj95VWiZVgMppgCB8MOin/V OMNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GHls/O/EJX+cwlbUJjFb5UNshOjm1y3XildNZ9dteow=; b=CElbaRzt5zXlYQ1pfPVZTVT6wB5FDQX4vW8SGI5bIJSKU2ldRRA2JfR3V//Idl1VU0 Q13WyXvigtY3RKbcXnX05MkK6+L4B8o5pENtcZAwcGzmJVTWbtFSduT8+mDm5cCvTyde +A8RCXvbCchTZqR4v8DWNhEAorDgc4MbBzVMnvAXNA7jcTdO7j9JWAYyqaC+bXWEZ+SZ 6BTfV9zDIVelOKdI3mSQz9LWjiFu1iZXONMpYMuONtEDxIae2VIXCrsp+BaZWEsjly63 bJw+xr/p61zN4pzguMao4iQZZN7OvXYpn0MbAFla7c+zhrtHRXNuKQWTPafdvu4Bqmya pcBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=esOufsf3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz27si13292739edb.371.2020.12.23.09.46.09; Wed, 23 Dec 2020 09:46:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=esOufsf3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbgLWRoG (ORCPT + 99 others); Wed, 23 Dec 2020 12:44:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbgLWRoE (ORCPT ); Wed, 23 Dec 2020 12:44:04 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60089C061257 for ; Wed, 23 Dec 2020 09:42:52 -0800 (PST) Received: from zn.tnic (p200300ec2f0de600b74d534b1676c98b.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:e600:b74d:534b:1676:c98b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id E9A7B1EC054C; Wed, 23 Dec 2020 18:42:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1608745371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GHls/O/EJX+cwlbUJjFb5UNshOjm1y3XildNZ9dteow=; b=esOufsf3lZentSvCe1sVYgDQmWoSFIZeAERVoWvFECDnLVhMefMKP9KjLL12+NT+/HCvLG ruxii0w9CGqQoRBSmsfjO4sMUsSbWFJc+r5bqS/SyAYspqhJc+lHxwQfAjfdOID76Z7ZS8 NSmWUwawuYZ/vzwapa3x0MathHid87E= From: Borislav Petkov To: Andy Lutomirski , Masami Hiramatsu Cc: X86 ML , LKML Subject: [PATCH v1 14/19] x86/tools/insn_decoder_test: Convert to insn_decode() Date: Wed, 23 Dec 2020 18:42:28 +0100 Message-Id: <20201223174233.28638-15-bp@alien8.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223174233.28638-1-bp@alien8.de> References: <20201223174233.28638-1-bp@alien8.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov Simplify code, no functional changes. Signed-off-by: Borislav Petkov --- arch/x86/tools/insn_decoder_test.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/tools/insn_decoder_test.c b/arch/x86/tools/insn_decoder_test.c index 34eda63c124b..472540aeabc2 100644 --- a/arch/x86/tools/insn_decoder_test.c +++ b/arch/x86/tools/insn_decoder_test.c @@ -120,7 +120,7 @@ int main(int argc, char **argv) while (fgets(line, BUFSIZE, stdin)) { char copy[BUFSIZE], *s, *tab1, *tab2; - int nb = 0; + int nb = 0, ret; unsigned int b; if (line[0] == '<') { @@ -148,10 +148,12 @@ int main(int argc, char **argv) } else break; } + /* Decode an instruction */ - insn_init(&insn, insn_buff, sizeof(insn_buff), x86_64); - insn_get_length(&insn); - if (insn.length != nb) { + ret = insn_decode(&insn, insn_buff, sizeof(insn_buff), + x86_64 ? INSN_MODE_64 : INSN_MODE_32); + + if (ret < 0 || insn.length != nb) { warnings++; pr_warn("Found an x86 instruction decoder bug, " "please report this.\n", sym); -- 2.29.2