Messages in this thread | | | Date | Mon, 18 Oct 2021 17:53:49 +0200 | From | Peter Zijlstra <> | Subject | Re: [PATCH 2/3] x86/insn-eval: Introduce insn_decode_mmio() |
| |
On Mon, Oct 18, 2021 at 06:33:32PM +0300, Kirill A. Shutemov wrote:
> diff --git a/arch/x86/lib/insn-eval.c b/arch/x86/lib/insn-eval.c > index fbaa3fa24bde..2ab29d8d6731 100644 > --- a/arch/x86/lib/insn-eval.c > +++ b/arch/x86/lib/insn-eval.c > @@ -1559,3 +1559,85 @@ bool insn_decode_from_regs(struct insn *insn, struct pt_regs *regs, > > return true; > } > + > +/** > + * insn_decode_mmio() - Decode a MMIO instruction > + * @insn: Structure to store decoded instruction > + * @bytes: Returns size of memory operand > + * > + * Decodes instruction that used for Memory-mapped I/O. > + * > + * Returns: > + * > + * Type of the instruction. Size of the memory operand is stored in > + * @bytes. If decode failed, MMIO_DECODE_FAILED returned. > + */ > +enum mmio_type insn_decode_mmio(struct insn *insn, int *bytes) > +{ > + int type = MMIO_DECODE_FAILED; > + > + *bytes = 0; > + > + insn_get_opcode(insn);
insn_get_opcode() can fail. Either you assume it's already called and don't call it, or you can't assume anything and get to do error handling.
> + switch (insn->opcode.bytes[0]) { ... > + } > + > + return type; > +} > -- > 2.32.0 >
| |