[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v12 3/9] tools: provide interface for generic MSR access
>>> On 24.07.14 at 08:31, <dongxiao.xu@xxxxxxxxx> wrote: > Considering many people in the list requires the white-list style to limit > the capability for resource access (e.g. MSR read/write), so I implement such > a white-list in my new version patch like following: > Does it look reasonable to you? Reasonable - perhaps. Efficiently coded - no: > static unsigned int allowed_msr_list[] = { > MSR_IA32_QOSEVTSEL, > MSR_IA32_QMC, > }; > > static unsigned int allow_access(unsigned int idx, unsigned int *list, > unsigned int nr) > { > unsigned int i; > > for ( i = 0; i < nr; i++ ) > if ( list[i] == idx ) > return 1; Using a big switch allows the compiler to (hopefully) find an optimal translation - possibly via lookup table, but maybe via other means. And if you were to stay with the explicit lookup table, you'd have to fix various mechanical issues (but I take this only as a sketch, not as something you're proposing as is). That said I continue to not be fully convinced of the need of a white or black list here, not the least with the consideration in mind of extending this to port I/O. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |