Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp209446rdb; Tue, 5 Dec 2023 03:22:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVW4a1qnAKpVgirj84Vg+w2t09msnuetUAOIa9J9woqJQA9M+3akjCJ6HzLbn6ubCtkdM9 X-Received: by 2002:a17:90a:e2ce:b0:286:6cc0:886e with SMTP id fr14-20020a17090ae2ce00b002866cc0886emr735782pjb.91.1701775324507; Tue, 05 Dec 2023 03:22:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701775324; cv=none; d=google.com; s=arc-20160816; b=BQROL2K/6A03xtEDi1N8yVbsMfpXyKyF47m2h5eBrqtzPVZq2N4O9mnBqi5u7MvieD Oq947/0otEkZCUOwQKjrUiJs8+kZ+whSEAv2gOIGgs5Af1ZKQY5DHbkkaaUCtHH0hjOO c+Bfx8ZV1uFsMB7I3QZv8m4GHsNk0f1r81z6EsdmgZY3KjGpLOo6iCf9yY6IJXEBPUm0 xVFulF9K1uAD6X6fJjBLaSfV5+EQzn9/EMg4q95dZ6Aq7rFszsVXAITiddsg3eOw8MEi i8rw5/KpQb8T9n2RjH9f8knirQoTV+h6Uzcrsm+4i0Ni7gugBUdQWsJQfBb1AhQ1w4nt k/NA== 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=Y/TD/VALuASHosN2MT9/9TMGtpqd4qzm5S2GVJifbc0=; fh=uCCWEUVpLc/xDP/D3WvGY/BxHU9d0NQYu/T71GEsNmA=; b=pXGc+WyxgQdRuv+I/iOFITdVKWoXabY0KIgYw1Jl/DzBUbwGYVD1vjmR1cI9ODT1jo QCvFrzcrVJl9+9AyGVoGebwkRZNj0fZu2j7MyYXAYvmEdGD2vDigpsjZRtrqeAg7L1Iw WM7QL0UtR8QeqD7EFg9EApFjvMSaZbQrxnbGyG8Nuxcp/sR5bHh3FGkX0isC3pq4E+bX yF1vTn8Zcwu0Vu7cbxxQrDW/VtJWHFCcz3d+E4ipyBIl0M7zkxBlpPUvur3aSz9jtkvj uZ1XEFI35ozueiEylUkmBBq3cI9tuWdNKIdlkMt0TjCwB6PYIUbumpHu1FcoXdbtJlca gd5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PisZ+4BE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w1-20020a17090abc0100b00286bba72e5fsi2887320pjr.16.2023.12.05.03.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 03:22:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PisZ+4BE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A37CB80C03A6; Tue, 5 Dec 2023 03:22:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442185AbjLELVr (ORCPT + 99 others); Tue, 5 Dec 2023 06:21:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442069AbjLELVS (ORCPT ); Tue, 5 Dec 2023 06:21:18 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A54B4135; Tue, 5 Dec 2023 03:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701775285; x=1733311285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8zwQaI6Tk7f8mb2xHC28eOqgRd27v5i+M1zjLpRj75Y=; b=PisZ+4BE2m9zWBVoo8xuTuXLh11Hg+UBXSSvCouiqe1VmyGTwho3LH5i n3E4mOYYnlHV116Yk8ESWRyK3moYDF2XMRTeyKAEqBY5tACy24RyRystt DN+KK+3pXK5QitLncIvVOLFIHcwnPqvoScoJe6hIYv/4aFo5GHugeO7nu eLaBu8idXTDpu/LP/tXWx9Bogw6v8/HRc/K20UUeIVgRmmdYOfWR4m+1j 6h+/QAGJz0GSIqVEwFgoT4xnJGP7zDQCey9GjERcP6kjZbroNvSZQON5n AHSqGyotZLO2ciKoUEkEg5CuU4qiwGYTCC5i3lV4CyYzzNw7Aq465SiGx g==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="942432" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="942432" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 03:21:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="1018192932" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018192932" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 03:21:18 -0800 From: Xin Li To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, pbonzini@redhat.com, seanjc@google.com, peterz@infradead.org, jgross@suse.com, ravi.v.shankar@intel.com, mhiramat@kernel.org, andrew.cooper3@citrix.com, jiangshanlai@gmail.com, nik.borisov@suse.com, shan.kang@intel.com Subject: [PATCH v13 10/35] x86/objtool: Teach objtool about ERET[US] Date: Tue, 5 Dec 2023 02:49:59 -0800 Message-ID: <20231205105030.8698-11-xin3.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205105030.8698-1-xin3.li@intel.com> References: <20231205105030.8698-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 05 Dec 2023 03:22:03 -0800 (PST) From: "H. Peter Anvin (Intel)" Update the objtool decoder to know about the ERET[US] instructions (type INSN_CONTEXT_SWITCH). Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- tools/objtool/arch/x86/decode.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index e327cd827135..3a1d80a7878d 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -509,11 +509,20 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec if (op2 == 0x01) { - if (modrm == 0xca) - insn->type = INSN_CLAC; - else if (modrm == 0xcb) - insn->type = INSN_STAC; - + switch (insn_last_prefix_id(&ins)) { + case INAT_PFX_REPE: + case INAT_PFX_REPNE: + if (modrm == 0xca) + /* eretu/erets */ + insn->type = INSN_CONTEXT_SWITCH; + break; + default: + if (modrm == 0xca) + insn->type = INSN_CLAC; + else if (modrm == 0xcb) + insn->type = INSN_STAC; + break; + } } else if (op2 >= 0x80 && op2 <= 0x8f) { insn->type = INSN_JUMP_CONDITIONAL; -- 2.43.0