From patchwork Fri Feb 24 07:01:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 61148 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp756137wrd; Thu, 23 Feb 2023 23:29:09 -0800 (PST) X-Google-Smtp-Source: AK7set9uDs55gZCKoY9IYB9HTrrkO11HhGbVgrym50OYV3Xv3SjouV2iAvxq0S/VZoI/b0ha7kWC X-Received: by 2002:aa7:cccc:0:b0:4ac:b308:d732 with SMTP id y12-20020aa7cccc000000b004acb308d732mr15350520edt.18.1677223749296; Thu, 23 Feb 2023 23:29:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677223749; cv=none; d=google.com; s=arc-20160816; b=lgZwFTglaPmqsWTwLjAsokQjmhur3m9xGeyvi6kXqeOLT3n5n7s5fr3+poEE+BoSSr bVezbk0PD39yGjS5Qqz9LyaxK7917nyJ2W3SiLZith6HzpFG+tr258QQBfYRkcJu6nUo /h6BbKG64OORQnZX0RMbehJ93FY3lS3APbChR4DCM+YRuXg9weO7epCKLanuAFixp30r CwrXvbYzmqY3AppESR505YZstf5/aVMUE5BxNrzmZGHcRhZVCK6PkgRHOTg6hS+PexaO ZbYcMkf4rJc2SfVeB8gveR9qf9kcg3Pj32VG44Jww1oX5TsOUqDGcmKO2PB4VzlQHKIu cjXA== 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=FdgpIHI+aRuh9Emrx/acOJHcoY/ts9JXxHqyYFGOvcs=; b=mXe+ghHmElJrTN6u3ZinQkGvPrH4HNjrmKS1Gb9gETtMebK/2P57NUvf5IIkHLBNG4 +7nVzfUY+o4SiLnoH/4kajw3GrgJ1f5mZP0N4DRgeBYvMywmayAPOesBnrdcVxX9YvvR 0SYJaH661IMIXbDLL5nZOZRLMQeyCa3zSn8ltkk9F8zsF7wBxv9uBICzjxTw6dPiFq6D vOHPwb2R37k/nzmtq2bmBPC0jSBZauuK0C8qZoQ3KHuvx4kam4gCvjaFAadwXFP/i9g6 N6TiJCBn0HIX2rQgsPWwuS0paKh+qJzMXwjQ6gXNHhmQcpaQR4QWPTaxJ7PWgOGGoVXi V2CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FOyHO+P+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t5-20020a05640203c500b004acb7e10eb1si6027818edw.238.2023.02.23.23.28.45; Thu, 23 Feb 2023 23:29:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FOyHO+P+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbjBXH2S (ORCPT + 99 others); Fri, 24 Feb 2023 02:28:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbjBXH2A (ORCPT ); Fri, 24 Feb 2023 02:28:00 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E28CFA; Thu, 23 Feb 2023 23:27:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677223676; x=1708759676; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LPt5KI78RHrT+nU0CTWy5sIjKcY7qI5WuuF75Mzk9KE=; b=FOyHO+P+PgPhBp3/aZD05bBqV/hH+KXihA3COHmVpGY9xw9ObdVydZ2O 10f6gA2Y4+mDdBUgXWJzpzfkLSNupnveg7fQLsZLCjSzyLLO6WyLT7se2 5syE29CqD2wFXT3F6vrggGC9Hz1GUFczSpD+wr2VkHkwneHfAHH4M4uuz +vsL7YCT2BkiWl2pTP4tdRMP8zFt9hf2+JAad6rEyvI7IPXNPd8+s7uWO C5TJSnW/581PizhovqFoNldH0VPzZ+9/abYD7vTapfEVE07hmMTOFNXic 85S/ET/L85s+GPk0rvXjQeEiMkWxbkZM5aDwf5ScmBnigsVTqmEs6TkdG w==; X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="334835980" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="334835980" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Feb 2023 23:27:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10630"; a="815639210" X-IronPort-AV: E=Sophos;i="5.97,324,1669104000"; d="scan'208";a="815639210" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga001.fm.intel.com with ESMTP; 23 Feb 2023 23:27:21 -0800 From: Xin Li To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, peterz@infradead.org, andrew.cooper3@citrix.com, seanjc@google.com, pbonzini@redhat.com, ravi.v.shankar@intel.com Subject: [RFC PATCH v3 08/32] x86/objtool: teach objtool about ERETU and ERETS Date: Thu, 23 Feb 2023 23:01:21 -0800 Message-Id: <20230224070145.3572-9-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230224070145.3572-1-xin3.li@intel.com> References: <20230224070145.3572-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758696570052087152?= X-GMAIL-MSGID: =?utf-8?q?1758696570052087152?= From: "H. Peter Anvin (Intel)" Update the objtool decoder to know about the ERETU and ERETS instructions (type INSN_CONTEXT_SWITCH.) Signed-off-by: H. Peter Anvin (Intel) Signed-off-by: Xin Li --- tools/objtool/arch/x86/decode.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index e7b030f7e2a5..735c909540b5 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -509,12 +509,22 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec case 0x0f: if (op2 == 0x01) { - - if (modrm == 0xca) - *type = INSN_CLAC; - else if (modrm == 0xcb) - *type = INSN_STAC; - + switch (insn_last_prefix_id(&insn)) { + case INAT_PFX_REPE: + case INAT_PFX_REPNE: + if (modrm == 0xca) { + /* eretu/erets */ + *type = INSN_CONTEXT_SWITCH; + } + break; + default: + if (modrm == 0xca) { + *type = INSN_CLAC; + } else if (modrm == 0xcb) { + *type = INSN_STAC; + } + break; + } } else if (op2 >= 0x80 && op2 <= 0x8f) { *type = INSN_JUMP_CONDITIONAL;