View | Details | Raw Unified | Return to bug 179523
Collapse All | Expand All

(-)sys/dev/cpuctl/cpuctl.c (-11 / +11 lines)
Lines 63-69 Link Here
63
# define	DPRINTF(...)
63
# define	DPRINTF(...)
64
#endif
64
#endif
65
65
66
#define	UCODE_SIZE_MAX	(10 * 1024)
66
#define	UCODE_SIZE_MAX	(32 * 1024)
67
67
68
static int cpuctl_do_msr(int cpu, cpuctl_msr_args_t *data, u_long cmd,
68
static int cpuctl_do_msr(int cpu, cpuctl_msr_args_t *data, u_long cmd,
69
    struct thread *td);
69
    struct thread *td);
Lines 295-301 Link Here
295
static int
295
static int
296
update_intel(int cpu, cpuctl_update_args_t *args, struct thread *td)
296
update_intel(int cpu, cpuctl_update_args_t *args, struct thread *td)
297
{
297
{
298
	void *ptr = NULL;
298
	void *ptr, *ptr_to_free = NULL;
299
	uint64_t rev0, rev1;
299
	uint64_t rev0, rev1;
300
	uint32_t tmp[4];
300
	uint32_t tmp[4];
301
	int is_bound = 0;
301
	int is_bound = 0;
Lines 314-321 Link Here
314
	/*
314
	/*
315
	 * 16 byte alignment required.
315
	 * 16 byte alignment required.
316
	 */
316
	 */
317
	ptr = malloc(args->size + 16, M_CPUCTL, M_WAITOK);
317
	ptr_to_free = malloc(args->size + 16, M_CPUCTL, M_WAITOK);
318
	ptr = (void *)(16 + ((intptr_t)ptr & ~0xf));
318
	ptr = (void *)(16 + ((intptr_t)ptr_to_free & ~0xf));
319
	if (copyin(args->data, ptr, args->size) != 0) {
319
	if (copyin(args->data, ptr, args->size) != 0) {
320
		DPRINTF("[cpuctl,%d]: copyin %p->%p of %zd bytes failed",
320
		DPRINTF("[cpuctl,%d]: copyin %p->%p of %zd bytes failed",
321
		    __LINE__, args->data, ptr, args->size);
321
		    __LINE__, args->data, ptr, args->size);
Lines 346-353 Link Here
346
	else
346
	else
347
		ret = EEXIST;
347
		ret = EEXIST;
348
fail:
348
fail:
349
	if (ptr != NULL)
349
	if (ptr_to_free != NULL)
350
		contigfree(ptr, args->size, M_CPUCTL);
350
		free(ptr_to_free, M_CPUCTL);
351
	return (ret);
351
	return (ret);
352
}
352
}
353
353
Lines 409-415 Link Here
409
static int
409
static int
410
update_via(int cpu, cpuctl_update_args_t *args, struct thread *td)
410
update_via(int cpu, cpuctl_update_args_t *args, struct thread *td)
411
{
411
{
412
	void *ptr = NULL;
412
	void *ptr, *ptr_to_free = NULL;
413
	uint64_t rev0, rev1, res;
413
	uint64_t rev0, rev1, res;
414
	uint32_t tmp[4];
414
	uint32_t tmp[4];
415
	int is_bound = 0;
415
	int is_bound = 0;
Lines 428-435 Link Here
428
	/*
428
	/*
429
	 * 4 byte alignment required.
429
	 * 4 byte alignment required.
430
	 */
430
	 */
431
	ptr = malloc(args->size + 16, M_CPUCTL, M_WAITOK);
431
	ptr_to_free = malloc(args->size + 16, M_CPUCTL, M_WAITOK);
432
	ptr = (void *)(16 + ((intptr_t)ptr & ~0xf));
432
	ptr = (void *)(16 + ((intptr_t)ptr_to_free & ~0xf));
433
	if (copyin(args->data, ptr, args->size) != 0) {
433
	if (copyin(args->data, ptr, args->size) != 0) {
434
		DPRINTF("[cpuctl,%d]: copyin %p->%p of %zd bytes failed",
434
		DPRINTF("[cpuctl,%d]: copyin %p->%p of %zd bytes failed",
435
		    __LINE__, args->data, ptr, args->size);
435
		    __LINE__, args->data, ptr, args->size);
Lines 476-483 Link Here
476
	else
476
	else
477
		ret = 0;
477
		ret = 0;
478
fail:
478
fail:
479
	if (ptr != NULL)
479
	if (ptr_to_free != NULL)
480
		contigfree(ptr, args->size, M_CPUCTL);
480
		free(ptr_to_free, M_CPUCTL);
481
	return (ret);
481
	return (ret);
482
}
482
}

Return to bug 179523