[PATCH] Support Intel USER_MSR
Hu, Lin1
lin1.hu@intel.com
Wed Oct 25 02:01:30 GMT 2023
> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: Tuesday, October 24, 2023 8:02 PM
> To: Hu, Lin1 <lin1.hu@intel.com>
> Cc: binutils@sourceware.org; Lu, Hongjiu <hongjiu.lu@intel.com>
> Subject: Re: [PATCH] Support Intel USER_MSR
>
> On 24.10.2023 12:01, Hu, Lin1 wrote:
> >> -----Original Message-----
> >> From: Jan Beulich <jbeulich@suse.com>
> >> Sent: Tuesday, October 24, 2023 4:56 PM
> >>
> >> On 24.10.2023 10:38, Hu, Lin1 wrote:
> >>> I've thought of it so far is I can use a Fixup function like
> >>>
> >>> static bool
> >>> uwrmsr_Fixup (instr_info *ins, int bytemode, int sizeflag) {
> >>> if (bytemode == d_mode)
> >>> {
> >>> if (OP_Skip_MODRM (ins, 0, sizeflag))
> >>> {
> >>> if (OP_I (ins, bytemode, sizeflag))
> >>> {
> >>> ins->codep--;
> >>> }
> >>> return true;
> >>> }
> >>> }
> >>> return false;
> >>> }
> >>>
> >>> Then the uwrmsr's unit will be { "uwrmsr", { { uwrmsr_Fixup,
> d_mode },
> >> Rq }, 0 }.
> >>> What‘s your opinion?
> >>
> >> Hmm, not very nice, but I can't exclude it simply won't get any better.
> >> My desire was for there to not be any new fixup function, and for
> >> OP_Skip_MODRM to be used directly in the table entry. (In any event,
> >> if you really need to keep this new function, please combine the
> >> three if()-s into a single one, helping readability quite a bit.
> >>
> >
> > I have another idea, can I have a new function like
> >
> > OP_back_codep(...)
> > {
> > Ins->codep--;
> > Return true;
> > }
> >
> > So the uwrmsr's unit will be { "uwrmsr", { Skip_MODRM, Id, Back_Codep, Rq },
> 0 }.
>
> Well, the main thing I dislike is the decrementing of codep, no matter where it's
> put. In case you don't think you can get away without, I guess I'll try afterwards,
> aiming at an incremental change then.
>
I have another one in mind at the moment. Can I have a bool variable in instr_info,
@@ -221,6 +221,9 @@ struct instr_info
/* Record whether EVEX masking is used incorrectly. */
bool illegal_masking;
+ /* Record whether the modrm byte has been skipped. */
+ bool has_skipped_modrm.
+
unsigned char op_ad;
And the Skip mod/rm byte pattern will be
@@ -11668,7 +11658,11 @@ OP_Skip_MODRM (instr_info *ins, int bytemode ATTRIBUTE_UNUSED,
/* Skip mod/rm byte. */
MODRM_CHECK;
- ins->codep++;
+ if (!ins->has_skipped_modrm)
+ {
+ ins->codep++;
+ ins->has_skipped_modrm = true;
+ }
return true;
}
.
This change will be applied to all other similar sections (include OP_E).
So the uwrmsr's unit will be { "uwrmsr", { Skip_MODRM, Id, Rq }, 0 }, because the codep won't increasing in Rq, I don't need the decrementing of codep.
> Jan
More information about the Binutils
mailing list