Remove VM_GUEST_XEN and define only Xen subtypes: VM_GUEST_XENPV VM_GUEST_XENPVH VM_GUEST_XENHVM VM_GUEST_XENPVHVM Set vm_guest in the start routine, if it is hypervisor-specific (e.g Xen PV). If vm_guest was not set early and we detect Xen in identify_hypervisor(), assume it is VM_GUEST_XENHVM. Refine to VM_GUEST_PVXENHVM in hypervisor_match().diff -r1.82 -r1.82.4.1 src/sys/arch/amd64/amd64/genassym.cf
(bouyer)
--- src/sys/arch/amd64/amd64/genassym.cf 2020/02/17 09:09:48 1.82
+++ src/sys/arch/amd64/amd64/genassym.cf 2020/04/08 17:59:16 1.82.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: genassym.cf,v 1.82 2020/02/17 09:09:48 skrll Exp $ | 1 | # $NetBSD: genassym.cf,v 1.82.4.1 2020/04/08 17:59:16 bouyer Exp $ | |
2 | 2 | |||
3 | # | 3 | # | |
4 | # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. | 4 | # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. | |
5 | # All rights reserved. | 5 | # All rights reserved. | |
6 | # | 6 | # | |
7 | # This code is derived from software contributed to The NetBSD Foundation | 7 | # This code is derived from software contributed to The NetBSD Foundation | |
8 | # by Charles M. Hannum, and by Andrew Doran. | 8 | # by Charles M. Hannum, and by Andrew Doran. | |
9 | # | 9 | # | |
10 | # Redistribution and use in source and binary forms, with or without | 10 | # Redistribution and use in source and binary forms, with or without | |
11 | # modification, are permitted provided that the following conditions | 11 | # modification, are permitted provided that the following conditions | |
12 | # are met: | 12 | # are met: | |
13 | # 1. Redistributions of source code must retain the above copyright | 13 | # 1. Redistributions of source code must retain the above copyright | |
14 | # notice, this list of conditions and the following disclaimer. | 14 | # notice, this list of conditions and the following disclaimer. | |
@@ -350,26 +350,28 @@ define RW_READ_INCR RW_READ_INCR | @@ -350,26 +350,28 @@ define RW_READ_INCR RW_READ_INCR | |||
350 | define RW_HAS_WAITERS RW_HAS_WAITERS | 350 | define RW_HAS_WAITERS RW_HAS_WAITERS | |
351 | define RW_THREAD RW_THREAD | 351 | define RW_THREAD RW_THREAD | |
352 | define RW_READER RW_READER | 352 | define RW_READER RW_READER | |
353 | define RW_WRITER RW_WRITER | 353 | define RW_WRITER RW_WRITER | |
354 | 354 | |||
355 | define EV_COUNT offsetof(struct evcnt, ev_count) | 355 | define EV_COUNT offsetof(struct evcnt, ev_count) | |
356 | 356 | |||
357 | define OPTERON_MSR_PASSCODE OPTERON_MSR_PASSCODE | 357 | define OPTERON_MSR_PASSCODE OPTERON_MSR_PASSCODE | |
358 | 358 | |||
359 | define X86_BUS_SPACE_IO X86_BUS_SPACE_IO | 359 | define X86_BUS_SPACE_IO X86_BUS_SPACE_IO | |
360 | 360 | |||
361 | define BST_TYPE offsetof(struct bus_space_tag, bst_type) | 361 | define BST_TYPE offsetof(struct bus_space_tag, bst_type) | |
362 | 362 | |||
363 | define VM_GUEST_XENPV VM_GUEST_XENPV | |||
364 | ||||
363 | ifdef XEN | 365 | ifdef XEN | |
364 | define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu) | 366 | define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu) | |
365 | define CPU_INFO_XPENDING offsetof(struct cpu_info, ci_xpending) | 367 | define CPU_INFO_XPENDING offsetof(struct cpu_info, ci_xpending) | |
366 | define CPU_INFO_XMASK offsetof(struct cpu_info, ci_xmask) | 368 | define CPU_INFO_XMASK offsetof(struct cpu_info, ci_xmask) | |
367 | define CPU_INFO_XUNMASK offsetof(struct cpu_info, ci_xunmask) | 369 | define CPU_INFO_XUNMASK offsetof(struct cpu_info, ci_xunmask) | |
368 | define CPU_INFO_XSOURCES offsetof(struct cpu_info, ci_xsources) | 370 | define CPU_INFO_XSOURCES offsetof(struct cpu_info, ci_xsources) | |
369 | define EVTCHN_UPCALL_MASK offsetof(struct vcpu_info, evtchn_upcall_mask) | 371 | define EVTCHN_UPCALL_MASK offsetof(struct vcpu_info, evtchn_upcall_mask) | |
370 | ifdef XENPV | 372 | ifdef XENPV | |
371 | define XEN_PT_BASE offsetof(struct start_info, pt_base) | 373 | define XEN_PT_BASE offsetof(struct start_info, pt_base) | |
372 | define XEN_NR_PT_FRAMES offsetof(struct start_info, nr_pt_frames) | 374 | define XEN_NR_PT_FRAMES offsetof(struct start_info, nr_pt_frames) | |
373 | define __HYPERVISOR_iret __HYPERVISOR_iret | 375 | define __HYPERVISOR_iret __HYPERVISOR_iret | |
374 | endif /* XENPV */ | 376 | endif /* XENPV */ | |
375 | endif | 377 | endif |
--- src/sys/arch/amd64/amd64/locore.S 2020/01/15 18:47:23 1.200
+++ src/sys/arch/amd64/amd64/locore.S 2020/04/08 17:59:16 1.200.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: locore.S,v 1.200 2020/01/15 18:47:23 ad Exp $ */ | 1 | /* $NetBSD: locore.S,v 1.200.4.1 2020/04/08 17:59:16 bouyer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright-o-rama! | 4 | * Copyright-o-rama! | |
5 | */ | 5 | */ | |
6 | 6 | |||
7 | /* | 7 | /* | |
8 | * Copyright (c) 1998, 2000, 2007, 2008, 2016 The NetBSD Foundation, Inc. | 8 | * Copyright (c) 1998, 2000, 2007, 2008, 2016 The NetBSD Foundation, Inc. | |
9 | * All rights reserved. | 9 | * All rights reserved. | |
10 | * | 10 | * | |
11 | * This code is derived from software contributed to The NetBSD Foundation | 11 | * This code is derived from software contributed to The NetBSD Foundation | |
12 | * by Charles M. Hannum and by Maxime Villard. | 12 | * by Charles M. Hannum and by Maxime Villard. | |
13 | * | 13 | * | |
14 | * Redistribution and use in source and binary forms, with or without | 14 | * Redistribution and use in source and binary forms, with or without | |
@@ -932,26 +932,28 @@ longmode_hi: | @@ -932,26 +932,28 @@ longmode_hi: | |||
932 | /* | 932 | /* | |
933 | * We want our own page tables, and will rebuild them. We will reclaim | 933 | * We want our own page tables, and will rebuild them. We will reclaim | |
934 | * the Xen space later, INCLUDING the stack. So we need to switch to a | 934 | * the Xen space later, INCLUDING the stack. So we need to switch to a | |
935 | * temporary one now. | 935 | * temporary one now. | |
936 | */ | 936 | */ | |
937 | movq $tmpstk,%rax | 937 | movq $tmpstk,%rax | |
938 | subq $8,%rax | 938 | subq $8,%rax | |
939 | movq %rax,%rsp | 939 | movq %rax,%rsp | |
940 | 940 | |||
941 | xorl %eax,%eax | 941 | xorl %eax,%eax | |
942 | cpuid | 942 | cpuid | |
943 | movl %eax,_C_LABEL(cpuid_level) | 943 | movl %eax,_C_LABEL(cpuid_level) | |
944 | 944 | |||
945 | movl $VM_GUEST_XENPV, _C_LABEL(vm_guest) | |||
946 | ||||
945 | movq $cpu_info_primary,%rdi | 947 | movq $cpu_info_primary,%rdi | |
946 | movq %rdi,CPU_INFO_SELF(%rdi) /* ci->ci_self = ci */ | 948 | movq %rdi,CPU_INFO_SELF(%rdi) /* ci->ci_self = ci */ | |
947 | movq $1,%rsi | 949 | movq $1,%rsi | |
948 | call cpu_init_msrs /* cpu_init_msrs(ci, true); */ | 950 | call cpu_init_msrs /* cpu_init_msrs(ci, true); */ | |
949 | 951 | |||
950 | call xen_locore | 952 | call xen_locore | |
951 | 953 | |||
952 | /* | 954 | /* | |
953 | * The first VA available is returned by xen_locore in %rax. We | 955 | * The first VA available is returned by xen_locore in %rax. We | |
954 | * use it as the UAREA, and set up the stack here. | 956 | * use it as the UAREA, and set up the stack here. | |
955 | */ | 957 | */ | |
956 | movq %rax,%rsi | 958 | movq %rax,%rsi | |
957 | movq %rsi,_C_LABEL(lwp0uarea)(%rip) | 959 | movq %rsi,_C_LABEL(lwp0uarea)(%rip) |
--- src/sys/arch/i386/i386/genassym.cf 2020/02/17 09:09:48 1.119
+++ src/sys/arch/i386/i386/genassym.cf 2020/04/08 17:59:16 1.119.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: genassym.cf,v 1.119 2020/02/17 09:09:48 skrll Exp $ | 1 | # $NetBSD: genassym.cf,v 1.119.4.1 2020/04/08 17:59:16 bouyer Exp $ | |
2 | 2 | |||
3 | # | 3 | # | |
4 | # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. | 4 | # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. | |
5 | # All rights reserved. | 5 | # All rights reserved. | |
6 | # | 6 | # | |
7 | # This code is derived from software contributed to The NetBSD Foundation | 7 | # This code is derived from software contributed to The NetBSD Foundation | |
8 | # by Charles M. Hannum, and by Andrew Doran. | 8 | # by Charles M. Hannum, and by Andrew Doran. | |
9 | # | 9 | # | |
10 | # Redistribution and use in source and binary forms, with or without | 10 | # Redistribution and use in source and binary forms, with or without | |
11 | # modification, are permitted provided that the following conditions | 11 | # modification, are permitted provided that the following conditions | |
12 | # are met: | 12 | # are met: | |
13 | # 1. Redistributions of source code must retain the above copyright | 13 | # 1. Redistributions of source code must retain the above copyright | |
14 | # notice, this list of conditions and the following disclaimer. | 14 | # notice, this list of conditions and the following disclaimer. | |
@@ -364,26 +364,28 @@ define EV_COUNT offsetof(struct evcnt, | @@ -364,26 +364,28 @@ define EV_COUNT offsetof(struct evcnt, | |||
364 | 364 | |||
365 | define OPTERON_MSR_PASSCODE OPTERON_MSR_PASSCODE | 365 | define OPTERON_MSR_PASSCODE OPTERON_MSR_PASSCODE | |
366 | 366 | |||
367 | define X86_BUS_SPACE_IO X86_BUS_SPACE_IO | 367 | define X86_BUS_SPACE_IO X86_BUS_SPACE_IO | |
368 | 368 | |||
369 | define BST_TYPE offsetof(struct bus_space_tag, bst_type) | 369 | define BST_TYPE offsetof(struct bus_space_tag, bst_type) | |
370 | 370 | |||
371 | define L1_SHIFT L1_SHIFT | 371 | define L1_SHIFT L1_SHIFT | |
372 | define L2_SHIFT L2_SHIFT | 372 | define L2_SHIFT L2_SHIFT | |
373 | define L2_FRAME L2_FRAME | 373 | define L2_FRAME L2_FRAME | |
374 | define PGOFSET PGOFSET | 374 | define PGOFSET PGOFSET | |
375 | define PGSHIFT PGSHIFT | 375 | define PGSHIFT PGSHIFT | |
376 | 376 | |||
377 | define VM_GUEST_XENPV VM_GUEST_XENPV | |||
378 | ||||
377 | ifdef XEN | 379 | ifdef XEN | |
378 | define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu) | 380 | define CPU_INFO_VCPU offsetof(struct cpu_info, ci_vcpu) | |
379 | define CPU_INFO_XPENDING offsetof(struct cpu_info, ci_xpending) | 381 | define CPU_INFO_XPENDING offsetof(struct cpu_info, ci_xpending) | |
380 | define CPU_INFO_XMASK offsetof(struct cpu_info, ci_xmask) | 382 | define CPU_INFO_XMASK offsetof(struct cpu_info, ci_xmask) | |
381 | define CPU_INFO_XUNMASK offsetof(struct cpu_info, ci_xunmask) | 383 | define CPU_INFO_XUNMASK offsetof(struct cpu_info, ci_xunmask) | |
382 | define CPU_INFO_XSOURCES offsetof(struct cpu_info, ci_xsources) | 384 | define CPU_INFO_XSOURCES offsetof(struct cpu_info, ci_xsources) | |
383 | define START_INFO_SHARED_INFO offsetof(struct start_info, shared_info) | 385 | define START_INFO_SHARED_INFO offsetof(struct start_info, shared_info) | |
384 | define START_INFO_FLAGS offsetof(struct start_info, flags) | 386 | define START_INFO_FLAGS offsetof(struct start_info, flags) | |
385 | define START_INFO_CONSOLE_MFN offsetof(struct start_info, console.domU.mfn) | 387 | define START_INFO_CONSOLE_MFN offsetof(struct start_info, console.domU.mfn) | |
386 | define START_INFO_STORE_MFN offsetof(struct start_info, store_mfn) | 388 | define START_INFO_STORE_MFN offsetof(struct start_info, store_mfn) | |
387 | define SIF_INITDOMAIN SIF_INITDOMAIN | 389 | define SIF_INITDOMAIN SIF_INITDOMAIN | |
388 | define EVTCHN_UPCALL_PENDING offsetof(struct vcpu_info, evtchn_upcall_pending) | 390 | define EVTCHN_UPCALL_PENDING offsetof(struct vcpu_info, evtchn_upcall_pending) | |
389 | define EVTCHN_UPCALL_MASK offsetof(struct vcpu_info, evtchn_upcall_mask) | 391 | define EVTCHN_UPCALL_MASK offsetof(struct vcpu_info, evtchn_upcall_mask) |
--- src/sys/arch/i386/i386/locore.S 2020/03/27 21:05:03 1.179
+++ src/sys/arch/i386/i386/locore.S 2020/04/08 17:59:16 1.179.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: locore.S,v 1.179 2020/03/27 21:05:03 ad Exp $ */ | 1 | /* $NetBSD: locore.S,v 1.179.2.1 2020/04/08 17:59:16 bouyer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright-o-rama! | 4 | * Copyright-o-rama! | |
5 | */ | 5 | */ | |
6 | 6 | |||
7 | /* | 7 | /* | |
8 | * Copyright (c) 1998, 2000, 2004, 2006, 2007, 2009, 2016 | 8 | * Copyright (c) 1998, 2000, 2004, 2006, 2007, 2009, 2016 | |
9 | * The NetBSD Foundation, Inc., All rights reserved. | 9 | * The NetBSD Foundation, Inc., All rights reserved. | |
10 | * | 10 | * | |
11 | * This code is derived from software contributed to The NetBSD Foundation | 11 | * This code is derived from software contributed to The NetBSD Foundation | |
12 | * by Charles M. Hannum, by Andrew Doran and by Maxime Villard. | 12 | * by Charles M. Hannum, by Andrew Doran and by Maxime Villard. | |
13 | * | 13 | * | |
14 | * Redistribution and use in source and binary forms, with or without | 14 | * Redistribution and use in source and binary forms, with or without | |
@@ -118,27 +118,27 @@ | @@ -118,27 +118,27 @@ | |||
118 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 118 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
119 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 119 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
120 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 120 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
121 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 121 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
122 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 122 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
123 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 123 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
124 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 124 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
125 | * SUCH DAMAGE. | 125 | * SUCH DAMAGE. | |
126 | * | 126 | * | |
127 | * @(#)locore.s 7.3 (Berkeley) 5/13/91 | 127 | * @(#)locore.s 7.3 (Berkeley) 5/13/91 | |
128 | */ | 128 | */ | |
129 | 129 | |||
130 | #include <machine/asm.h> | 130 | #include <machine/asm.h> | |
131 | __KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.179 2020/03/27 21:05:03 ad Exp $"); | 131 | __KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.179.2.1 2020/04/08 17:59:16 bouyer Exp $"); | |
132 | 132 | |||
133 | #include "opt_copy_symtab.h" | 133 | #include "opt_copy_symtab.h" | |
134 | #include "opt_ddb.h" | 134 | #include "opt_ddb.h" | |
135 | #include "opt_modular.h" | 135 | #include "opt_modular.h" | |
136 | #include "opt_multiboot.h" | 136 | #include "opt_multiboot.h" | |
137 | #include "opt_realmem.h" | 137 | #include "opt_realmem.h" | |
138 | #include "opt_xen.h" | 138 | #include "opt_xen.h" | |
139 | 139 | |||
140 | #include "assym.h" | 140 | #include "assym.h" | |
141 | #include "lapic.h" | 141 | #include "lapic.h" | |
142 | #include "ioapic.h" | 142 | #include "ioapic.h" | |
143 | #include "ksyms.h" | 143 | #include "ksyms.h" | |
144 | 144 | |||
@@ -1105,26 +1105,28 @@ begin: | @@ -1105,26 +1105,28 @@ begin: | |||
1105 | movl $128,%ecx | 1105 | movl $128,%ecx | |
1106 | rep | 1106 | rep | |
1107 | movsl | 1107 | movsl | |
1108 | 1108 | |||
1109 | /* Clear segment registers. */ | 1109 | /* Clear segment registers. */ | |
1110 | xorl %eax,%eax | 1110 | xorl %eax,%eax | |
1111 | movw %ax,%fs | 1111 | movw %ax,%fs | |
1112 | movw %ax,%gs | 1112 | movw %ax,%gs | |
1113 | 1113 | |||
1114 | xorl %eax,%eax | 1114 | xorl %eax,%eax | |
1115 | cpuid | 1115 | cpuid | |
1116 | movl %eax,RELOC(cpuid_level) | 1116 | movl %eax,RELOC(cpuid_level) | |
1117 | 1117 | |||
1118 | movl $VM_GUEST_XENPV, RELOC(vm_guest) | |||
1119 | ||||
1118 | /* | 1120 | /* | |
1119 | * Use a temporary GDT page. We'll re-add it to uvm(9) once we're done | 1121 | * Use a temporary GDT page. We'll re-add it to uvm(9) once we're done | |
1120 | * using it. | 1122 | * using it. | |
1121 | */ | 1123 | */ | |
1122 | movl $RELOC(tmpgdt),%eax | 1124 | movl $RELOC(tmpgdt),%eax | |
1123 | pushl %eax /* start of temporary gdt */ | 1125 | pushl %eax /* start of temporary gdt */ | |
1124 | call _C_LABEL(initgdt) | 1126 | call _C_LABEL(initgdt) | |
1125 | addl $4,%esp | 1127 | addl $4,%esp | |
1126 | 1128 | |||
1127 | call xen_locore | 1129 | call xen_locore | |
1128 | 1130 | |||
1129 | /* | 1131 | /* | |
1130 | * The first VA available is returned by xen_locore in %eax. We | 1132 | * The first VA available is returned by xen_locore in %eax. We |
--- src/sys/arch/x86/include/cpu.h 2020/01/15 13:22:03 1.117
+++ src/sys/arch/x86/include/cpu.h 2020/04/08 17:59:16 1.117.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpu.h,v 1.117 2020/01/15 13:22:03 ad Exp $ */ | 1 | /* $NetBSD: cpu.h,v 1.117.4.1 2020/04/08 17:59:16 bouyer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1990 The Regents of the University of California. | 4 | * Copyright (c) 1990 The Regents of the University of California. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * William Jolitz. | 8 | * William Jolitz. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -486,27 +486,29 @@ void cpu_reset(void); | @@ -486,27 +486,29 @@ void cpu_reset(void); | |||
486 | /* longrun.c */ | 486 | /* longrun.c */ | |
487 | u_int tmx86_get_longrun_mode(void); | 487 | u_int tmx86_get_longrun_mode(void); | |
488 | void tmx86_get_longrun_status(u_int *, u_int *, u_int *); | 488 | void tmx86_get_longrun_status(u_int *, u_int *, u_int *); | |
489 | void tmx86_init_longrun(void); | 489 | void tmx86_init_longrun(void); | |
490 | 490 | |||
491 | /* identcpu.c */ | 491 | /* identcpu.c */ | |
492 | void cpu_probe(struct cpu_info *); | 492 | void cpu_probe(struct cpu_info *); | |
493 | void cpu_identify(struct cpu_info *); | 493 | void cpu_identify(struct cpu_info *); | |
494 | void identify_hypervisor(void); | 494 | void identify_hypervisor(void); | |
495 | 495 | |||
496 | typedef enum vm_guest { | 496 | typedef enum vm_guest { | |
497 | VM_GUEST_NO = 0, | 497 | VM_GUEST_NO = 0, | |
498 | VM_GUEST_VM, | 498 | VM_GUEST_VM, | |
499 | VM_GUEST_XEN, | 499 | VM_GUEST_XENPV, | |
500 | VM_GUEST_XENPVH, | |||
501 | VM_GUEST_XENHVM, | |||
500 | VM_GUEST_XENPVHVM, | 502 | VM_GUEST_XENPVHVM, | |
501 | VM_GUEST_HV, | 503 | VM_GUEST_HV, | |
502 | VM_GUEST_VMWARE, | 504 | VM_GUEST_VMWARE, | |
503 | VM_GUEST_KVM, | 505 | VM_GUEST_KVM, | |
504 | VM_LAST | 506 | VM_LAST | |
505 | } vm_guest_t; | 507 | } vm_guest_t; | |
506 | extern vm_guest_t vm_guest; | 508 | extern vm_guest_t vm_guest; | |
507 | 509 | |||
508 | /* cpu_topology.c */ | 510 | /* cpu_topology.c */ | |
509 | void x86_cpu_topology(struct cpu_info *); | 511 | void x86_cpu_topology(struct cpu_info *); | |
510 | 512 | |||
511 | /* locore.s */ | 513 | /* locore.s */ | |
512 | struct region_descriptor; | 514 | struct region_descriptor; |
--- src/sys/arch/x86/x86/identcpu.c 2020/04/04 14:49:35 1.102
+++ src/sys/arch/x86/x86/identcpu.c 2020/04/08 17:59:16 1.102.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: identcpu.c,v 1.102 2020/04/04 14:49:35 ad Exp $ */ | 1 | /* $NetBSD: identcpu.c,v 1.102.2.1 2020/04/08 17:59:16 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Frank van der Linden, and by Jason R. Thorpe. | 8 | * by Frank van der Linden, and by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.102 2020/04/04 14:49:35 ad Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.102.2.1 2020/04/08 17:59:16 bouyer Exp $"); | |
34 | 34 | |||
35 | #include "opt_xen.h" | 35 | #include "opt_xen.h" | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | #include <sys/cpu.h> | 40 | #include <sys/cpu.h> | |
41 | 41 | |||
42 | #include <uvm/uvm_extern.h> | 42 | #include <uvm/uvm_extern.h> | |
43 | 43 | |||
44 | #include <machine/specialreg.h> | 44 | #include <machine/specialreg.h> | |
45 | #include <machine/pio.h> | 45 | #include <machine/pio.h> | |
46 | #include <machine/cpu.h> | 46 | #include <machine/cpu.h> | |
@@ -1119,27 +1119,27 @@ identify_hypervisor(void) | @@ -1119,27 +1119,27 @@ identify_hypervisor(void) | |||
1119 | memcpy(&hv_vendor[0], ®s[1], sizeof(*regs)); | 1119 | memcpy(&hv_vendor[0], ®s[1], sizeof(*regs)); | |
1120 | memcpy(&hv_vendor[4], ®s[2], sizeof(*regs)); | 1120 | memcpy(&hv_vendor[4], ®s[2], sizeof(*regs)); | |
1121 | memcpy(&hv_vendor[8], ®s[3], sizeof(*regs)); | 1121 | memcpy(&hv_vendor[8], ®s[3], sizeof(*regs)); | |
1122 | if (memcmp(hv_vendor, "VMwareVMware", 12) == 0) | 1122 | if (memcmp(hv_vendor, "VMwareVMware", 12) == 0) | |
1123 | vm_guest = VM_GUEST_VMWARE; | 1123 | vm_guest = VM_GUEST_VMWARE; | |
1124 | else if (memcmp(hv_vendor, "Microsoft Hv", 12) == 0) { | 1124 | else if (memcmp(hv_vendor, "Microsoft Hv", 12) == 0) { | |
1125 | vm_guest = VM_GUEST_HV; | 1125 | vm_guest = VM_GUEST_HV; | |
1126 | #if NHYPERV > 0 | 1126 | #if NHYPERV > 0 | |
1127 | hyperv_early_init(); | 1127 | hyperv_early_init(); | |
1128 | #endif | 1128 | #endif | |
1129 | } else if (memcmp(hv_vendor, "KVMKVMKVM\0\0\0", 12) == 0) | 1129 | } else if (memcmp(hv_vendor, "KVMKVMKVM\0\0\0", 12) == 0) | |
1130 | vm_guest = VM_GUEST_KVM; | 1130 | vm_guest = VM_GUEST_KVM; | |
1131 | else if (memcmp(hv_vendor, "XenVMMXenVMM", 12) == 0) | 1131 | else if (memcmp(hv_vendor, "XenVMMXenVMM", 12) == 0) | |
1132 | vm_guest = VM_GUEST_XEN; | 1132 | vm_guest = VM_GUEST_XENHVM; | |
1133 | /* FreeBSD bhyve: "bhyve bhyve " */ | 1133 | /* FreeBSD bhyve: "bhyve bhyve " */ | |
1134 | /* OpenBSD vmm: "OpenBSDVMM58" */ | 1134 | /* OpenBSD vmm: "OpenBSDVMM58" */ | |
1135 | /* NetBSD nvmm: "___ NVMM ___" */ | 1135 | /* NetBSD nvmm: "___ NVMM ___" */ | |
1136 | } | 1136 | } | |
1137 | return; | 1137 | return; | |
1138 | } | 1138 | } | |
1139 | 1139 | |||
1140 | /* | 1140 | /* | |
1141 | * Examine SMBIOS strings for older hypervisors. | 1141 | * Examine SMBIOS strings for older hypervisors. | |
1142 | */ | 1142 | */ | |
1143 | p = pmf_get_platform("system-serial"); | 1143 | p = pmf_get_platform("system-serial"); | |
1144 | if (p != NULL) { | 1144 | if (p != NULL) { | |
1145 | if (strncmp(p, "VMware-", 7) == 0 || strncmp(p, "VMW", 3) == 0) { | 1145 | if (strncmp(p, "VMware-", 7) == 0 || strncmp(p, "VMW", 3) == 0) { |
--- src/sys/arch/x86/x86/lapic.c 2019/12/01 08:23:09 1.76
+++ src/sys/arch/x86/x86/lapic.c 2020/04/08 17:59:16 1.76.6.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lapic.c,v 1.76 2019/12/01 08:23:09 maxv Exp $ */ | 1 | /* $NetBSD: lapic.c,v 1.76.6.1 2020/04/08 17:59:16 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by RedBack Networks Inc. | 8 | * by RedBack Networks Inc. | |
9 | * | 9 | * | |
10 | * Author: Bill Sommerfeld | 10 | * Author: Bill Sommerfeld | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 23 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | * POSSIBILITY OF SUCH DAMAGE. | 31 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.76 2019/12/01 08:23:09 maxv Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.76.6.1 2020/04/08 17:59:16 bouyer Exp $"); | |
36 | 36 | |||
37 | #include "acpica.h" | 37 | #include "acpica.h" | |
38 | #include "ioapic.h" | 38 | #include "ioapic.h" | |
39 | #include "opt_acpi.h" | 39 | #include "opt_acpi.h" | |
40 | #include "opt_ddb.h" | 40 | #include "opt_ddb.h" | |
41 | #include "opt_mpbios.h" /* for MPDEBUG */ | 41 | #include "opt_mpbios.h" /* for MPDEBUG */ | |
42 | #include "opt_multiprocessor.h" | 42 | #include "opt_multiprocessor.h" | |
43 | #include "opt_ntp.h" | 43 | #include "opt_ntp.h" | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/proc.h> | 46 | #include <sys/proc.h> | |
47 | #include <sys/systm.h> | 47 | #include <sys/systm.h> | |
48 | #include <sys/device.h> | 48 | #include <sys/device.h> | |
@@ -268,27 +268,27 @@ lapic_setup_bsp(paddr_t lapic_base) | @@ -268,27 +268,27 @@ lapic_setup_bsp(paddr_t lapic_base) | |||
268 | if (ISSET(dmar->Flags, ACPI_DMAR_X2APIC_OPT_OUT)) { | 268 | if (ISSET(dmar->Flags, ACPI_DMAR_X2APIC_OPT_OUT)) { | |
269 | reason = "by DMAR table"; | 269 | reason = "by DMAR table"; | |
270 | } | 270 | } | |
271 | AcpiPutTable(&dmar->Header); | 271 | AcpiPutTable(&dmar->Header); | |
272 | } | 272 | } | |
273 | } | 273 | } | |
274 | #endif /* NACPICA > 0 */ | 274 | #endif /* NACPICA > 0 */ | |
275 | if (vm_guest == VM_GUEST_VMWARE) { | 275 | if (vm_guest == VM_GUEST_VMWARE) { | |
276 | vmt_hvcall(VM_CMD_GET_VCPU_INFO, regs); | 276 | vmt_hvcall(VM_CMD_GET_VCPU_INFO, regs); | |
277 | if (ISSET(regs[0], VCPUINFO_VCPU_RESERVED) || | 277 | if (ISSET(regs[0], VCPUINFO_VCPU_RESERVED) || | |
278 | !ISSET(regs[0], VCPUINFO_LEGACY_X2APIC)) | 278 | !ISSET(regs[0], VCPUINFO_LEGACY_X2APIC)) | |
279 | reason = "inside VMWare without intr " | 279 | reason = "inside VMWare without intr " | |
280 | "redirection"; | 280 | "redirection"; | |
281 | } else if (vm_guest == VM_GUEST_XEN) { | 281 | } else if (vm_guest == VM_GUEST_XENHVM) { | |
282 | reason = "due to running under XEN"; | 282 | reason = "due to running under XEN"; | |
283 | } else if (vm_guest == VM_GUEST_NO && | 283 | } else if (vm_guest == VM_GUEST_NO && | |
284 | CPUID_TO_FAMILY(curcpu()->ci_signature) == 6 && | 284 | CPUID_TO_FAMILY(curcpu()->ci_signature) == 6 && | |
285 | CPUID_TO_MODEL(curcpu()->ci_signature) == 0x2a) { | 285 | CPUID_TO_MODEL(curcpu()->ci_signature) == 0x2a) { | |
286 | hw_vendor = pmf_get_platform("board-vendor"); | 286 | hw_vendor = pmf_get_platform("board-vendor"); | |
287 | if (hw_vendor != NULL) { | 287 | if (hw_vendor != NULL) { | |
288 | /* | 288 | /* | |
289 | * It seems that some Lenovo and ASUS | 289 | * It seems that some Lenovo and ASUS | |
290 | * SandyBridge-based notebook BIOSes have a bug | 290 | * SandyBridge-based notebook BIOSes have a bug | |
291 | * which prevents booting AP in x2APIC mode. | 291 | * which prevents booting AP in x2APIC mode. | |
292 | * Since the only way to detect mobile CPU is | 292 | * Since the only way to detect mobile CPU is | |
293 | * to check northbridge pci id, which cannot be | 293 | * to check northbridge pci id, which cannot be | |
294 | * done that early, disable x2APIC for all | 294 | * done that early, disable x2APIC for all |
--- src/sys/arch/x86/x86/x86_machdep.c 2020/04/04 19:50:54 1.137
+++ src/sys/arch/x86/x86/x86_machdep.c 2020/04/08 17:59:16 1.137.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: x86_machdep.c,v 1.137 2020/04/04 19:50:54 christos Exp $ */ | 1 | /* $NetBSD: x86_machdep.c,v 1.137.2.1 2020/04/08 17:59:16 bouyer Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, | 4 | * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, | |
5 | * Copyright (c) 2005, 2008, 2009, 2019 The NetBSD Foundation, Inc. | 5 | * Copyright (c) 2005, 2008, 2009, 2019 The NetBSD Foundation, Inc. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to The NetBSD Foundation | 8 | * This code is derived from software contributed to The NetBSD Foundation | |
9 | * by Julio M. Merino Vidal, and Andrew Doran. | 9 | * by Julio M. Merino Vidal, and Andrew Doran. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.137 2020/04/04 19:50:54 christos Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.137.2.1 2020/04/08 17:59:16 bouyer Exp $"); | |
35 | 35 | |||
36 | #include "opt_modular.h" | 36 | #include "opt_modular.h" | |
37 | #include "opt_physmem.h" | 37 | #include "opt_physmem.h" | |
38 | #include "opt_splash.h" | 38 | #include "opt_splash.h" | |
39 | #include "opt_kaslr.h" | 39 | #include "opt_kaslr.h" | |
40 | #include "opt_svs.h" | 40 | #include "opt_svs.h" | |
41 | #include "opt_xen.h" | 41 | #include "opt_xen.h" | |
42 | 42 | |||
43 | #include <sys/types.h> | 43 | #include <sys/types.h> | |
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/systm.h> | 45 | #include <sys/systm.h> | |
46 | #include <sys/kcore.h> | 46 | #include <sys/kcore.h> | |
47 | #include <sys/errno.h> | 47 | #include <sys/errno.h> | |
@@ -1245,38 +1245,41 @@ sysctl_machdep_tsc_enable(SYSCTLFN_ARGS) | @@ -1245,38 +1245,41 @@ sysctl_machdep_tsc_enable(SYSCTLFN_ARGS) | |||
1245 | } | 1245 | } | |
1246 | if (error) | 1246 | if (error) | |
1247 | return error; | 1247 | return error; | |
1248 | 1248 | |||
1249 | *(int *)rnode->sysctl_data = val; | 1249 | *(int *)rnode->sysctl_data = val; | |
1250 | 1250 | |||
1251 | return 0; | 1251 | return 0; | |
1252 | } | 1252 | } | |
1253 | #endif | 1253 | #endif | |
1254 | 1254 | |||
1255 | static const char * const vm_guest_name[VM_LAST] = { | 1255 | static const char * const vm_guest_name[VM_LAST] = { | |
1256 | [VM_GUEST_NO] = "none", | 1256 | [VM_GUEST_NO] = "none", | |
1257 | [VM_GUEST_VM] = "generic", | 1257 | [VM_GUEST_VM] = "generic", | |
1258 | [VM_GUEST_XEN] = "Xen", | 1258 | [VM_GUEST_XENPV] = "Xen PV", | |
1259 | [VM_GUEST_XENPVH] = "Xen PVH", | |||
1260 | [VM_GUEST_XENHVM] = "Xen HVM", | |||
1261 | [VM_GUEST_XENPVHVM] = "Xen PVHVM", | |||
1259 | [VM_GUEST_HV] = "Hyper-V", | 1262 | [VM_GUEST_HV] = "Hyper-V", | |
1260 | [VM_GUEST_VMWARE] = "VMware", | 1263 | [VM_GUEST_VMWARE] = "VMware", | |
1261 | [VM_GUEST_KVM] = "KVM", | 1264 | [VM_GUEST_KVM] = "KVM", | |
1262 | }; | 1265 | }; | |
1263 | 1266 | |||
1264 | static int | 1267 | static int | |
1265 | sysctl_machdep_hypervisor(SYSCTLFN_ARGS) | 1268 | sysctl_machdep_hypervisor(SYSCTLFN_ARGS) | |
1266 | { | 1269 | { | |
1267 | struct sysctlnode node; | 1270 | struct sysctlnode node; | |
1268 | const char *t = NULL; | 1271 | const char *t = NULL; | |
1269 | char buf[8]; | 1272 | char buf[10]; | |
1270 | 1273 | |||
1271 | node = *rnode; | 1274 | node = *rnode; | |
1272 | node.sysctl_data = buf; | 1275 | node.sysctl_data = buf; | |
1273 | if (vm_guest >= VM_GUEST_NO && vm_guest < VM_LAST) | 1276 | if (vm_guest >= VM_GUEST_NO && vm_guest < VM_LAST) | |
1274 | t = vm_guest_name[vm_guest]; | 1277 | t = vm_guest_name[vm_guest]; | |
1275 | if (t == NULL) | 1278 | if (t == NULL) | |
1276 | t = "unknown"; | 1279 | t = "unknown"; | |
1277 | strlcpy(buf, t, sizeof(buf)); | 1280 | strlcpy(buf, t, sizeof(buf)); | |
1278 | return sysctl_lookup(SYSCTLFN_CALL(&node)); | 1281 | return sysctl_lookup(SYSCTLFN_CALL(&node)); | |
1279 | } | 1282 | } | |
1280 | 1283 | |||
1281 | static void | 1284 | static void | |
1282 | const_sysctl(struct sysctllog **clog, const char *name, int type, | 1285 | const_sysctl(struct sysctllog **clog, const char *name, int type, |
--- src/sys/arch/xen/x86/autoconf.c 2019/05/24 14:28:48 1.23
+++ src/sys/arch/xen/x86/autoconf.c 2020/04/08 17:59:16 1.23.8.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: autoconf.c,v 1.23 2019/05/24 14:28:48 nonaka Exp $ */ | 1 | /* $NetBSD: autoconf.c,v 1.23.8.1 2020/04/08 17:59:16 bouyer Exp $ */ | |
2 | /* NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp */ | 2 | /* NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 1990 The Regents of the University of California. | 5 | * Copyright (c) 1990 The Regents of the University of California. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to Berkeley by | 8 | * This code is derived from software contributed to Berkeley by | |
9 | * William Jolitz. | 9 | * William Jolitz. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -35,27 +35,27 @@ | @@ -35,27 +35,27 @@ | |||
35 | * @(#)autoconf.c 7.1 (Berkeley) 5/9/91 | 35 | * @(#)autoconf.c 7.1 (Berkeley) 5/9/91 | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | /* | 38 | /* | |
39 | * Setup the system to run on the current machine. | 39 | * Setup the system to run on the current machine. | |
40 | * | 40 | * | |
41 | * Configure() is called at boot time and initializes the vba | 41 | * Configure() is called at boot time and initializes the vba | |
42 | * device tables and the memory controller monitoring. Available | 42 | * device tables and the memory controller monitoring. Available | |
43 | * devices are determined (from possibilities mentioned in ioconf.c), | 43 | * devices are determined (from possibilities mentioned in ioconf.c), | |
44 | * and the drivers are initialized. | 44 | * and the drivers are initialized. | |
45 | */ | 45 | */ | |
46 | 46 | |||
47 | #include <sys/cdefs.h> | 47 | #include <sys/cdefs.h> | |
48 | __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23 2019/05/24 14:28:48 nonaka Exp $"); | 48 | __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23.8.1 2020/04/08 17:59:16 bouyer Exp $"); | |
49 | 49 | |||
50 | #include "opt_xen.h" | 50 | #include "opt_xen.h" | |
51 | #include "opt_multiprocessor.h" | 51 | #include "opt_multiprocessor.h" | |
52 | #include "opt_nfs_boot.h" | 52 | #include "opt_nfs_boot.h" | |
53 | 53 | |||
54 | #include <sys/param.h> | 54 | #include <sys/param.h> | |
55 | #include <sys/systm.h> | 55 | #include <sys/systm.h> | |
56 | #include <sys/buf.h> | 56 | #include <sys/buf.h> | |
57 | #include <sys/disklabel.h> | 57 | #include <sys/disklabel.h> | |
58 | #include <sys/disk.h> | 58 | #include <sys/disk.h> | |
59 | #include <sys/conf.h> | 59 | #include <sys/conf.h> | |
60 | #include <sys/device.h> | 60 | #include <sys/device.h> | |
61 | #include <sys/vnode.h> | 61 | #include <sys/vnode.h> | |
@@ -118,27 +118,26 @@ cpu_configure(void) | @@ -118,27 +118,26 @@ cpu_configure(void) | |||
118 | 118 | |||
119 | startrtclock(); | 119 | startrtclock(); | |
120 | 120 | |||
121 | #if defined(DOM0OPS) | 121 | #if defined(DOM0OPS) | |
122 | if (xendomain_is_dom0()) { | 122 | if (xendomain_is_dom0()) { | |
123 | #if NBIOS32 > 0 | 123 | #if NBIOS32 > 0 | |
124 | bios32_init(); | 124 | bios32_init(); | |
125 | platform_init(); | 125 | platform_init(); | |
126 | /* identify hypervisor type from SMBIOS */ | 126 | /* identify hypervisor type from SMBIOS */ | |
127 | identify_hypervisor(); | 127 | identify_hypervisor(); | |
128 | #endif /* NBIOS32 > 0 */ | 128 | #endif /* NBIOS32 > 0 */ | |
129 | } else | 129 | } else | |
130 | #endif /* DOM0OPS */ | 130 | #endif /* DOM0OPS */ | |
131 | vm_guest = VM_GUEST_XEN; | |||
132 | #ifdef PCIBIOS | 131 | #ifdef PCIBIOS | |
133 | pcibios_init(); | 132 | pcibios_init(); | |
134 | #endif | 133 | #endif | |
135 | 134 | |||
136 | if (config_rootfound("mainbus", NULL) == NULL) | 135 | if (config_rootfound("mainbus", NULL) == NULL) | |
137 | panic("configure: mainbus not configured"); | 136 | panic("configure: mainbus not configured"); | |
138 | 137 | |||
139 | #ifdef INTRDEBUG | 138 | #ifdef INTRDEBUG | |
140 | intr_printconfig(); | 139 | intr_printconfig(); | |
141 | #endif | 140 | #endif | |
142 | 141 | |||
143 | #if NIOAPIC > 0 | 142 | #if NIOAPIC > 0 | |
144 | ioapic_enable(); | 143 | ioapic_enable(); |
--- src/sys/arch/xen/xen/hypervisor.c 2020/04/07 08:14:42 1.73
+++ src/sys/arch/xen/xen/hypervisor.c 2020/04/08 17:59:17 1.73.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */ | 1 | /* $NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2005 Manuel Bouyer. | 4 | * Copyright (c) 2005 Manuel Bouyer. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -43,27 +43,27 @@ | @@ -43,27 +43,27 @@ | |||
43 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 43 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
44 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 44 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
45 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 45 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
46 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 46 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
47 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 47 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
48 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 48 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
49 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 49 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
50 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 50 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
51 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 51 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
52 | */ | 52 | */ | |
53 | 53 | |||
54 | 54 | |||
55 | #include <sys/cdefs.h> | 55 | #include <sys/cdefs.h> | |
56 | __KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $"); | 56 | __KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $"); | |
57 | 57 | |||
58 | #include <sys/param.h> | 58 | #include <sys/param.h> | |
59 | #include <sys/systm.h> | 59 | #include <sys/systm.h> | |
60 | #include <sys/device.h> | 60 | #include <sys/device.h> | |
61 | #include <sys/sysctl.h> | 61 | #include <sys/sysctl.h> | |
62 | 62 | |||
63 | #include "xenbus.h" | 63 | #include "xenbus.h" | |
64 | #include "xencons.h" | 64 | #include "xencons.h" | |
65 | #include "isa.h" | 65 | #include "isa.h" | |
66 | #include "pci.h" | 66 | #include "pci.h" | |
67 | #include "acpica.h" | 67 | #include "acpica.h" | |
68 | 68 | |||
69 | #include "opt_xen.h" | 69 | #include "opt_xen.h" | |
@@ -207,27 +207,27 @@ hypervisor_match(device_t parent, cfdata | @@ -207,27 +207,27 @@ hypervisor_match(device_t parent, cfdata | |||
207 | /* | 207 | /* | |
208 | * The strategy here is to setup hypercall and all PVHVM | 208 | * The strategy here is to setup hypercall and all PVHVM | |
209 | * interfaces on match, or fail to match. | 209 | * interfaces on match, or fail to match. | |
210 | * Ideally this should happen under attach, but it's too late | 210 | * Ideally this should happen under attach, but it's too late | |
211 | * then and there's no way to bailout. | 211 | * then and there's no way to bailout. | |
212 | * | 212 | * | |
213 | * If match fails, hypervisor does not attach, and the domain | 213 | * If match fails, hypervisor does not attach, and the domain | |
214 | * can boot with the minimal PC AT ISA configuration just | 214 | * can boot with the minimal PC AT ISA configuration just | |
215 | * enough to attach wd(4) and mount the rootfs. | 215 | * enough to attach wd(4) and mount the rootfs. | |
216 | */ | 216 | */ | |
217 | int vec; | 217 | int vec; | |
218 | extern vaddr_t hypercall_page; | 218 | extern vaddr_t hypercall_page; | |
219 | 219 | |||
220 | if (vm_guest == VM_GUEST_XEN) { | 220 | if (vm_guest == VM_GUEST_XENHVM) { | |
221 | aprint_normal("%s: Identified Guest XEN in HVM mode.\n", | 221 | aprint_normal("%s: Identified Guest XEN in HVM mode.\n", | |
222 | haa->haa_busname); | 222 | haa->haa_busname); | |
223 | 223 | |||
224 | u_int descs[4]; | 224 | u_int descs[4]; | |
225 | x86_cpuid(XEN_CPUID_LEAF(2), descs); | 225 | x86_cpuid(XEN_CPUID_LEAF(2), descs); | |
226 | 226 | |||
227 | /* | 227 | /* | |
228 | * Given 32 bytes per hypercall stub, and an optimistic number | 228 | * Given 32 bytes per hypercall stub, and an optimistic number | |
229 | * of 100 hypercalls ( the current max is 55), there shouldn't | 229 | * of 100 hypercalls ( the current max is 55), there shouldn't | |
230 | * be any reason to spill over the arbitrary number of 1 | 230 | * be any reason to spill over the arbitrary number of 1 | |
231 | * hypercall page. This is what we allocate in locore.S | 231 | * hypercall page. This is what we allocate in locore.S | |
232 | * anyway. Make sure the allocation matches the registration. | 232 | * anyway. Make sure the allocation matches the registration. | |
233 | */ | 233 | */ | |
@@ -405,27 +405,27 @@ hypervisor_match(device_t parent, cfdata | @@ -405,27 +405,27 @@ hypervisor_match(device_t parent, cfdata | |||
405 | * | 405 | * | |
406 | * We need to do this because the HVM domain loader uses the | 406 | * We need to do this because the HVM domain loader uses the | |
407 | * regular BIOS based native boot(8) procedure, which sets the | 407 | * regular BIOS based native boot(8) procedure, which sets the | |
408 | * boot device to the native driver/partition of whatever was | 408 | * boot device to the native driver/partition of whatever was | |
409 | * detected by the native bootloader. | 409 | * detected by the native bootloader. | |
410 | */ | 410 | */ | |
411 | 411 | |||
412 | struct btinfo_rootdevice bi; | 412 | struct btinfo_rootdevice bi; | |
413 | snprintf(bi.devname, 6, "xbd0a"); | 413 | snprintf(bi.devname, 6, "xbd0a"); | |
414 | bi.common.type = BTINFO_ROOTDEVICE; | 414 | bi.common.type = BTINFO_ROOTDEVICE; | |
415 | bi.common.len = sizeof(struct btinfo_rootdevice); | 415 | bi.common.len = sizeof(struct btinfo_rootdevice); | |
416 | 416 | |||
417 | /* From i386/multiboot.c */ | 417 | /* From i386/multiboot.c */ | |
418 | /* $NetBSD: hypervisor.c,v 1.73 2020/04/07 08:14:42 jdolecek Exp $ */ | 418 | /* $NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $ */ | |
419 | int i, len; | 419 | int i, len; | |
420 | vaddr_t data; | 420 | vaddr_t data; | |
421 | extern struct bootinfo bootinfo; | 421 | extern struct bootinfo bootinfo; | |
422 | struct bootinfo *bip = (struct bootinfo *)&bootinfo; | 422 | struct bootinfo *bip = (struct bootinfo *)&bootinfo; | |
423 | len = bi.common.len; | 423 | len = bi.common.len; | |
424 | 424 | |||
425 | data = (vaddr_t)&bip->bi_data; | 425 | data = (vaddr_t)&bip->bi_data; | |
426 | for (i = 0; i < bip->bi_nentries; i++) { | 426 | for (i = 0; i < bip->bi_nentries; i++) { | |
427 | struct btinfo_common *tmp; | 427 | struct btinfo_common *tmp; | |
428 | 428 | |||
429 | tmp = (struct btinfo_common *)data; | 429 | tmp = (struct btinfo_common *)data; | |
430 | data += tmp->len; | 430 | data += tmp->len; | |
431 | } | 431 | } |