Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2005793ybh; Fri, 17 Jul 2020 07:08:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKuX2laqrDoT34IfG/Uu3v1ZEa0evPtkP3TF7WoIyVZIYmXVua+aOTl22gDpo+eTRt1g8+ X-Received: by 2002:a05:6402:b84:: with SMTP id cf4mr9126472edb.21.1594994879867; Fri, 17 Jul 2020 07:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594994879; cv=none; d=google.com; s=arc-20160816; b=xs3qTl9D4No267FG160SnGJefAQ/XvjDKC5IZ328J/lrznywIgqVmjzAh3ZvNCnlmI 74dHhHg0bLLtYH98xyEHniqF+rxb9ZOT8O4Xdkd2jDCI9cFLhLpaZhUZRYvNkNrYkKFK by6kTMa/0DflIXrZYEHD2CEmLd9/plXVbko1uFKzCP4RGKWOV2TU+REIcqeruii/tCi+ QlOdjkrvBOiSdm+4I8wgjUkyZs457pMNHxeD2bYuRe+FDh5OWmHLsYTy//Qc7QtK/QXx niUK61L6jjvnr+9pih5YfVbBbzoZzCsGB0VTcIDFzQj606GibP/iAZiuR/uy9Ca0RsmE 6iVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=96KOi3QyA4aG9b93O8xRRBW91/hB8TRqMD8FEkwTx0I=; b=HrgqiC2F3/09NpFcahGeXD8xf7Dh5vbiERa93OyhEtnINwq+CpHWIY3fcSVHhPSQgA RHjLOMGTPmm/4eE8UMU3E4UYc+AfyaX1+nv+FsNPsJyAPFe0cCbQrpvO3Qw0EURHr5qs LhcxqLQjYojANQx9t9E2cXcEYIhf1TWAmaeL9BtQoFr8K8WJinqUYaVKgKAHrRy8Jk7j 4q5ANBg2U4Wzc4zY2tm+WigZPvCsPQRUVvyl6m7s1rjykmf72Z2ZjGTb4G6BXXzVpPg3 9+24bJ2zSKa+3HUNX8ukMmS+MrCh401w5IuL5xxjeygxUsQOrQabuZdz1GM+t5AU9cJa M8YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KaQrFt+Y; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h19si5155315ejj.80.2020.07.17.07.07.37; Fri, 17 Jul 2020 07:07:59 -0700 (PDT) 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=@kernel.org header.s=default header.b=KaQrFt+Y; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727916AbgGQOGb (ORCPT + 99 others); Fri, 17 Jul 2020 10:06:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:54612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727876AbgGQOGa (ORCPT ); Fri, 17 Jul 2020 10:06:30 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 22AFE2067D; Fri, 17 Jul 2020 14:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594994790; bh=idhd2mun2o3KTZfXKc7yxApyqOFeBVXhlYMrKvNie5U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KaQrFt+YhFkTXtEgafkFEb1WYvRfdZ4Kw0ki3VoubVwnrLGVDz8sU/1yskahu7eCy 7gQmmSH6lOqgTLjYUK+DloD0v5HMyHQie7V+qLc+Edn8y8RmecTmQSPolQQwRh4bK3 IUvtlU6lhpCZpunU3IsRYhQnTKqj0S8gGlEmwpSY= Date: Fri, 17 Jul 2020 23:06:22 +0900 From: Masami Hiramatsu To: Joerg Roedel Cc: x86@kernel.org, Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v4 10/75] x86/insn: Add insn_has_rep_prefix() helper Message-Id: <20200717230622.5be651b71711368acbfe6bb0@kernel.org> In-Reply-To: <20200714120917.11253-11-joro@8bytes.org> References: <20200714120917.11253-1-joro@8bytes.org> <20200714120917.11253-11-joro@8bytes.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 14 Jul 2020 14:08:12 +0200 Joerg Roedel wrote: > From: Joerg Roedel > > Add a function to check whether an instruction has a REP prefix. This looks good to me. Reviewed-by: Masami Hiramatsu Thank you, > > Signed-off-by: Joerg Roedel > --- > arch/x86/include/asm/insn-eval.h | 1 + > arch/x86/lib/insn-eval.c | 24 ++++++++++++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/arch/x86/include/asm/insn-eval.h b/arch/x86/include/asm/insn-eval.h > index f748f57f1491..a0f839aa144d 100644 > --- a/arch/x86/include/asm/insn-eval.h > +++ b/arch/x86/include/asm/insn-eval.h > @@ -15,6 +15,7 @@ > #define INSN_CODE_SEG_OPND_SZ(params) (params & 0xf) > #define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4)) > > +bool insn_has_rep_prefix(struct insn *insn); > void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs); > int insn_get_modrm_rm_off(struct insn *insn, struct pt_regs *regs); > int insn_get_modrm_reg_off(struct insn *insn, struct pt_regs *regs); > diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c > index a8ac5c5e94f0..8ed9d645259c 100644 > --- a/arch/x86/lib/insn-eval.c > +++ b/arch/x86/lib/insn-eval.c > @@ -53,6 +53,30 @@ static bool is_string_insn(struct insn *insn) > } > } > > +/** > + * insn_has_rep_prefix() - Determine if instruction has a REP prefix > + * @insn: Instruction containing the prefix to inspect > + * > + * Returns: > + * > + * true if the instruction has a REP prefix, false if not. > + */ > +bool insn_has_rep_prefix(struct insn *insn) > +{ > + int i; > + > + insn_get_prefixes(insn); > + > + for (i = 0; i < insn->prefixes.nbytes; i++) { > + insn_byte_t p = insn->prefixes.bytes[i]; > + > + if (p == 0xf2 || p == 0xf3) > + return true; > + } > + > + return false; > +} > + > /** > * get_seg_reg_override_idx() - obtain segment register override index > * @insn: Valid instruction with segment override prefixes > -- > 2.27.0 > -- Masami Hiramatsu