On 08/09/2017 00:09, Dexuan Cui wrote:
> Hi jkim,
> The patch breaks FreeBSD VM on Hyper-V.
> 
> identify_hypervisor() is moved from identify_cpu() to an earlier place, but 
> the global 
> variable cpu_feature2 used by the function is still initialized in 
> identify_cpu().
> 
> I'm not sure about the background of your patch. Can you please have a look?

Can you please test the attached patch?

Jung-uk Kim
Index: sys/amd64/amd64/machdep.c
===================================================================
--- sys/amd64/amd64/machdep.c	(revision 322319)
+++ sys/amd64/amd64/machdep.c	(working copy)
@@ -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();
 
Index: sys/i386/include/md_var.h
===================================================================
--- sys/i386/include/md_var.h	(revision 322319)
+++ sys/i386/include/md_var.h	(working copy)
@@ -59,7 +59,6 @@ void	doreti_popl_es(void) __asm(__STRING(doreti_po
 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);
Index: sys/x86/include/x86_var.h
===================================================================
--- sys/x86/include/x86_var.h	(revision 322319)
+++ sys/x86/include/x86_var.h	(working copy)
@@ -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);
Index: sys/x86/x86/identcpu.c
===================================================================
--- sys/x86/x86/identcpu.c	(revision 322319)
+++ sys/x86/x86/identcpu.c	(working copy)
@@ -1372,23 +1372,12 @@ fix_cpuid(void)
 	return (false);
 }
 
-/*
- * Final stage of CPU identification.
- */
-#ifdef __i386__
+#ifdef __amd64__
 void
-finishidentcpu(void)
-#else
-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,8 +1390,20 @@ 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();
 
 	if (fix_cpuid()) {

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to