• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _ASM_X86_MICROCODE_INTEL_H
2 #define _ASM_X86_MICROCODE_INTEL_H
3 
4 #include <asm/microcode.h>
5 
6 struct microcode_header_intel {
7 	unsigned int            hdrver;
8 	unsigned int            rev;
9 	unsigned int            date;
10 	unsigned int            sig;
11 	unsigned int            cksum;
12 	unsigned int            ldrver;
13 	unsigned int            pf;
14 	unsigned int            datasize;
15 	unsigned int            totalsize;
16 	unsigned int            reserved[3];
17 };
18 
19 struct microcode_intel {
20 	struct microcode_header_intel hdr;
21 	unsigned int            bits[0];
22 };
23 
24 /* microcode format is extended from prescott processors */
25 struct extended_signature {
26 	unsigned int            sig;
27 	unsigned int            pf;
28 	unsigned int            cksum;
29 };
30 
31 struct extended_sigtable {
32 	unsigned int            count;
33 	unsigned int            cksum;
34 	unsigned int            reserved[3];
35 	struct extended_signature sigs[0];
36 };
37 
38 #define DEFAULT_UCODE_DATASIZE	(2000)
39 #define MC_HEADER_SIZE		(sizeof(struct microcode_header_intel))
40 #define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE)
41 #define EXT_HEADER_SIZE		(sizeof(struct extended_sigtable))
42 #define EXT_SIGNATURE_SIZE	(sizeof(struct extended_signature))
43 #define DWSIZE			(sizeof(u32))
44 
45 #define get_totalsize(mc) \
46 	(((struct microcode_intel *)mc)->hdr.datasize ? \
47 	 ((struct microcode_intel *)mc)->hdr.totalsize : \
48 	 DEFAULT_UCODE_TOTALSIZE)
49 
50 #define get_datasize(mc) \
51 	(((struct microcode_intel *)mc)->hdr.datasize ? \
52 	 ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)
53 
54 #define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE)
55 
intel_get_microcode_revision(void)56 static inline u32 intel_get_microcode_revision(void)
57 {
58 	u32 rev, dummy;
59 
60 	native_wrmsrl(MSR_IA32_UCODE_REV, 0);
61 
62 	/* As documented in the SDM: Do a CPUID 1 here */
63 	native_cpuid_eax(1);
64 
65 	/* get the current revision from MSR 0x8B */
66 	native_rdmsr(MSR_IA32_UCODE_REV, dummy, rev);
67 
68 	return rev;
69 }
70 
71 extern int has_newer_microcode(void *mc, unsigned int csig, int cpf, int rev);
72 extern int microcode_sanity_check(void *mc, int print_err);
73 extern int find_matching_signature(void *mc, unsigned int csig, int cpf);
74 
75 #ifdef CONFIG_MICROCODE_INTEL
76 extern void __init load_ucode_intel_bsp(void);
77 extern void load_ucode_intel_ap(void);
78 extern void show_ucode_info_early(void);
79 extern int __init save_microcode_in_initrd_intel(void);
80 void reload_ucode_intel(void);
81 #else
load_ucode_intel_bsp(void)82 static inline __init void load_ucode_intel_bsp(void) {}
load_ucode_intel_ap(void)83 static inline void load_ucode_intel_ap(void) {}
show_ucode_info_early(void)84 static inline void show_ucode_info_early(void) {}
save_microcode_in_initrd_intel(void)85 static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; }
reload_ucode_intel(void)86 static inline void reload_ucode_intel(void) {}
87 #endif
88 
89 #ifdef CONFIG_HOTPLUG_CPU
90 extern int save_mc_for_early(u8 *mc);
91 #else
save_mc_for_early(u8 * mc)92 static inline int save_mc_for_early(u8 *mc) { return 0; }
93 #endif
94 #endif /* _ASM_X86_MICROCODE_INTEL_H */
95