Split identify_cpu() into two functions for amd64 as we do for i386. This

reduces diff between amd64 and i386.  Also, it fixes a regression introduced
in r322076, i.e., identify_hypervisor() failed to identify some hypervisors.
This function assumes cpu_feature2 is already initialized.

Reported by:	dexuan
Tested by:	dexuan
This commit is contained in:
jkim 2017-08-09 18:09:09 +00:00
parent db45713071
commit d871b34dbc
4 changed files with 17 additions and 15 deletions

View File

@ -1537,6 +1537,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
kmdp = init_ops.parse_preload_data(modulep);
identify_cpu();
identify_hypervisor();
/* Init basic tunables, hz etc */
@ -1643,7 +1644,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
!= NULL)
vty_set_preferred(VTY_VT);
identify_cpu(); /* Final stage of CPU initialization */
finishidentcpu(); /* Final stage of CPU initialization */
initializecpu(); /* Initialize CPU registers */
initializecpucache();

View File

@ -59,7 +59,6 @@ void doreti_popl_es(void) __asm(__STRING(doreti_popl_es));
void doreti_popl_es_fault(void) __asm(__STRING(doreti_popl_es_fault));
void doreti_popl_fs(void) __asm(__STRING(doreti_popl_fs));
void doreti_popl_fs_fault(void) __asm(__STRING(doreti_popl_fs_fault));
void finishidentcpu(void);
void fill_based_sd(struct segment_descriptor *sdp, uint32_t base);
void i686_pagezero(void *addr);
void sse2_pagezero(void *addr);

View File

@ -115,6 +115,7 @@ void cpu_probe_amdc1e(void);
void cpu_setregs(void);
void dump_add_page(vm_paddr_t);
void dump_drop_page(vm_paddr_t);
void finishidentcpu(void);
void identify_cpu(void);
void identify_hypervisor(void);
void initializecpu(void);

View File

@ -1372,23 +1372,12 @@ fix_cpuid(void)
return (false);
}
/*
* Final stage of CPU identification.
*/
#ifdef __i386__
void
finishidentcpu(void)
#else
#ifdef __amd64__
void
identify_cpu(void)
#endif
{
u_int regs[4], cpu_stdext_disable;
#ifdef __i386__
u_char ccr3;
#endif
u_int regs[4];
#ifdef __amd64__
do_cpuid(0, regs);
cpu_high = regs[0];
((u_int *)&cpu_vendor)[0] = regs[1];
@ -1401,6 +1390,18 @@ identify_cpu(void)
cpu_procinfo = regs[1];
cpu_feature = regs[3];
cpu_feature2 = regs[2];
}
#endif
/*
* Final stage of CPU identification.
*/
void
finishidentcpu(void)
{
u_int regs[4], cpu_stdext_disable;
#ifdef __i386__
u_char ccr3;
#endif
cpu_vendor_id = find_cpu_vendor_id();