|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v6 01/12] misc/xenmicrocode: Upload a microcode blob to the hypervisor
On Tue, Mar 12, 2019 at 04:27:33PM +0100, Roger Pau Monné wrote:
>On Mon, Mar 11, 2019 at 03:57:25PM +0800, Chao Gao wrote:
>> This patch provides a tool for late microcode update.
>>
>> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
>> Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
>> ---
>> tools/libxc/include/xenctrl.h | 1 +
>> tools/libxc/xc_misc.c | 20 ++++++++++
>> tools/misc/Makefile | 4 ++
>> tools/misc/xenmicrocode.c | 89
>> +++++++++++++++++++++++++++++++++++++++++++
>
>Would you mind naming the tool xen-ucode or xen-microcode?
>
>That seems more inline with the naming schemed used for most of the
>tools in misc/.
>
>> +int main(int argc, char *argv[])
>> +{
>> + int fd, len, ret;
>> + char *filename, *buf;
>> + struct stat st;
>> + struct xen_platform_op op;
>> + xc_interface *xch;
>> + DECLARE_HYPERCALL_BUFFER(struct xenpf_microcode_update, uc);
>> +
>> + if (argc < 2)
>> + {
>> + show_help();
>> + return 0;
>> + }
>> +
>> + filename = argv[1];
>> + fd = open(filename, O_RDONLY);
>> + if (fd < 0) {
>> + fprintf(stderr, "Could not open %s. (err: %s)\n",
>> + filename, strerror(errno));
>> + return errno;
>> + }
>> +
>> + if (stat(filename, &st) != 0) {
>> + fprintf(stderr, "Could not get the size of %s. (err: %s)\n",
>> + filename, strerror(errno));
>> + return errno;
>> + }
>> +
>> + len = st.st_size;
>> + buf = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
>> + if (buf == MAP_FAILED) {
>> + fprintf(stderr, "mmap failed. (error: %s)\n", strerror(errno));
>> + return errno;
>> + }
>
>IMO you could just use fread to read the full contents of the file
>into the buffer you allocate and avoid this mmap dance.
Sure. Will follow your advices.
Thanks
Chao
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |