Skip to content

Commit

Permalink
x86: structure declaration renaming
Browse files Browse the repository at this point in the history
Renamed common structures to vendor specific naming scheme
so other vendors will be able to use the same naming
convention.

Signed-off-by: Peter Oruba <peter.oruba@amd.com>
Cc: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Oruba authored and Ingo Molnar committed Jul 28, 2008
1 parent 3e135d8 commit d4ee366
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
46 changes: 24 additions & 22 deletions arch/x86/kernel/microcode_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,19 @@ MODULE_AUTHOR("Tigran Aivazian <tigran@aivazian.fsnet.co.uk>");
MODULE_LICENSE("GPL");

#define DEFAULT_UCODE_DATASIZE (2000) /* 2000 bytes */
#define MC_HEADER_SIZE (sizeof(struct microcode_header)) /* 48 bytes */
#define MC_HEADER_SIZE (sizeof(struct microcode_header_intel)) /* 48 bytes */
#define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE) /* 2048 bytes */
#define EXT_HEADER_SIZE (sizeof(struct extended_sigtable)) /* 20 bytes */
#define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature)) /* 12 bytes */
#define DWSIZE (sizeof(u32))
#define get_totalsize(mc) \
(((struct microcode *)mc)->hdr.totalsize ? \
((struct microcode *)mc)->hdr.totalsize : DEFAULT_UCODE_TOTALSIZE)
(((struct microcode_intel *)mc)->hdr.totalsize ? \
((struct microcode_intel *)mc)->hdr.totalsize : \
DEFAULT_UCODE_TOTALSIZE)

#define get_datasize(mc) \
(((struct microcode *)mc)->hdr.datasize ? \
((struct microcode *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)
(((struct microcode_intel *)mc)->hdr.datasize ? \
((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)

#define sigmatch(s1, s2, p1, p2) \
(((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0))))
Expand All @@ -134,7 +136,7 @@ void collect_cpu_info(int cpu_num)
/* We should bind the task to the CPU */
BUG_ON(raw_smp_processor_id() != cpu_num);
uci->pf = uci->rev = 0;
uci->mc = NULL;
uci->mc.mc_intel = NULL;
uci->valid = 1;

if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
Expand Down Expand Up @@ -163,7 +165,7 @@ void collect_cpu_info(int cpu_num)
}

static inline int microcode_update_match(int cpu_num,
struct microcode_header *mc_header, int sig, int pf)
struct microcode_header_intel *mc_header, int sig, int pf)
{
struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;

Expand All @@ -175,7 +177,7 @@ static inline int microcode_update_match(int cpu_num,

int microcode_sanity_check(void *mc)
{
struct microcode_header *mc_header = mc;
struct microcode_header_intel *mc_header = mc;
struct extended_sigtable *ext_header = NULL;
struct extended_signature *ext_sig;
unsigned long total_size, data_size, ext_table_size;
Expand Down Expand Up @@ -260,7 +262,7 @@ int microcode_sanity_check(void *mc)
int get_matching_microcode(void *mc, int cpu)
{
struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
struct microcode_header *mc_header = mc;
struct microcode_header_intel *mc_header = mc;
struct extended_sigtable *ext_header;
unsigned long total_size = get_totalsize(mc_header);
int ext_sigcount, i;
Expand Down Expand Up @@ -294,10 +296,10 @@ int get_matching_microcode(void *mc, int cpu)
}

/* free previous update file */
vfree(uci->mc);
vfree(uci->mc.mc_intel);

memcpy(new_mc, mc, total_size);
uci->mc = new_mc;
uci->mc.mc_intel = new_mc;
return 1;
}

Expand All @@ -311,16 +313,16 @@ void apply_microcode(int cpu)
/* We should bind the task to the CPU */
BUG_ON(cpu_num != cpu);

if (uci->mc == NULL)
if (uci->mc.mc_intel == NULL)
return;

/* serialize access to the physical write to MSR 0x79 */
spin_lock_irqsave(&microcode_update_lock, flags);

/* write microcode via MSR 0x79 */
wrmsr(MSR_IA32_UCODE_WRITE,
(unsigned long) uci->mc->bits,
(unsigned long) uci->mc->bits >> 16 >> 16);
(unsigned long) uci->mc.mc_intel->bits,
(unsigned long) uci->mc.mc_intel->bits >> 16 >> 16);
wrmsr(MSR_IA32_UCODE_REV, 0, 0);

/* see notes above for revision 1.07. Apparent chip bug */
Expand All @@ -330,14 +332,14 @@ void apply_microcode(int cpu)
rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);

spin_unlock_irqrestore(&microcode_update_lock, flags);
if (val[1] != uci->mc->hdr.rev) {
if (val[1] != uci->mc.mc_intel->hdr.rev) {
printk(KERN_ERR "microcode: CPU%d update from revision "
"0x%x to 0x%x failed\n", cpu_num, uci->rev, val[1]);
return;
}
printk(KERN_INFO "microcode: CPU%d updated from revision "
"0x%x to 0x%x, date = %08x \n",
cpu_num, uci->rev, val[1], uci->mc->hdr.date);
cpu_num, uci->rev, val[1], uci->mc.mc_intel->hdr.date);
uci->rev = val[1];
}

Expand All @@ -347,7 +349,7 @@ extern unsigned int user_buffer_size; /* it's size */

long get_next_ucode(void **mc, long offset)
{
struct microcode_header mc_header;
struct microcode_header_intel mc_header;
unsigned long total_size;

/* No more data */
Expand Down Expand Up @@ -378,13 +380,13 @@ long get_next_ucode(void **mc, long offset)
static long get_next_ucode_from_buffer(void **mc, const u8 *buf,
unsigned long size, long offset)
{
struct microcode_header *mc_header;
struct microcode_header_intel *mc_header;
unsigned long total_size;

/* No more data */
if (offset >= size)
return 0;
mc_header = (struct microcode_header *)(buf + offset);
mc_header = (struct microcode_header_intel *)(buf + offset);
total_size = get_totalsize(mc_header);

if (offset + total_size > size) {
Expand Down Expand Up @@ -463,7 +465,7 @@ int apply_microcode_check_cpu(int cpu)
int err = 0;

/* Check if the microcode is available */
if (!uci->mc)
if (!uci->mc.mc_intel)
return 0;

old = current->cpus_allowed;
Expand Down Expand Up @@ -508,7 +510,7 @@ void microcode_fini_cpu(int cpu)

mutex_lock(&microcode_mutex);
uci->valid = 0;
kfree(uci->mc);
uci->mc = NULL;
kfree(uci->mc.mc_intel);
uci->mc.mc_intel = NULL;
mutex_unlock(&microcode_mutex);
}
10 changes: 6 additions & 4 deletions include/asm-x86/microcode.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
struct microcode_header {
struct microcode_header_intel {
unsigned int hdrver;
unsigned int rev;
unsigned int date;
Expand All @@ -11,8 +11,8 @@ struct microcode_header {
unsigned int reserved[3];
};

struct microcode {
struct microcode_header hdr;
struct microcode_intel {
struct microcode_header_intel hdr;
unsigned int bits[0];
};

Expand All @@ -35,5 +35,7 @@ struct ucode_cpu_info {
unsigned int sig;
unsigned int pf;
unsigned int rev;
struct microcode *mc;
union {
struct microcode_intel *mc_intel;
} mc;
};

0 comments on commit d4ee366

Please sign in to comment.