Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f46b120 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'x86-microcode-for-linus' of...

Merge branch 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86, microcode, AMD: Cleanup code a bit
  x86, microcode, AMD: Replace vmalloc+memset with vzalloc
parents 4e1db5e5 c7657ac0
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -48,6 +48,12 @@ static inline struct microcode_ops * __init init_intel_microcode(void)


#ifdef CONFIG_MICROCODE_AMD
#ifdef CONFIG_MICROCODE_AMD
extern struct microcode_ops * __init init_amd_microcode(void);
extern struct microcode_ops * __init init_amd_microcode(void);

static inline void get_ucode_data(void *to, const u8 *from, size_t n)
{
	memcpy(to, from, n);
}

#else
#else
static inline struct microcode_ops * __init init_amd_microcode(void)
static inline struct microcode_ops * __init init_amd_microcode(void)
{
{
+10 −24
Original line number Original line Diff line number Diff line
@@ -155,12 +155,6 @@ static int apply_microcode_amd(int cpu)
	return 0;
	return 0;
}
}


static int get_ucode_data(void *to, const u8 *from, size_t n)
{
	memcpy(to, from, n);
	return 0;
}

static void *
static void *
get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size)
get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size)
{
{
@@ -168,8 +162,7 @@ get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size)
	u8 section_hdr[UCODE_CONTAINER_SECTION_HDR];
	u8 section_hdr[UCODE_CONTAINER_SECTION_HDR];
	void *mc;
	void *mc;


	if (get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR))
	get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR);
		return NULL;


	if (section_hdr[0] != UCODE_UCODE_TYPE) {
	if (section_hdr[0] != UCODE_UCODE_TYPE) {
		pr_err("error: invalid type field in container file section header\n");
		pr_err("error: invalid type field in container file section header\n");
@@ -183,16 +176,13 @@ get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size)
		return NULL;
		return NULL;
	}
	}


	mc = vmalloc(UCODE_MAX_SIZE);
	mc = vzalloc(UCODE_MAX_SIZE);
	if (mc) {
	if (!mc)
		memset(mc, 0, UCODE_MAX_SIZE);
		return NULL;
		if (get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR,

				   total_size)) {
	get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, total_size);
			vfree(mc);
			mc = NULL;
		} else
	*mc_size = total_size + UCODE_CONTAINER_SECTION_HDR;
	*mc_size = total_size + UCODE_CONTAINER_SECTION_HDR;
	}

	return mc;
	return mc;
}
}


@@ -202,8 +192,7 @@ static int install_equiv_cpu_table(const u8 *buf)
	unsigned int *buf_pos = (unsigned int *)container_hdr;
	unsigned int *buf_pos = (unsigned int *)container_hdr;
	unsigned long size;
	unsigned long size;


	if (get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE))
	get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE);
		return 0;


	size = buf_pos[2];
	size = buf_pos[2];


@@ -219,10 +208,7 @@ static int install_equiv_cpu_table(const u8 *buf)
	}
	}


	buf += UCODE_CONTAINER_HEADER_SIZE;
	buf += UCODE_CONTAINER_HEADER_SIZE;
	if (get_ucode_data(equiv_cpu_table, buf, size)) {
	get_ucode_data(equiv_cpu_table, buf, size);
		vfree(equiv_cpu_table);
		return 0;
	}


	return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */
	return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */
}
}