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

+16 -24
+6
arch/x86/include/asm/microcode.h
··· 48 49 #ifdef CONFIG_MICROCODE_AMD 50 extern struct microcode_ops * __init init_amd_microcode(void); 51 #else 52 static inline struct microcode_ops * __init init_amd_microcode(void) 53 {
··· 48 49 #ifdef CONFIG_MICROCODE_AMD 50 extern struct microcode_ops * __init init_amd_microcode(void); 51 + 52 + static inline void get_ucode_data(void *to, const u8 *from, size_t n) 53 + { 54 + memcpy(to, from, n); 55 + } 56 + 57 #else 58 static inline struct microcode_ops * __init init_amd_microcode(void) 59 {
+10 -24
arch/x86/kernel/microcode_amd.c
··· 155 return 0; 156 } 157 158 - static int get_ucode_data(void *to, const u8 *from, size_t n) 159 - { 160 - memcpy(to, from, n); 161 - return 0; 162 - } 163 - 164 static void * 165 get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size) 166 { ··· 162 u8 section_hdr[UCODE_CONTAINER_SECTION_HDR]; 163 void *mc; 164 165 - if (get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR)) 166 - return NULL; 167 168 if (section_hdr[0] != UCODE_UCODE_TYPE) { 169 pr_err("error: invalid type field in container file section header\n"); ··· 176 return NULL; 177 } 178 179 - mc = vmalloc(UCODE_MAX_SIZE); 180 - if (mc) { 181 - memset(mc, 0, UCODE_MAX_SIZE); 182 - if (get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, 183 - total_size)) { 184 - vfree(mc); 185 - mc = NULL; 186 - } else 187 - *mc_size = total_size + UCODE_CONTAINER_SECTION_HDR; 188 - } 189 return mc; 190 } 191 ··· 192 unsigned int *buf_pos = (unsigned int *)container_hdr; 193 unsigned long size; 194 195 - if (get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE)) 196 - return 0; 197 198 size = buf_pos[2]; 199 ··· 208 } 209 210 buf += UCODE_CONTAINER_HEADER_SIZE; 211 - if (get_ucode_data(equiv_cpu_table, buf, size)) { 212 - vfree(equiv_cpu_table); 213 - return 0; 214 - } 215 216 return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */ 217 }
··· 155 return 0; 156 } 157 158 static void * 159 get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size) 160 { ··· 168 u8 section_hdr[UCODE_CONTAINER_SECTION_HDR]; 169 void *mc; 170 171 + get_ucode_data(section_hdr, buf, UCODE_CONTAINER_SECTION_HDR); 172 173 if (section_hdr[0] != UCODE_UCODE_TYPE) { 174 pr_err("error: invalid type field in container file section header\n"); ··· 183 return NULL; 184 } 185 186 + mc = vzalloc(UCODE_MAX_SIZE); 187 + if (!mc) 188 + return NULL; 189 + 190 + get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR, total_size); 191 + *mc_size = total_size + UCODE_CONTAINER_SECTION_HDR; 192 + 193 return mc; 194 } 195 ··· 202 unsigned int *buf_pos = (unsigned int *)container_hdr; 203 unsigned long size; 204 205 + get_ucode_data(&container_hdr, buf, UCODE_CONTAINER_HEADER_SIZE); 206 207 size = buf_pos[2]; 208 ··· 219 } 220 221 buf += UCODE_CONTAINER_HEADER_SIZE; 222 + get_ucode_data(equiv_cpu_table, buf, size); 223 224 return size + UCODE_CONTAINER_HEADER_SIZE; /* add header length */ 225 }