KNF. No functional change.diff -r1.82 -r1.83 src/sys/arch/x86/x86/bus_dma.c
(msaitoh)
--- src/sys/arch/x86/x86/bus_dma.c 2020/03/14 18:08:38 1.82
+++ src/sys/arch/x86/x86/bus_dma.c 2021/10/07 12:52:27 1.83
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bus_dma.c,v 1.82 2020/03/14 18:08:38 ad Exp $ */ | 1 | /* $NetBSD: bus_dma.c,v 1.83 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996, 1997, 1998, 2007, 2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1996, 1997, 1998, 2007, 2020 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 Jason R. Thorpe of the Numerical Aerospace | 8 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace | |
9 | * Simulation Facility NASA Ames Research Center, and by Andrew Doran. | 9 | * Simulation Facility NASA Ames Research Center, and by 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: bus_dma.c,v 1.82 2020/03/14 18:08:38 ad Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.83 2021/10/07 12:52:27 msaitoh Exp $"); | |
35 | 35 | |||
36 | /* | 36 | /* | |
37 | * The following is included because _bus_dma_uiomove is derived from | 37 | * The following is included because _bus_dma_uiomove is derived from | |
38 | * uiomove() in kern_subr.c. | 38 | * uiomove() in kern_subr.c. | |
39 | */ | 39 | */ | |
40 | 40 | |||
41 | /* | 41 | /* | |
42 | * Copyright (c) 1982, 1986, 1991, 1993 | 42 | * Copyright (c) 1982, 1986, 1991, 1993 | |
43 | * The Regents of the University of California. All rights reserved. | 43 | * The Regents of the University of California. All rights reserved. | |
44 | * (c) UNIX System Laboratories, Inc. | 44 | * (c) UNIX System Laboratories, Inc. | |
45 | * All or some portions of this file are derived from material licensed | 45 | * All or some portions of this file are derived from material licensed | |
46 | * to the University of California by American Telephone and Telegraph | 46 | * to the University of California by American Telephone and Telegraph | |
47 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | 47 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
@@ -202,28 +202,28 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, | @@ -202,28 +202,28 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, | |||
202 | struct pglist mlist; | 202 | struct pglist mlist; | |
203 | int curseg, error; | 203 | int curseg, error; | |
204 | bus_size_t uboundary; | 204 | bus_size_t uboundary; | |
205 | 205 | |||
206 | /* Always round the size. */ | 206 | /* Always round the size. */ | |
207 | size = round_page(size); | 207 | size = round_page(size); | |
208 | 208 | |||
209 | KASSERT(boundary >= PAGE_SIZE || boundary == 0); | 209 | KASSERT(boundary >= PAGE_SIZE || boundary == 0); | |
210 | 210 | |||
211 | /* | 211 | /* | |
212 | * Allocate pages from the VM system. | 212 | * Allocate pages from the VM system. | |
213 | * We accept boundaries < size, splitting in multiple segments | 213 | * We accept boundaries < size, splitting in multiple segments | |
214 | * if needed. uvm_pglistalloc does not, so compute an appropriate | 214 | * if needed. uvm_pglistalloc does not, so compute an appropriate | |
215 | * boundary: next power of 2 >= size | 215 | * boundary: next power of 2 >= size | |
216 | */ | 216 | */ | |
217 | 217 | |||
218 | if (boundary == 0) | 218 | if (boundary == 0) | |
219 | uboundary = 0; | 219 | uboundary = 0; | |
220 | else { | 220 | else { | |
221 | uboundary = boundary; | 221 | uboundary = boundary; | |
222 | while (uboundary < size) | 222 | while (uboundary < size) | |
223 | uboundary = uboundary << 1; | 223 | uboundary = uboundary << 1; | |
224 | } | 224 | } | |
225 | error = uvm_pglistalloc(size, low, high, alignment, uboundary, | 225 | error = uvm_pglistalloc(size, low, high, alignment, uboundary, | |
226 | &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); | 226 | &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); | |
227 | if (error) | 227 | if (error) | |
228 | return (error); | 228 | return (error); | |
229 | 229 | |||
@@ -1162,28 +1162,28 @@ _bus_dmamem_unmap(bus_dma_tag_t t, void | @@ -1162,28 +1162,28 @@ _bus_dmamem_unmap(bus_dma_tag_t t, void | |||
1162 | pt_entry_t *pte, opte; | 1162 | pt_entry_t *pte, opte; | |
1163 | vaddr_t va, sva, eva; | 1163 | vaddr_t va, sva, eva; | |
1164 | 1164 | |||
1165 | #ifdef DIAGNOSTIC | 1165 | #ifdef DIAGNOSTIC | |
1166 | if ((u_long)kva & PGOFSET) | 1166 | if ((u_long)kva & PGOFSET) | |
1167 | panic("_bus_dmamem_unmap"); | 1167 | panic("_bus_dmamem_unmap"); | |
1168 | #endif | 1168 | #endif | |
1169 | 1169 | |||
1170 | size = round_page(size); | 1170 | size = round_page(size); | |
1171 | sva = (vaddr_t)kva; | 1171 | sva = (vaddr_t)kva; | |
1172 | eva = sva + size; | 1172 | eva = sva + size; | |
1173 | 1173 | |||
1174 | /* | 1174 | /* | |
1175 | * mark pages cacheable again. | 1175 | * mark pages cacheable again. | |
1176 | */ | 1176 | */ | |
1177 | for (va = sva; va < eva; va += PAGE_SIZE) { | 1177 | for (va = sva; va < eva; va += PAGE_SIZE) { | |
1178 | pte = kvtopte(va); | 1178 | pte = kvtopte(va); | |
1179 | opte = *pte; | 1179 | opte = *pte; | |
1180 | if ((opte & PTE_PCD) != 0) | 1180 | if ((opte & PTE_PCD) != 0) | |
1181 | pmap_pte_clearbits(pte, PTE_PCD); | 1181 | pmap_pte_clearbits(pte, PTE_PCD); | |
1182 | } | 1182 | } | |
1183 | pmap_remove(pmap_kernel(), (vaddr_t)kva, (vaddr_t)kva + size); | 1183 | pmap_remove(pmap_kernel(), (vaddr_t)kva, (vaddr_t)kva + size); | |
1184 | pmap_update(pmap_kernel()); | 1184 | pmap_update(pmap_kernel()); | |
1185 | uvm_km_free(kernel_map, (vaddr_t)kva, size, UVM_KMF_VAONLY); | 1185 | uvm_km_free(kernel_map, (vaddr_t)kva, size, UVM_KMF_VAONLY); | |
1186 | } | 1186 | } | |
1187 | 1187 | |||
1188 | /* | 1188 | /* | |
1189 | * Common function for mmap(2)'ing DMA-safe memory. May be called by | 1189 | * Common function for mmap(2)'ing DMA-safe memory. May be called by |
--- src/sys/arch/x86/x86/bus_space.c 2020/04/25 15:26:18 1.45
+++ src/sys/arch/x86/x86/bus_space.c 2021/10/07 12:52:27 1.46
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bus_space.c,v 1.45 2020/04/25 15:26:18 bouyer Exp $ */ | 1 | /* $NetBSD: bus_space.c,v 1.46 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1996, 1997, 1998 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 Jason R. Thorpe of the Numerical Aerospace | 8 | * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace | |
9 | * Simulation Facility, NASA Ames Research Center. | 9 | * Simulation Facility, NASA Ames Research Center. | |
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,53 +21,53 @@ | @@ -21,53 +21,53 @@ | |||
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: bus_space.c,v 1.45 2020/04/25 15:26:18 bouyer Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.46 2021/10/07 12:52:27 msaitoh Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/malloc.h> | 38 | #include <sys/malloc.h> | |
39 | #include <sys/extent.h> | 39 | #include <sys/extent.h> | |
40 | #include <sys/kmem.h> | 40 | #include <sys/kmem.h> | |
41 | 41 | |||
42 | #include <uvm/uvm_extern.h> | 42 | #include <uvm/uvm_extern.h> | |
43 | 43 | |||
44 | #include <dev/isa/isareg.h> | 44 | #include <dev/isa/isareg.h> | |
45 | 45 | |||
46 | #include <sys/bus.h> | 46 | #include <sys/bus.h> | |
47 | #include <machine/pio.h> | 47 | #include <machine/pio.h> | |
48 | #include <machine/isa_machdep.h> | 48 | #include <machine/isa_machdep.h> | |
49 | 49 | |||
50 | #ifdef XEN | 50 | #ifdef XEN | |
51 | #include <xen/hypervisor.h> | 51 | #include <xen/hypervisor.h> | |
52 | #endif | 52 | #endif | |
53 | 53 | |||
54 | /* | 54 | /* | |
55 | * Macros for sanity-checking the aligned-ness of pointers passed to | 55 | * Macros for sanity-checking the aligned-ness of pointers passed to | |
56 | * bus space ops. These are not strictly necessary on the x86, but | 56 | * bus space ops. These are not strictly necessary on the x86, but | |
57 | * could lead to performance improvements, and help catch problems | 57 | * could lead to performance improvements, and help catch problems | |
58 | * with drivers that would creep up on other architectures. | 58 | * with drivers that would creep up on other architectures. | |
59 | */ | 59 | */ | |
60 | #ifdef BUS_SPACE_DEBUG | 60 | #ifdef BUS_SPACE_DEBUG | |
61 | #define BUS_SPACE_ALIGNED_ADDRESS(p, t) \ | 61 | #define BUS_SPACE_ALIGNED_ADDRESS(p, t) \ | |
62 | ((((u_long)(p)) & (sizeof(t)-1)) == 0) | 62 | ((((u_long)(p)) & (sizeof(t)-1)) == 0) | |
63 | 63 | |||
64 | #define BUS_SPACE_ADDRESS_SANITY(p, t, d) \ | 64 | #define BUS_SPACE_ADDRESS_SANITY(p, t, d) \ | |
65 | ({ \ | 65 | ({ \ | |
66 | if (BUS_SPACE_ALIGNED_ADDRESS((p), t) == 0) { \ | 66 | if (BUS_SPACE_ALIGNED_ADDRESS((p), t) == 0) { \ | |
67 | printf("%s 0x%lx not aligned to %zu bytes %s:%d\n", \ | 67 | printf("%s 0x%lx not aligned to %zu bytes %s:%d\n", \ | |
68 | d, (u_long)(p), sizeof(t), __FILE__, __LINE__); \ | 68 | d, (u_long)(p), sizeof(t), __FILE__, __LINE__); \ | |
69 | } \ | 69 | } \ | |
70 | (void) 0; \ | 70 | (void) 0; \ | |
71 | }) | 71 | }) | |
72 | #else | 72 | #else | |
73 | #define BUS_SPACE_ADDRESS_SANITY(p,t,d) (void) 0 | 73 | #define BUS_SPACE_ADDRESS_SANITY(p,t,d) (void) 0 |
--- src/sys/arch/x86/x86/consinit.c 2020/05/02 16:44:36 1.33
+++ src/sys/arch/x86/x86/consinit.c 2021/10/07 12:52:27 1.34
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: consinit.c,v 1.33 2020/05/02 16:44:36 bouyer Exp $ */ | 1 | /* $NetBSD: consinit.c,v 1.34 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998 | 4 | * Copyright (c) 1998 | |
5 | * Matthias Drochner. All rights reserved. | 5 | * Matthias Drochner. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | * | 26 | * | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.33 2020/05/02 16:44:36 bouyer Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.34 2021/10/07 12:52:27 msaitoh Exp $"); | |
31 | 31 | |||
32 | #include "opt_kgdb.h" | 32 | #include "opt_kgdb.h" | |
33 | #include "opt_puc.h" | 33 | #include "opt_puc.h" | |
34 | #include "opt_xen.h" | 34 | #include "opt_xen.h" | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | #include <sys/bus.h> | 39 | #include <sys/bus.h> | |
40 | #include <sys/cpu.h> | 40 | #include <sys/cpu.h> | |
41 | #include <machine/bootinfo.h> | 41 | #include <machine/bootinfo.h> | |
42 | #include <arch/x86/include/genfb_machdep.h> | 42 | #include <arch/x86/include/genfb_machdep.h> | |
43 | 43 | |||
@@ -267,20 +267,20 @@ dokbd: | @@ -267,20 +267,20 @@ dokbd: | |||
267 | 267 | |||
268 | nullcninit(0); | 268 | nullcninit(0); | |
269 | return; | 269 | return; | |
270 | } | 270 | } | |
271 | #endif | 271 | #endif | |
272 | panic("invalid console device %s", consinfo->devname); | 272 | panic("invalid console device %s", consinfo->devname); | |
273 | } | 273 | } | |
274 | 274 | |||
275 | #ifdef KGDB | 275 | #ifdef KGDB | |
276 | void | 276 | void | |
277 | kgdb_port_init(void) | 277 | kgdb_port_init(void) | |
278 | { | 278 | { | |
279 | #if (NCOM > 0) | 279 | #if (NCOM > 0) | |
280 | if(!strcmp(kgdb_devname, "com")) { | 280 | if (!strcmp(kgdb_devname, "com")) { | |
281 | com_kgdb_attach(x86_bus_space_io, comkgdbaddr, comkgdbrate, | 281 | com_kgdb_attach(x86_bus_space_io, comkgdbaddr, comkgdbrate, | |
282 | COM_FREQ, COM_TYPE_NORMAL, comkgdbmode); | 282 | COM_FREQ, COM_TYPE_NORMAL, comkgdbmode); | |
283 | } | 283 | } | |
284 | #endif | 284 | #endif | |
285 | } | 285 | } | |
286 | #endif | 286 | #endif |
--- src/sys/arch/x86/x86/coretemp.c 2020/03/27 09:47:03 1.37
+++ src/sys/arch/x86/x86/coretemp.c 2021/10/07 12:52:27 1.38
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: coretemp.c,v 1.37 2020/03/27 09:47:03 msaitoh Exp $ */ | 1 | /* $NetBSD: coretemp.c,v 1.38 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2011 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 Jukka Ruohonen. | 8 | * by Jukka Ruohonen. | |
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 | * | 13 | * | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -51,27 +51,27 @@ | @@ -51,27 +51,27 @@ | |||
51 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 51 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
52 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 52 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
55 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | 55 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
56 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 56 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
57 | * POSSIBILITY OF SUCH DAMAGE. | 57 | * POSSIBILITY OF SUCH DAMAGE. | |
58 | * | 58 | * | |
59 | * $FreeBSD: src/sys/dev/coretemp/coretemp.c,v 1.4 2007/10/15 20:00:21 netchild Exp $ | 59 | * $FreeBSD: src/sys/dev/coretemp/coretemp.c,v 1.4 2007/10/15 20:00:21 netchild Exp $ | |
60 | * | 60 | * | |
61 | */ | 61 | */ | |
62 | 62 | |||
63 | #include <sys/cdefs.h> | 63 | #include <sys/cdefs.h> | |
64 | __KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.37 2020/03/27 09:47:03 msaitoh Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.38 2021/10/07 12:52:27 msaitoh Exp $"); | |
65 | 65 | |||
66 | #include <sys/param.h> | 66 | #include <sys/param.h> | |
67 | #include <sys/device.h> | 67 | #include <sys/device.h> | |
68 | #include <sys/cpu.h> | 68 | #include <sys/cpu.h> | |
69 | #include <sys/module.h> | 69 | #include <sys/module.h> | |
70 | #include <sys/xcall.h> | 70 | #include <sys/xcall.h> | |
71 | 71 | |||
72 | #include <dev/sysmon/sysmonvar.h> | 72 | #include <dev/sysmon/sysmonvar.h> | |
73 | 73 | |||
74 | #include <machine/cpuvar.h> | 74 | #include <machine/cpuvar.h> | |
75 | #include <machine/cpufunc.h> | 75 | #include <machine/cpufunc.h> | |
76 | #include <machine/cputypes.h> | 76 | #include <machine/cputypes.h> | |
77 | #include <machine/specialreg.h> | 77 | #include <machine/specialreg.h> | |
@@ -324,27 +324,27 @@ notee: | @@ -324,27 +324,27 @@ notee: | |||
324 | static void | 324 | static void | |
325 | coretemp_refresh(struct sysmon_envsys *sme, envsys_data_t *edata) | 325 | coretemp_refresh(struct sysmon_envsys *sme, envsys_data_t *edata) | |
326 | { | 326 | { | |
327 | struct coretemp_softc *sc = sme->sme_cookie; | 327 | struct coretemp_softc *sc = sme->sme_cookie; | |
328 | uint64_t xc; | 328 | uint64_t xc; | |
329 | 329 | |||
330 | xc = xc_unicast(0, coretemp_refresh_xcall, sc, edata, sc->sc_ci); | 330 | xc = xc_unicast(0, coretemp_refresh_xcall, sc, edata, sc->sc_ci); | |
331 | xc_wait(xc); | 331 | xc_wait(xc); | |
332 | } | 332 | } | |
333 | 333 | |||
334 | static void | 334 | static void | |
335 | coretemp_refresh_xcall(void *arg0, void *arg1) | 335 | coretemp_refresh_xcall(void *arg0, void *arg1) | |
336 | { | 336 | { | |
337 | struct coretemp_softc *sc = arg0; | 337 | struct coretemp_softc *sc = arg0; | |
338 | envsys_data_t *edata = arg1; | 338 | envsys_data_t *edata = arg1; | |
339 | uint64_t msr; | 339 | uint64_t msr; | |
340 | 340 | |||
341 | msr = rdmsr(MSR_THERM_STATUS); | 341 | msr = rdmsr(MSR_THERM_STATUS); | |
342 | 342 | |||
343 | if ((msr & MSR_THERM_STATUS_VALID) == 0) | 343 | if ((msr & MSR_THERM_STATUS_VALID) == 0) | |
344 | edata->state = ENVSYS_SINVALID; | 344 | edata->state = ENVSYS_SINVALID; | |
345 | else { | 345 | else { | |
346 | /* | 346 | /* | |
347 | * The temperature is computed by | 347 | * The temperature is computed by | |
348 | * subtracting the reading by Tj(max). | 348 | * subtracting the reading by Tj(max). | |
349 | */ | 349 | */ | |
350 | edata->value_cur = sc->sc_tjmax; | 350 | edata->value_cur = sc->sc_tjmax; |
--- src/sys/arch/x86/x86/cpu.c 2021/08/07 16:19:08 1.201
+++ src/sys/arch/x86/x86/cpu.c 2021/10/07 12:52:27 1.202
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpu.c,v 1.201 2021/08/07 16:19:08 thorpej Exp $ */ | 1 | /* $NetBSD: cpu.c,v 1.202 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2000-2020 NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000-2020 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 Bill Sommerfeld of RedBack Networks Inc, and by Andrew Doran. | 8 | * by Bill Sommerfeld of RedBack Networks Inc, 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. | |
@@ -52,27 +52,27 @@ | @@ -52,27 +52,27 @@ | |||
52 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 52 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
53 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 53 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
54 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE | 54 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE | |
55 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 55 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
57 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 57 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 58 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 59 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 60 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
61 | * SUCH DAMAGE. | 61 | * SUCH DAMAGE. | |
62 | */ | 62 | */ | |
63 | 63 | |||
64 | #include <sys/cdefs.h> | 64 | #include <sys/cdefs.h> | |
65 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.201 2021/08/07 16:19:08 thorpej Exp $"); | 65 | __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.202 2021/10/07 12:52:27 msaitoh Exp $"); | |
66 | 66 | |||
67 | #include "opt_ddb.h" | 67 | #include "opt_ddb.h" | |
68 | #include "opt_mpbios.h" /* for MPDEBUG */ | 68 | #include "opt_mpbios.h" /* for MPDEBUG */ | |
69 | #include "opt_mtrr.h" | 69 | #include "opt_mtrr.h" | |
70 | #include "opt_multiprocessor.h" | 70 | #include "opt_multiprocessor.h" | |
71 | #include "opt_svs.h" | 71 | #include "opt_svs.h" | |
72 | 72 | |||
73 | #include "lapic.h" | 73 | #include "lapic.h" | |
74 | #include "ioapic.h" | 74 | #include "ioapic.h" | |
75 | #include "acpica.h" | 75 | #include "acpica.h" | |
76 | #include "hpet.h" | 76 | #include "hpet.h" | |
77 | 77 | |||
78 | #include <sys/param.h> | 78 | #include <sys/param.h> | |
@@ -1331,27 +1331,27 @@ cpu_get_tsc_freq(struct cpu_info *ci) | @@ -1331,27 +1331,27 @@ cpu_get_tsc_freq(struct cpu_info *ci) | |||
1331 | * freq from CPUID by calling cpu_tsc_freq_cpuid(). | 1331 | * freq from CPUID by calling cpu_tsc_freq_cpuid(). | |
1332 | * The function also set lapic_per_second variable if it's | 1332 | * The function also set lapic_per_second variable if it's | |
1333 | * known. This is required for Intel's Comet Lake and newer | 1333 | * known. This is required for Intel's Comet Lake and newer | |
1334 | * processors to set LAPIC timer correctly. | 1334 | * processors to set LAPIC timer correctly. | |
1335 | */ | 1335 | */ | |
1336 | if (ci->ci_data.cpu_cc_freq == 0) | 1336 | if (ci->ci_data.cpu_cc_freq == 0) | |
1337 | freq = freq_from_cpuid = cpu_tsc_freq_cpuid(ci); | 1337 | freq = freq_from_cpuid = cpu_tsc_freq_cpuid(ci); | |
1338 | #if NHPET > 0 | 1338 | #if NHPET > 0 | |
1339 | if (freq == 0) | 1339 | if (freq == 0) | |
1340 | freq = hpet_tsc_freq(); | 1340 | freq = hpet_tsc_freq(); | |
1341 | #endif | 1341 | #endif | |
1342 | if (freq == 0) { | 1342 | if (freq == 0) { | |
1343 | /* | 1343 | /* | |
1344 | * Work out the approximate overhead involved below. | 1344 | * Work out the approximate overhead involved below. | |
1345 | * Discard the result of the first go around the | 1345 | * Discard the result of the first go around the | |
1346 | * loop. | 1346 | * loop. | |
1347 | */ | 1347 | */ | |
1348 | overhead = 0; | 1348 | overhead = 0; | |
1349 | for (int i = 0; i <= 8; i++) { | 1349 | for (int i = 0; i <= 8; i++) { | |
1350 | t0 = cpu_counter(); | 1350 | t0 = cpu_counter(); | |
1351 | delay_func(0); | 1351 | delay_func(0); | |
1352 | t1 = cpu_counter(); | 1352 | t1 = cpu_counter(); | |
1353 | if (i > 0) { | 1353 | if (i > 0) { | |
1354 | overhead += (t1 - t0); | 1354 | overhead += (t1 - t0); | |
1355 | } | 1355 | } | |
1356 | } | 1356 | } | |
1357 | overhead >>= 3; | 1357 | overhead >>= 3; |
--- src/sys/arch/x86/x86/cpu_rng.c 2020/07/30 17:26:23 1.19
+++ src/sys/arch/x86/x86/cpu_rng.c 2021/10/07 12:52:27 1.20
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cpu_rng.c,v 1.19 2020/07/30 17:26:23 riastradh Exp $ */ | 1 | /* $NetBSD: cpu_rng.c,v 1.20 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2015 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2015 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 Thor Lancelot Simon. | 8 | * by Thor Lancelot Simon. | |
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. | |
@@ -144,27 +144,27 @@ cpu_rng_rdseed(uint64_t *out) | @@ -144,27 +144,27 @@ cpu_rng_rdseed(uint64_t *out) | |||
144 | 144 | |||
145 | /* | 145 | /* | |
146 | * XXX The Intel DRNG SIG recommends (Sec. 5.3.1 `Retry | 146 | * XXX The Intel DRNG SIG recommends (Sec. 5.3.1 `Retry | |
147 | * recommendations', p. 22) that we consider retrying up to 100 | 147 | * recommendations', p. 22) that we consider retrying up to 100 | |
148 | * times, separated by PAUSE, but offers no guarantees about | 148 | * times, separated by PAUSE, but offers no guarantees about | |
149 | * success after that many retries. In particular, userland | 149 | * success after that many retries. In particular, userland | |
150 | * threads could starve the kernel by issuing RDSEED. | 150 | * threads could starve the kernel by issuing RDSEED. | |
151 | */ | 151 | */ | |
152 | 152 | |||
153 | #ifdef __i386__ | 153 | #ifdef __i386__ | |
154 | uint32_t lo, hi; | 154 | uint32_t lo, hi; | |
155 | 155 | |||
156 | __asm __volatile("rdseed %0; setc %1" : "=r"(lo), "=qm"(rndsts)); | 156 | __asm __volatile("rdseed %0; setc %1" : "=r"(lo), "=qm"(rndsts)); | |
157 | if (rndsts != 1) | 157 | if (rndsts != 1) | |
158 | return 0; | 158 | return 0; | |
159 | __asm __volatile("rdseed %0; setc %1" : "=r"(hi), "=qm"(rndsts)); | 159 | __asm __volatile("rdseed %0; setc %1" : "=r"(hi), "=qm"(rndsts)); | |
160 | if (rndsts != 1) | 160 | if (rndsts != 1) | |
161 | return 0; | 161 | return 0; | |
162 | 162 | |||
163 | *out = (uint64_t)lo | ((uint64_t)hi << 32); | 163 | *out = (uint64_t)lo | ((uint64_t)hi << 32); | |
164 | explicit_memset(&lo, 0, sizeof(lo)); | 164 | explicit_memset(&lo, 0, sizeof(lo)); | |
165 | explicit_memset(&hi, 0, sizeof(hi)); | 165 | explicit_memset(&hi, 0, sizeof(hi)); | |
166 | #else | 166 | #else | |
167 | __asm __volatile("rdseed %0; setc %1" : "=r"(*out), "=qm"(rndsts)); | 167 | __asm __volatile("rdseed %0; setc %1" : "=r"(*out), "=qm"(rndsts)); | |
168 | #endif | 168 | #endif | |
169 | if (rndsts != 1) | 169 | if (rndsts != 1) | |
170 | return 0; | 170 | return 0; |
--- src/sys/arch/x86/x86/db_memrw.c 2019/04/21 06:37:21 1.11
+++ src/sys/arch/x86/x86/db_memrw.c 2021/10/07 12:52:27 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: db_memrw.c,v 1.11 2019/04/21 06:37:21 maxv Exp $ */ | 1 | /* $NetBSD: db_memrw.c,v 1.12 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1996, 2000 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 Gordon W. Ross and Jason R. Thorpe. | 8 | * by Gordon W. Ross and 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. | |
@@ -38,32 +38,32 @@ | @@ -38,32 +38,32 @@ | |||
38 | * the page writable, do the write, then restore the PTE. | 38 | * the page writable, do the write, then restore the PTE. | |
39 | * For writes outside the text segment, and all reads, | 39 | * For writes outside the text segment, and all reads, | |
40 | * just do the access -- if it causes a fault, the debugger | 40 | * just do the access -- if it causes a fault, the debugger | |
41 | * will recover with a longjmp to an appropriate place. | 41 | * will recover with a longjmp to an appropriate place. | |
42 | * | 42 | * | |
43 | * ALERT! If you want to access device registers with a | 43 | * ALERT! If you want to access device registers with a | |
44 | * specific size, then the read/write functions have to | 44 | * specific size, then the read/write functions have to | |
45 | * make sure to do the correct sized pointer access. | 45 | * make sure to do the correct sized pointer access. | |
46 | * | 46 | * | |
47 | * Modified for i386 from hp300 version by | 47 | * Modified for i386 from hp300 version by | |
48 | * Jason R. Thorpe <thorpej@zembu.com>. | 48 | * Jason R. Thorpe <thorpej@zembu.com>. | |
49 | * | 49 | * | |
50 | * Basic copy to amd64 by fvdl. | 50 | * Basic copy to amd64 by fvdl. | |
51 | * | 51 | * | |
52 | * i386 and amd64 merge by jym. | 52 | * i386 and amd64 merge by jym. | |
53 | */ | 53 | */ | |
54 | 54 | |||
55 | #include <sys/cdefs.h> | 55 | #include <sys/cdefs.h> | |
56 | __KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.11 2019/04/21 06:37:21 maxv Exp $"); | 56 | __KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.12 2021/10/07 12:52:27 msaitoh Exp $"); | |
57 | 57 | |||
58 | #include <sys/param.h> | 58 | #include <sys/param.h> | |
59 | #include <sys/proc.h> | 59 | #include <sys/proc.h> | |
60 | #include <sys/systm.h> | 60 | #include <sys/systm.h> | |
61 | 61 | |||
62 | #include <machine/db_machdep.h> | 62 | #include <machine/db_machdep.h> | |
63 | 63 | |||
64 | #include <ddb/db_access.h> | 64 | #include <ddb/db_access.h> | |
65 | #include <ddb/db_output.h> | 65 | #include <ddb/db_output.h> | |
66 | 66 | |||
67 | static int | 67 | static int | |
68 | db_validate_address(vaddr_t addr) | 68 | db_validate_address(vaddr_t addr) | |
69 | { | 69 | { |
--- src/sys/arch/x86/x86/linux_trap.c 2012/02/19 21:06:35 1.11
+++ src/sys/arch/x86/x86/linux_trap.c 2021/10/07 12:52:27 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux_trap.c,v 1.11 2012/02/19 21:06:35 rmind Exp $ */ | 1 | /* $NetBSD: linux_trap.c,v 1.12 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001 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 Christos Zoulas. | 8 | * by Christos Zoulas. | |
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. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
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 | /* | 32 | /* | |
33 | * x86 Trap and System call handling | 33 | * x86 Trap and System call handling | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: linux_trap.c,v 1.11 2012/02/19 21:06:35 rmind Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: linux_trap.c,v 1.12 2021/10/07 12:52:27 msaitoh Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/proc.h> | 41 | #include <sys/proc.h> | |
42 | #include <sys/acct.h> | 42 | #include <sys/acct.h> | |
43 | #include <sys/kernel.h> | 43 | #include <sys/kernel.h> | |
44 | #include <sys/signal.h> | 44 | #include <sys/signal.h> | |
45 | #include <sys/signalvar.h> | 45 | #include <sys/signalvar.h> | |
46 | #include <sys/syscall.h> | 46 | #include <sys/syscall.h> | |
47 | 47 | |||
48 | #include <uvm/uvm_extern.h> | 48 | #include <uvm/uvm_extern.h> | |
49 | 49 | |||
50 | #include <machine/cpu.h> | 50 | #include <machine/cpu.h> | |
@@ -87,88 +87,88 @@ struct linux_user_desc { | @@ -87,88 +87,88 @@ struct linux_user_desc { | |||
87 | #define LINUX_T_INVALID_TSS 10 | 87 | #define LINUX_T_INVALID_TSS 10 | |
88 | #define LINUX_T_SEG_NOT_PRESENT 11 | 88 | #define LINUX_T_SEG_NOT_PRESENT 11 | |
89 | #define LINUX_T_STACK_SEG_FAULT 12 | 89 | #define LINUX_T_STACK_SEG_FAULT 12 | |
90 | #define LINUX_T_GENERAL_PROT_FAULT 13 | 90 | #define LINUX_T_GENERAL_PROT_FAULT 13 | |
91 | #define LINUX_T_PAGE_FAULT 14 | 91 | #define LINUX_T_PAGE_FAULT 14 | |
92 | #define LINUX_T_SPURIOUS_INTERRUPT 15 | 92 | #define LINUX_T_SPURIOUS_INTERRUPT 15 | |
93 | #define LINUX_T_COPROC_ERROR 16 | 93 | #define LINUX_T_COPROC_ERROR 16 | |
94 | #define LINUX_T_ALIGN_CHECK 17 | 94 | #define LINUX_T_ALIGN_CHECK 17 | |
95 | #define LINUX_T_MACHINE_CHECK 18 /* XXX */ | 95 | #define LINUX_T_MACHINE_CHECK 18 /* XXX */ | |
96 | #define LINUX_T_SIMD_COPROC_ERROR 19 /* XXX */ | 96 | #define LINUX_T_SIMD_COPROC_ERROR 19 /* XXX */ | |
97 | 97 | |||
98 | /* Note 255 is bogus */ | 98 | /* Note 255 is bogus */ | |
99 | static const int trapno_to_x86_vec[] = { | 99 | static const int trapno_to_x86_vec[] = { | |
100 | LINUX_T_INVALID_OP, /* 0 T_PRIVINFLT */ | 100 | LINUX_T_INVALID_OP, /* 0 T_PRIVINFLT */ | |
101 | LINUX_T_INT3, /* 1 T_BPTFLT */ | 101 | LINUX_T_INT3, /* 1 T_BPTFLT */ | |
102 | LINUX_T_COPROC_ERROR, /* 2 T_ARITHTRAP */ | 102 | LINUX_T_COPROC_ERROR, /* 2 T_ARITHTRAP */ | |
103 | LINUX_T_SPURIOUS_INTERRUPT, /* 3 T_ASTFLT XXX: ??? */ | 103 | LINUX_T_SPURIOUS_INTERRUPT, /* 3 T_ASTFLT XXX: ??? */ | |
104 | LINUX_T_GENERAL_PROT_FAULT, /* 4 T_PROTFLT */ | 104 | LINUX_T_GENERAL_PROT_FAULT, /* 4 T_PROTFLT */ | |
105 | LINUX_T_DEBUG, /* 5 T_TRCTRAP */ | 105 | LINUX_T_DEBUG, /* 5 T_TRCTRAP */ | |
106 | LINUX_T_PAGE_FAULT, /* 6 T_PAGEFLT */ | 106 | LINUX_T_PAGE_FAULT, /* 6 T_PAGEFLT */ | |
107 | LINUX_T_ALIGN_CHECK, /* 7 T_ALIGNFLT */ | 107 | LINUX_T_ALIGN_CHECK, /* 7 T_ALIGNFLT */ | |
108 | LINUX_T_DIVIDE, /* 8 T_DIVIDE */ | 108 | LINUX_T_DIVIDE, /* 8 T_DIVIDE */ | |
109 | LINUX_T_NMI, /* 9 T_NMI */ | 109 | LINUX_T_NMI, /* 9 T_NMI */ | |
110 | LINUX_T_OVERFLOW, /* 10 T_OFLOW */ | 110 | LINUX_T_OVERFLOW, /* 10 T_OFLOW */ | |
111 | LINUX_T_BOUNDS, /* 11 T_BOUND */ | 111 | LINUX_T_BOUNDS, /* 11 T_BOUND */ | |
112 | LINUX_T_DEVICE_NOT_AVAIL, /* 12 T_DNA */ | 112 | LINUX_T_DEVICE_NOT_AVAIL, /* 12 T_DNA */ | |
113 | LINUX_T_DOUBLE_FAULT, /* 13 T_DOUBLEFLT */ | 113 | LINUX_T_DOUBLE_FAULT, /* 13 T_DOUBLEFLT */ | |
114 | LINUX_T_COPROC_SEG_OVERRUN, /* 14 T_FPOPFLT */ | 114 | LINUX_T_COPROC_SEG_OVERRUN, /* 14 T_FPOPFLT */ | |
115 | LINUX_T_INVALID_TSS, /* 15 T_TSSFLT */ | 115 | LINUX_T_INVALID_TSS, /* 15 T_TSSFLT */ | |
116 | LINUX_T_SEG_NOT_PRESENT, /* 16 T_SEGNPFLT */ | 116 | LINUX_T_SEG_NOT_PRESENT, /* 16 T_SEGNPFLT */ | |
117 | LINUX_T_STACK_SEG_FAULT, /* 17 T_STKFLT */ | 117 | LINUX_T_STACK_SEG_FAULT, /* 17 T_STKFLT */ | |
118 | LINUX_T_MACHINE_CHECK /* 18 T_RESERVED XXX: ??? */ | 118 | LINUX_T_MACHINE_CHECK /* 18 T_RESERVED XXX: ??? */ | |
119 | }; | 119 | }; | |
120 | 120 | |||
121 | /* For the nmi and reserved below linux does not post a signal. */ | 121 | /* For the nmi and reserved below linux does not post a signal. */ | |
122 | static const int linux_x86_vec_to_sig[] = { | 122 | static const int linux_x86_vec_to_sig[] = { | |
123 | SIGFPE, /* 0 LINUX_T_DIVIDE */ | 123 | SIGFPE, /* 0 LINUX_T_DIVIDE */ | |
124 | SIGTRAP, /* 1 LINUX_T_DEBUG */ | 124 | SIGTRAP, /* 1 LINUX_T_DEBUG */ | |
125 | /*nmi*/ SIGSEGV, /* 2 LINUX_T_NMI */ | 125 | /*nmi*/ SIGSEGV, /* 2 LINUX_T_NMI */ | |
126 | SIGTRAP, /* 3 LINUX_T_INT3 */ | 126 | SIGTRAP, /* 3 LINUX_T_INT3 */ | |
127 | SIGSEGV, /* 4 LINUX_T_OVERFLOW */ | 127 | SIGSEGV, /* 4 LINUX_T_OVERFLOW */ | |
128 | SIGSEGV, /* 5 LINUX_T_BOUNDS */ | 128 | SIGSEGV, /* 5 LINUX_T_BOUNDS */ | |
129 | SIGILL, /* 6 LINUX_T_INVALIDOP */ | 129 | SIGILL, /* 6 LINUX_T_INVALIDOP */ | |
130 | SIGSEGV, /* 7 LINUX_T_DEVICE_NOT_AVAIL */ | 130 | SIGSEGV, /* 7 LINUX_T_DEVICE_NOT_AVAIL */ | |
131 | SIGSEGV, /* 8 LINUX_T_DOUBLE_FAULT */ | 131 | SIGSEGV, /* 8 LINUX_T_DOUBLE_FAULT */ | |
132 | SIGFPE, /* 9 LINUX_T_COPROC_SEG_OVERRUN */ | 132 | SIGFPE, /* 9 LINUX_T_COPROC_SEG_OVERRUN */ | |
133 | SIGSEGV, /* 10 LINUX_T_INVALID_TSS */ | 133 | SIGSEGV, /* 10 LINUX_T_INVALID_TSS */ | |
134 | SIGBUS, /* 11 LINUX_T_SEG_NOT_PRESENT */ | 134 | SIGBUS, /* 11 LINUX_T_SEG_NOT_PRESENT */ | |
135 | SIGBUS, /* 12 LINUX_T_STACK_SEG_FAULT */ | 135 | SIGBUS, /* 12 LINUX_T_STACK_SEG_FAULT */ | |
136 | SIGSEGV, /* 13 LINUX_T_GENERAL_PROT_FAULT */ | 136 | SIGSEGV, /* 13 LINUX_T_GENERAL_PROT_FAULT */ | |
137 | SIGSEGV, /* 14 LINUX_T_PAGE_FAULT */ | 137 | SIGSEGV, /* 14 LINUX_T_PAGE_FAULT */ | |
138 | /*resv*/SIGSEGV, /* 15 LINUX_T_SPURIOUS_INTERRUPT */ | 138 | /*resv*/SIGSEGV, /* 15 LINUX_T_SPURIOUS_INTERRUPT */ | |
139 | SIGFPE, /* 16 LINUX_T_COPROC_ERROR */ | 139 | SIGFPE, /* 16 LINUX_T_COPROC_ERROR */ | |
140 | SIGSEGV, /* 17 LINUX_T_ALIGN_CHECK */ | 140 | SIGSEGV, /* 17 LINUX_T_ALIGN_CHECK */ | |
141 | SIGSEGV /* 18 LINUX_T_MACHINE_CHECK */ | 141 | SIGSEGV /* 18 LINUX_T_MACHINE_CHECK */ | |
142 | }; | 142 | }; | |
143 | 143 | |||
144 | void | 144 | void | |
145 | linux_trapsignal(struct lwp *l, ksiginfo_t *ksi) | 145 | linux_trapsignal(struct lwp *l, ksiginfo_t *ksi) | |
146 | { | 146 | { | |
147 | ksiginfo_t nksi; | 147 | ksiginfo_t nksi; | |
148 | 148 | |||
149 | switch (ksi->ksi_signo) { | 149 | switch (ksi->ksi_signo) { | |
150 | case SIGILL: | 150 | case SIGILL: | |
151 | case SIGTRAP: | 151 | case SIGTRAP: | |
152 | case SIGIOT: | 152 | case SIGIOT: | |
153 | case SIGBUS: | 153 | case SIGBUS: | |
154 | case SIGFPE: | 154 | case SIGFPE: | |
155 | case SIGSEGV: | 155 | case SIGSEGV: | |
156 | KASSERT(KSI_TRAP_P(ksi)); | 156 | KASSERT(KSI_TRAP_P(ksi)); | |
157 | if (ksi->ksi_trap < __arraycount(trapno_to_x86_vec)) { | 157 | if (ksi->ksi_trap < __arraycount(trapno_to_x86_vec)) { | |
158 | nksi = *ksi; | 158 | nksi = *ksi; | |
159 | nksi.ksi_trap = trapno_to_x86_vec[ksi->ksi_trap]; | 159 | nksi.ksi_trap = trapno_to_x86_vec[ksi->ksi_trap]; | |
160 | if (nksi.ksi_trap < __arraycount(linux_x86_vec_to_sig)) { | 160 | if (nksi.ksi_trap < __arraycount(linux_x86_vec_to_sig)) { | |
161 | nksi.ksi_signo | 161 | nksi.ksi_signo | |
162 | = linux_x86_vec_to_sig[nksi.ksi_trap]; | 162 | = linux_x86_vec_to_sig[nksi.ksi_trap]; | |
163 | } else { | 163 | } else { | |
164 | uprintf("Unhandled sig type %d\n", | 164 | uprintf("Unhandled sig type %d\n", | |
165 | ksi->ksi_trap); | 165 | ksi->ksi_trap); | |
166 | } | 166 | } | |
167 | ksi = &nksi; | 167 | ksi = &nksi; | |
168 | } else { | 168 | } else { | |
169 | uprintf("Unhandled trap type %d\n", ksi->ksi_trap); | 169 | uprintf("Unhandled trap type %d\n", ksi->ksi_trap); | |
170 | } | 170 | } | |
171 | /*FALLTHROUGH*/ | 171 | /*FALLTHROUGH*/ | |
172 | 172 | |||
173 | default: | 173 | default: | |
174 | trapsignal(l, ksi); | 174 | trapsignal(l, ksi); |
--- src/sys/arch/x86/x86/powernow.c 2020/10/25 16:39:00 1.11
+++ src/sys/arch/x86/x86/powernow.c 2021/10/07 12:52:27 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: powernow.c,v 1.11 2020/10/25 16:39:00 nia Exp $ */ | 1 | /* $NetBSD: powernow.c,v 1.12 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | /* $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */ | 2 | /* $OpenBSD: powernow-k8.c,v 1.8 2006/06/16 05:58:50 gwk Exp $ */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2004, 2006, 2008 The NetBSD Foundation, Inc. | 5 | * Copyright (c) 2004, 2006, 2008 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 Juan Romero Pardines and Martin Vegiard. | 9 | * by Juan Romero Pardines and Martin Vegiard. | |
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 | |
@@ -47,27 +47,27 @@ | @@ -47,27 +47,27 @@ | |||
47 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 47 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 49 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 50 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 51 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 52 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 53 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 54 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 55 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 56 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
57 | */ | 57 | */ | |
58 | 58 | |||
59 | #include <sys/cdefs.h> | 59 | #include <sys/cdefs.h> | |
60 | __KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.11 2020/10/25 16:39:00 nia Exp $"); | 60 | __KERNEL_RCSID(0, "$NetBSD: powernow.c,v 1.12 2021/10/07 12:52:27 msaitoh Exp $"); | |
61 | 61 | |||
62 | #include <sys/param.h> | 62 | #include <sys/param.h> | |
63 | #include <sys/device.h> | 63 | #include <sys/device.h> | |
64 | #include <sys/kmem.h> | 64 | #include <sys/kmem.h> | |
65 | #include <sys/module.h> | 65 | #include <sys/module.h> | |
66 | #include <sys/sysctl.h> | 66 | #include <sys/sysctl.h> | |
67 | #include <sys/xcall.h> | 67 | #include <sys/xcall.h> | |
68 | 68 | |||
69 | #include <dev/isa/isareg.h> | 69 | #include <dev/isa/isareg.h> | |
70 | 70 | |||
71 | #include <x86/cpuvar.h> | 71 | #include <x86/cpuvar.h> | |
72 | #include <x86/cputypes.h> | 72 | #include <x86/cputypes.h> | |
73 | #include <x86/cpu_msr.h> | 73 | #include <x86/cpu_msr.h> | |
@@ -85,27 +85,27 @@ static int powernow_k7_fidtomult[32] = { | @@ -85,27 +85,27 @@ static int powernow_k7_fidtomult[32] = { | |||
85 | 70, 75, 80, 85, 90, 95, 100, 105, | 85 | 70, 75, 80, 85, 90, 95, 100, 105, | |
86 | 30, 190, 40, 200, 130, 135, 140, 210, | 86 | 30, 190, 40, 200, 130, 135, 140, 210, | |
87 | 150, 225, 160, 165, 170, 180, -1, -1 | 87 | 150, 225, 160, 165, 170, 180, -1, -1 | |
88 | }; | 88 | }; | |
89 | 89 | |||
90 | /* | 90 | /* | |
91 | * The following CPUs do not have same CPUID signature | 91 | * The following CPUs do not have same CPUID signature | |
92 | * in the PST tables, but they have correct FID/VID values. | 92 | * in the PST tables, but they have correct FID/VID values. | |
93 | */ | 93 | */ | |
94 | static struct powernow_k7_quirk { | 94 | static struct powernow_k7_quirk { | |
95 | uint32_t rcpusig; /* Correct cpu signature */ | 95 | uint32_t rcpusig; /* Correct cpu signature */ | |
96 | uint32_t pcpusig; /* PST cpu signature */ | 96 | uint32_t pcpusig; /* PST cpu signature */ | |
97 | } powernow_k7_quirk[] = { | 97 | } powernow_k7_quirk[] = { | |
98 | { 0x680, 0x780 }, /* Reported by Olaf 'Rhialto' Seibert */ | 98 | { 0x680, 0x780 }, /* Reported by Olaf 'Rhialto' Seibert */ | |
99 | { 0x6a0, 0x781 }, /* Reported by Eric Schnoebelen */ | 99 | { 0x6a0, 0x781 }, /* Reported by Eric Schnoebelen */ | |
100 | { 0x6a0, 0x7a0 }, /* Reported by Nino Dehne */ | 100 | { 0x6a0, 0x7a0 }, /* Reported by Nino Dehne */ | |
101 | { 0, 0 } | 101 | { 0, 0 } | |
102 | }; | 102 | }; | |
103 | 103 | |||
104 | #endif /* __i386__ */ | 104 | #endif /* __i386__ */ | |
105 | 105 | |||
106 | struct powernow_softc { | 106 | struct powernow_softc { | |
107 | device_t sc_dev; | 107 | device_t sc_dev; | |
108 | struct cpu_info *sc_ci; | 108 | struct cpu_info *sc_ci; | |
109 | struct sysctllog *sc_log; | 109 | struct sysctllog *sc_log; | |
110 | struct powernow_cpu_state *sc_state; | 110 | struct powernow_cpu_state *sc_state; | |
111 | const char *sc_tech; | 111 | const char *sc_tech; | |
@@ -483,27 +483,27 @@ powernow_k7_states(device_t self, unsign | @@ -483,27 +483,27 @@ powernow_k7_states(device_t self, unsign | |||
483 | for (maxpst = 0; maxpst < psb->n_pst; maxpst++) { | 483 | for (maxpst = 0; maxpst < psb->n_pst; maxpst++) { | |
484 | pst = (struct powernow_pst_s*) p; | 484 | pst = (struct powernow_pst_s*) p; | |
485 | 485 | |||
486 | /* | 486 | /* | |
487 | * Some models do not have same CPUID | 487 | * Some models do not have same CPUID | |
488 | * signature in the PST table. Accept to | 488 | * signature in the PST table. Accept to | |
489 | * report frequencies via a quirk table | 489 | * report frequencies via a quirk table | |
490 | * and fid/vid match. | 490 | * and fid/vid match. | |
491 | */ | 491 | */ | |
492 | DPRINTF(("%s: cpusig=0x%x pst->sig:0x%x\n", | 492 | DPRINTF(("%s: cpusig=0x%x pst->sig:0x%x\n", | |
493 | __func__, cpusig, pst->signature)); | 493 | __func__, cpusig, pst->signature)); | |
494 | 494 | |||
495 | cpusig_ok = powernow_k7_check(cpusig, | 495 | cpusig_ok = powernow_k7_check(cpusig, | |
496 | pst->signature); | 496 | pst->signature); | |
497 | 497 | |||
498 | if ((cpusig_ok != false && | 498 | if ((cpusig_ok != false && | |
499 | (fid == pst->fid && vid == pst->vid))) { | 499 | (fid == pst->fid && vid == pst->vid))) { | |
500 | DPRINTF(("%s: pst->signature ok\n", | 500 | DPRINTF(("%s: pst->signature ok\n", | |
501 | __func__)); | 501 | __func__)); | |
502 | if (abs(cstate->fsb - pst->pll) > 5) | 502 | if (abs(cstate->fsb - pst->pll) > 5) | |
503 | continue; | 503 | continue; | |
504 | cstate->n_states = pst->n_states; | 504 | cstate->n_states = pst->n_states; | |
505 | return (powernow_k7_decode_pst(sc, | 505 | return (powernow_k7_decode_pst(sc, | |
506 | p + sizeof(struct powernow_pst_s), | 506 | p + sizeof(struct powernow_pst_s), | |
507 | cstate->n_states)); | 507 | cstate->n_states)); | |
508 | 508 | |||
509 | } | 509 | } | |
@@ -744,27 +744,27 @@ powernow_k8_states(device_t self, unsign | @@ -744,27 +744,27 @@ powernow_k8_states(device_t self, unsign | |||
744 | if (psb->version != 0x14) { | 744 | if (psb->version != 0x14) { | |
745 | DPRINTF(("%s: psb->version != 0x14\n", __func__)); | 745 | DPRINTF(("%s: psb->version != 0x14\n", __func__)); | |
746 | return 0; | 746 | return 0; | |
747 | } | 747 | } | |
748 | 748 | |||
749 | cstate->vst = psb->ttime; | 749 | cstate->vst = psb->ttime; | |
750 | cstate->rvo = PN8_PSB_TO_RVO(psb->reserved); | 750 | cstate->rvo = PN8_PSB_TO_RVO(psb->reserved); | |
751 | cstate->irt = PN8_PSB_TO_IRT(psb->reserved); | 751 | cstate->irt = PN8_PSB_TO_IRT(psb->reserved); | |
752 | cstate->mvs = PN8_PSB_TO_MVS(psb->reserved); | 752 | cstate->mvs = PN8_PSB_TO_MVS(psb->reserved); | |
753 | cstate->low = PN8_PSB_TO_BATT(psb->reserved); | 753 | cstate->low = PN8_PSB_TO_BATT(psb->reserved); | |
754 | 754 | |||
755 | p += sizeof(struct powernow_psb_s); | 755 | p += sizeof(struct powernow_psb_s); | |
756 | 756 | |||
757 | for(i = 0; i < psb->n_pst; ++i) { | 757 | for (i = 0; i < psb->n_pst; ++i) { | |
758 | 758 | |||
759 | pst = (struct powernow_pst_s *)p; | 759 | pst = (struct powernow_pst_s *)p; | |
760 | 760 | |||
761 | cstate->pll = pst->pll; | 761 | cstate->pll = pst->pll; | |
762 | cstate->n_states = pst->n_states; | 762 | cstate->n_states = pst->n_states; | |
763 | 763 | |||
764 | if (cpusig == pst->signature && | 764 | if (cpusig == pst->signature && | |
765 | pst->fid == fid && pst->vid == vid) { | 765 | pst->fid == fid && pst->vid == vid) { | |
766 | 766 | |||
767 | DPRINTF(("%s: cpusig = sig\n", __func__)); | 767 | DPRINTF(("%s: cpusig = sig\n", __func__)); | |
768 | 768 | |||
769 | return (powernow_k8_decode_pst(cstate, | 769 | return (powernow_k8_decode_pst(cstate, | |
770 | p+= sizeof(struct powernow_pst_s))); | 770 | p+= sizeof(struct powernow_pst_s))); |
--- src/sys/arch/x86/x86/Attic/efi.c 2019/12/10 02:06:07 1.21
+++ src/sys/arch/x86/x86/Attic/efi.c 2021/10/07 12:52:27 1.22
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: efi.c,v 1.21 2019/12/10 02:06:07 manu Exp $ */ | 1 | /* $NetBSD: efi.c,v 1.22 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2016 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2016 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,78 +17,78 @@ | @@ -17,78 +17,78 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.21 2019/12/10 02:06:07 manu Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: efi.c,v 1.22 2021/10/07 12:52:27 msaitoh Exp $"); | |
31 | 31 | |||
32 | #include <sys/kmem.h> | 32 | #include <sys/kmem.h> | |
33 | #include <sys/param.h> | 33 | #include <sys/param.h> | |
34 | #include <sys/systm.h> | 34 | #include <sys/systm.h> | |
35 | #include <sys/uuid.h> | 35 | #include <sys/uuid.h> | |
36 | 36 | |||
37 | #include <uvm/uvm_extern.h> | 37 | #include <uvm/uvm_extern.h> | |
38 | 38 | |||
39 | #include <machine/bootinfo.h> | 39 | #include <machine/bootinfo.h> | |
40 | #include <x86/bus_defs.h> | 40 | #include <x86/bus_defs.h> | |
41 | #include <x86/bus_funcs.h> | 41 | #include <x86/bus_funcs.h> | |
42 | #include <x86/efi.h> | 42 | #include <x86/efi.h> | |
43 | 43 | |||
44 | #include <dev/mm.h> | 44 | #include <dev/mm.h> | |
45 | #if NPCI > 0 | 45 | #if NPCI > 0 | |
46 | #include <dev/pci/pcivar.h> /* for pci_mapreg_map_enable_decode */ | 46 | #include <dev/pci/pcivar.h> /* for pci_mapreg_map_enable_decode */ | |
47 | #endif | 47 | #endif | |
48 | 48 | |||
49 | const struct uuid EFI_UUID_ACPI20 = EFI_TABLE_ACPI20; | 49 | const struct uuid EFI_UUID_ACPI20 = EFI_TABLE_ACPI20; | |
50 | const struct uuid EFI_UUID_ACPI10 = EFI_TABLE_ACPI10; | 50 | const struct uuid EFI_UUID_ACPI10 = EFI_TABLE_ACPI10; | |
51 | const struct uuid EFI_UUID_SMBIOS = EFI_TABLE_SMBIOS; | 51 | const struct uuid EFI_UUID_SMBIOS = EFI_TABLE_SMBIOS; | |
52 | const struct uuid EFI_UUID_SMBIOS3 = EFI_TABLE_SMBIOS3; | 52 | const struct uuid EFI_UUID_SMBIOS3 = EFI_TABLE_SMBIOS3; | |
53 | 53 | |||
54 | static vaddr_t efi_getva(paddr_t); | 54 | static vaddr_t efi_getva(paddr_t); | |
55 | static void efi_relva(paddr_t, vaddr_t); | 55 | static void efi_relva(paddr_t, vaddr_t); | |
56 | struct efi_cfgtbl *efi_getcfgtblhead(void); | 56 | struct efi_cfgtbl *efi_getcfgtblhead(void); | |
57 | void efi_aprintcfgtbl(void); | 57 | void efi_aprintcfgtbl(void); | |
58 | void efi_aprintuuid(const struct uuid *); | 58 | void efi_aprintuuid(const struct uuid *); | |
59 | bool efi_uuideq(const struct uuid *, const struct uuid *); | 59 | bool efi_uuideq(const struct uuid *, const struct uuid *); | |
60 | 60 | |||
61 | static bool efi_is32x64 = false; | 61 | static bool efi_is32x64 = false; | |
62 | static paddr_t efi_systbl_pa; | 62 | static paddr_t efi_systbl_pa; | |
63 | static struct efi_systbl *efi_systbl_va = NULL; | 63 | static struct efi_systbl *efi_systbl_va = NULL; | |
64 | static struct efi_cfgtbl *efi_cfgtblhead_va = NULL; | 64 | static struct efi_cfgtbl *efi_cfgtblhead_va = NULL; | |
65 | static struct efi_e820memmap { | 65 | static struct efi_e820memmap { | |
66 | struct btinfo_memmap bim; | 66 | struct btinfo_memmap bim; | |
67 | struct bi_memmap_entry entry[VM_PHYSSEG_MAX - 1]; | 67 | struct bi_memmap_entry entry[VM_PHYSSEG_MAX - 1]; | |
68 | } efi_e820memmap; | 68 | } efi_e820memmap; | |
69 | 69 | |||
70 | /* | 70 | /* | |
71 | * Map a physical address (PA) to a newly allocated virtual address (VA). | 71 | * Map a physical address (PA) to a newly allocated virtual address (VA). | |
72 | * The VA must be freed using efi_relva(). | 72 | * The VA must be freed using efi_relva(). | |
73 | */ | 73 | */ | |
74 | static vaddr_t | 74 | static vaddr_t | |
75 | efi_getva(paddr_t pa) | 75 | efi_getva(paddr_t pa) | |
76 | { | 76 | { | |
77 | vaddr_t va; | 77 | vaddr_t va; | |
78 | int rv; | 78 | int rv; | |
79 | 79 | |||
80 | rv = _x86_memio_map(x86_bus_space_mem, pa, | 80 | rv = _x86_memio_map(x86_bus_space_mem, pa, | |
81 | PAGE_SIZE, 0, (bus_space_handle_t *)&va); | 81 | PAGE_SIZE, 0, (bus_space_handle_t *)&va); | |
82 | if (rv != 0) { | 82 | if (rv != 0) { | |
83 | aprint_debug("efi: unable to allocate va\n"); | 83 | aprint_debug("efi: unable to allocate va\n"); | |
84 | return 0; | 84 | return 0; | |
85 | } | 85 | } | |
86 | 86 | |||
87 | return va; | 87 | return va; | |
88 | } | 88 | } | |
89 | 89 | |||
90 | /* | 90 | /* | |
91 | * Free a virtual address (VA) allocated using efi_getva(). | 91 | * Free a virtual address (VA) allocated using efi_getva(). | |
92 | */ | 92 | */ | |
93 | static void | 93 | static void | |
94 | efi_relva(paddr_t pa, vaddr_t va) | 94 | efi_relva(paddr_t pa, vaddr_t va) | |
@@ -395,27 +395,27 @@ efi_init(void) | @@ -395,27 +395,27 @@ efi_init(void) | |||
395 | 395 | |||
396 | if (efi_getsystbl() == NULL) { | 396 | if (efi_getsystbl() == NULL) { | |
397 | aprint_debug("efi: missing or invalid systbl\n"); | 397 | aprint_debug("efi: missing or invalid systbl\n"); | |
398 | bootmethod_efi = false; | 398 | bootmethod_efi = false; | |
399 | return; | 399 | return; | |
400 | } | 400 | } | |
401 | if (efi_getcfgtblhead() == NULL) { | 401 | if (efi_getcfgtblhead() == NULL) { | |
402 | aprint_debug("efi: missing or invalid cfgtbl\n"); | 402 | aprint_debug("efi: missing or invalid cfgtbl\n"); | |
403 | efi_relva(efi_systbl_pa, (vaddr_t) efi_systbl_va); | 403 | efi_relva(efi_systbl_pa, (vaddr_t) efi_systbl_va); | |
404 | bootmethod_efi = false; | 404 | bootmethod_efi = false; | |
405 | return; | 405 | return; | |
406 | } | 406 | } | |
407 | bootmethod_efi = true; | 407 | bootmethod_efi = true; | |
408 | #if NPCI > 0 | 408 | #if NPCI > 0 | |
409 | pci_mapreg_map_enable_decode = true; /* PR port-amd64/53286 */ | 409 | pci_mapreg_map_enable_decode = true; /* PR port-amd64/53286 */ | |
410 | #endif | 410 | #endif | |
411 | } | 411 | } | |
412 | 412 | |||
413 | bool | 413 | bool | |
414 | efi_probe(void) | 414 | efi_probe(void) | |
415 | { | 415 | { | |
416 | 416 | |||
417 | return bootmethod_efi; | 417 | return bootmethod_efi; | |
418 | } | 418 | } | |
419 | 419 | |||
420 | int | 420 | int | |
421 | efi_getbiosmemtype(uint32_t type, uint64_t attr) | 421 | efi_getbiosmemtype(uint32_t type, uint64_t attr) |
--- src/sys/arch/x86/x86/errata.c 2019/05/18 07:49:31 1.26
+++ src/sys/arch/x86/x86/errata.c 2021/10/07 12:52:27 1.27
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: errata.c,v 1.26 2019/05/18 07:49:31 maxv Exp $ */ | 1 | /* $NetBSD: errata.c,v 1.27 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 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 Andrew Doran. | 8 | * 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. | |
@@ -35,27 +35,27 @@ | @@ -35,27 +35,27 @@ | |||
35 | * This currently only handles AMD CPUs, and is generalised because | 35 | * This currently only handles AMD CPUs, and is generalised because | |
36 | * there are quite a few problems that the BIOS can patch via MSR, | 36 | * there are quite a few problems that the BIOS can patch via MSR, | |
37 | * but it is not known if the OS can patch these yet. The list is | 37 | * but it is not known if the OS can patch these yet. The list is | |
38 | * expected to grow over time. | 38 | * expected to grow over time. | |
39 | * | 39 | * | |
40 | * The data here are from: Revision Guide for AMD Athlon 64 and | 40 | * The data here are from: Revision Guide for AMD Athlon 64 and | |
41 | * AMD Opteron Processors, Publication #25759, Revision: 3.69, | 41 | * AMD Opteron Processors, Publication #25759, Revision: 3.69, | |
42 | * Issue Date: September 2006 | 42 | * Issue Date: September 2006 | |
43 | * | 43 | * | |
44 | * XXX This should perhaps be integrated with the identcpu code. | 44 | * XXX This should perhaps be integrated with the identcpu code. | |
45 | */ | 45 | */ | |
46 | 46 | |||
47 | #include <sys/cdefs.h> | 47 | #include <sys/cdefs.h> | |
48 | __KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.26 2019/05/18 07:49:31 maxv Exp $"); | 48 | __KERNEL_RCSID(0, "$NetBSD: errata.c,v 1.27 2021/10/07 12:52:27 msaitoh Exp $"); | |
49 | 49 | |||
50 | #include <sys/types.h> | 50 | #include <sys/types.h> | |
51 | #include <sys/systm.h> | 51 | #include <sys/systm.h> | |
52 | 52 | |||
53 | #include <machine/cpu.h> | 53 | #include <machine/cpu.h> | |
54 | #include <machine/cpufunc.h> | 54 | #include <machine/cpufunc.h> | |
55 | #include <machine/specialreg.h> | 55 | #include <machine/specialreg.h> | |
56 | 56 | |||
57 | #include <x86/cpuvar.h> | 57 | #include <x86/cpuvar.h> | |
58 | #include <x86/cputypes.h> | 58 | #include <x86/cputypes.h> | |
59 | 59 | |||
60 | typedef struct errata { | 60 | typedef struct errata { | |
61 | u_short e_num; | 61 | u_short e_num; | |
@@ -117,27 +117,27 @@ static const uint8_t x86_errata_set5[] = | @@ -117,27 +117,27 @@ static const uint8_t x86_errata_set5[] = | |||
117 | }; | 117 | }; | |
118 | 118 | |||
119 | static const uint8_t x86_errata_set6[] = { | 119 | static const uint8_t x86_errata_set6[] = { | |
120 | SH_C0, SH_CG, DH_CG, CH_CG, OINK | 120 | SH_C0, SH_CG, DH_CG, CH_CG, OINK | |
121 | }; | 121 | }; | |
122 | 122 | |||
123 | static const uint8_t x86_errata_set7[] = { | 123 | static const uint8_t x86_errata_set7[] = { | |
124 | SH_C0, SH_CG, DH_CG, CH_CG, SH_D0, DH_D0, CH_D0, OINK | 124 | SH_C0, SH_CG, DH_CG, CH_CG, SH_D0, DH_D0, CH_D0, OINK | |
125 | }; | 125 | }; | |
126 | 126 | |||
127 | static const uint8_t x86_errata_set8[] = { | 127 | static const uint8_t x86_errata_set8[] = { | |
128 | BH_E4, CH_CG, CH_CG, CH_D0, CH_D0, DH_CG, DH_CG, DH_CG, | 128 | BH_E4, CH_CG, CH_CG, CH_D0, CH_D0, DH_CG, DH_CG, DH_CG, | |
129 | DH_D0, DH_D0, DH_E3, DH_E3, DH_E6, DH_E6, JH_E1, JH_E6, | 129 | DH_D0, DH_D0, DH_E3, DH_E3, DH_E6, DH_E6, JH_E1, JH_E6, | |
130 | JH_E6, SH_B0, SH_B3, SH_C0, SH_C0, SH_CG, SH_CG, SH_CG, | 130 | JH_E6, SH_B0, SH_B3, SH_C0, SH_C0, SH_CG, SH_CG, SH_CG, | |
131 | SH_D0, SH_D0, SH_D0, SH_E4, SH_E4, SH_E5, OINK | 131 | SH_D0, SH_D0, SH_D0, SH_E4, SH_E4, SH_E5, OINK | |
132 | }; | 132 | }; | |
133 | 133 | |||
134 | static const uint8_t x86_errata_set9[] = { | 134 | static const uint8_t x86_errata_set9[] = { | |
135 | DR_BA, DR_B2, OINK | 135 | DR_BA, DR_B2, OINK | |
136 | }; | 136 | }; | |
137 | 137 | |||
138 | static const uint8_t x86_errata_set10[] = { | 138 | static const uint8_t x86_errata_set10[] = { | |
139 | DR_BA, DR_B2, DR_B3, OINK | 139 | DR_BA, DR_B2, DR_B3, OINK | |
140 | }; | 140 | }; | |
141 | 141 | |||
142 | static const uint8_t x86_errata_set11[] = { | 142 | static const uint8_t x86_errata_set11[] = { | |
143 | DR_BA, DR_B2, DR_B3, RB_C2, RB_C3, BL_C2, BL_C3, DA_C2, | 143 | DR_BA, DR_B2, DR_B3, RB_C2, RB_C3, BL_C2, BL_C3, DA_C2, | |
@@ -351,42 +351,42 @@ static errata_t errata[] = { | @@ -351,42 +351,42 @@ static errata_t errata[] = { | |||
351 | x86_errata_setmsr, LS_CFG2_ERRATA_1091 | 351 | x86_errata_setmsr, LS_CFG2_ERRATA_1091 | |
352 | }, | 352 | }, | |
353 | #endif | 353 | #endif | |
354 | /* | 354 | /* | |
355 | * 1095: Potential Violation of Read Ordering In Lock Operation | 355 | * 1095: Potential Violation of Read Ordering In Lock Operation | |
356 | * In SMT (Simultaneous Multithreading) Mode | 356 | * In SMT (Simultaneous Multithreading) Mode | |
357 | */ | 357 | */ | |
358 | { | 358 | { | |
359 | 1095, FALSE, MSR_LS_CFG, x86_errata_set13, | 359 | 1095, FALSE, MSR_LS_CFG, x86_errata_set13, | |
360 | x86_errata_setmsr, LS_CFG_ERRATA_1095 | 360 | x86_errata_setmsr, LS_CFG_ERRATA_1095 | |
361 | }, | 361 | }, | |
362 | }; | 362 | }; | |
363 | 363 | |||
364 | static bool | 364 | static bool | |
365 | x86_errata_testmsr(struct cpu_info *ci, errata_t *e) | 365 | x86_errata_testmsr(struct cpu_info *ci, errata_t *e) | |
366 | { | 366 | { | |
367 | uint64_t val; | 367 | uint64_t val; | |
368 | 368 | |||
369 | (void)ci; | 369 | (void)ci; | |
370 | 370 | |||
371 | val = rdmsr_locked(e->e_data1); | 371 | val = rdmsr_locked(e->e_data1); | |
372 | if ((val & e->e_data2) != 0) | 372 | if ((val & e->e_data2) != 0) | |
373 | return FALSE; | 373 | return FALSE; | |
374 | 374 | |||
375 | e->e_reported = TRUE; | 375 | e->e_reported = TRUE; | |
376 | return TRUE; | 376 | return TRUE; | |
377 | } | 377 | } | |
378 | 378 | |||
379 | static bool | 379 | static bool | |
380 | x86_errata_setmsr(struct cpu_info *ci, errata_t *e) | 380 | x86_errata_setmsr(struct cpu_info *ci, errata_t *e) | |
381 | { | 381 | { | |
382 | uint64_t val; | 382 | uint64_t val; | |
383 | 383 | |||
384 | (void)ci; | 384 | (void)ci; | |
385 | 385 | |||
386 | val = rdmsr_locked(e->e_data1); | 386 | val = rdmsr_locked(e->e_data1); | |
387 | if ((val & e->e_data2) != 0) | 387 | if ((val & e->e_data2) != 0) | |
388 | return FALSE; | 388 | return FALSE; | |
389 | wrmsr_locked(e->e_data1, val | e->e_data2); | 389 | wrmsr_locked(e->e_data1, val | e->e_data2); | |
390 | aprint_debug_dev(ci->ci_dev, "erratum %d patched\n", | 390 | aprint_debug_dev(ci->ci_dev, "erratum %d patched\n", | |
391 | e->e_num); | 391 | e->e_num); | |
392 | 392 |
--- src/sys/arch/x86/x86/est.c 2020/10/25 16:39:00 1.32
+++ src/sys/arch/x86/x86/est.c 2021/10/07 12:52:27 1.33
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: est.c,v 1.32 2020/10/25 16:39:00 nia Exp $ */ | 1 | /* $NetBSD: est.c,v 1.33 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2003 Michael Eriksson. | 3 | * Copyright (c) 2003 Michael Eriksson. | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
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 | * 3. The name of the author may not be used to endorse or promote products | 14 | * 3. The name of the author may not be used to endorse or promote products | |
@@ -66,27 +66,27 @@ | @@ -66,27 +66,27 @@ | |||
66 | * - Intel Pentium M Processor Datasheet. | 66 | * - Intel Pentium M Processor Datasheet. | |
67 | * Table 5, Voltage and Current Specifications. | 67 | * Table 5, Voltage and Current Specifications. | |
68 | * http://www.intel.com/design/mobile/datashts/252612.htm | 68 | * http://www.intel.com/design/mobile/datashts/252612.htm | |
69 | * | 69 | * | |
70 | * - Intel Pentium M Processor on 90 nm Process with 2-MB L2 Cache Datasheet | 70 | * - Intel Pentium M Processor on 90 nm Process with 2-MB L2 Cache Datasheet | |
71 | * Table 3-4, 3-5, 3-6, Voltage and Current Specifications. | 71 | * Table 3-4, 3-5, 3-6, Voltage and Current Specifications. | |
72 | * http://www.intel.com/design/mobile/datashts/302189.htm | 72 | * http://www.intel.com/design/mobile/datashts/302189.htm | |
73 | * | 73 | * | |
74 | * - Linux cpufreq patches, speedstep-centrino.c. | 74 | * - Linux cpufreq patches, speedstep-centrino.c. | |
75 | * Encoding of MSR_PERF_CTL and MSR_PERF_STATUS. | 75 | * Encoding of MSR_PERF_CTL and MSR_PERF_STATUS. | |
76 | * http://www.codemonkey.org.uk/projects/cpufreq/cpufreq-2.4.22-pre6-1.gz | 76 | * http://www.codemonkey.org.uk/projects/cpufreq/cpufreq-2.4.22-pre6-1.gz | |
77 | */ | 77 | */ | |
78 | #include <sys/cdefs.h> | 78 | #include <sys/cdefs.h> | |
79 | __KERNEL_RCSID(0, "$NetBSD: est.c,v 1.32 2020/10/25 16:39:00 nia Exp $"); | 79 | __KERNEL_RCSID(0, "$NetBSD: est.c,v 1.33 2021/10/07 12:52:27 msaitoh Exp $"); | |
80 | 80 | |||
81 | #include <sys/param.h> | 81 | #include <sys/param.h> | |
82 | #include <sys/device.h> | 82 | #include <sys/device.h> | |
83 | #include <sys/kmem.h> | 83 | #include <sys/kmem.h> | |
84 | #include <sys/module.h> | 84 | #include <sys/module.h> | |
85 | #include <sys/sysctl.h> | 85 | #include <sys/sysctl.h> | |
86 | #include <sys/xcall.h> | 86 | #include <sys/xcall.h> | |
87 | 87 | |||
88 | #include <x86/cpuvar.h> | 88 | #include <x86/cpuvar.h> | |
89 | #include <x86/cputypes.h> | 89 | #include <x86/cputypes.h> | |
90 | #include <x86/cpu_msr.h> | 90 | #include <x86/cpu_msr.h> | |
91 | #include <x86/est.h> | 91 | #include <x86/est.h> | |
92 | #include <x86/specialreg.h> | 92 | #include <x86/specialreg.h> | |
@@ -1196,30 +1196,30 @@ est_tables(device_t self) | @@ -1196,30 +1196,30 @@ est_tables(device_t self) | |||
1196 | aprint_normal_dev(self, "idlo = 0x%x\n", idlo); | 1196 | aprint_normal_dev(self, "idlo = 0x%x\n", idlo); | |
1197 | aprint_normal_dev(self, "lo %4d mV, %4d MHz\n", | 1197 | aprint_normal_dev(self, "lo %4d mV, %4d MHz\n", | |
1198 | MSR2MV(idlo), MSR2MHZ(idlo, sc->sc_bus_clock)); | 1198 | MSR2MV(idlo), MSR2MHZ(idlo, sc->sc_bus_clock)); | |
1199 | aprint_normal_dev(self, "raw %4d , %4d \n", | 1199 | aprint_normal_dev(self, "raw %4d , %4d \n", | |
1200 | (idlo & 0xff), ((idlo >> 8) & 0xff)); | 1200 | (idlo & 0xff), ((idlo >> 8) & 0xff)); | |
1201 | aprint_normal_dev(self, "idhi = 0x%x\n", idhi); | 1201 | aprint_normal_dev(self, "idhi = 0x%x\n", idhi); | |
1202 | aprint_normal_dev(self, "hi %4d mV, %4d MHz\n", | 1202 | aprint_normal_dev(self, "hi %4d mV, %4d MHz\n", | |
1203 | MSR2MV(idhi), MSR2MHZ(idhi, sc->sc_bus_clock)); | 1203 | MSR2MV(idhi), MSR2MHZ(idhi, sc->sc_bus_clock)); | |
1204 | aprint_normal_dev(self, "raw %4d , %4d \n", | 1204 | aprint_normal_dev(self, "raw %4d , %4d \n", | |
1205 | (idhi & 0xff), ((idhi >> 8) & 0xff)); | 1205 | (idhi & 0xff), ((idhi >> 8) & 0xff)); | |
1206 | aprint_normal_dev(self, "cur = 0x%x\n", cur); | 1206 | aprint_normal_dev(self, "cur = 0x%x\n", cur); | |
1207 | #endif | 1207 | #endif | |
1208 | 1208 | |||
1209 | /* | 1209 | /* | |
1210 | * Generate a fake table with the power states we know, | 1210 | * Generate a fake table with the power states we know, | |
1211 | * interpolating the voltages and frequencies between the | 1211 | * interpolating the voltages and frequencies between the | |
1212 | * high and low values. The (milli)voltages are always | 1212 | * high and low values. The (milli)voltages are always | |
1213 | * rounded up when computing the table. | 1213 | * rounded up when computing the table. | |
1214 | */ | 1214 | */ | |
1215 | minfreq = MSR2FREQINC(idlo); | 1215 | minfreq = MSR2FREQINC(idlo); | |
1216 | maxfreq = MSR2FREQINC(idhi); | 1216 | maxfreq = MSR2FREQINC(idhi); | |
1217 | minvolt = MSR2VOLTINC(idlo); | 1217 | minvolt = MSR2VOLTINC(idlo); | |
1218 | maxvolt = MSR2VOLTINC(idhi); | 1218 | maxvolt = MSR2VOLTINC(idhi); | |
1219 | freqinc = maxfreq - minfreq; | 1219 | freqinc = maxfreq - minfreq; | |
1220 | voltinc = maxvolt - minvolt; | 1220 | voltinc = maxvolt - minvolt; | |
1221 | 1221 | |||
1222 | /* Avoid diving by zero. */ | 1222 | /* Avoid diving by zero. */ | |
1223 | if (freqinc == 0) | 1223 | if (freqinc == 0) | |
1224 | return false; | 1224 | return false; | |
1225 | 1225 |
--- src/sys/arch/x86/x86/identcpu.c 2021/04/12 02:23:01 1.121
+++ src/sys/arch/x86/x86/identcpu.c 2021/10/07 12:52:27 1.122
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: identcpu.c,v 1.121 2021/04/12 02:23:01 mrg Exp $ */ | 1 | /* $NetBSD: identcpu.c,v 1.122 2021/10/07 12:52:27 msaitoh 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.121 2021/04/12 02:23:01 mrg Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.122 2021/10/07 12:52:27 msaitoh 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 <crypto/aes/aes_impl.h> | 42 | #include <crypto/aes/aes_impl.h> | |
43 | #include <crypto/aes/arch/x86/aes_ni.h> | 43 | #include <crypto/aes/arch/x86/aes_ni.h> | |
44 | #include <crypto/aes/arch/x86/aes_sse2.h> | 44 | #include <crypto/aes/arch/x86/aes_sse2.h> | |
45 | #include <crypto/aes/arch/x86/aes_ssse3.h> | 45 | #include <crypto/aes/arch/x86/aes_ssse3.h> | |
46 | #include <crypto/aes/arch/x86/aes_via.h> | 46 | #include <crypto/aes/arch/x86/aes_via.h> | |
@@ -538,27 +538,27 @@ cpu_probe_winchip(struct cpu_info *ci) | @@ -538,27 +538,27 @@ cpu_probe_winchip(struct cpu_info *ci) | |||
538 | /* WinChip C6 */ | 538 | /* WinChip C6 */ | |
539 | if (CPUID_TO_MODEL(ci->ci_signature) == 4) | 539 | if (CPUID_TO_MODEL(ci->ci_signature) == 4) | |
540 | ci->ci_feat_val[0] &= ~CPUID_TSC; | 540 | ci->ci_feat_val[0] &= ~CPUID_TSC; | |
541 | } | 541 | } | |
542 | 542 | |||
543 | static void | 543 | static void | |
544 | cpu_probe_c3(struct cpu_info *ci) | 544 | cpu_probe_c3(struct cpu_info *ci) | |
545 | { | 545 | { | |
546 | u_int family, model, stepping, descs[4], lfunc, msr; | 546 | u_int family, model, stepping, descs[4], lfunc, msr; | |
547 | struct x86_cache_info *cai; | 547 | struct x86_cache_info *cai; | |
548 | 548 | |||
549 | if (cpu_vendor != CPUVENDOR_IDT || | 549 | if (cpu_vendor != CPUVENDOR_IDT || | |
550 | CPUID_TO_FAMILY(ci->ci_signature) < 6) | 550 | CPUID_TO_FAMILY(ci->ci_signature) < 6) | |
551 | return; | 551 | return; | |
552 | 552 | |||
553 | family = CPUID_TO_FAMILY(ci->ci_signature); | 553 | family = CPUID_TO_FAMILY(ci->ci_signature); | |
554 | model = CPUID_TO_MODEL(ci->ci_signature); | 554 | model = CPUID_TO_MODEL(ci->ci_signature); | |
555 | stepping = CPUID_TO_STEPPING(ci->ci_signature); | 555 | stepping = CPUID_TO_STEPPING(ci->ci_signature); | |
556 | 556 | |||
557 | /* Determine the largest extended function value. */ | 557 | /* Determine the largest extended function value. */ | |
558 | x86_cpuid(0x80000000, descs); | 558 | x86_cpuid(0x80000000, descs); | |
559 | lfunc = descs[0]; | 559 | lfunc = descs[0]; | |
560 | 560 | |||
561 | if (family == 6) { | 561 | if (family == 6) { | |
562 | /* | 562 | /* | |
563 | * VIA Eden ESP. | 563 | * VIA Eden ESP. | |
564 | * | 564 | * | |
@@ -576,27 +576,27 @@ cpu_probe_c3(struct cpu_info *ci) | @@ -576,27 +576,27 @@ cpu_probe_c3(struct cpu_info *ci) | |||
576 | } | 576 | } | |
577 | 577 | |||
578 | if (family > 6 || model > 0x9 || (model == 0x9 && stepping >= 3)) { | 578 | if (family > 6 || model > 0x9 || (model == 0x9 && stepping >= 3)) { | |
579 | /* VIA Nehemiah or Esther. */ | 579 | /* VIA Nehemiah or Esther. */ | |
580 | x86_cpuid(0xc0000000, descs); | 580 | x86_cpuid(0xc0000000, descs); | |
581 | lfunc = descs[0]; | 581 | lfunc = descs[0]; | |
582 | if (lfunc >= 0xc0000001) { /* has ACE, RNG */ | 582 | if (lfunc >= 0xc0000001) { /* has ACE, RNG */ | |
583 | int rng_enable = 0, ace_enable = 0; | 583 | int rng_enable = 0, ace_enable = 0; | |
584 | x86_cpuid(0xc0000001, descs); | 584 | x86_cpuid(0xc0000001, descs); | |
585 | lfunc = descs[3]; | 585 | lfunc = descs[3]; | |
586 | ci->ci_feat_val[4] = lfunc; | 586 | ci->ci_feat_val[4] = lfunc; | |
587 | /* Check for and enable RNG */ | 587 | /* Check for and enable RNG */ | |
588 | if (lfunc & CPUID_VIA_HAS_RNG) { | 588 | if (lfunc & CPUID_VIA_HAS_RNG) { | |
589 | if (!(lfunc & CPUID_VIA_DO_RNG)) { | 589 | if (!(lfunc & CPUID_VIA_DO_RNG)) { | |
590 | rng_enable++; | 590 | rng_enable++; | |
591 | ci->ci_feat_val[4] |= CPUID_VIA_DO_RNG; | 591 | ci->ci_feat_val[4] |= CPUID_VIA_DO_RNG; | |
592 | } | 592 | } | |
593 | } | 593 | } | |
594 | /* Check for and enable ACE (AES-CBC) */ | 594 | /* Check for and enable ACE (AES-CBC) */ | |
595 | if (lfunc & CPUID_VIA_HAS_ACE) { | 595 | if (lfunc & CPUID_VIA_HAS_ACE) { | |
596 | if (!(lfunc & CPUID_VIA_DO_ACE)) { | 596 | if (!(lfunc & CPUID_VIA_DO_ACE)) { | |
597 | ace_enable++; | 597 | ace_enable++; | |
598 | ci->ci_feat_val[4] |= CPUID_VIA_DO_ACE; | 598 | ci->ci_feat_val[4] |= CPUID_VIA_DO_ACE; | |
599 | } | 599 | } | |
600 | } | 600 | } | |
601 | /* Check for and enable SHA */ | 601 | /* Check for and enable SHA */ | |
602 | if (lfunc & CPUID_VIA_HAS_PHE) { | 602 | if (lfunc & CPUID_VIA_HAS_PHE) { | |
@@ -1125,27 +1125,27 @@ static const struct vm_name_guest vm_sys | @@ -1125,27 +1125,27 @@ static const struct vm_name_guest vm_sys | |||
1125 | { "VirtualBox", VM_GUEST_VIRTUALBOX }, /* Sun xVM VirtualBox */ | 1125 | { "VirtualBox", VM_GUEST_VIRTUALBOX }, /* Sun xVM VirtualBox */ | |
1126 | { "Parallels Virtual Platform", VM_GUEST_VM }, /* Parallels VM */ | 1126 | { "Parallels Virtual Platform", VM_GUEST_VM }, /* Parallels VM */ | |
1127 | { "KVM", VM_GUEST_VM }, /* KVM */ | 1127 | { "KVM", VM_GUEST_VM }, /* KVM */ | |
1128 | }; | 1128 | }; | |
1129 | 1129 | |||
1130 | void | 1130 | void | |
1131 | identify_hypervisor(void) | 1131 | identify_hypervisor(void) | |
1132 | { | 1132 | { | |
1133 | u_int regs[6]; | 1133 | u_int regs[6]; | |
1134 | char hv_vendor[12]; | 1134 | char hv_vendor[12]; | |
1135 | const char *p; | 1135 | const char *p; | |
1136 | int i; | 1136 | int i; | |
1137 | 1137 | |||
1138 | switch(vm_guest) { | 1138 | switch (vm_guest) { | |
1139 | case VM_GUEST_XENPV: | 1139 | case VM_GUEST_XENPV: | |
1140 | case VM_GUEST_XENPVH: | 1140 | case VM_GUEST_XENPVH: | |
1141 | /* guest type already known, no bios info */ | 1141 | /* guest type already known, no bios info */ | |
1142 | return; | 1142 | return; | |
1143 | default: | 1143 | default: | |
1144 | break; | 1144 | break; | |
1145 | } | 1145 | } | |
1146 | 1146 | |||
1147 | /* | 1147 | /* | |
1148 | * [RFC] CPUID usage for interaction between Hypervisors and Linux. | 1148 | * [RFC] CPUID usage for interaction between Hypervisors and Linux. | |
1149 | * http://lkml.org/lkml/2008/10/1/246 | 1149 | * http://lkml.org/lkml/2008/10/1/246 | |
1150 | * | 1150 | * | |
1151 | * KB1009458: Mechanisms to determine if software is running in | 1151 | * KB1009458: Mechanisms to determine if software is running in |
--- src/sys/arch/x86/x86/intel_busclock.c 2015/07/02 05:11:50 1.24
+++ src/sys/arch/x86/x86/intel_busclock.c 2021/10/07 12:52:27 1.25
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intel_busclock.c,v 1.24 2015/07/02 05:11:50 msaitoh Exp $ */ | 1 | /* $NetBSD: intel_busclock.c,v 1.25 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999, 2000, 2001 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: intel_busclock.c,v 1.24 2015/07/02 05:11:50 msaitoh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: intel_busclock.c,v 1.25 2021/10/07 12:52:27 msaitoh Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/device.h> | 37 | #include <sys/device.h> | |
38 | #include <sys/cpu.h> | 38 | #include <sys/cpu.h> | |
39 | 39 | |||
40 | #include <machine/specialreg.h> | 40 | #include <machine/specialreg.h> | |
41 | #include <machine/pio.h> | 41 | #include <machine/pio.h> | |
42 | 42 | |||
43 | #include <x86/cpuvar.h> | 43 | #include <x86/cpuvar.h> | |
44 | #include <x86/cpufunc.h> | 44 | #include <x86/cpufunc.h> | |
45 | #include <x86/est.h> | 45 | #include <x86/est.h> | |
46 | 46 | |||
@@ -85,27 +85,27 @@ viac7_get_bus_clock(struct cpu_info *ci) | @@ -85,27 +85,27 @@ viac7_get_bus_clock(struct cpu_info *ci) | |||
85 | 85 | |||
86 | return ((ci->ci_data.cpu_cc_freq + 10000000) / 10000000 * 10000000) / | 86 | return ((ci->ci_data.cpu_cc_freq + 10000000) / 10000000 * 10000000) / | |
87 | mult / 10000; | 87 | mult / 10000; | |
88 | } | 88 | } | |
89 | 89 | |||
90 | int | 90 | int | |
91 | p3_get_bus_clock(struct cpu_info *ci) | 91 | p3_get_bus_clock(struct cpu_info *ci) | |
92 | { | 92 | { | |
93 | uint64_t msr; | 93 | uint64_t msr; | |
94 | int bus, bus_clock = 0; | 94 | int bus, bus_clock = 0; | |
95 | uint32_t model; | 95 | uint32_t model; | |
96 | 96 | |||
97 | model = CPUID_TO_MODEL(ci->ci_signature); | 97 | model = CPUID_TO_MODEL(ci->ci_signature); | |
98 | 98 | |||
99 | switch (model) { | 99 | switch (model) { | |
100 | case 0x9: /* Pentium M (130 nm, Banias) */ | 100 | case 0x9: /* Pentium M (130 nm, Banias) */ | |
101 | bus_clock = 10000; | 101 | bus_clock = 10000; | |
102 | break; | 102 | break; | |
103 | case 0xc: /* Core i7, Atom, model 1 */ | 103 | case 0xc: /* Core i7, Atom, model 1 */ | |
104 | /* | 104 | /* | |
105 | * Newer CPUs will GP when attemping to access MSR_FSB_FREQ. | 105 | * Newer CPUs will GP when attemping to access MSR_FSB_FREQ. | |
106 | * In the long-term, use ACPI instead of all this. | 106 | * In the long-term, use ACPI instead of all this. | |
107 | */ | 107 | */ | |
108 | if (rdmsr_safe(MSR_FSB_FREQ, &msr) == EFAULT) { | 108 | if (rdmsr_safe(MSR_FSB_FREQ, &msr) == EFAULT) { | |
109 | aprint_debug_dev(ci->ci_dev, | 109 | aprint_debug_dev(ci->ci_dev, | |
110 | "unable to determine bus speed"); | 110 | "unable to determine bus speed"); | |
111 | goto print_msr; | 111 | goto print_msr; |
--- src/sys/arch/x86/x86/intr.c 2021/08/09 21:20:50 1.155
+++ src/sys/arch/x86/x86/intr.c 2021/10/07 12:52:27 1.156
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: intr.c,v 1.155 2021/08/09 21:20:50 andvar Exp $ */ | 1 | /* $NetBSD: intr.c,v 1.156 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2008, 2009, 2019 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 Andrew Doran, and by Jason R. Thorpe. | 8 | * by Andrew Doran, 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. | |
@@ -123,27 +123,27 @@ | @@ -123,27 +123,27 @@ | |||
123 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 123 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
124 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 124 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
125 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 125 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
126 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 126 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
127 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 127 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
128 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 128 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
129 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 129 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
130 | * SUCH DAMAGE. | 130 | * SUCH DAMAGE. | |
131 | * | 131 | * | |
132 | * @(#)isa.c 7.2 (Berkeley) 5/13/91 | 132 | * @(#)isa.c 7.2 (Berkeley) 5/13/91 | |
133 | */ | 133 | */ | |
134 | 134 | |||
135 | #include <sys/cdefs.h> | 135 | #include <sys/cdefs.h> | |
136 | __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.155 2021/08/09 21:20:50 andvar Exp $"); | 136 | __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.156 2021/10/07 12:52:27 msaitoh Exp $"); | |
137 | 137 | |||
138 | #include "opt_intrdebug.h" | 138 | #include "opt_intrdebug.h" | |
139 | #include "opt_multiprocessor.h" | 139 | #include "opt_multiprocessor.h" | |
140 | #include "opt_acpi.h" | 140 | #include "opt_acpi.h" | |
141 | 141 | |||
142 | #include <sys/param.h> | 142 | #include <sys/param.h> | |
143 | #include <sys/systm.h> | 143 | #include <sys/systm.h> | |
144 | #include <sys/kernel.h> | 144 | #include <sys/kernel.h> | |
145 | #include <sys/syslog.h> | 145 | #include <sys/syslog.h> | |
146 | #include <sys/device.h> | 146 | #include <sys/device.h> | |
147 | #include <sys/kmem.h> | 147 | #include <sys/kmem.h> | |
148 | #include <sys/proc.h> | 148 | #include <sys/proc.h> | |
149 | #include <sys/errno.h> | 149 | #include <sys/errno.h> | |
@@ -448,27 +448,27 @@ intr_allocate_slot_cpu(struct cpu_info * | @@ -448,27 +448,27 @@ intr_allocate_slot_cpu(struct cpu_info * | |||
448 | if (pic == &i8259_pic) { | 448 | if (pic == &i8259_pic) { | |
449 | KASSERT(CPU_IS_PRIMARY(ci)); | 449 | KASSERT(CPU_IS_PRIMARY(ci)); | |
450 | slot = pin; | 450 | slot = pin; | |
451 | } else { | 451 | } else { | |
452 | int start = 0; | 452 | int start = 0; | |
453 | int max = MAX_INTR_SOURCES; | 453 | int max = MAX_INTR_SOURCES; | |
454 | slot = -1; | 454 | slot = -1; | |
455 | 455 | |||
456 | /* avoid reserved slots for legacy interrupts. */ | 456 | /* avoid reserved slots for legacy interrupts. */ | |
457 | if (CPU_IS_PRIMARY(ci) && msipic_is_msi_pic(pic)) | 457 | if (CPU_IS_PRIMARY(ci) && msipic_is_msi_pic(pic)) | |
458 | start = NUM_LEGACY_IRQS; | 458 | start = NUM_LEGACY_IRQS; | |
459 | /* don't step over Xen's slots */ | 459 | /* don't step over Xen's slots */ | |
460 | if (vm_guest == VM_GUEST_XENPVH) | 460 | if (vm_guest == VM_GUEST_XENPVH) | |
461 | max = SIR_XENIPL_VM; | 461 | max = SIR_XENIPL_VM; | |
462 | /* | 462 | /* | |
463 | * intr_allocate_slot has checked for an existing mapping. | 463 | * intr_allocate_slot has checked for an existing mapping. | |
464 | * Now look for a free slot. | 464 | * Now look for a free slot. | |
465 | */ | 465 | */ | |
466 | for (i = start; i < max ; i++) { | 466 | for (i = start; i < max ; i++) { | |
467 | if (ci->ci_isources[i] == NULL) { | 467 | if (ci->ci_isources[i] == NULL) { | |
468 | slot = i; | 468 | slot = i; | |
469 | break; | 469 | break; | |
470 | } | 470 | } | |
471 | } | 471 | } | |
472 | if (slot == -1) { | 472 | if (slot == -1) { | |
473 | return EBUSY; | 473 | return EBUSY; | |
474 | } | 474 | } | |
@@ -545,27 +545,27 @@ intr_allocate_slot(struct pic *pic, int | @@ -545,27 +545,27 @@ intr_allocate_slot(struct pic *pic, int | |||
545 | error = intr_allocate_slot_cpu(ci, pic, pin, &slot, chained); | 545 | error = intr_allocate_slot_cpu(ci, pic, pin, &slot, chained); | |
546 | } else { | 546 | } else { | |
547 | /* | 547 | /* | |
548 | * Find least loaded AP/BP and try to allocate there. | 548 | * Find least loaded AP/BP and try to allocate there. | |
549 | */ | 549 | */ | |
550 | ci = NULL; | 550 | ci = NULL; | |
551 | for (CPU_INFO_FOREACH(cii, lci)) { | 551 | for (CPU_INFO_FOREACH(cii, lci)) { | |
552 | if ((lci->ci_schedstate.spc_flags & SPCF_NOINTR) != 0) { | 552 | if ((lci->ci_schedstate.spc_flags & SPCF_NOINTR) != 0) { | |
553 | continue; | 553 | continue; | |
554 | } | 554 | } | |
555 | #if 0 | 555 | #if 0 | |
556 | if (ci == NULL || | 556 | if (ci == NULL || | |
557 | ci->ci_nintrhand > lci->ci_nintrhand) { | 557 | ci->ci_nintrhand > lci->ci_nintrhand) { | |
558 | ci = lci; | 558 | ci = lci; | |
559 | } | 559 | } | |
560 | #else | 560 | #else | |
561 | ci = &cpu_info_primary; | 561 | ci = &cpu_info_primary; | |
562 | #endif | 562 | #endif | |
563 | } | 563 | } | |
564 | KASSERT(ci != NULL); | 564 | KASSERT(ci != NULL); | |
565 | error = intr_allocate_slot_cpu(ci, pic, pin, &slot, chained); | 565 | error = intr_allocate_slot_cpu(ci, pic, pin, &slot, chained); | |
566 | 566 | |||
567 | /* | 567 | /* | |
568 | * If that did not work, allocate anywhere. | 568 | * If that did not work, allocate anywhere. | |
569 | */ | 569 | */ | |
570 | if (error != 0) { | 570 | if (error != 0) { | |
571 | for (CPU_INFO_FOREACH(cii, ci)) { | 571 | for (CPU_INFO_FOREACH(cii, ci)) { | |
@@ -928,27 +928,27 @@ intr_establish_xname(int legacy_irq, str | @@ -928,27 +928,27 @@ intr_establish_xname(int legacy_irq, str | |||
928 | intr_hwunmask_xcall(ih, NULL); | 928 | intr_hwunmask_xcall(ih, NULL); | |
929 | } else { | 929 | } else { | |
930 | where = xc_unicast(0, intr_hwunmask_xcall, ih, NULL, ci); | 930 | where = xc_unicast(0, intr_hwunmask_xcall, ih, NULL, ci); | |
931 | xc_wait(where); | 931 | xc_wait(where); | |
932 | } | 932 | } | |
933 | mutex_exit(&cpu_lock); | 933 | mutex_exit(&cpu_lock); | |
934 | 934 | |||
935 | if (bootverbose || cpu_index(ci) != 0) | 935 | if (bootverbose || cpu_index(ci) != 0) | |
936 | aprint_verbose("allocated pic %s type %s pin %d level %d to " | 936 | aprint_verbose("allocated pic %s type %s pin %d level %d to " | |
937 | "%s slot %d idt entry %d\n", | 937 | "%s slot %d idt entry %d\n", | |
938 | pic->pic_name, type == IST_EDGE ? "edge" : "level", pin, | 938 | pic->pic_name, type == IST_EDGE ? "edge" : "level", pin, | |
939 | level, device_xname(ci->ci_dev), slot, idt_vec); | 939 | level, device_xname(ci->ci_dev), slot, idt_vec); | |
940 | 940 | |||
941 | return (ih); | 941 | return ih; | |
942 | } | 942 | } | |
943 | 943 | |||
944 | void * | 944 | void * | |
945 | intr_establish(int legacy_irq, struct pic *pic, int pin, int type, int level, | 945 | intr_establish(int legacy_irq, struct pic *pic, int pin, int type, int level, | |
946 | int (*handler)(void *), void *arg, bool known_mpsafe) | 946 | int (*handler)(void *), void *arg, bool known_mpsafe) | |
947 | { | 947 | { | |
948 | 948 | |||
949 | return intr_establish_xname(legacy_irq, pic, pin, type, | 949 | return intr_establish_xname(legacy_irq, pic, pin, type, | |
950 | level, handler, arg, known_mpsafe, "unknown"); | 950 | level, handler, arg, known_mpsafe, "unknown"); | |
951 | } | 951 | } | |
952 | 952 | |||
953 | /* | 953 | /* | |
954 | * Called on bound CPU to handle intr_mask() / intr_unmask(). | 954 | * Called on bound CPU to handle intr_mask() / intr_unmask(). | |
@@ -1894,27 +1894,28 @@ intr_set_affinity(struct intrsource *isp | @@ -1894,27 +1894,28 @@ intr_set_affinity(struct intrsource *isp | |||
1894 | DPRINTF(("failed to allocate interrupt slot for PIC %s intrid " | 1894 | DPRINTF(("failed to allocate interrupt slot for PIC %s intrid " | |
1895 | "%s\n", isp->is_pic->pic_name, isp->is_intrid)); | 1895 | "%s\n", isp->is_pic->pic_name, isp->is_intrid)); | |
1896 | return err; | 1896 | return err; | |
1897 | } | 1897 | } | |
1898 | 1898 | |||
1899 | old_idtvec = isp->is_idtvec; | 1899 | old_idtvec = isp->is_idtvec; | |
1900 | 1900 | |||
1901 | if (isp->is_idtvec > 0 && idt_vec_is_pcpu()) { | 1901 | if (isp->is_idtvec > 0 && idt_vec_is_pcpu()) { | |
1902 | new_idtvec = idt_vec_alloc(&newci->ci_idtvec, | 1902 | new_idtvec = idt_vec_alloc(&newci->ci_idtvec, | |
1903 | APIC_LEVEL(ih->ih_level), IDT_INTR_HIGH); | 1903 | APIC_LEVEL(ih->ih_level), IDT_INTR_HIGH); | |
1904 | if (new_idtvec == 0) | 1904 | if (new_idtvec == 0) | |
1905 | return EBUSY; | 1905 | return EBUSY; | |
1906 | DPRINTF(("interrupt from cpu%d vec %d to cpu%d vec %d\n", | 1906 | DPRINTF(("interrupt from cpu%d vec %d to cpu%d vec %d\n", | |
1907 | cpu_index(oldci), old_idtvec, cpu_index(newci), new_idtvec)); | 1907 | cpu_index(oldci), old_idtvec, cpu_index(newci), | |
1908 | new_idtvec)); | |||
1908 | } else { | 1909 | } else { | |
1909 | new_idtvec = isp->is_idtvec; | 1910 | new_idtvec = isp->is_idtvec; | |
1910 | } | 1911 | } | |
1911 | 1912 | |||
1912 | /* Prevent intr_unmask() from reenabling the source at the hw. */ | 1913 | /* Prevent intr_unmask() from reenabling the source at the hw. */ | |
1913 | isp->is_distribute_pending = true; | 1914 | isp->is_distribute_pending = true; | |
1914 | 1915 | |||
1915 | pin = isp->is_pin; | 1916 | pin = isp->is_pin; | |
1916 | (*pic->pic_hwmask)(pic, pin); /* for ci_ipending check */ | 1917 | (*pic->pic_hwmask)(pic, pin); /* for ci_ipending check */ | |
1917 | while (oldci->ci_ipending & (1 << oldslot)) { | 1918 | while (oldci->ci_ipending & (1 << oldslot)) { | |
1918 | (void)kpause("intrdist", false, 1, &cpu_lock); | 1919 | (void)kpause("intrdist", false, 1, &cpu_lock); | |
1919 | } | 1920 | } | |
1920 | 1921 | |||
@@ -2094,27 +2095,27 @@ interrupt_get_count(const char *intrid, | @@ -2094,27 +2095,27 @@ interrupt_get_count(const char *intrid, | |||
2094 | return count; | 2095 | return count; | |
2095 | } | 2096 | } | |
2096 | 2097 | |||
2097 | /* | 2098 | /* | |
2098 | * MI interface for subr_interrupt.c | 2099 | * MI interface for subr_interrupt.c | |
2099 | */ | 2100 | */ | |
2100 | void | 2101 | void | |
2101 | interrupt_get_assigned(const char *intrid, kcpuset_t *cpuset) | 2102 | interrupt_get_assigned(const char *intrid, kcpuset_t *cpuset) | |
2102 | { | 2103 | { | |
2103 | struct intrsource *isp; | 2104 | struct intrsource *isp; | |
2104 | 2105 | |||
2105 | mutex_enter(&cpu_lock); | 2106 | mutex_enter(&cpu_lock); | |
2106 | isp = intr_get_io_intrsource(intrid); | 2107 | isp = intr_get_io_intrsource(intrid); | |
2107 | if (isp != NULL) | 2108 | if (isp != NULL) | |
2108 | isp->is_pic->pic_intr_get_assigned(intrid, cpuset); | 2109 | isp->is_pic->pic_intr_get_assigned(intrid, cpuset); | |
2109 | mutex_exit(&cpu_lock); | 2110 | mutex_exit(&cpu_lock); | |
2110 | } | 2111 | } | |
2111 | 2112 | |||
2112 | /* | 2113 | /* | |
2113 | * MI interface for subr_interrupt.c | 2114 | * MI interface for subr_interrupt.c | |
2114 | */ | 2115 | */ | |
2115 | void | 2116 | void | |
2116 | interrupt_get_available(kcpuset_t *cpuset) | 2117 | interrupt_get_available(kcpuset_t *cpuset) | |
2117 | { | 2118 | { | |
2118 | CPU_INFO_ITERATOR cii; | 2119 | CPU_INFO_ITERATOR cii; | |
2119 | struct cpu_info *ci; | 2120 | struct cpu_info *ci; | |
2120 | 2121 |
--- src/sys/arch/x86/x86/ioapic.c 2020/04/25 15:26:18 1.64
+++ src/sys/arch/x86/x86/ioapic.c 2021/10/07 12:52:27 1.65
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ioapic.c,v 1.64 2020/04/25 15:26:18 bouyer Exp $ */ | 1 | /* $NetBSD: ioapic.c,v 1.65 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2000, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000, 2009 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, and by Andrew Doran. | 8 | * by RedBack Networks Inc, and by Andrew Doran. | |
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: | |
@@ -54,27 +54,27 @@ | @@ -54,27 +54,27 @@ | |||
54 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 54 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
55 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 55 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE | 56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE | |
57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
63 | * SUCH DAMAGE. | 63 | * SUCH DAMAGE. | |
64 | */ | 64 | */ | |
65 | 65 | |||
66 | #include <sys/cdefs.h> | 66 | #include <sys/cdefs.h> | |
67 | __KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.64 2020/04/25 15:26:18 bouyer Exp $"); | 67 | __KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.65 2021/10/07 12:52:27 msaitoh Exp $"); | |
68 | 68 | |||
69 | #include "opt_ddb.h" | 69 | #include "opt_ddb.h" | |
70 | 70 | |||
71 | #include <sys/param.h> | 71 | #include <sys/param.h> | |
72 | #include <sys/systm.h> | 72 | #include <sys/systm.h> | |
73 | #include <sys/device.h> | 73 | #include <sys/device.h> | |
74 | #include <sys/malloc.h> | 74 | #include <sys/malloc.h> | |
75 | #include <sys/kernel.h> | 75 | #include <sys/kernel.h> | |
76 | #include <sys/bus.h> | 76 | #include <sys/bus.h> | |
77 | 77 | |||
78 | #include <uvm/uvm_extern.h> | 78 | #include <uvm/uvm_extern.h> | |
79 | 79 | |||
80 | #include <machine/isa_machdep.h> /* XXX intrhand */ | 80 | #include <machine/isa_machdep.h> /* XXX intrhand */ | |
@@ -102,28 +102,28 @@ __KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1 | @@ -102,28 +102,28 @@ __KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1 | |||
102 | 102 | |||
103 | int ioapic_match(device_t, cfdata_t, void *); | 103 | int ioapic_match(device_t, cfdata_t, void *); | |
104 | void ioapic_attach(device_t, device_t, void *); | 104 | void ioapic_attach(device_t, device_t, void *); | |
105 | 105 | |||
106 | extern int x86_mem_add_mapping(bus_addr_t, bus_size_t, | 106 | extern int x86_mem_add_mapping(bus_addr_t, bus_size_t, | |
107 | int, bus_space_handle_t *); /* XXX XXX */ | 107 | int, bus_space_handle_t *); /* XXX XXX */ | |
108 | 108 | |||
109 | void ioapic_hwmask(struct pic *, int); | 109 | void ioapic_hwmask(struct pic *, int); | |
110 | void ioapic_hwunmask(struct pic *, int); | 110 | void ioapic_hwunmask(struct pic *, int); | |
111 | bool ioapic_trymask(struct pic *, int); | 111 | bool ioapic_trymask(struct pic *, int); | |
112 | static void ioapic_addroute(struct pic *, struct cpu_info *, int, int, int); | 112 | static void ioapic_addroute(struct pic *, struct cpu_info *, int, int, int); | |
113 | static void ioapic_delroute(struct pic *, struct cpu_info *, int, int, int); | 113 | static void ioapic_delroute(struct pic *, struct cpu_info *, int, int, int); | |
114 | 114 | |||
115 | struct ioapic_softc *ioapics; /* head of linked list */ | 115 | struct ioapic_softc *ioapics; /* head of linked list */ | |
116 | int nioapics = 0; /* number attached */ | 116 | int nioapics = 0; /* number attached */ | |
117 | static int ioapic_vecbase; | 117 | static int ioapic_vecbase; | |
118 | 118 | |||
119 | static inline u_long | 119 | static inline u_long | |
120 | ioapic_lock(struct ioapic_softc *sc) | 120 | ioapic_lock(struct ioapic_softc *sc) | |
121 | { | 121 | { | |
122 | u_long flags; | 122 | u_long flags; | |
123 | 123 | |||
124 | flags = x86_read_psl(); | 124 | flags = x86_read_psl(); | |
125 | x86_disable_intr(); | 125 | x86_disable_intr(); | |
126 | __cpu_simple_lock(&sc->sc_pic.pic_lock); | 126 | __cpu_simple_lock(&sc->sc_pic.pic_lock); | |
127 | return flags; | 127 | return flags; | |
128 | } | 128 | } | |
129 | 129 | |||
@@ -412,27 +412,27 @@ apic_set_redir(struct ioapic_softc *sc, | @@ -412,27 +412,27 @@ apic_set_redir(struct ioapic_softc *sc, | |||
412 | uint32_t redhi; | 412 | uint32_t redhi; | |
413 | int delmode; | 413 | int delmode; | |
414 | struct ioapic_pin *pp; | 414 | struct ioapic_pin *pp; | |
415 | struct mp_intr_map *map; | 415 | struct mp_intr_map *map; | |
416 | 416 | |||
417 | pp = &sc->sc_pins[pin]; | 417 | pp = &sc->sc_pins[pin]; | |
418 | map = pp->ip_map; | 418 | map = pp->ip_map; | |
419 | redlo = map == NULL ? IOAPIC_REDLO_MASK : map->redir; | 419 | redlo = map == NULL ? IOAPIC_REDLO_MASK : map->redir; | |
420 | redhi = 0; | 420 | redhi = 0; | |
421 | delmode = (redlo & IOAPIC_REDLO_DEL_MASK) >> IOAPIC_REDLO_DEL_SHIFT; | 421 | delmode = (redlo & IOAPIC_REDLO_DEL_MASK) >> IOAPIC_REDLO_DEL_SHIFT; | |
422 | 422 | |||
423 | if (delmode == IOAPIC_REDLO_DEL_FIXED || | 423 | if (delmode == IOAPIC_REDLO_DEL_FIXED || | |
424 | delmode == IOAPIC_REDLO_DEL_LOPRI) { | 424 | delmode == IOAPIC_REDLO_DEL_LOPRI) { | |
425 | if (pp->ip_type == IST_NONE) { | 425 | if (pp->ip_type == IST_NONE) { | |
426 | redlo |= IOAPIC_REDLO_MASK; | 426 | redlo |= IOAPIC_REDLO_MASK; | |
427 | } else { | 427 | } else { | |
428 | redhi = (ci->ci_cpuid << IOAPIC_REDHI_DEST_SHIFT); | 428 | redhi = (ci->ci_cpuid << IOAPIC_REDHI_DEST_SHIFT); | |
429 | redlo |= (idt_vec & 0xff); | 429 | redlo |= (idt_vec & 0xff); | |
430 | redlo |= IOAPIC_REDLO_DEL_FIXED | 430 | redlo |= IOAPIC_REDLO_DEL_FIXED | |
431 | << IOAPIC_REDLO_DEL_SHIFT; | 431 | << IOAPIC_REDLO_DEL_SHIFT; | |
432 | redlo &= ~IOAPIC_REDLO_DSTMOD; | 432 | redlo &= ~IOAPIC_REDLO_DSTMOD; | |
433 | 433 | |||
434 | /* XXX derive this bit from BIOS info */ | 434 | /* XXX derive this bit from BIOS info */ | |
435 | if (pp->ip_type == IST_LEVEL) | 435 | if (pp->ip_type == IST_LEVEL) | |
436 | redlo |= IOAPIC_REDLO_LEVEL; | 436 | redlo |= IOAPIC_REDLO_LEVEL; | |
437 | else | 437 | else | |
438 | redlo &= ~IOAPIC_REDLO_LEVEL; | 438 | redlo &= ~IOAPIC_REDLO_LEVEL; |
--- src/sys/arch/x86/x86/lapic.c 2020/10/27 08:57:11 1.85
+++ src/sys/arch/x86/x86/lapic.c 2021/10/07 12:52:27 1.86
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lapic.c,v 1.85 2020/10/27 08:57:11 ryo Exp $ */ | 1 | /* $NetBSD: lapic.c,v 1.86 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2000, 2008, 2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000, 2008, 2020 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.85 2020/10/27 08:57:11 ryo Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.86 2021/10/07 12:52:27 msaitoh 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 | #include "opt_xen.h" | 44 | #include "opt_xen.h" | |
45 | 45 | |||
46 | 46 | |||
47 | #include <sys/param.h> | 47 | #include <sys/param.h> | |
48 | #include <sys/proc.h> | 48 | #include <sys/proc.h> | |
@@ -88,28 +88,28 @@ extern vector Xintr_x2apic_ddbipi; | @@ -88,28 +88,28 @@ extern vector Xintr_x2apic_ddbipi; | |||
88 | extern int ddb_vec; | 88 | extern int ddb_vec; | |
89 | #endif | 89 | #endif | |
90 | #endif | 90 | #endif | |
91 | #endif | 91 | #endif | |
92 | 92 | |||
93 | #include <dev/vmt/vmtreg.h> /* for vmt_hvcall() */ | 93 | #include <dev/vmt/vmtreg.h> /* for vmt_hvcall() */ | |
94 | #include <dev/vmt/vmtvar.h> /* for vmt_hvcall() */ | 94 | #include <dev/vmt/vmtvar.h> /* for vmt_hvcall() */ | |
95 | 95 | |||
96 | /* Referenced from vector.S */ | 96 | /* Referenced from vector.S */ | |
97 | void lapic_clockintr(void *, struct intrframe *); | 97 | void lapic_clockintr(void *, struct intrframe *); | |
98 | 98 | |||
99 | static void lapic_delay(unsigned int); | 99 | static void lapic_delay(unsigned int); | |
100 | static uint32_t lapic_gettick(void); | 100 | static uint32_t lapic_gettick(void); | |
101 | static void lapic_setup_bsp(paddr_t); | 101 | static void lapic_setup_bsp(paddr_t); | |
102 | static void lapic_map(paddr_t); | 102 | static void lapic_map(paddr_t); | |
103 | 103 | |||
104 | static void lapic_hwmask(struct pic *, int); | 104 | static void lapic_hwmask(struct pic *, int); | |
105 | static void lapic_hwunmask(struct pic *, int); | 105 | static void lapic_hwunmask(struct pic *, int); | |
106 | static void lapic_setup(struct pic *, struct cpu_info *, int, int, int); | 106 | static void lapic_setup(struct pic *, struct cpu_info *, int, int, int); | |
107 | /* Make it public to call via ddb */ | 107 | /* Make it public to call via ddb */ | |
108 | void lapic_dump(void); | 108 | void lapic_dump(void); | |
109 | 109 | |||
110 | struct pic local_pic = { | 110 | struct pic local_pic = { | |
111 | .pic_name = "lapic", | 111 | .pic_name = "lapic", | |
112 | .pic_type = PIC_LAPIC, | 112 | .pic_type = PIC_LAPIC, | |
113 | .pic_lock = __SIMPLELOCK_UNLOCKED, | 113 | .pic_lock = __SIMPLELOCK_UNLOCKED, | |
114 | .pic_hwmask = lapic_hwmask, | 114 | .pic_hwmask = lapic_hwmask, | |
115 | .pic_hwunmask = lapic_hwunmask, | 115 | .pic_hwunmask = lapic_hwunmask, | |
@@ -879,27 +879,27 @@ i82489_ipi(int vec, int target, int dl) | @@ -879,27 +879,27 @@ i82489_ipi(int vec, int target, int dl) | |||
879 | i82489_icr_wait(); | 879 | i82489_icr_wait(); | |
880 | 880 | |||
881 | if ((target & LAPIC_DEST_MASK) == 0) | 881 | if ((target & LAPIC_DEST_MASK) == 0) | |
882 | i82489_writereg(LAPIC_ICRHI, target << LAPIC_ID_SHIFT); | 882 | i82489_writereg(LAPIC_ICRHI, target << LAPIC_ID_SHIFT); | |
883 | 883 | |||
884 | i82489_writereg(LAPIC_ICRLO, | 884 | i82489_writereg(LAPIC_ICRLO, | |
885 | (target & LAPIC_DEST_MASK) | vec | dl | LAPIC_LEVEL_ASSERT); | 885 | (target & LAPIC_DEST_MASK) | vec | dl | LAPIC_LEVEL_ASSERT); | |
886 | 886 | |||
887 | #ifdef DIAGNOSTIC | 887 | #ifdef DIAGNOSTIC | |
888 | i82489_icr_wait(); | 888 | i82489_icr_wait(); | |
889 | result = (i82489_readreg(LAPIC_ICRLO) & LAPIC_DLSTAT_BUSY) ? EBUSY : 0; | 889 | result = (i82489_readreg(LAPIC_ICRLO) & LAPIC_DLSTAT_BUSY) ? EBUSY : 0; | |
890 | #else | 890 | #else | |
891 | /* Don't wait - if it doesn't go, we're in big trouble anyway. */ | 891 | /* Don't wait - if it doesn't go, we're in big trouble anyway. */ | |
892 | result = 0; | 892 | result = 0; | |
893 | #endif | 893 | #endif | |
894 | splx(s); | 894 | splx(s); | |
895 | 895 | |||
896 | return result; | 896 | return result; | |
897 | } | 897 | } | |
898 | 898 | |||
899 | static int | 899 | static int | |
900 | x2apic_ipi_init(int target) | 900 | x2apic_ipi_init(int target) | |
901 | { | 901 | { | |
902 | 902 | |||
903 | x2apic_write_icr(target, LAPIC_DLMODE_INIT | LAPIC_LEVEL_ASSERT); | 903 | x2apic_write_icr(target, LAPIC_DLMODE_INIT | LAPIC_LEVEL_ASSERT); | |
904 | 904 | |||
905 | delay_func(10000); | 905 | delay_func(10000); |
--- src/sys/arch/x86/x86/mp.c 2021/08/07 16:19:08 1.6
+++ src/sys/arch/x86/x86/mp.c 2021/10/07 12:52:27 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mp.c,v 1.6 2021/08/07 16:19:08 thorpej Exp $ */ | 1 | /* $NetBSD: mp.c,v 1.7 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Frank van der Linden for Wasabi Systems, Inc. | 7 | * Written by Frank van der Linden for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | __KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.6 2021/08/07 16:19:08 thorpej Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.7 2021/10/07 12:52:27 msaitoh Exp $"); | |
40 | 40 | |||
41 | #include "opt_multiprocessor.h" | 41 | #include "opt_multiprocessor.h" | |
42 | #include "opt_acpi.h" | 42 | #include "opt_acpi.h" | |
43 | 43 | |||
44 | #include "acpica.h" | 44 | #include "acpica.h" | |
45 | #include "ioapic.h" | 45 | #include "ioapic.h" | |
46 | #include "pchb.h" | 46 | #include "pchb.h" | |
47 | 47 | |||
48 | #include <sys/param.h> | 48 | #include <sys/param.h> | |
49 | #include <sys/systm.h> | 49 | #include <sys/systm.h> | |
50 | #include <sys/kernel.h> | 50 | #include <sys/kernel.h> | |
51 | #include <sys/device.h> | 51 | #include <sys/device.h> | |
52 | #include <sys/kmem.h> | 52 | #include <sys/kmem.h> | |
@@ -71,27 +71,27 @@ __KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.6 2 | @@ -71,27 +71,27 @@ __KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.6 2 | |||
71 | #include <dev/pci/ppbreg.h> | 71 | #include <dev/pci/ppbreg.h> | |
72 | #endif | 72 | #endif | |
73 | 73 | |||
74 | #if NIOAPIC > 0 || NACPICA > 0 | 74 | #if NIOAPIC > 0 || NACPICA > 0 | |
75 | static int intr_scan_bus(int, int, intr_handle_t *); | 75 | static int intr_scan_bus(int, int, intr_handle_t *); | |
76 | #if NPCI > 0 | 76 | #if NPCI > 0 | |
77 | static int intr_find_pcibridge(int, pcitag_t *, pci_chipset_tag_t *); | 77 | static int intr_find_pcibridge(int, pcitag_t *, pci_chipset_tag_t *); | |
78 | #endif | 78 | #endif | |
79 | #endif | 79 | #endif | |
80 | 80 | |||
81 | #if NPCI > 0 | 81 | #if NPCI > 0 | |
82 | int | 82 | int | |
83 | mp_pci_scan(device_t self, struct pcibus_attach_args *pba, | 83 | mp_pci_scan(device_t self, struct pcibus_attach_args *pba, | |
84 | cfprint_t print) | 84 | cfprint_t print) | |
85 | { | 85 | { | |
86 | int i, cnt; | 86 | int i, cnt; | |
87 | struct mp_bus *mpb; | 87 | struct mp_bus *mpb; | |
88 | 88 | |||
89 | cnt = 0; | 89 | cnt = 0; | |
90 | for (i = 0; i < mp_nbus; i++) { | 90 | for (i = 0; i < mp_nbus; i++) { | |
91 | mpb = &mp_busses[i]; | 91 | mpb = &mp_busses[i]; | |
92 | if (mpb->mb_name == NULL) | 92 | if (mpb->mb_name == NULL) | |
93 | continue; | 93 | continue; | |
94 | if (strcmp(mpb->mb_name, "pci") == 0 && mpb->mb_dev == NULL) { | 94 | if (strcmp(mpb->mb_name, "pci") == 0 && mpb->mb_dev == NULL) { | |
95 | pba->pba_bus = i; | 95 | pba->pba_bus = i; | |
96 | mpb->mb_dev = config_found(self, pba, print, | 96 | mpb->mb_dev = config_found(self, pba, print, | |
97 | CFARGS(.iattr = "pcibus")); | 97 | CFARGS(.iattr = "pcibus")); |
--- src/sys/arch/x86/x86/mpacpi.c 2021/08/07 16:19:08 1.107
+++ src/sys/arch/x86/x86/mpacpi.c 2021/10/07 12:52:27 1.108
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mpacpi.c,v 1.107 2021/08/07 16:19:08 thorpej Exp $ */ | 1 | /* $NetBSD: mpacpi.c,v 1.108 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Frank van der Linden for Wasabi Systems, Inc. | 7 | * Written by Frank van der Linden for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC | |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | __KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.107 2021/08/07 16:19:08 thorpej Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.108 2021/10/07 12:52:27 msaitoh Exp $"); | |
40 | 40 | |||
41 | #include "acpica.h" | 41 | #include "acpica.h" | |
42 | #include "opt_acpi.h" | 42 | #include "opt_acpi.h" | |
43 | #include "opt_ddb.h" | 43 | #include "opt_ddb.h" | |
44 | #include "opt_mpbios.h" | 44 | #include "opt_mpbios.h" | |
45 | #include "opt_multiprocessor.h" | 45 | #include "opt_multiprocessor.h" | |
46 | #include "pchb.h" | 46 | #include "pchb.h" | |
47 | 47 | |||
48 | #include <sys/param.h> | 48 | #include <sys/param.h> | |
49 | #include <sys/systm.h> | 49 | #include <sys/systm.h> | |
50 | #include <sys/kernel.h> | 50 | #include <sys/kernel.h> | |
51 | #include <sys/device.h> | 51 | #include <sys/device.h> | |
52 | #include <sys/kmem.h> | 52 | #include <sys/kmem.h> | |
@@ -142,38 +142,38 @@ static int mpacpi_intr_index; | @@ -142,38 +142,38 @@ static int mpacpi_intr_index; | |||
142 | static paddr_t mpacpi_lapic_base = LAPIC_BASE; | 142 | static paddr_t mpacpi_lapic_base = LAPIC_BASE; | |
143 | 143 | |||
144 | int mpacpi_step; | 144 | int mpacpi_step; | |
145 | int mpacpi_force; | 145 | int mpacpi_force; | |
146 | 146 | |||
147 | static int | 147 | static int | |
148 | mpacpi_cpuprint(void *aux, const char *pnp) | 148 | mpacpi_cpuprint(void *aux, const char *pnp) | |
149 | { | 149 | { | |
150 | struct cpu_attach_args *caa = aux; | 150 | struct cpu_attach_args *caa = aux; | |
151 | 151 | |||
152 | if (pnp) | 152 | if (pnp) | |
153 | aprint_normal("cpu at %s", pnp); | 153 | aprint_normal("cpu at %s", pnp); | |
154 | aprint_normal(" apid %d", caa->cpu_number); | 154 | aprint_normal(" apid %d", caa->cpu_number); | |
155 | return (UNCONF); | 155 | return UNCONF; | |
156 | } | 156 | } | |
157 | 157 | |||
158 | static int | 158 | static int | |
159 | mpacpi_ioapicprint(void *aux, const char *pnp) | 159 | mpacpi_ioapicprint(void *aux, const char *pnp) | |
160 | { | 160 | { | |
161 | struct apic_attach_args *aaa = aux; | 161 | struct apic_attach_args *aaa = aux; | |
162 | 162 | |||
163 | if (pnp) | 163 | if (pnp) | |
164 | aprint_normal("ioapic at %s", pnp); | 164 | aprint_normal("ioapic at %s", pnp); | |
165 | aprint_normal(" apid %d", aaa->apic_id); | 165 | aprint_normal(" apid %d", aaa->apic_id); | |
166 | return (UNCONF); | 166 | return UNCONF; | |
167 | } | 167 | } | |
168 | 168 | |||
169 | /* | 169 | /* | |
170 | * Handle special interrupt sources and overrides from the MADT. | 170 | * Handle special interrupt sources and overrides from the MADT. | |
171 | * This is a callback function for acpi_madt_walk() (see acpi.c). | 171 | * This is a callback function for acpi_madt_walk() (see acpi.c). | |
172 | */ | 172 | */ | |
173 | static ACPI_STATUS | 173 | static ACPI_STATUS | |
174 | mpacpi_nonpci_intr(ACPI_SUBTABLE_HEADER *hdrp, void *aux) | 174 | mpacpi_nonpci_intr(ACPI_SUBTABLE_HEADER *hdrp, void *aux) | |
175 | { | 175 | { | |
176 | int *index = aux, pin, lindex; | 176 | int *index = aux, pin, lindex; | |
177 | struct mp_intr_map *mpi; | 177 | struct mp_intr_map *mpi; | |
178 | ACPI_MADT_NMI_SOURCE *ioapic_nmi; | 178 | ACPI_MADT_NMI_SOURCE *ioapic_nmi; | |
179 | ACPI_MADT_LOCAL_APIC_NMI *lapic_nmi; | 179 | ACPI_MADT_LOCAL_APIC_NMI *lapic_nmi; | |
@@ -554,27 +554,27 @@ mpacpi_find_pcibusses(struct acpi_softc | @@ -554,27 +554,27 @@ mpacpi_find_pcibusses(struct acpi_softc | |||
554 | 554 | |||
555 | TAILQ_INIT(&mpacpi_pcibusses); | 555 | TAILQ_INIT(&mpacpi_pcibusses); | |
556 | mpacpi_pci_walk(sc->sc_root); | 556 | mpacpi_pci_walk(sc->sc_root); | |
557 | return 0; | 557 | return 0; | |
558 | } | 558 | } | |
559 | 559 | |||
560 | /* | 560 | /* | |
561 | * Find all static PRT entries for a PCI bus. | 561 | * Find all static PRT entries for a PCI bus. | |
562 | */ | 562 | */ | |
563 | static int | 563 | static int | |
564 | mpacpi_pciroute(struct mpacpi_pcibus *mpr) | 564 | mpacpi_pciroute(struct mpacpi_pcibus *mpr) | |
565 | { | 565 | { | |
566 | ACPI_PCI_ROUTING_TABLE *ptrp; | 566 | ACPI_PCI_ROUTING_TABLE *ptrp; | |
567 | ACPI_HANDLE linkdev; | 567 | ACPI_HANDLE linkdev; | |
568 | char *p; | 568 | char *p; | |
569 | struct mp_intr_map *mpi, *iter; | 569 | struct mp_intr_map *mpi, *iter; | |
570 | struct mp_bus *mpb; | 570 | struct mp_bus *mpb; | |
571 | struct pic *pic; | 571 | struct pic *pic; | |
572 | unsigned dev; | 572 | unsigned dev; | |
573 | int pin; | 573 | int pin; | |
574 | 574 | |||
575 | if (mp_verbose) | 575 | if (mp_verbose) | |
576 | printf("mpacpi: configuring PCI bus %d int routing\n", | 576 | printf("mpacpi: configuring PCI bus %d int routing\n", | |
577 | mpr->mpr_bus); | 577 | mpr->mpr_bus); | |
578 | 578 | |||
579 | mpb = &mp_busses[mpr->mpr_bus]; | 579 | mpb = &mp_busses[mpr->mpr_bus]; | |
580 | 580 | |||
@@ -880,27 +880,27 @@ mpacpi_print_intr(struct mp_intr_map *mp | @@ -880,27 +880,27 @@ mpacpi_print_intr(struct mp_intr_map *mp | |||
880 | acpi_pci_link_name(mpi->linkdev), busname); | 880 | acpi_pci_link_name(mpi->linkdev), busname); | |
881 | else | 881 | else | |
882 | printf("%s: pin %d attached to %s", | 882 | printf("%s: pin %d attached to %s", | |
883 | sc ? sc->pic_name : "local apic", | 883 | sc ? sc->pic_name : "local apic", | |
884 | pin, busname); | 884 | pin, busname); | |
885 | 885 | |||
886 | if (mpi->bus != NULL) { | 886 | if (mpi->bus != NULL) { | |
887 | if (mpi->bus->mb_idx != -1) | 887 | if (mpi->bus->mb_idx != -1) | |
888 | printf("%d", mpi->bus->mb_idx); | 888 | printf("%d", mpi->bus->mb_idx); | |
889 | (*(mpi->bus->mb_intr_print))(mpi->bus_pin); | 889 | (*(mpi->bus->mb_intr_print))(mpi->bus_pin); | |
890 | } | 890 | } | |
891 | snprintb(buf, sizeof(buf), inttype_fmt, mpi->type); | 891 | snprintb(buf, sizeof(buf), inttype_fmt, mpi->type); | |
892 | printf(" (type %s", buf); | 892 | printf(" (type %s", buf); | |
893 | 893 | |||
894 | snprintb(buf, sizeof(buf), flagtype_fmt, mpi->flags); | 894 | snprintb(buf, sizeof(buf), flagtype_fmt, mpi->flags); | |
895 | printf(" flags %s)\n", buf); | 895 | printf(" flags %s)\n", buf); | |
896 | 896 | |||
897 | } | 897 | } | |
898 | 898 | |||
899 | 899 | |||
900 | int | 900 | int | |
901 | mpacpi_find_interrupts(void *self) | 901 | mpacpi_find_interrupts(void *self) | |
902 | { | 902 | { | |
903 | #if NIOAPIC > 0 | 903 | #if NIOAPIC > 0 | |
904 | ACPI_STATUS rv; | 904 | ACPI_STATUS rv; | |
905 | #endif | 905 | #endif | |
906 | struct acpi_softc *acpi = self; | 906 | struct acpi_softc *acpi = self; | |
@@ -1050,34 +1050,34 @@ mpacpi_findintr_linkdev(struct mp_intr_m | @@ -1050,34 +1050,34 @@ mpacpi_findintr_linkdev(struct mp_intr_m | |||
1050 | return ENOENT; | 1050 | return ENOENT; | |
1051 | if (irq != line) { | 1051 | if (irq != line) { | |
1052 | aprint_error("%s: mpacpi_findintr_linkdev:" | 1052 | aprint_error("%s: mpacpi_findintr_linkdev:" | |
1053 | " irq mismatch (%d vs %d)\n", | 1053 | " irq mismatch (%d vs %d)\n", | |
1054 | acpi_pci_link_name(mip->linkdev), irq, line); | 1054 | acpi_pci_link_name(mip->linkdev), irq, line); | |
1055 | return ENOENT; | 1055 | return ENOENT; | |
1056 | } | 1056 | } | |
1057 | 1057 | |||
1058 | /* | 1058 | /* | |
1059 | * Convert ACPICA values to MPS values | 1059 | * Convert ACPICA values to MPS values | |
1060 | */ | 1060 | */ | |
1061 | if (pol == ACPI_ACTIVE_LOW) | 1061 | if (pol == ACPI_ACTIVE_LOW) | |
1062 | pol = MPS_INTPO_ACTLO; | 1062 | pol = MPS_INTPO_ACTLO; | |
1063 | else | 1063 | else | |
1064 | pol = MPS_INTPO_ACTHI; | 1064 | pol = MPS_INTPO_ACTHI; | |
1065 | 1065 | |||
1066 | if (trig == ACPI_EDGE_SENSITIVE) | 1066 | if (trig == ACPI_EDGE_SENSITIVE) | |
1067 | trig = MPS_INTTR_EDGE; | 1067 | trig = MPS_INTTR_EDGE; | |
1068 | else | 1068 | else | |
1069 | trig = MPS_INTTR_LEVEL; | 1069 | trig = MPS_INTTR_LEVEL; | |
1070 | 1070 | |||
1071 | mip->flags = pol | (trig << 2); | 1071 | mip->flags = pol | (trig << 2); | |
1072 | mip->global_int = irq; | 1072 | mip->global_int = irq; | |
1073 | pic = intr_findpic(irq); | 1073 | pic = intr_findpic(irq); | |
1074 | if (pic == NULL) | 1074 | if (pic == NULL) | |
1075 | return ENOENT; | 1075 | return ENOENT; | |
1076 | mip->ioapic = pic; | 1076 | mip->ioapic = pic; | |
1077 | pin = irq - pic->pic_vecbase; | 1077 | pin = irq - pic->pic_vecbase; | |
1078 | 1078 | |||
1079 | if (pic->pic_type == PIC_IOAPIC) { | 1079 | if (pic->pic_type == PIC_IOAPIC) { | |
1080 | #if NIOAPIC > 0 | 1080 | #if NIOAPIC > 0 | |
1081 | mip->redir = (IOAPIC_REDLO_DEL_FIXED <<IOAPIC_REDLO_DEL_SHIFT); | 1081 | mip->redir = (IOAPIC_REDLO_DEL_FIXED <<IOAPIC_REDLO_DEL_SHIFT); | |
1082 | if (pol == MPS_INTPO_ACTLO) | 1082 | if (pol == MPS_INTPO_ACTLO) | |
1083 | mip->redir |= IOAPIC_REDLO_ACTLO; | 1083 | mip->redir |= IOAPIC_REDLO_ACTLO; |
--- src/sys/arch/x86/x86/mpbios.c 2021/08/07 16:19:08 1.70
+++ src/sys/arch/x86/x86/mpbios.c 2021/10/07 12:52:27 1.71
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mpbios.c,v 1.70 2021/08/07 16:19:08 thorpej Exp $ */ | 1 | /* $NetBSD: mpbios.c,v 1.71 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000 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: | |
@@ -86,27 +86,27 @@ | @@ -86,27 +86,27 @@ | |||
86 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 86 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
87 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 87 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
88 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 88 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
89 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 89 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
90 | * SUCH DAMAGE. | 90 | * SUCH DAMAGE. | |
91 | */ | 91 | */ | |
92 | 92 | |||
93 | /* | 93 | /* | |
94 | * The Intel MP-stuff is just one way of x86 SMP systems | 94 | * The Intel MP-stuff is just one way of x86 SMP systems | |
95 | * so only Intel MP specific stuff is here. | 95 | * so only Intel MP specific stuff is here. | |
96 | */ | 96 | */ | |
97 | 97 | |||
98 | #include <sys/cdefs.h> | 98 | #include <sys/cdefs.h> | |
99 | __KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.70 2021/08/07 16:19:08 thorpej Exp $"); | 99 | __KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.71 2021/10/07 12:52:27 msaitoh Exp $"); | |
100 | 100 | |||
101 | #include "acpica.h" | 101 | #include "acpica.h" | |
102 | #include "lapic.h" | 102 | #include "lapic.h" | |
103 | #include "ioapic.h" | 103 | #include "ioapic.h" | |
104 | #include "opt_acpi.h" | 104 | #include "opt_acpi.h" | |
105 | #include "opt_mpbios.h" | 105 | #include "opt_mpbios.h" | |
106 | 106 | |||
107 | #include <sys/param.h> | 107 | #include <sys/param.h> | |
108 | #include <sys/systm.h> | 108 | #include <sys/systm.h> | |
109 | #include <sys/kernel.h> | 109 | #include <sys/kernel.h> | |
110 | #include <sys/device.h> | 110 | #include <sys/device.h> | |
111 | #include <sys/kmem.h> | 111 | #include <sys/kmem.h> | |
112 | #include <sys/bus.h> | 112 | #include <sys/bus.h> | |
@@ -139,44 +139,44 @@ int mpbios_ncpu; | @@ -139,44 +139,44 @@ int mpbios_ncpu; | |||
139 | int mpbios_nioapic; | 139 | int mpbios_nioapic; | |
140 | 140 | |||
141 | #include "pci.h" | 141 | #include "pci.h" | |
142 | 142 | |||
143 | #if NPCI > 0 | 143 | #if NPCI > 0 | |
144 | #include <dev/pci/pcivar.h> | 144 | #include <dev/pci/pcivar.h> | |
145 | #include <dev/pci/pcireg.h> | 145 | #include <dev/pci/pcireg.h> | |
146 | #endif | 146 | #endif | |
147 | 147 | |||
148 | #include "locators.h" | 148 | #include "locators.h" | |
149 | 149 | |||
150 | /* descriptions of MP basetable entries */ | 150 | /* descriptions of MP basetable entries */ | |
151 | struct mpbios_baseentry { | 151 | struct mpbios_baseentry { | |
152 | uint8_t type; | 152 | uint8_t type; | |
153 | uint8_t length; | 153 | uint8_t length; | |
154 | uint16_t count; | 154 | uint16_t count; | |
155 | const char *name; | 155 | const char *name; | |
156 | }; | 156 | }; | |
157 | 157 | |||
158 | static const char *loc_where[] = { | 158 | static const char *loc_where[] = { | |
159 | "extended bios data area", | 159 | "extended bios data area", | |
160 | "last page of base memory", | 160 | "last page of base memory", | |
161 | "bios" | 161 | "bios" | |
162 | }; | 162 | }; | |
163 | 163 | |||
164 | struct mp_map | 164 | struct mp_map | |
165 | { | 165 | { | |
166 | vaddr_t baseva; | 166 | vaddr_t baseva; | |
167 | int vsize; | 167 | int vsize; | |
168 | paddr_t pa; | 168 | paddr_t pa; | |
169 | paddr_t pg; | 169 | paddr_t pg; | |
170 | int psize; | 170 | int psize; | |
171 | }; | 171 | }; | |
172 | 172 | |||
173 | struct dflt_conf_entry { | 173 | struct dflt_conf_entry { | |
174 | const char *bus_type[2]; | 174 | const char *bus_type[2]; | |
175 | int flags; | 175 | int flags; | |
176 | }; | 176 | }; | |
177 | 177 | |||
178 | int mp_cpuprint(void *, const char *); | 178 | int mp_cpuprint(void *, const char *); | |
179 | int mp_ioapicprint(void *, const char *); | 179 | int mp_ioapicprint(void *, const char *); | |
180 | static const void *mpbios_search(device_t, paddr_t, int, | 180 | static const void *mpbios_search(device_t, paddr_t, int, | |
181 | struct mp_map *); | 181 | struct mp_map *); | |
182 | static inline int mpbios_cksum(const void *,int); | 182 | static inline int mpbios_cksum(const void *,int); | |
@@ -189,27 +189,27 @@ static void mp_print_pci_intr (int intr) | @@ -189,27 +189,27 @@ static void mp_print_pci_intr (int intr) | |||
189 | 189 | |||
190 | #ifdef X86_MPBIOS_SUPPORT_EISA | 190 | #ifdef X86_MPBIOS_SUPPORT_EISA | |
191 | static void mp_print_eisa_intr (int intr); | 191 | static void mp_print_eisa_intr (int intr); | |
192 | static void mp_cfg_eisa_intr(const struct mpbios_int *, uint32_t *); | 192 | static void mp_cfg_eisa_intr(const struct mpbios_int *, uint32_t *); | |
193 | #endif | 193 | #endif | |
194 | 194 | |||
195 | static void mp_cfg_isa_intr(const struct mpbios_int *, uint32_t *); | 195 | static void mp_cfg_isa_intr(const struct mpbios_int *, uint32_t *); | |
196 | static void mp_print_isa_intr(int intr); | 196 | static void mp_print_isa_intr(int intr); | |
197 | 197 | |||
198 | static void mpbios_dflt_conf_cpu(device_t); | 198 | static void mpbios_dflt_conf_cpu(device_t); | |
199 | static void mpbios_dflt_conf_bus(device_t, const struct dflt_conf_entry *); | 199 | static void mpbios_dflt_conf_bus(device_t, const struct dflt_conf_entry *); | |
200 | static void mpbios_dflt_conf_ioapic(device_t); | 200 | static void mpbios_dflt_conf_ioapic(device_t); | |
201 | static void mpbios_dflt_conf_int(device_t, const struct dflt_conf_entry *, | 201 | static void mpbios_dflt_conf_int(device_t, const struct dflt_conf_entry *, | |
202 | const int *); | 202 | const int *); | |
203 | 203 | |||
204 | static void mpbios_cpu(const uint8_t *, device_t); | 204 | static void mpbios_cpu(const uint8_t *, device_t); | |
205 | static void mpbios_bus(const uint8_t *, device_t); | 205 | static void mpbios_bus(const uint8_t *, device_t); | |
206 | static void mpbios_ioapic(const uint8_t *, device_t); | 206 | static void mpbios_ioapic(const uint8_t *, device_t); | |
207 | static void mpbios_int(const uint8_t *, int, struct mp_intr_map *); | 207 | static void mpbios_int(const uint8_t *, int, struct mp_intr_map *); | |
208 | 208 | |||
209 | static const void *mpbios_map(paddr_t, int, struct mp_map *); | 209 | static const void *mpbios_map(paddr_t, int, struct mp_map *); | |
210 | static void mpbios_unmap(struct mp_map *); | 210 | static void mpbios_unmap(struct mp_map *); | |
211 | 211 | |||
212 | /* | 212 | /* | |
213 | * globals to help us bounce our way through parsing the config table. | 213 | * globals to help us bounce our way through parsing the config table. | |
214 | */ | 214 | */ | |
215 | 215 | |||
@@ -218,38 +218,38 @@ static struct mp_map mp_fp_map; | @@ -218,38 +218,38 @@ static struct mp_map mp_fp_map; | |||
218 | const struct mpbios_cth *mp_cth; | 218 | const struct mpbios_cth *mp_cth; | |
219 | const struct mpbios_fps *mp_fps; | 219 | const struct mpbios_fps *mp_fps; | |
220 | 220 | |||
221 | int mpbios_scanned; | 221 | int mpbios_scanned; | |
222 | 222 | |||
223 | int | 223 | int | |
224 | mp_cpuprint(void *aux, const char *pnp) | 224 | mp_cpuprint(void *aux, const char *pnp) | |
225 | { | 225 | { | |
226 | struct cpu_attach_args *caa = aux; | 226 | struct cpu_attach_args *caa = aux; | |
227 | 227 | |||
228 | if (pnp) | 228 | if (pnp) | |
229 | aprint_normal("cpu at %s", pnp); | 229 | aprint_normal("cpu at %s", pnp); | |
230 | aprint_normal(" apid %d", caa->cpu_number); | 230 | aprint_normal(" apid %d", caa->cpu_number); | |
231 | return (UNCONF); | 231 | return UNCONF; | |
232 | } | 232 | } | |
233 | 233 | |||
234 | int | 234 | int | |
235 | mp_ioapicprint(void *aux, const char *pnp) | 235 | mp_ioapicprint(void *aux, const char *pnp) | |
236 | { | 236 | { | |
237 | struct apic_attach_args *aaa = aux; | 237 | struct apic_attach_args *aaa = aux; | |
238 | 238 | |||
239 | if (pnp) | 239 | if (pnp) | |
240 | aprint_normal("ioapic at %s", pnp); | 240 | aprint_normal("ioapic at %s", pnp); | |
241 | aprint_normal(" apid %d", aaa->apic_id); | 241 | aprint_normal(" apid %d", aaa->apic_id); | |
242 | return (UNCONF); | 242 | return UNCONF; | |
243 | } | 243 | } | |
244 | 244 | |||
245 | /* | 245 | /* | |
246 | * Map a chunk of memory read-only and return an appropriately | 246 | * Map a chunk of memory read-only and return an appropriately | |
247 | * const'ed pointer. | 247 | * const'ed pointer. | |
248 | */ | 248 | */ | |
249 | 249 | |||
250 | static const void * | 250 | static const void * | |
251 | mpbios_map(paddr_t pa, int len, struct mp_map *handle) | 251 | mpbios_map(paddr_t pa, int len, struct mp_map *handle) | |
252 | { | 252 | { | |
253 | paddr_t pgpa = x86_trunc_page(pa); | 253 | paddr_t pgpa = x86_trunc_page(pa); | |
254 | paddr_t endpa = x86_round_page(pa + len); | 254 | paddr_t endpa = x86_round_page(pa + len); | |
255 | vaddr_t va = uvm_km_alloc(kernel_map, endpa - pgpa, 0, UVM_KMF_VAONLY); | 255 | vaddr_t va = uvm_km_alloc(kernel_map, endpa - pgpa, 0, UVM_KMF_VAONLY); | |
@@ -275,32 +275,32 @@ inline static void | @@ -275,32 +275,32 @@ inline static void | |||
275 | mpbios_unmap(struct mp_map *handle) | 275 | mpbios_unmap(struct mp_map *handle) | |
276 | { | 276 | { | |
277 | pmap_kremove(handle->baseva, handle->vsize); | 277 | pmap_kremove(handle->baseva, handle->vsize); | |
278 | pmap_update(pmap_kernel()); | 278 | pmap_update(pmap_kernel()); | |
279 | uvm_km_free(kernel_map, handle->baseva, handle->vsize, UVM_KMF_VAONLY); | 279 | uvm_km_free(kernel_map, handle->baseva, handle->vsize, UVM_KMF_VAONLY); | |
280 | } | 280 | } | |
281 | 281 | |||
282 | /* | 282 | /* | |
283 | * Look for an Intel MP spec table, indicating SMP capable hardware. | 283 | * Look for an Intel MP spec table, indicating SMP capable hardware. | |
284 | */ | 284 | */ | |
285 | int | 285 | int | |
286 | mpbios_probe(device_t self) | 286 | mpbios_probe(device_t self) | |
287 | { | 287 | { | |
288 | paddr_t ebda, memtop; | 288 | paddr_t ebda, memtop; | |
289 | 289 | |||
290 | paddr_t cthpa; | 290 | paddr_t cthpa; | |
291 | int cthlen; | 291 | int cthlen; | |
292 | const uint8_t *mpbios_page; | 292 | const uint8_t *mpbios_page; | |
293 | int scan_loc; | 293 | int scan_loc; | |
294 | 294 | |||
295 | struct mp_map t; | 295 | struct mp_map t; | |
296 | 296 | |||
297 | /* If MP is disabled, don't use MPBIOS or the ioapics. */ | 297 | /* If MP is disabled, don't use MPBIOS or the ioapics. */ | |
298 | if ((boothowto & RB_MD1) != 0) | 298 | if ((boothowto & RB_MD1) != 0) | |
299 | return 0; | 299 | return 0; | |
300 | 300 | |||
301 | /* see if EBDA exists */ | 301 | /* see if EBDA exists */ | |
302 | 302 | |||
303 | mpbios_page = mpbios_map(0, PAGE_SIZE, &t); | 303 | mpbios_page = mpbios_map(0, PAGE_SIZE, &t); | |
304 | 304 | |||
305 | ebda = *(const uint16_t *)(&mpbios_page[0x40e]); | 305 | ebda = *(const uint16_t *)(&mpbios_page[0x40e]); | |
306 | ebda <<= 4; | 306 | ebda <<= 4; | |
@@ -540,27 +540,27 @@ static const uint8_t dflt_lint_tab[2] = | @@ -540,27 +540,27 @@ static const uint8_t dflt_lint_tab[2] = | |||
540 | * mp_ncpus = 1 | 540 | * mp_ncpus = 1 | |
541 | * | 541 | * | |
542 | * determines: | 542 | * determines: | |
543 | * cpu_apic_address (common to all CPUs) | 543 | * cpu_apic_address (common to all CPUs) | |
544 | * ioapic_address[N] | 544 | * ioapic_address[N] | |
545 | * mp_naps | 545 | * mp_naps | |
546 | * mp_nbus | 546 | * mp_nbus | |
547 | * mp_napics | 547 | * mp_napics | |
548 | * nintrs | 548 | * nintrs | |
549 | */ | 549 | */ | |
550 | void | 550 | void | |
551 | mpbios_scan(device_t self, int *ncpup) | 551 | mpbios_scan(device_t self, int *ncpup) | |
552 | { | 552 | { | |
553 | const uint8_t *position, *end; | 553 | const uint8_t *position, *end; | |
554 | size_t i; | 554 | size_t i; | |
555 | int count; | 555 | int count; | |
556 | int type; | 556 | int type; | |
557 | int intr_cnt, cur_intr; | 557 | int intr_cnt, cur_intr; | |
558 | #if NLAPIC > 0 | 558 | #if NLAPIC > 0 | |
559 | paddr_t lapic_base; | 559 | paddr_t lapic_base; | |
560 | #endif | 560 | #endif | |
561 | const struct dflt_conf_entry *dflt_conf; | 561 | const struct dflt_conf_entry *dflt_conf; | |
562 | const int *dflt_bus_irq; | 562 | const int *dflt_bus_irq; | |
563 | const struct mpbios_int *iep; | 563 | const struct mpbios_int *iep; | |
564 | struct mpbios_int ie; | 564 | struct mpbios_int ie; | |
565 | 565 | |||
566 | aprint_normal_dev(self, "Intel MP Specification "); | 566 | aprint_normal_dev(self, "Intel MP Specification "); | |
@@ -622,44 +622,44 @@ mpbios_scan(device_t self, int *ncpup) | @@ -622,44 +622,44 @@ mpbios_scan(device_t self, int *ncpup) | |||
622 | mpbios_dflt_conf_ioapic(self); | 622 | mpbios_dflt_conf_ioapic(self); | |
623 | 623 | |||
624 | /* | 624 | /* | |
625 | * Walk the table once, counting items. | 625 | * Walk the table once, counting items. | |
626 | */ | 626 | */ | |
627 | mp_nbus = 0; | 627 | mp_nbus = 0; | |
628 | for (i = 0; i < __arraycount(dflt_conf->bus_type); i++) { | 628 | for (i = 0; i < __arraycount(dflt_conf->bus_type); i++) { | |
629 | if (dflt_conf->bus_type[i] != NULL) | 629 | if (dflt_conf->bus_type[i] != NULL) | |
630 | mp_nbus++; | 630 | mp_nbus++; | |
631 | } | 631 | } | |
632 | KASSERT(mp_nbus != 0); | 632 | KASSERT(mp_nbus != 0); | |
633 | 633 | |||
634 | mp_busses = kmem_zalloc(sizeof(struct mp_bus) * mp_nbus, | 634 | mp_busses = kmem_zalloc(sizeof(struct mp_bus) * mp_nbus, | |
635 | KM_SLEEP); | 635 | KM_SLEEP); | |
636 | KASSERT(mp_busses != NULL); | 636 | KASSERT(mp_busses != NULL); | |
637 | 637 | |||
638 | /* INTIN0 */ | 638 | /* INTIN0 */ | |
639 | intr_cnt = (dflt_conf->flags & INTIN0_NC) ? 0 : 1; | 639 | intr_cnt = (dflt_conf->flags & INTIN0_NC) ? 0 : 1; | |
640 | /* INTINx */ | 640 | /* INTINx */ | |
641 | for (i = 0; i < __arraycount(dflt_bus_irq_tab[0]); i++) { | 641 | for (i = 0; i < __arraycount(dflt_bus_irq_tab[0]); i++) { | |
642 | if (dflt_bus_irq[i] >= 0) | 642 | if (dflt_bus_irq[i] >= 0) | |
643 | intr_cnt++; | 643 | intr_cnt++; | |
644 | } | 644 | } | |
645 | KASSERT(intr_cnt != 0); | 645 | KASSERT(intr_cnt != 0); | |
646 | 646 | |||
647 | /* LINTINx */ | 647 | /* LINTINx */ | |
648 | for (i = 0; i < __arraycount(dflt_lint_tab); i++) | 648 | for (i = 0; i < __arraycount(dflt_lint_tab); i++) | |
649 | intr_cnt++; | 649 | intr_cnt++; | |
650 | 650 | |||
651 | mp_intrs = kmem_zalloc(sizeof(struct mp_intr_map) * intr_cnt, | 651 | mp_intrs = kmem_zalloc(sizeof(struct mp_intr_map) * intr_cnt, | |
652 | KM_SLEEP); | 652 | KM_SLEEP); | |
653 | KASSERT(mp_intrs != NULL); | 653 | KASSERT(mp_intrs != NULL); | |
654 | mp_nintr = intr_cnt; | 654 | mp_nintr = intr_cnt; | |
655 | 655 | |||
656 | /* | 656 | /* | |
657 | * Re-walk the table, recording info of interest. | 657 | * Re-walk the table, recording info of interest. | |
658 | */ | 658 | */ | |
659 | mpbios_dflt_conf_bus(self, dflt_conf); | 659 | mpbios_dflt_conf_bus(self, dflt_conf); | |
660 | mpbios_dflt_conf_int(self, dflt_conf, dflt_bus_irq); | 660 | mpbios_dflt_conf_int(self, dflt_conf, dflt_bus_irq); | |
661 | } else { | 661 | } else { | |
662 | /* | 662 | /* | |
663 | * should not happen; mp_probe returns 0 in this case, | 663 | * should not happen; mp_probe returns 0 in this case, | |
664 | * but.. | 664 | * but.. | |
665 | */ | 665 | */ | |
@@ -867,51 +867,51 @@ mpbios_dflt_conf_ioapic(device_t self) | @@ -867,51 +867,51 @@ mpbios_dflt_conf_ioapic(device_t self) | |||
867 | struct mpbios_ioapic mpio; | 867 | struct mpbios_ioapic mpio; | |
868 | 868 | |||
869 | /* mpio.type is irrelevant for mpbios_ioapic(). */ | 869 | /* mpio.type is irrelevant for mpbios_ioapic(). */ | |
870 | mpio.apic_id = DFLT_IOAPIC_ID; | 870 | mpio.apic_id = DFLT_IOAPIC_ID; | |
871 | /* XXX Let ioapic driver read real APIC version... */ | 871 | /* XXX Let ioapic driver read real APIC version... */ | |
872 | mpio.apic_version = 0; | 872 | mpio.apic_version = 0; | |
873 | mpio.apic_flags = IOAPICENTRY_FLAG_EN; | 873 | mpio.apic_flags = IOAPICENTRY_FLAG_EN; | |
874 | mpio.apic_address = (uint32_t)IOAPIC_BASE_DEFAULT; | 874 | mpio.apic_address = (uint32_t)IOAPIC_BASE_DEFAULT; | |
875 | mpbios_ioapic((uint8_t *)&mpio, self); | 875 | mpbios_ioapic((uint8_t *)&mpio, self); | |
876 | } | 876 | } | |
877 | 877 | |||
878 | static void | 878 | static void | |
879 | mpbios_dflt_conf_int(device_t self, const struct dflt_conf_entry *dflt_conf, | 879 | mpbios_dflt_conf_int(device_t self, const struct dflt_conf_entry *dflt_conf, | |
880 | const int *dflt_bus_irq) | 880 | const int *dflt_bus_irq) | |
881 | { | 881 | { | |
882 | struct mpbios_int mpi; | 882 | struct mpbios_int mpi; | |
883 | size_t i; | 883 | size_t i; | |
884 | int cur_intr; | 884 | int cur_intr; | |
885 | uint16_t level_inv; | 885 | uint16_t level_inv; | |
886 | 886 | |||
887 | cur_intr = 0; | 887 | cur_intr = 0; | |
888 | /* | 888 | /* | |
889 | * INTIN0 | 889 | * INTIN0 | |
890 | */ | 890 | */ | |
891 | /* | 891 | /* | |
892 | * 8259A INTR is connected to INTIN0 for default configs 1-6, but not | 892 | * 8259A INTR is connected to INTIN0 for default configs 1-6, but not | |
893 | * for default config 7 (sec. 5.3). | 893 | * for default config 7 (sec. 5.3). | |
894 | */ | 894 | */ | |
895 | if ((dflt_conf->flags & INTIN0_NC) == 0) { | 895 | if ((dflt_conf->flags & INTIN0_NC) == 0) { | |
896 | /* mpi.type is irrelevant for mpbios_int(). */ | 896 | /* mpi.type is irrelevant for mpbios_int(). */ | |
897 | mpi.int_type = MPS_INTTYPE_ExtINT; | 897 | mpi.int_type = MPS_INTTYPE_ExtINT; | |
898 | mpi.int_flags = 0; | 898 | mpi.int_flags = 0; | |
899 | mpi.src_bus_id = 0; | 899 | mpi.src_bus_id = 0; | |
900 | mpi.src_bus_irq = 0; | 900 | mpi.src_bus_irq = 0; | |
901 | mpi.dst_apic_id = DFLT_IOAPIC_ID; | 901 | mpi.dst_apic_id = DFLT_IOAPIC_ID; | |
902 | mpi.dst_apic_int = 0; | 902 | mpi.dst_apic_int = 0; | |
903 | mpbios_int((u_int8_t *)&mpi, MPS_MCT_IOINT, | 903 | mpbios_int((u_int8_t *)&mpi, MPS_MCT_IOINT, | |
904 | &mp_intrs[cur_intr++]); | 904 | &mp_intrs[cur_intr++]); | |
905 | } | 905 | } | |
906 | 906 | |||
907 | /* | 907 | /* | |
908 | * INTINx | 908 | * INTINx | |
909 | */ | 909 | */ | |
910 | /* mpi.type is irrelevant for mpbios_int(). */ | 910 | /* mpi.type is irrelevant for mpbios_int(). */ | |
911 | mpi.int_type = MPS_INTTYPE_INT; | 911 | mpi.int_type = MPS_INTTYPE_INT; | |
912 | /* | 912 | /* | |
913 | * PCI interrupt lines appear as (E)ISA interrupt lines/on bus 0 | 913 | * PCI interrupt lines appear as (E)ISA interrupt lines/on bus 0 | |
914 | * (sec. 5.2). | 914 | * (sec. 5.2). | |
915 | */ | 915 | */ | |
916 | mpi.src_bus_id = 0; | 916 | mpi.src_bus_id = 0; | |
917 | mpi.dst_apic_id = DFLT_IOAPIC_ID; | 917 | mpi.dst_apic_id = DFLT_IOAPIC_ID; | |
@@ -928,48 +928,48 @@ mpbios_dflt_conf_int(device_t self, cons | @@ -928,48 +928,48 @@ mpbios_dflt_conf_int(device_t self, cons | |||
928 | level_inv = 0; | 928 | level_inv = 0; | |
929 | #endif | 929 | #endif | |
930 | } else if (dflt_conf->flags & MCA_INV) { | 930 | } else if (dflt_conf->flags & MCA_INV) { | |
931 | /* MCA systems have fixed inverters. */ | 931 | /* MCA systems have fixed inverters. */ | |
932 | level_inv = 0xffffU; | 932 | level_inv = 0xffffU; | |
933 | } else | 933 | } else | |
934 | level_inv = 0; | 934 | level_inv = 0; | |
935 | 935 | |||
936 | for (i = 0; i < __arraycount(dflt_bus_irq_tab[0]); i++) { | 936 | for (i = 0; i < __arraycount(dflt_bus_irq_tab[0]); i++) { | |
937 | if (dflt_bus_irq[i] >= 0) { | 937 | if (dflt_bus_irq[i] >= 0) { | |
938 | mpi.src_bus_irq = (uint8_t)dflt_bus_irq[i]; | 938 | mpi.src_bus_irq = (uint8_t)dflt_bus_irq[i]; | |
939 | if (level_inv & (1U << mpi.src_bus_irq)) | 939 | if (level_inv & (1U << mpi.src_bus_irq)) | |
940 | mpi.int_flags = (MPS_INTTR_LEVEL << 2) | 940 | mpi.int_flags = (MPS_INTTR_LEVEL << 2) | |
941 | | MPS_INTPO_ACTHI; | 941 | | MPS_INTPO_ACTHI; | |
942 | else | 942 | else | |
943 | mpi.int_flags = 0; /* conforms to bus spec. */ | 943 | mpi.int_flags = 0; /* conforms to bus spec. */ | |
944 | mpi.dst_apic_int = (uint8_t)i; | 944 | mpi.dst_apic_int = (uint8_t)i; | |
945 | mpbios_int((u_int8_t *)&mpi, MPS_MCT_IOINT, | 945 | mpbios_int((u_int8_t *)&mpi, MPS_MCT_IOINT, | |
946 | &mp_intrs[cur_intr++]); | 946 | &mp_intrs[cur_intr++]); | |
947 | } | 947 | } | |
948 | } | 948 | } | |
949 | 949 | |||
950 | /* | 950 | /* | |
951 | * LINTINx | 951 | * LINTINx | |
952 | */ | 952 | */ | |
953 | /* mpi.type is irrelevant for mpbios_int(). */ | 953 | /* mpi.type is irrelevant for mpbios_int(). */ | |
954 | mpi.int_flags = 0; | 954 | mpi.int_flags = 0; | |
955 | mpi.src_bus_id = 0; | 955 | mpi.src_bus_id = 0; | |
956 | mpi.src_bus_irq = 0; | 956 | mpi.src_bus_irq = 0; | |
957 | mpi.dst_apic_id = MPS_ALL_APICS; | 957 | mpi.dst_apic_id = MPS_ALL_APICS; | |
958 | for (i = 0; i < __arraycount(dflt_lint_tab); i++) { | 958 | for (i = 0; i < __arraycount(dflt_lint_tab); i++) { | |
959 | mpi.int_type = dflt_lint_tab[i]; | 959 | mpi.int_type = dflt_lint_tab[i]; | |
960 | mpi.dst_apic_int = (uint8_t)i; | 960 | mpi.dst_apic_int = (uint8_t)i; | |
961 | mpbios_int((u_int8_t *)&mpi, MPS_MCT_LINT, | 961 | mpbios_int((u_int8_t *)&mpi, MPS_MCT_LINT, | |
962 | &mp_intrs[cur_intr++]); | 962 | &mp_intrs[cur_intr++]); | |
963 | } | 963 | } | |
964 | } | 964 | } | |
965 | 965 | |||
966 | /* | 966 | /* | |
967 | * The following functions conspire to compute base ioapic redirection | 967 | * The following functions conspire to compute base ioapic redirection | |
968 | * table entry for a given interrupt line. | 968 | * table entry for a given interrupt line. | |
969 | * | 969 | * | |
970 | * Fill in: trigger mode, polarity, and possibly delivery mode. | 970 | * Fill in: trigger mode, polarity, and possibly delivery mode. | |
971 | */ | 971 | */ | |
972 | static void | 972 | static void | |
973 | mp_cfg_special_intr(const struct mpbios_int *entry, uint32_t *redir) | 973 | mp_cfg_special_intr(const struct mpbios_int *entry, uint32_t *redir) | |
974 | { | 974 | { | |
975 | 975 |
--- src/sys/arch/x86/x86/mtrr_i686.c 2020/01/31 08:21:11 1.31
+++ src/sys/arch/x86/x86/mtrr_i686.c 2021/10/07 12:52:27 1.32
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mtrr_i686.c,v 1.31 2020/01/31 08:21:11 maxv Exp $ */ | 1 | /* $NetBSD: mtrr_i686.c,v 1.32 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2000, 2011 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2000, 2011 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 Bill Sommerfeld. | 8 | * by Bill Sommerfeld. | |
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: mtrr_i686.c,v 1.31 2020/01/31 08:21:11 maxv Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: mtrr_i686.c,v 1.32 2021/10/07 12:52:27 msaitoh Exp $"); | |
34 | 34 | |||
35 | #include "opt_multiprocessor.h" | 35 | #include "opt_multiprocessor.h" | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | 39 | |||
40 | #include <sys/atomic.h> | 40 | #include <sys/atomic.h> | |
41 | #include <sys/cpu.h> | 41 | #include <sys/cpu.h> | |
42 | #include <sys/kmem.h> | 42 | #include <sys/kmem.h> | |
43 | #include <sys/proc.h> | 43 | #include <sys/proc.h> | |
44 | 44 | |||
45 | #include <uvm/uvm_extern.h> | 45 | #include <uvm/uvm_extern.h> | |
46 | 46 | |||
@@ -480,28 +480,28 @@ i686_mtrr_validate(struct mtrr *mtrrp, s | @@ -480,28 +480,28 @@ i686_mtrr_validate(struct mtrr *mtrrp, s | |||
480 | */ | 480 | */ | |
481 | if (p == NULL && (mtrrp->flags & MTRR_PRIVATE)) | 481 | if (p == NULL && (mtrrp->flags & MTRR_PRIVATE)) | |
482 | return EINVAL; | 482 | return EINVAL; | |
483 | 483 | |||
484 | high = mtrrp->base + mtrrp->len; | 484 | high = mtrrp->base + mtrrp->len; | |
485 | 485 | |||
486 | /* | 486 | /* | |
487 | * Check for bad types. | 487 | * Check for bad types. | |
488 | */ | 488 | */ | |
489 | if ((mtrrp->type == MTRR_TYPE_UNDEF1 || mtrrp->type == MTRR_TYPE_UNDEF2 | 489 | if ((mtrrp->type == MTRR_TYPE_UNDEF1 || mtrrp->type == MTRR_TYPE_UNDEF2 | |
490 | || mtrrp->type > MTRR_TYPE_WB) && (mtrrp->flags & MTRR_VALID)) | 490 | || mtrrp->type > MTRR_TYPE_WB) && (mtrrp->flags & MTRR_VALID)) | |
491 | return EINVAL; | 491 | return EINVAL; | |
492 | 492 | |||
493 | /* | 493 | /* | |
494 | * If write-combining is requested, make sure that the WC feature | 494 | * If write-combining is requested, make sure that the WC feature | |
495 | * is supported by the processor. | 495 | * is supported by the processor. | |
496 | */ | 496 | */ | |
497 | if (mtrrp->type == MTRR_TYPE_WC && | 497 | if (mtrrp->type == MTRR_TYPE_WC && | |
498 | !(i686_mtrr_cap & MTRR_I686_CAP_WC_MASK)) | 498 | !(i686_mtrr_cap & MTRR_I686_CAP_WC_MASK)) | |
499 | return ENODEV; | 499 | return ENODEV; | |
500 | 500 | |||
501 | /* | 501 | /* | |
502 | * Only use fixed ranges < 1M. | 502 | * Only use fixed ranges < 1M. | |
503 | */ | 503 | */ | |
504 | if ((mtrrp->flags & MTRR_FIXED) && high > 0x100000) | 504 | if ((mtrrp->flags & MTRR_FIXED) && high > 0x100000) | |
505 | return EINVAL; | 505 | return EINVAL; | |
506 | 506 | |||
507 | /* | 507 | /* | |
@@ -629,29 +629,29 @@ i686_mtrr_setone(struct mtrr *mtrrp, str | @@ -629,29 +629,29 @@ i686_mtrr_setone(struct mtrr *mtrrp, str | |||
629 | continue; | 629 | continue; | |
630 | } | 630 | } | |
631 | curlow = mtrr_var[i].base; | 631 | curlow = mtrr_var[i].base; | |
632 | curhigh = curlow + mtrr_var[i].len - 1; | 632 | curhigh = curlow + mtrr_var[i].len - 1; | |
633 | if (low == curlow && high == curhigh && | 633 | if (low == curlow && high == curhigh && | |
634 | (!(mtrr_var[i].flags & MTRR_PRIVATE) || | 634 | (!(mtrr_var[i].flags & MTRR_PRIVATE) || | |
635 | ((mtrrp->flags & MTRR_PRIVATE) && (p != NULL) && | 635 | ((mtrrp->flags & MTRR_PRIVATE) && (p != NULL) && | |
636 | (mtrr_var[i].owner == p->p_pid)))) { | 636 | (mtrr_var[i].owner == p->p_pid)))) { | |
637 | freep = &mtrr_var[i]; | 637 | freep = &mtrr_var[i]; | |
638 | break; | 638 | break; | |
639 | } | 639 | } | |
640 | if (((high >= curlow && high < curhigh) || | 640 | if (((high >= curlow && high < curhigh) || | |
641 | (low >= curlow && low < curhigh)) && | 641 | (low >= curlow && low < curhigh)) && | |
642 | (i686_mtrr_conflict(mtrr_var[i].type, mtrrp->type) || | 642 | (i686_mtrr_conflict(mtrr_var[i].type, mtrrp->type) || | |
643 | ((mtrr_var[i].flags & MTRR_PRIVATE) && | 643 | ((mtrr_var[i].flags & MTRR_PRIVATE) && | |
644 | (!(mtrrp->flags & MTRR_PRIVATE) || (p == NULL) || | 644 | (!(mtrrp->flags & MTRR_PRIVATE) || (p == NULL) || | |
645 | (mtrr_var[i].owner != p->p_pid))))) { | 645 | (mtrr_var[i].owner != p->p_pid))))) { | |
646 | return EBUSY; | 646 | return EBUSY; | |
647 | } | 647 | } | |
648 | } | 648 | } | |
649 | if (freep == NULL) | 649 | if (freep == NULL) | |
650 | return EBUSY; | 650 | return EBUSY; | |
651 | mtrrp->flags &= ~MTRR_CANTSET; | 651 | mtrrp->flags &= ~MTRR_CANTSET; | |
652 | *freep = *mtrrp; | 652 | *freep = *mtrrp; | |
653 | freep->owner = (mtrrp->flags & MTRR_PRIVATE) ? p->p_pid : 0; | 653 | freep->owner = (mtrrp->flags & MTRR_PRIVATE) ? p->p_pid : 0; | |
654 | 654 | |||
655 | return 0; | 655 | return 0; | |
656 | } | 656 | } | |
657 | 657 |
--- src/sys/arch/x86/x86/multiboot2.c 2021/10/03 18:47:16 1.7
+++ src/sys/arch/x86/x86/multiboot2.c 2021/10/07 12:52:27 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: multiboot2.c,v 1.7 2021/10/03 18:47:16 fcambus Exp $ */ | 1 | /* $NetBSD: multiboot2.c,v 1.8 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2005, 2006 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 Julio M. Merino Vidal. | 8 | * by Julio M. Merino Vidal. | |
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: multiboot2.c,v 1.7 2021/10/03 18:47:16 fcambus Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: multiboot2.c,v 1.8 2021/10/07 12:52:27 msaitoh Exp $"); | |
34 | 34 | |||
35 | #include "opt_multiboot.h" | 35 | #include "opt_multiboot.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/cdefs_elf.h> | 39 | #include <sys/cdefs_elf.h> | |
40 | #include <sys/boot_flag.h> | 40 | #include <sys/boot_flag.h> | |
41 | #include <sys/exec.h> | 41 | #include <sys/exec.h> | |
42 | #include <sys/exec_elf.h> | 42 | #include <sys/exec_elf.h> | |
43 | #include <sys/optstr.h> | 43 | #include <sys/optstr.h> | |
44 | #include <sys/ksyms.h> | 44 | #include <sys/ksyms.h> | |
45 | #include <sys/common_ansi.h> | 45 | #include <sys/common_ansi.h> | |
46 | #include <sys/intr.h> | 46 | #include <sys/intr.h> | |
@@ -62,63 +62,63 @@ typedef Elf_Word locore_Elf_Word; | @@ -62,63 +62,63 @@ typedef Elf_Word locore_Elf_Word; | |||
62 | typedef Elf_Addr locore_Elf_Addr; | 62 | typedef Elf_Addr locore_Elf_Addr; | |
63 | #endif | 63 | #endif | |
64 | 64 | |||
65 | #if !defined(MULTIBOOT) | 65 | #if !defined(MULTIBOOT) | |
66 | # error "MULTIBOOT not defined; this cannot happen." | 66 | # error "MULTIBOOT not defined; this cannot happen." | |
67 | #endif | 67 | #endif | |
68 | 68 | |||
69 | /* | 69 | /* | |
70 | * This is an attempt to get an early debug output. It | 70 | * This is an attempt to get an early debug output. It | |
71 | * requires EFI Boot Services, and it does not work anyway: | 71 | * requires EFI Boot Services, and it does not work anyway: | |
72 | * it causes EFI to try to handle interrupts while the kernel | 72 | * it causes EFI to try to handle interrupts while the kernel | |
73 | * already took that over, hence we get a reboot. | 73 | * already took that over, hence we get a reboot. | |
74 | */ | 74 | */ | |
75 | #define BS_PRINT(efisystbl, wstring) \ | 75 | #define BS_PRINT(efisystbl, wstring) \ | |
76 | efi_systbl->st_coutif->ei_outputstring(efi_systbl->st_coutif, \ | 76 | efi_systbl->st_coutif->ei_outputstring(efi_systbl->st_coutif, \ | |
77 | (efi_char *)__UNCONST(wstring)) | 77 | (efi_char *)__UNCONST(wstring)) | |
78 | 78 | |||
79 | struct multiboot_symbols { | 79 | struct multiboot_symbols { | |
80 | uint32_t s_symstart; | 80 | uint32_t s_symstart; | |
81 | uint32_t s_symsize; | 81 | uint32_t s_symsize; | |
82 | uint32_t s_strstart; | 82 | uint32_t s_strstart; | |
83 | uint32_t s_strsize; | 83 | uint32_t s_strsize; | |
84 | }; | 84 | }; | |
85 | 85 | |||
86 | void multiboot2_copy_syms(struct multiboot_tag_elf_sections *, | 86 | void multiboot2_copy_syms(struct multiboot_tag_elf_sections *, | |
87 | struct multiboot_symbols *, | 87 | struct multiboot_symbols *, | |
88 | bool *, int **, void *, vaddr_t); | 88 | bool *, int **, void *, vaddr_t); | |
89 | /* | 89 | /* | |
90 | * Because of clashes between multiboot.h and multiboot2.h we | 90 | * Because of clashes between multiboot.h and multiboot2.h we | |
91 | * cannot include both, and we need to redefine here: | 91 | * cannot include both, and we need to redefine here: | |
92 | */ | 92 | */ | |
93 | void multiboot2_pre_reloc(char *); | 93 | void multiboot2_pre_reloc(char *); | |
94 | void multiboot2_post_reloc(void); | 94 | void multiboot2_post_reloc(void); | |
95 | void multiboot2_print_info(void); | 95 | void multiboot2_print_info(void); | |
96 | bool multiboot2_ksyms_addsyms_elf(void); | 96 | bool multiboot2_ksyms_addsyms_elf(void); | |
97 | 97 | |||
98 | extern int biosbasemem; | 98 | extern int biosbasemem; | |
99 | extern int biosextmem; | 99 | extern int biosextmem; | |
100 | #ifdef __i386__ | 100 | #ifdef __i386__ | |
101 | extern int biosmem_implicit; | 101 | extern int biosmem_implicit; | |
102 | #endif | 102 | #endif | |
103 | extern int boothowto; | 103 | extern int boothowto; | |
104 | extern struct bootinfo bootinfo; | 104 | extern struct bootinfo bootinfo; | |
105 | extern int end; | 105 | extern int end; | |
106 | extern int * esym; | 106 | extern int * esym; | |
107 | extern char start; | 107 | extern char start; | |
108 | 108 | |||
109 | /* | 109 | /* | |
110 | * There is no way to perform dynamic allocation | 110 | * There is no way to perform dynamic allocation | |
111 | * at this time, hence we need to waste memory, | 111 | * at this time, hence we need to waste memory, | |
112 | * with the hope data will fit. | 112 | * with the hope data will fit. | |
113 | */ | 113 | */ | |
114 | char multiboot_info[16384] = "\0\0\0\0"; | 114 | char multiboot_info[16384] = "\0\0\0\0"; | |
115 | bool multiboot2_enabled = false; | 115 | bool multiboot2_enabled = false; | |
116 | bool has_syms = false; | 116 | bool has_syms = false; | |
117 | struct multiboot_symbols Multiboot_Symbols; | 117 | struct multiboot_symbols Multiboot_Symbols; | |
118 | 118 | |||
119 | #define RELOC(type, x) ((type)((vaddr_t)(x) - KERNBASE)) | 119 | #define RELOC(type, x) ((type)((vaddr_t)(x) - KERNBASE)) | |
120 | 120 | |||
121 | static void | 121 | static void | |
122 | efi_exit_bs(struct efi_systbl *efi_systbl, void *efi_ih) | 122 | efi_exit_bs(struct efi_systbl *efi_systbl, void *efi_ih) | |
123 | { | 123 | { | |
124 | struct efi_bs *efi_bs; | 124 | struct efi_bs *efi_bs; | |
@@ -159,27 +159,27 @@ efi_exit_bs(struct efi_systbl *efi_systb | @@ -159,27 +159,27 @@ efi_exit_bs(struct efi_systbl *efi_systb | |||
159 | panic("EFI AllocatePool failed"); | 159 | panic("EFI AllocatePool failed"); | |
160 | 160 | |||
161 | if (efi_bs->bs_getmemorymap(&bufsize, desc, &key, &size, &vers) != 0) | 161 | if (efi_bs->bs_getmemorymap(&bufsize, desc, &key, &size, &vers) != 0) | |
162 | panic("EFI GetMemoryMap failed"); | 162 | panic("EFI GetMemoryMap failed"); | |
163 | 163 | |||
164 | exit_bs: | 164 | exit_bs: | |
165 | if (efi_bs->bs_exitbootservices(efi_ih, key) != 0) | 165 | if (efi_bs->bs_exitbootservices(efi_ih, key) != 0) | |
166 | panic("EFI ExitBootServices failed"); | 166 | panic("EFI ExitBootServices failed"); | |
167 | 167 | |||
168 | return; | 168 | return; | |
169 | } | 169 | } | |
170 | 170 | |||
171 | void | 171 | void | |
172 | multiboot2_copy_syms(struct multiboot_tag_elf_sections *mbt_elf, | 172 | multiboot2_copy_syms(struct multiboot_tag_elf_sections *mbt_elf, | |
173 | struct multiboot_symbols *ms, | 173 | struct multiboot_symbols *ms, | |
174 | bool *has_symsp, int **esymp, void *endp, | 174 | bool *has_symsp, int **esymp, void *endp, | |
175 | vaddr_t kernbase) | 175 | vaddr_t kernbase) | |
176 | { | 176 | { | |
177 | int i; | 177 | int i; | |
178 | locore_Elf_Shdr *symtabp, *strtabp; | 178 | locore_Elf_Shdr *symtabp, *strtabp; | |
179 | locore_Elf_Word symsize, strsize; | 179 | locore_Elf_Word symsize, strsize; | |
180 | locore_Elf_Addr symaddr, straddr; | 180 | locore_Elf_Addr symaddr, straddr; | |
181 | locore_Elf_Addr symstart, strstart; | 181 | locore_Elf_Addr symstart, strstart; | |
182 | locore_Elf_Addr cp1src, cp1dst; | 182 | locore_Elf_Addr cp1src, cp1dst; | |
183 | locore_Elf_Word cp1size; | 183 | locore_Elf_Word cp1size; | |
184 | locore_Elf_Addr cp2src, cp2dst; | 184 | locore_Elf_Addr cp2src, cp2dst; | |
185 | locore_Elf_Word cp2size; | 185 | locore_Elf_Word cp2size; | |
@@ -219,35 +219,35 @@ multiboot2_copy_syms(struct multiboot_ta | @@ -219,35 +219,35 @@ multiboot2_copy_syms(struct multiboot_ta | |||
219 | 219 | |||
220 | /* | 220 | /* | |
221 | * Copy the symbol and string tables just after the kernel's | 221 | * Copy the symbol and string tables just after the kernel's | |
222 | * end address, in this order. Only the contents of these ELF | 222 | * end address, in this order. Only the contents of these ELF | |
223 | * sections are copied; headers are discarded. esym is later | 223 | * sections are copied; headers are discarded. esym is later | |
224 | * updated to point to the lowest "free" address after the tables | 224 | * updated to point to the lowest "free" address after the tables | |
225 | * so that they are mapped appropriately when enabling paging. | 225 | * so that they are mapped appropriately when enabling paging. | |
226 | * | 226 | * | |
227 | * We need to be careful to not overwrite valid data doing the | 227 | * We need to be careful to not overwrite valid data doing the | |
228 | * copies, hence all the different cases below. We can assume | 228 | * copies, hence all the different cases below. We can assume | |
229 | * that if the tables start before the kernel's end address, | 229 | * that if the tables start before the kernel's end address, | |
230 | * they will not grow over this address. | 230 | * they will not grow over this address. | |
231 | */ | 231 | */ | |
232 | if ((void *)(uintptr_t)symaddr < endp && | 232 | if ((void *)(uintptr_t)symaddr < endp && | |
233 | (void *)(uintptr_t)straddr < endp) { | 233 | (void *)(uintptr_t)straddr < endp) { | |
234 | cp1src = symaddr; cp1size = symsize; | 234 | cp1src = symaddr; cp1size = symsize; | |
235 | cp2src = straddr; cp2size = strsize; | 235 | cp2src = straddr; cp2size = strsize; | |
236 | } else if ((void *)(uintptr_t)symaddr > endp && | 236 | } else if ((void *)(uintptr_t)symaddr > endp && | |
237 | (void *)(uintptr_t)straddr < endp) { | 237 | (void *)(uintptr_t)straddr < endp) { | |
238 | cp1src = symaddr; cp1size = symsize; | 238 | cp1src = symaddr; cp1size = symsize; | |
239 | cp2src = straddr; cp2size = strsize; | 239 | cp2src = straddr; cp2size = strsize; | |
240 | } else if ((void *)(uintptr_t)symaddr < endp && | 240 | } else if ((void *)(uintptr_t)symaddr < endp && | |
241 | (void *)(uintptr_t)straddr > endp) { | 241 | (void *)(uintptr_t)straddr > endp) { | |
242 | cp1src = straddr; cp1size = strsize; | 242 | cp1src = straddr; cp1size = strsize; | |
243 | cp2src = symaddr; cp2size = symsize; | 243 | cp2src = symaddr; cp2size = symsize; | |
244 | } else { | 244 | } else { | |
245 | /* symaddr and straddr are both over end */ | 245 | /* symaddr and straddr are both over end */ | |
246 | if (symaddr < straddr) { | 246 | if (symaddr < straddr) { | |
247 | cp1src = symaddr; cp1size = symsize; | 247 | cp1src = symaddr; cp1size = symsize; | |
248 | cp2src = straddr; cp2size = strsize; | 248 | cp2src = straddr; cp2size = strsize; | |
249 | } else { | 249 | } else { | |
250 | cp1src = straddr; cp1size = strsize; | 250 | cp1src = straddr; cp1size = strsize; | |
251 | cp2src = symaddr; cp2size = symsize; | 251 | cp2src = symaddr; cp2size = symsize; | |
252 | } | 252 | } | |
253 | } | 253 | } | |
@@ -322,43 +322,43 @@ multiboot2_pre_reloc(char *mbi) | @@ -322,43 +322,43 @@ multiboot2_pre_reloc(char *mbi) | |||
322 | #endif | 322 | #endif | |
323 | case MULTIBOOT_TAG_TYPE_EFI_BS: | 323 | case MULTIBOOT_TAG_TYPE_EFI_BS: | |
324 | #if notyet | 324 | #if notyet | |
325 | has_bs = true; | 325 | has_bs = true; | |
326 | #endif | 326 | #endif | |
327 | break; | 327 | break; | |
328 | default: | 328 | default: | |
329 | break; | 329 | break; | |
330 | } | 330 | } | |
331 | } | 331 | } | |
332 | 332 | |||
333 | /* Broken */ | 333 | /* Broken */ | |
334 | if (has_bs) | 334 | if (has_bs) | |
335 | efi_exit_bs(efi_systbl, efi_ih); | 335 | efi_exit_bs(efi_systbl, efi_ih); | |
336 | 336 | |||
337 | if (mbt_elf) | 337 | if (mbt_elf) | |
338 | multiboot2_copy_syms(mbt_elf, | 338 | multiboot2_copy_syms(mbt_elf, | |
339 | RELOC(struct multiboot_symbols *, &Multiboot_Symbols), | 339 | RELOC(struct multiboot_symbols *, &Multiboot_Symbols), | |
340 | RELOC(bool *, &has_syms), | 340 | RELOC(bool *, &has_syms), | |
341 | RELOC(int **, &esym), | 341 | RELOC(int **, &esym), | |
342 | RELOC(void *, &end), | 342 | RELOC(void *, &end), | |
343 | KERNBASE); | 343 | KERNBASE); | |
344 | 344 | |||
345 | return; | 345 | return; | |
346 | } | 346 | } | |
347 | 347 | |||
348 | static struct btinfo_common * | 348 | static struct btinfo_common * | |
349 | bootinfo_init(int type, int len) | 349 | bootinfo_init(int type, int len) | |
350 | { | 350 | { | |
351 | int i; | 351 | int i; | |
352 | struct bootinfo *bip = (struct bootinfo *)&bootinfo; | 352 | struct bootinfo *bip = (struct bootinfo *)&bootinfo; | |
353 | vaddr_t data; | 353 | vaddr_t data; | |
354 | 354 | |||
355 | data = (vaddr_t)&bip->bi_data; | 355 | data = (vaddr_t)&bip->bi_data; | |
356 | for (i = 0; i < bip->bi_nentries; i++) { | 356 | for (i = 0; i < bip->bi_nentries; i++) { | |
357 | struct btinfo_common *tmp; | 357 | struct btinfo_common *tmp; | |
358 | 358 | |||
359 | tmp = (struct btinfo_common *)data; | 359 | tmp = (struct btinfo_common *)data; | |
360 | data += tmp->len; | 360 | data += tmp->len; | |
361 | } | 361 | } | |
362 | if (data + len < (vaddr_t)&bip->bi_data + sizeof(bip->bi_data)) { | 362 | if (data + len < (vaddr_t)&bip->bi_data + sizeof(bip->bi_data)) { | |
363 | /* Initialize the common part */ | 363 | /* Initialize the common part */ | |
364 | struct btinfo_common *item = (struct btinfo_common *)data; | 364 | struct btinfo_common *item = (struct btinfo_common *)data; | |
@@ -381,58 +381,58 @@ bootinfo_add(struct btinfo_common *item, | @@ -381,58 +381,58 @@ bootinfo_add(struct btinfo_common *item, | |||
381 | /* Copy the data after the common part over */ | 381 | /* Copy the data after the common part over */ | |
382 | memcpy(&bip[1], &item[1], len - sizeof(*item)); | 382 | memcpy(&bip[1], &item[1], len - sizeof(*item)); | |
383 | } | 383 | } | |
384 | 384 | |||
385 | static void | 385 | static void | |
386 | mbi_cmdline(struct multiboot_tag_string *mbt) | 386 | mbi_cmdline(struct multiboot_tag_string *mbt) | |
387 | { | 387 | { | |
388 | char *cmdline = mbt->string; | 388 | char *cmdline = mbt->string; | |
389 | struct btinfo_console bic; | 389 | struct btinfo_console bic; | |
390 | struct btinfo_rootdevice bir; | 390 | struct btinfo_rootdevice bir; | |
391 | char *cl; | 391 | char *cl; | |
392 | 392 | |||
393 | if (optstr_get(cmdline, "console", bic.devname, sizeof(bic.devname))) { | 393 | if (optstr_get(cmdline, "console", bic.devname, sizeof(bic.devname))) { | |
394 | if (strncmp(bic.devname, "com", sizeof(bic.devname)) == 0) { | 394 | if (strncmp(bic.devname, "com", sizeof(bic.devname)) == 0) { | |
395 | char opt[10]; | 395 | char opt[10]; | |
396 | 396 | |||
397 | if (optstr_get(cmdline, "console_speed", | 397 | if (optstr_get(cmdline, "console_speed", | |
398 | opt, sizeof(opt))) | 398 | opt, sizeof(opt))) | |
399 | bic.speed = strtoul(opt, NULL, 10); | 399 | bic.speed = strtoul(opt, NULL, 10); | |
400 | else | 400 | else | |
401 | bic.speed = 0; /* Use default speed. */ | 401 | bic.speed = 0; /* Use default speed. */ | |
402 | 402 | |||
403 | if (optstr_get(cmdline, "console_addr", | 403 | if (optstr_get(cmdline, "console_addr", | |
404 | opt, sizeof(opt))) { | 404 | opt, sizeof(opt))) { | |
405 | if (opt[0] == '0' && opt[1] == 'x') | 405 | if (opt[0] == '0' && opt[1] == 'x') | |
406 | bic.addr = strtoul(opt + 2, NULL, 16); | 406 | bic.addr = strtoul(opt + 2, NULL, 16); | |
407 | else | 407 | else | |
408 | bic.addr = strtoul(opt, NULL, 10); | 408 | bic.addr = strtoul(opt, NULL, 10); | |
409 | } else { | 409 | } else { | |
410 | bic.addr = 0; /* Use default address. */ | 410 | bic.addr = 0; /* Use default address. */ | |
411 | } | 411 | } | |
412 | 412 | |||
413 | bootinfo_add((struct btinfo_common *)&bic, | 413 | bootinfo_add((struct btinfo_common *)&bic, | |
414 | BTINFO_CONSOLE, sizeof(bic)); | 414 | BTINFO_CONSOLE, sizeof(bic)); | |
415 | 415 | |||
416 | } | 416 | } | |
417 | 417 | |||
418 | if (strncmp(bic.devname, "pc", sizeof(bic.devname)) == 0) | 418 | if (strncmp(bic.devname, "pc", sizeof(bic.devname)) == 0) | |
419 | bootinfo_add((struct btinfo_common *)&bic, | 419 | bootinfo_add((struct btinfo_common *)&bic, | |
420 | BTINFO_CONSOLE, sizeof(bic)); | 420 | BTINFO_CONSOLE, sizeof(bic)); | |
421 | } | 421 | } | |
422 | 422 | |||
423 | if (optstr_get(cmdline, "root", bir.devname, sizeof(bir.devname))) | 423 | if (optstr_get(cmdline, "root", bir.devname, sizeof(bir.devname))) | |
424 | bootinfo_add((struct btinfo_common *)&bir, BTINFO_ROOTDEVICE, | 424 | bootinfo_add((struct btinfo_common *)&bir, BTINFO_ROOTDEVICE, | |
425 | sizeof(bir)); | 425 | sizeof(bir)); | |
426 | 426 | |||
427 | /* | 427 | /* | |
428 | * Parse boot flags (-s and friends) | 428 | * Parse boot flags (-s and friends) | |
429 | */ | 429 | */ | |
430 | cl = cmdline; | 430 | cl = cmdline; | |
431 | 431 | |||
432 | /* Skip kernel file name. */ | 432 | /* Skip kernel file name. */ | |
433 | while (*cl != '\0' && *cl != ' ') | 433 | while (*cl != '\0' && *cl != ' ') | |
434 | cl++; | 434 | cl++; | |
435 | while (*cl == ' ') | 435 | while (*cl == ' ') | |
436 | cl++; | 436 | cl++; | |
437 | 437 | |||
438 | /* Check if there are flags and set 'howto' accordingly. */ | 438 | /* Check if there are flags and set 'howto' accordingly. */ | |
@@ -482,54 +482,54 @@ mbi_modules(char *mbi, uint32_t mbi_size | @@ -482,54 +482,54 @@ mbi_modules(char *mbi, uint32_t mbi_size | |||
482 | 482 | |||
483 | strncpy(bie->path, mbt->cmdline, sizeof(bie->path)); | 483 | strncpy(bie->path, mbt->cmdline, sizeof(bie->path)); | |
484 | bie->type = BI_MODULE_ELF; | 484 | bie->type = BI_MODULE_ELF; | |
485 | bie->len = mbt->mod_end - mbt->mod_start; | 485 | bie->len = mbt->mod_end - mbt->mod_start; | |
486 | bie->base = mbt->mod_start; | 486 | bie->base = mbt->mod_start; | |
487 | 487 | |||
488 | bie++; | 488 | bie++; | |
489 | } | 489 | } | |
490 | } | 490 | } | |
491 | 491 | |||
492 | static void | 492 | static void | |
493 | mbi_basic_meminfo(struct multiboot_tag_basic_meminfo *mbt) | 493 | mbi_basic_meminfo(struct multiboot_tag_basic_meminfo *mbt) | |
494 | { | 494 | { | |
495 | /* Make sure we don't override user-set variables. */ | 495 | /* Make sure we don't override user-set variables. */ | |
496 | if (biosbasemem == 0) { | 496 | if (biosbasemem == 0) { | |
497 | biosbasemem = mbt->mem_lower; | 497 | biosbasemem = mbt->mem_lower; | |
498 | #ifdef __i386__ | 498 | #ifdef __i386__ | |
499 | biosmem_implicit = 1; | 499 | biosmem_implicit = 1; | |
500 | #endif | 500 | #endif | |
501 | } | 501 | } | |
502 | if (biosextmem == 0) { | 502 | if (biosextmem == 0) { | |
503 | biosextmem = mbt->mem_upper; | 503 | biosextmem = mbt->mem_upper; | |
504 | #ifdef __i386__ | 504 | #ifdef __i386__ | |
505 | biosmem_implicit = 1; | 505 | biosmem_implicit = 1; | |
506 | #endif | 506 | #endif | |
507 | } | 507 | } | |
508 | 508 | |||
509 | return; | 509 | return; | |
510 | } | 510 | } | |
511 | 511 | |||
512 | static void | 512 | static void | |
513 | mbi_bootdev(struct multiboot_tag_bootdev *mbt) | 513 | mbi_bootdev(struct multiboot_tag_bootdev *mbt) | |
514 | { | 514 | { | |
515 | struct btinfo_bootdisk bid; | 515 | struct btinfo_bootdisk bid; | |
516 | 516 | |||
517 | bid.labelsector = -1; | 517 | bid.labelsector = -1; | |
518 | bid.biosdev = mbt->biosdev; | 518 | bid.biosdev = mbt->biosdev; | |
519 | bid.partition = mbt->slice; | 519 | bid.partition = mbt->slice; | |
520 | 520 | |||
521 | bootinfo_add((struct btinfo_common *)&bid, | 521 | bootinfo_add((struct btinfo_common *)&bid, | |
522 | BTINFO_BOOTDISK, sizeof(bid)); | 522 | BTINFO_BOOTDISK, sizeof(bid)); | |
523 | } | 523 | } | |
524 | 524 | |||
525 | static void | 525 | static void | |
526 | mbi_mmap(struct multiboot_tag_mmap *mbt) | 526 | mbi_mmap(struct multiboot_tag_mmap *mbt) | |
527 | { | 527 | { | |
528 | struct btinfo_memmap *bim; | 528 | struct btinfo_memmap *bim; | |
529 | int num; | 529 | int num; | |
530 | char *cp; | 530 | char *cp; | |
531 | 531 | |||
532 | if (mbt->entry_version != 0) | 532 | if (mbt->entry_version != 0) | |
533 | return; | 533 | return; | |
534 | 534 | |||
535 | /* Determine size */ | 535 | /* Determine size */ | |
@@ -584,55 +584,53 @@ mbi_mmap(struct multiboot_tag_mmap *mbt) | @@ -584,55 +584,53 @@ mbi_mmap(struct multiboot_tag_mmap *mbt) | |||
584 | 584 | |||
585 | static void | 585 | static void | |
586 | mbi_vbe(struct multiboot_tag_vbe *mbt, struct btinfo_framebuffer *bif) | 586 | mbi_vbe(struct multiboot_tag_vbe *mbt, struct btinfo_framebuffer *bif) | |
587 | { | 587 | { | |
588 | bif->vbemode = mbt->vbe_mode; | 588 | bif->vbemode = mbt->vbe_mode; | |
589 | return; | 589 | return; | |
590 | } | 590 | } | |
591 | 591 | |||
592 | static void | 592 | static void | |
593 | mbi_framebuffer(struct multiboot_tag_framebuffer *mbt, | 593 | mbi_framebuffer(struct multiboot_tag_framebuffer *mbt, | |
594 | struct btinfo_framebuffer *bif) | 594 | struct btinfo_framebuffer *bif) | |
595 | { | 595 | { | |
596 | bif->physaddr = mbt->common.framebuffer_addr; | 596 | bif->physaddr = mbt->common.framebuffer_addr; | |
597 | bif->width = mbt->common.framebuffer_width; | 597 | bif->width = mbt->common.framebuffer_width; | |
598 | bif->height = mbt->common.framebuffer_height; | 598 | bif->height = mbt->common.framebuffer_height; | |
599 | bif->depth = mbt->common.framebuffer_bpp; | 599 | bif->depth = mbt->common.framebuffer_bpp; | |
600 | bif->stride = mbt->common.framebuffer_pitch; | 600 | bif->stride = mbt->common.framebuffer_pitch; | |
601 | 601 | |||
602 | return; | 602 | return; | |
603 | } | 603 | } | |
604 | 604 | |||
605 | static void | 605 | static void | |
606 | mbi_efi32(struct multiboot_tag_efi32 *mbt) | 606 | mbi_efi32(struct multiboot_tag_efi32 *mbt) | |
607 | { | 607 | { | |
608 | struct btinfo_efi bie; | 608 | struct btinfo_efi bie; | |
609 | 609 | |||
610 | bie.systblpa = mbt->pointer; | 610 | bie.systblpa = mbt->pointer; | |
611 | bie.flags = BI_EFI_32BIT; | 611 | bie.flags = BI_EFI_32BIT; | |
612 | 612 | |||
613 | bootinfo_add((struct btinfo_common *)&bie, | 613 | bootinfo_add((struct btinfo_common *)&bie, BTINFO_EFI, sizeof(bie)); | |
614 | BTINFO_EFI, sizeof(bie)); | |||
615 | } | 614 | } | |
616 | 615 | |||
617 | static void | 616 | static void | |
618 | mbi_efi64(struct multiboot_tag_efi64 *mbt) | 617 | mbi_efi64(struct multiboot_tag_efi64 *mbt) | |
619 | { | 618 | { | |
620 | struct btinfo_efi bie; | 619 | struct btinfo_efi bie; | |
621 | 620 | |||
622 | bie.systblpa = mbt->pointer; | 621 | bie.systblpa = mbt->pointer; | |
623 | 622 | |||
624 | bootinfo_add((struct btinfo_common *)&bie, | 623 | bootinfo_add((struct btinfo_common *)&bie, BTINFO_EFI, sizeof(bie)); | |
625 | BTINFO_EFI, sizeof(bie)); | |||
626 | } | 624 | } | |
627 | 625 | |||
628 | static void | 626 | static void | |
629 | mbi_efi_mmap(struct multiboot_tag_efi_mmap *mbt) | 627 | mbi_efi_mmap(struct multiboot_tag_efi_mmap *mbt) | |
630 | { | 628 | { | |
631 | struct btinfo_efimemmap *bie; | 629 | struct btinfo_efimemmap *bie; | |
632 | size_t bie_len; | 630 | size_t bie_len; | |
633 | 631 | |||
634 | if (mbt->descr_vers != 0) | 632 | if (mbt->descr_vers != 0) | |
635 | return; | 633 | return; | |
636 | 634 | |||
637 | bie_len = sizeof(*bie) + mbt->size - sizeof(*mbt); | 635 | bie_len = sizeof(*bie) + mbt->size - sizeof(*mbt); | |
638 | bie = (struct btinfo_efimemmap *)bootinfo_init(BTINFO_EFIMEMMAP, | 636 | bie = (struct btinfo_efimemmap *)bootinfo_init(BTINFO_EFIMEMMAP, | |
@@ -662,27 +660,27 @@ multiboot2_post_reloc(void) | @@ -662,27 +660,27 @@ multiboot2_post_reloc(void) | |||
662 | 660 | |||
663 | mbi_size = *(uint32_t *)multiboot_info; | 661 | mbi_size = *(uint32_t *)multiboot_info; | |
664 | if (mbi_size < 2 * sizeof(uint32_t)) | 662 | if (mbi_size < 2 * sizeof(uint32_t)) | |
665 | goto out; | 663 | goto out; | |
666 | 664 | |||
667 | bootinfo.bi_nentries = 0; | 665 | bootinfo.bi_nentries = 0; | |
668 | 666 | |||
669 | memset(&fbinfo, 0, sizeof(fbinfo)); | 667 | memset(&fbinfo, 0, sizeof(fbinfo)); | |
670 | 668 | |||
671 | for (cp = mbi + (2 * sizeof(uint32_t)); | 669 | for (cp = mbi + (2 * sizeof(uint32_t)); | |
672 | cp - mbi < mbi_size; | 670 | cp - mbi < mbi_size; | |
673 | cp += roundup(mbt->size, MULTIBOOT_INFO_ALIGN)) { | 671 | cp += roundup(mbt->size, MULTIBOOT_INFO_ALIGN)) { | |
674 | mbt = (struct multiboot_tag *)cp; | 672 | mbt = (struct multiboot_tag *)cp; | |
675 | switch(mbt->type) { | 673 | switch (mbt->type) { | |
676 | case MULTIBOOT_TAG_TYPE_CMDLINE: | 674 | case MULTIBOOT_TAG_TYPE_CMDLINE: | |
677 | mbi_cmdline((void *)mbt); | 675 | mbi_cmdline((void *)mbt); | |
678 | break; | 676 | break; | |
679 | case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME: | 677 | case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME: | |
680 | break; | 678 | break; | |
681 | case MULTIBOOT_TAG_TYPE_MMAP: | 679 | case MULTIBOOT_TAG_TYPE_MMAP: | |
682 | mbi_mmap((void *)mbt); | 680 | mbi_mmap((void *)mbt); | |
683 | break; | 681 | break; | |
684 | case MULTIBOOT_TAG_TYPE_MODULE: | 682 | case MULTIBOOT_TAG_TYPE_MODULE: | |
685 | module_count++; | 683 | module_count++; | |
686 | break; | 684 | break; | |
687 | case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: | 685 | case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: | |
688 | mbi_basic_meminfo((void *)mbt); | 686 | mbi_basic_meminfo((void *)mbt); | |
@@ -716,47 +714,47 @@ multiboot2_post_reloc(void) | @@ -716,47 +714,47 @@ multiboot2_post_reloc(void) | |||
716 | break; | 714 | break; | |
717 | case MULTIBOOT_TAG_TYPE_EFI_BS: | 715 | case MULTIBOOT_TAG_TYPE_EFI_BS: | |
718 | case MULTIBOOT_TAG_TYPE_EFI32_IH: | 716 | case MULTIBOOT_TAG_TYPE_EFI32_IH: | |
719 | case MULTIBOOT_TAG_TYPE_EFI64_IH: | 717 | case MULTIBOOT_TAG_TYPE_EFI64_IH: | |
720 | case MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR: | 718 | case MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR: | |
721 | case MULTIBOOT_TAG_TYPE_END: | 719 | case MULTIBOOT_TAG_TYPE_END: | |
722 | default: | 720 | default: | |
723 | break; | 721 | break; | |
724 | } | 722 | } | |
725 | } | 723 | } | |
726 | 724 | |||
727 | if (has_fbinfo) | 725 | if (has_fbinfo) | |
728 | bootinfo_add((struct btinfo_common *)&fbinfo, | 726 | bootinfo_add((struct btinfo_common *)&fbinfo, | |
729 | BTINFO_FRAMEBUFFER, sizeof(fbinfo)); | 727 | BTINFO_FRAMEBUFFER, sizeof(fbinfo)); | |
730 | 728 | |||
731 | if (module_count > 0) | 729 | if (module_count > 0) | |
732 | mbi_modules(mbi, mbi_size, module_count); | 730 | mbi_modules(mbi, mbi_size, module_count); | |
733 | 731 | |||
734 | out: | 732 | out: | |
735 | return; | 733 | return; | |
736 | } | 734 | } | |
737 | 735 | |||
738 | 736 | |||
739 | #ifdef DEBUG | 737 | #ifdef DEBUG | |
740 | static void | 738 | static void | |
741 | mbi_hexdump(char *addr, size_t len) | 739 | mbi_hexdump(char *addr, size_t len) | |
742 | { | 740 | { | |
743 | int i,j; | 741 | int i,j; | |
744 | 742 | |||
745 | for (i = 0; i < len; i += 16) { | 743 | for (i = 0; i < len; i += 16) { | |
746 | printf(" %p ", addr + i); | 744 | printf(" %p ", addr + i); | |
747 | for (j = 0; j < 16 && i + j < len; j++) { | 745 | for (j = 0; j < 16 && i + j < len; j++) { | |
748 | char *cp = addr + i + j; | 746 | char *cp = addr + i + j; | |
749 | printf("%s%s%x", | 747 | printf("%s%s%x", | |
750 | (i+j) % 4 ? "" : " ", | 748 | (i+j) % 4 ? "" : " ", | |
751 | (unsigned char)*cp < 0x10 ? "0" : "", | 749 | (unsigned char)*cp < 0x10 ? "0" : "", | |
752 | (unsigned char)*cp); | 750 | (unsigned char)*cp); | |
753 | } | 751 | } | |
754 | printf("\n"); | 752 | printf("\n"); | |
755 | } | 753 | } | |
756 | 754 | |||
757 | return; | 755 | return; | |
758 | } | 756 | } | |
759 | #endif | 757 | #endif | |
760 | 758 | |||
761 | static const char * | 759 | static const char * | |
762 | mbi_tag_name(uint32_t type) | 760 | mbi_tag_name(uint32_t type) | |
@@ -884,30 +882,30 @@ multiboot2_print_info(void) | @@ -884,30 +882,30 @@ multiboot2_print_info(void) | |||
884 | case MULTIBOOT_TAG_TYPE_MMAP: { | 882 | case MULTIBOOT_TAG_TYPE_MMAP: { | |
885 | struct multiboot_tag_mmap *memmap; | 883 | struct multiboot_tag_mmap *memmap; | |
886 | multiboot_memory_map_t *mmap; | 884 | multiboot_memory_map_t *mmap; | |
887 | uint32_t entry_size; | 885 | uint32_t entry_size; | |
888 | uint32_t entry_version; | 886 | uint32_t entry_version; | |
889 | 887 | |||
890 | memmap = (struct multiboot_tag_mmap *)mbt; | 888 | memmap = (struct multiboot_tag_mmap *)mbt; | |
891 | entry_size = memmap->entry_size; | 889 | entry_size = memmap->entry_size; | |
892 | entry_version = memmap->entry_version; | 890 | entry_version = memmap->entry_version; | |
893 | printf ("entry version = %d\n", entry_version); | 891 | printf ("entry version = %d\n", entry_version); | |
894 | 892 | |||
895 | if (entry_version != 0) | 893 | if (entry_version != 0) | |
896 | break; | 894 | break; | |
897 | 895 | |||
898 | for (mmap = ((struct multiboot_tag_mmap *)mbt)->entries; | 896 | for (mmap = ((struct multiboot_tag_mmap *)mbt)->entries; | |
899 | (char *)mmap - (char *)mbt < mbt->size; | 897 | (char *)mmap - (char *)mbt < mbt->size; | |
900 | mmap = (void *)((char *)mmap + entry_size)) | 898 | mmap = (void *)((char *)mmap + entry_size)) | |
901 | printf(" 0x%016"PRIx64" @ 0x%016"PRIx64" " | 899 | printf(" 0x%016"PRIx64" @ 0x%016"PRIx64" " | |
902 | "type 0x%x\n", | 900 | "type 0x%x\n", | |
903 | (uint64_t)mmap->len, (uint64_t)mmap->addr, | 901 | (uint64_t)mmap->len, (uint64_t)mmap->addr, | |
904 | mmap->type); | 902 | mmap->type); | |
905 | break; | 903 | break; | |
906 | } | 904 | } | |
907 | case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: { | 905 | case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: { | |
908 | struct multiboot_tag_framebuffer *fb = (void *)mbt; | 906 | struct multiboot_tag_framebuffer *fb = (void *)mbt; | |
909 | 907 | |||
910 | printf ("%dx%dx%d @ 0x%"PRIx64"\n", | 908 | printf ("%dx%dx%d @ 0x%"PRIx64"\n", | |
911 | fb->common.framebuffer_width, | 909 | fb->common.framebuffer_width, | |
912 | fb->common.framebuffer_height, | 910 | fb->common.framebuffer_height, | |
913 | fb->common.framebuffer_bpp, | 911 | fb->common.framebuffer_bpp, | |
@@ -942,27 +940,27 @@ multiboot2_print_info(void) | @@ -942,27 +940,27 @@ multiboot2_print_info(void) | |||
942 | ((struct multiboot_tag_apm *)mbt)->dseg_len); | 940 | ((struct multiboot_tag_apm *)mbt)->dseg_len); | |
943 | break; | 941 | break; | |
944 | case MULTIBOOT_TAG_TYPE_EFI32: | 942 | case MULTIBOOT_TAG_TYPE_EFI32: | |
945 | printf("0x%x\n", | 943 | printf("0x%x\n", | |
946 | ((struct multiboot_tag_efi32 *)mbt)->pointer); | 944 | ((struct multiboot_tag_efi32 *)mbt)->pointer); | |
947 | break; | 945 | break; | |
948 | case MULTIBOOT_TAG_TYPE_EFI64: | 946 | case MULTIBOOT_TAG_TYPE_EFI64: | |
949 | printf("0x%"PRIx64"\n", (uint64_t) | 947 | printf("0x%"PRIx64"\n", (uint64_t) | |
950 | ((struct multiboot_tag_efi64 *)mbt)->pointer); | 948 | ((struct multiboot_tag_efi64 *)mbt)->pointer); | |
951 | break; | 949 | break; | |
952 | case MULTIBOOT_TAG_TYPE_SMBIOS: | 950 | case MULTIBOOT_TAG_TYPE_SMBIOS: | |
953 | printf("major = %d, minor = %d\n", | 951 | printf("major = %d, minor = %d\n", | |
954 | ((struct multiboot_tag_smbios *)mbt)->major, | 952 | ((struct multiboot_tag_smbios *)mbt)->major, | |
955 | ((struct multiboot_tag_smbios *)mbt)->minor); | 953 | ((struct multiboot_tag_smbios *)mbt)->minor); | |
956 | #ifdef DEBUG | 954 | #ifdef DEBUG | |
957 | mbi_hexdump((char *)mbt, mbt->size); | 955 | mbi_hexdump((char *)mbt, mbt->size); | |
958 | #endif | 956 | #endif | |
959 | break; | 957 | break; | |
960 | case MULTIBOOT_TAG_TYPE_ACPI_OLD: | 958 | case MULTIBOOT_TAG_TYPE_ACPI_OLD: | |
961 | printf("\n"); | 959 | printf("\n"); | |
962 | #ifdef DEBUG | 960 | #ifdef DEBUG | |
963 | mbi_hexdump((char *)mbt, mbt->size); | 961 | mbi_hexdump((char *)mbt, mbt->size); | |
964 | #endif | 962 | #endif | |
965 | break; | 963 | break; | |
966 | case MULTIBOOT_TAG_TYPE_ACPI_NEW: | 964 | case MULTIBOOT_TAG_TYPE_ACPI_NEW: | |
967 | printf("\n"); | 965 | printf("\n"); | |
968 | #ifdef DEBUG | 966 | #ifdef DEBUG | |
@@ -975,27 +973,27 @@ multiboot2_print_info(void) | @@ -975,27 +973,27 @@ multiboot2_print_info(void) | |||
975 | mbi_hexdump((char *)mbt, mbt->size); | 973 | mbi_hexdump((char *)mbt, mbt->size); | |
976 | #endif | 974 | #endif | |
977 | break; | 975 | break; | |
978 | case MULTIBOOT_TAG_TYPE_EFI_MMAP: | 976 | case MULTIBOOT_TAG_TYPE_EFI_MMAP: | |
979 | printf("\n"); | 977 | printf("\n"); | |
980 | #ifdef DEBUG | 978 | #ifdef DEBUG | |
981 | mbi_hexdump((char *)mbt, mbt->size); | 979 | mbi_hexdump((char *)mbt, mbt->size); | |
982 | #endif | 980 | #endif | |
983 | break; | 981 | break; | |
984 | case MULTIBOOT_TAG_TYPE_EFI_BS: | 982 | case MULTIBOOT_TAG_TYPE_EFI_BS: | |
985 | printf("\n"); | 983 | printf("\n"); | |
986 | break; | 984 | break; | |
987 | case MULTIBOOT_TAG_TYPE_EFI32_IH: | 985 | case MULTIBOOT_TAG_TYPE_EFI32_IH: | |
988 | printf("0x%"PRIx32"\n", | 986 | printf("0x%"PRIx32"\n", | |
989 | ((struct multiboot_tag_efi32_ih *)mbt)->pointer); | 987 | ((struct multiboot_tag_efi32_ih *)mbt)->pointer); | |
990 | break; | 988 | break; | |
991 | case MULTIBOOT_TAG_TYPE_EFI64_IH: | 989 | case MULTIBOOT_TAG_TYPE_EFI64_IH: | |
992 | printf("0x%"PRIx64"\n", (uint64_t) | 990 | printf("0x%"PRIx64"\n", (uint64_t) | |
993 | ((struct multiboot_tag_efi64_ih *)mbt)->pointer); | 991 | ((struct multiboot_tag_efi64_ih *)mbt)->pointer); | |
994 | break; | 992 | break; | |
995 | case MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR: { | 993 | case MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR: { | |
996 | struct multiboot_tag_load_base_addr *ld = (void *)mbt; | 994 | struct multiboot_tag_load_base_addr *ld = (void *)mbt; | |
997 | printf("0x%x\n", ld->load_base_addr); | 995 | printf("0x%x\n", ld->load_base_addr); | |
998 | break; | 996 | break; | |
999 | } | 997 | } | |
1000 | case MULTIBOOT_TAG_TYPE_END: | 998 | case MULTIBOOT_TAG_TYPE_END: | |
1001 | printf("\n"); | 999 | printf("\n"); |
--- src/sys/arch/x86/x86/pmap.c 2021/08/02 12:56:23 1.411
+++ src/sys/arch/x86/x86/pmap.c 2021/10/07 12:52:27 1.412
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pmap.c,v 1.411 2021/08/02 12:56:23 andvar Exp $ */ | 1 | /* $NetBSD: pmap.c,v 1.412 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 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 Andrew Doran, and by Maxime Villard. | 8 | * by Andrew Doran, and by Maxime Villard. | |
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. | |
@@ -120,27 +120,27 @@ | @@ -120,27 +120,27 @@ | |||
120 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 120 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
121 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 121 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
122 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 122 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
123 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 123 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
124 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 124 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
125 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 125 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
126 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 126 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
127 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 127 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
128 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 128 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
129 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 129 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
130 | */ | 130 | */ | |
131 | 131 | |||
132 | #include <sys/cdefs.h> | 132 | #include <sys/cdefs.h> | |
133 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.411 2021/08/02 12:56:23 andvar Exp $"); | 133 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.412 2021/10/07 12:52:27 msaitoh Exp $"); | |
134 | 134 | |||
135 | #include "opt_user_ldt.h" | 135 | #include "opt_user_ldt.h" | |
136 | #include "opt_lockdebug.h" | 136 | #include "opt_lockdebug.h" | |
137 | #include "opt_multiprocessor.h" | 137 | #include "opt_multiprocessor.h" | |
138 | #include "opt_xen.h" | 138 | #include "opt_xen.h" | |
139 | #include "opt_svs.h" | 139 | #include "opt_svs.h" | |
140 | #include "opt_kaslr.h" | 140 | #include "opt_kaslr.h" | |
141 | 141 | |||
142 | #define __MUTEX_PRIVATE /* for assertions */ | 142 | #define __MUTEX_PRIVATE /* for assertions */ | |
143 | 143 | |||
144 | #include <sys/param.h> | 144 | #include <sys/param.h> | |
145 | #include <sys/systm.h> | 145 | #include <sys/systm.h> | |
146 | #include <sys/proc.h> | 146 | #include <sys/proc.h> | |
@@ -222,27 +222,27 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.4 | @@ -222,27 +222,27 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.4 | |||
222 | * page is mapped in. this is critical for page based operations | 222 | * page is mapped in. this is critical for page based operations | |
223 | * such as pmap_page_protect() [change protection on _all_ mappings | 223 | * such as pmap_page_protect() [change protection on _all_ mappings | |
224 | * of a page] | 224 | * of a page] | |
225 | */ | 225 | */ | |
226 | 226 | |||
227 | /* | 227 | /* | |
228 | * Locking | 228 | * Locking | |
229 | * | 229 | * | |
230 | * We have the following locks that we must deal with, listed in the order | 230 | * We have the following locks that we must deal with, listed in the order | |
231 | * that they are acquired: | 231 | * that they are acquired: | |
232 | * | 232 | * | |
233 | * pg->uobject->vmobjlock, pg->uanon->an_lock | 233 | * pg->uobject->vmobjlock, pg->uanon->an_lock | |
234 | * | 234 | * | |
235 | * For managed pages, these per-object locks are taken by the VM system | 235 | * For managed pages, these per-object locks are taken by the VM system | |
236 | * before calling into the pmap module - either a read or write hold. | 236 | * before calling into the pmap module - either a read or write hold. | |
237 | * The lock hold prevent pages from changing identity while the pmap is | 237 | * The lock hold prevent pages from changing identity while the pmap is | |
238 | * operating on them. For example, the same lock is held across a call | 238 | * operating on them. For example, the same lock is held across a call | |
239 | * to pmap_remove() and the following call to pmap_update(), so that a | 239 | * to pmap_remove() and the following call to pmap_update(), so that a | |
240 | * page does not gain a new identity while its TLB visibility is stale. | 240 | * page does not gain a new identity while its TLB visibility is stale. | |
241 | * | 241 | * | |
242 | * pmap->pm_lock | 242 | * pmap->pm_lock | |
243 | * | 243 | * | |
244 | * This lock protects the fields in the pmap structure including the | 244 | * This lock protects the fields in the pmap structure including the | |
245 | * non-kernel PDEs in the PDP, the PTEs, and PTPs and connected data | 245 | * non-kernel PDEs in the PDP, the PTEs, and PTPs and connected data | |
246 | * structures. For modifying unmanaged kernel PTEs it is not needed as | 246 | * structures. For modifying unmanaged kernel PTEs it is not needed as | |
247 | * kernel PDEs are never freed, and the kernel is expected to be self | 247 | * kernel PDEs are never freed, and the kernel is expected to be self | |
248 | * consistent (and the lock can't be taken for unmanaged kernel PTEs, | 248 | * consistent (and the lock can't be taken for unmanaged kernel PTEs, | |
@@ -2877,27 +2877,27 @@ pmap_create(void) | @@ -2877,27 +2877,27 @@ pmap_create(void) | |||
2877 | pmap->pm_extract = NULL; | 2877 | pmap->pm_extract = NULL; | |
2878 | pmap->pm_remove = NULL; | 2878 | pmap->pm_remove = NULL; | |
2879 | pmap->pm_sync_pv = NULL; | 2879 | pmap->pm_sync_pv = NULL; | |
2880 | pmap->pm_pp_remove_ent = NULL; | 2880 | pmap->pm_pp_remove_ent = NULL; | |
2881 | pmap->pm_write_protect = NULL; | 2881 | pmap->pm_write_protect = NULL; | |
2882 | pmap->pm_unwire = NULL; | 2882 | pmap->pm_unwire = NULL; | |
2883 | pmap->pm_tlb_flush = NULL; | 2883 | pmap->pm_tlb_flush = NULL; | |
2884 | pmap->pm_data = NULL; | 2884 | pmap->pm_data = NULL; | |
2885 | 2885 | |||
2886 | /* init the LDT */ | 2886 | /* init the LDT */ | |
2887 | pmap->pm_ldt = NULL; | 2887 | pmap->pm_ldt = NULL; | |
2888 | pmap->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL); | 2888 | pmap->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL); | |
2889 | 2889 | |||
2890 | return (pmap); | 2890 | return pmap; | |
2891 | } | 2891 | } | |
2892 | 2892 | |||
2893 | /* | 2893 | /* | |
2894 | * pmap_check_ptps: verify that none of the pmap's page table objects | 2894 | * pmap_check_ptps: verify that none of the pmap's page table objects | |
2895 | * have any pages allocated to them. | 2895 | * have any pages allocated to them. | |
2896 | */ | 2896 | */ | |
2897 | static void | 2897 | static void | |
2898 | pmap_check_ptps(struct pmap *pmap) | 2898 | pmap_check_ptps(struct pmap *pmap) | |
2899 | { | 2899 | { | |
2900 | int i; | 2900 | int i; | |
2901 | 2901 | |||
2902 | for (i = 0; i < PTP_LEVELS - 1; i++) { | 2902 | for (i = 0; i < PTP_LEVELS - 1; i++) { | |
2903 | KASSERTMSG(pmap->pm_obj[i].uo_npages == 0, | 2903 | KASSERTMSG(pmap->pm_obj[i].uo_npages == 0, | |
@@ -3275,30 +3275,30 @@ retry: | @@ -3275,30 +3275,30 @@ retry: | |||
3275 | uvm_km_free(kernel_map, (vaddr_t)new_ldt, | 3275 | uvm_km_free(kernel_map, (vaddr_t)new_ldt, | |
3276 | MAX_USERLDT_SIZE, UVM_KMF_WIRED); | 3276 | MAX_USERLDT_SIZE, UVM_KMF_WIRED); | |
3277 | printf("WARNING: %s: unable to allocate LDT selector\n", | 3277 | printf("WARNING: %s: unable to allocate LDT selector\n", | |
3278 | __func__); | 3278 | __func__); | |
3279 | return; | 3279 | return; | |
3280 | } | 3280 | } | |
3281 | } else { | 3281 | } else { | |
3282 | /* Wasn't anything there after all. */ | 3282 | /* Wasn't anything there after all. */ | |
3283 | new_ldt = NULL; | 3283 | new_ldt = NULL; | |
3284 | sel = -1; | 3284 | sel = -1; | |
3285 | mutex_enter(&cpu_lock); | 3285 | mutex_enter(&cpu_lock); | |
3286 | } | 3286 | } | |
3287 | 3287 | |||
3288 | /* | 3288 | /* | |
3289 | * Now that we have cpu_lock, ensure the LDT status is the same. | 3289 | * Now that we have cpu_lock, ensure the LDT status is the same. | |
3290 | */ | 3290 | */ | |
3291 | if (pmap1->pm_ldt != NULL) { | 3291 | if (pmap1->pm_ldt != NULL) { | |
3292 | if (new_ldt == NULL) { | 3292 | if (new_ldt == NULL) { | |
3293 | /* A wild LDT just appeared. */ | 3293 | /* A wild LDT just appeared. */ | |
3294 | mutex_exit(&cpu_lock); | 3294 | mutex_exit(&cpu_lock); | |
3295 | goto retry; | 3295 | goto retry; | |
3296 | } | 3296 | } | |
3297 | 3297 | |||
3298 | /* Copy the LDT data and install it in pmap2 */ | 3298 | /* Copy the LDT data and install it in pmap2 */ | |
3299 | memcpy(new_ldt, pmap1->pm_ldt, MAX_USERLDT_SIZE); | 3299 | memcpy(new_ldt, pmap1->pm_ldt, MAX_USERLDT_SIZE); | |
3300 | pmap2->pm_ldt = new_ldt; | 3300 | pmap2->pm_ldt = new_ldt; | |
3301 | pmap2->pm_ldt_sel = sel; | 3301 | pmap2->pm_ldt_sel = sel; | |
3302 | mutex_exit(&cpu_lock); | 3302 | mutex_exit(&cpu_lock); | |
3303 | } else { | 3303 | } else { | |
3304 | if (new_ldt != NULL) { | 3304 | if (new_ldt != NULL) { | |
@@ -3424,27 +3424,27 @@ pmap_activate(struct lwp *l) | @@ -3424,27 +3424,27 @@ pmap_activate(struct lwp *l) | |||
3424 | } | 3424 | } | |
3425 | 3425 | |||
3426 | #if defined(XENPV) && defined(__x86_64__) | 3426 | #if defined(XENPV) && defined(__x86_64__) | |
3427 | #define KASSERT_PDIRPA(pmap) \ | 3427 | #define KASSERT_PDIRPA(pmap) \ | |
3428 | KASSERT(pmap_pdirpa(pmap, 0) == ci->ci_xen_current_user_pgd || \ | 3428 | KASSERT(pmap_pdirpa(pmap, 0) == ci->ci_xen_current_user_pgd || \ | |
3429 | pmap == pmap_kernel()) | 3429 | pmap == pmap_kernel()) | |
3430 | #elif defined(PAE) | 3430 | #elif defined(PAE) | |
3431 | #define KASSERT_PDIRPA(pmap) \ | 3431 | #define KASSERT_PDIRPA(pmap) \ | |
3432 | KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(ci->ci_pae_l3_pdir[0])) | 3432 | KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(ci->ci_pae_l3_pdir[0])) | |
3433 | #elif !defined(XENPV) | 3433 | #elif !defined(XENPV) | |
3434 | #define KASSERT_PDIRPA(pmap) \ | 3434 | #define KASSERT_PDIRPA(pmap) \ | |
3435 | KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(rcr3())) | 3435 | KASSERT(pmap_pdirpa(pmap, 0) == pmap_pte2pa(rcr3())) | |
3436 | #else | 3436 | #else | |
3437 | #define KASSERT_PDIRPA(pmap) KASSERT(true) /* nothing to do */ | 3437 | #define KASSERT_PDIRPA(pmap) KASSERT(true) /* nothing to do */ | |
3438 | #endif | 3438 | #endif | |
3439 | 3439 | |||
3440 | /* | 3440 | /* | |
3441 | * pmap_reactivate: try to regain reference to the pmap. | 3441 | * pmap_reactivate: try to regain reference to the pmap. | |
3442 | * | 3442 | * | |
3443 | * => Must be called with kernel preemption disabled. | 3443 | * => Must be called with kernel preemption disabled. | |
3444 | */ | 3444 | */ | |
3445 | static void | 3445 | static void | |
3446 | pmap_reactivate(struct pmap *pmap) | 3446 | pmap_reactivate(struct pmap *pmap) | |
3447 | { | 3447 | { | |
3448 | struct cpu_info * const ci = curcpu(); | 3448 | struct cpu_info * const ci = curcpu(); | |
3449 | const cpuid_t cid = cpu_index(ci); | 3449 | const cpuid_t cid = cpu_index(ci); | |
3450 | 3450 | |||
@@ -4135,27 +4135,27 @@ pmap_remove_locked(struct pmap *pmap, va | @@ -4135,27 +4135,27 @@ pmap_remove_locked(struct pmap *pmap, va | |||
4135 | 4135 | |||
4136 | if (result && ptp && ptp->wire_count <= 1) | 4136 | if (result && ptp && ptp->wire_count <= 1) | |
4137 | pmap_free_ptp(pmap, ptp, va, ptes, pdes); | 4137 | pmap_free_ptp(pmap, ptp, va, ptes, pdes); | |
4138 | } | 4138 | } | |
4139 | } else for (/* null */ ; va < eva ; va = blkendva) { | 4139 | } else for (/* null */ ; va < eva ; va = blkendva) { | |
4140 | /* determine range of block */ | 4140 | /* determine range of block */ | |
4141 | blkendva = x86_round_pdr(va+1); | 4141 | blkendva = x86_round_pdr(va+1); | |
4142 | if (blkendva > eva) | 4142 | if (blkendva > eva) | |
4143 | blkendva = eva; | 4143 | blkendva = eva; | |
4144 | 4144 | |||
4145 | if (!pmap_pdes_valid(va, pdes, &pde, &lvl)) { | 4145 | if (!pmap_pdes_valid(va, pdes, &pde, &lvl)) { | |
4146 | /* Skip a range corresponding to an invalid pde. */ | 4146 | /* Skip a range corresponding to an invalid pde. */ | |
4147 | blkendva = (va & ptp_frames[lvl - 1]) + nbpd[lvl - 1]; | 4147 | blkendva = (va & ptp_frames[lvl - 1]) + nbpd[lvl - 1]; | |
4148 | continue; | 4148 | continue; | |
4149 | } | 4149 | } | |
4150 | KASSERT(lvl == 1); | 4150 | KASSERT(lvl == 1); | |
4151 | 4151 | |||
4152 | /* Get PTP if non-kernel mapping. */ | 4152 | /* Get PTP if non-kernel mapping. */ | |
4153 | if (pmap != pmap_kernel()) { | 4153 | if (pmap != pmap_kernel()) { | |
4154 | ptp = pmap_find_ptp(pmap, va, 1); | 4154 | ptp = pmap_find_ptp(pmap, va, 1); | |
4155 | KASSERTMSG(ptp != NULL, "%s: unmanaged PTP detected", | 4155 | KASSERTMSG(ptp != NULL, "%s: unmanaged PTP detected", | |
4156 | __func__); | 4156 | __func__); | |
4157 | } else { | 4157 | } else { | |
4158 | /* Never free kernel PTPs. */ | 4158 | /* Never free kernel PTPs. */ | |
4159 | ptp = NULL; | 4159 | ptp = NULL; | |
4160 | } | 4160 | } | |
4161 | 4161 | |||
@@ -4313,27 +4313,27 @@ pmap_pp_remove(struct pmap_page *pp, pad | @@ -4313,27 +4313,27 @@ pmap_pp_remove(struct pmap_page *pp, pad | |||
4313 | bool locked; | 4313 | bool locked; | |
4314 | 4314 | |||
4315 | /* | 4315 | /* | |
4316 | * Do an unlocked check to see if the page has no mappings, eg when | 4316 | * Do an unlocked check to see if the page has no mappings, eg when | |
4317 | * pmap_remove_all() was called before amap_wipeout() for a process | 4317 | * pmap_remove_all() was called before amap_wipeout() for a process | |
4318 | * private amap - common. The page being removed must be on the way | 4318 | * private amap - common. The page being removed must be on the way | |
4319 | * out, so we don't have to worry about concurrent attempts to enter | 4319 | * out, so we don't have to worry about concurrent attempts to enter | |
4320 | * it (otherwise the caller either doesn't care or has screwed up). | 4320 | * it (otherwise the caller either doesn't care or has screwed up). | |
4321 | */ | 4321 | */ | |
4322 | sum = (uintptr_t)atomic_load_relaxed(&pp->pp_pte.pte_va); | 4322 | sum = (uintptr_t)atomic_load_relaxed(&pp->pp_pte.pte_va); | |
4323 | sum |= (uintptr_t)atomic_load_relaxed(&pp->pp_pte.pte_ptp); | 4323 | sum |= (uintptr_t)atomic_load_relaxed(&pp->pp_pte.pte_ptp); | |
4324 | sum |= (uintptr_t)atomic_load_relaxed(&pp->pp_pvlist.lh_first); | 4324 | sum |= (uintptr_t)atomic_load_relaxed(&pp->pp_pvlist.lh_first); | |
4325 | if (sum == 0) { | 4325 | if (sum == 0) { | |
4326 | return; | 4326 | return; | |
4327 | } | 4327 | } | |
4328 | 4328 | |||
4329 | kpreempt_disable(); | 4329 | kpreempt_disable(); | |
4330 | for (;;) { | 4330 | for (;;) { | |
4331 | struct pmap *pmap; | 4331 | struct pmap *pmap; | |
4332 | struct pv_entry *pve; | 4332 | struct pv_entry *pve; | |
4333 | pt_entry_t opte; | 4333 | pt_entry_t opte; | |
4334 | vaddr_t va; | 4334 | vaddr_t va; | |
4335 | 4335 | |||
4336 | mutex_spin_enter(&pp->pp_lock); | 4336 | mutex_spin_enter(&pp->pp_lock); | |
4337 | if ((pvpte = pv_pte_first(pp)) == NULL) { | 4337 | if ((pvpte = pv_pte_first(pp)) == NULL) { | |
4338 | mutex_spin_exit(&pp->pp_lock); | 4338 | mutex_spin_exit(&pp->pp_lock); | |
4339 | break; | 4339 | break; | |
@@ -4816,27 +4816,27 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t | @@ -4816,27 +4816,27 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t | |||
4816 | KASSERTMSG(va != (vaddr_t)PDP_BASE, "%s: trying to map va=%#" | 4816 | KASSERTMSG(va != (vaddr_t)PDP_BASE, "%s: trying to map va=%#" | |
4817 | PRIxVADDR " over PDP!", __func__, va); | 4817 | PRIxVADDR " over PDP!", __func__, va); | |
4818 | KASSERTMSG(va < VM_MIN_KERNEL_ADDRESS || | 4818 | KASSERTMSG(va < VM_MIN_KERNEL_ADDRESS || | |
4819 | pmap_valid_entry(pmap->pm_pdir[pl_i(va, PTP_LEVELS)]), | 4819 | pmap_valid_entry(pmap->pm_pdir[pl_i(va, PTP_LEVELS)]), | |
4820 | "%s: missing kernel PTP for va=%#" PRIxVADDR, __func__, va); | 4820 | "%s: missing kernel PTP for va=%#" PRIxVADDR, __func__, va); | |
4821 | 4821 | |||
4822 | #ifdef XENPV | 4822 | #ifdef XENPV | |
4823 | KASSERT(domid == DOMID_SELF || pa == 0); | 4823 | KASSERT(domid == DOMID_SELF || pa == 0); | |
4824 | #endif | 4824 | #endif | |
4825 | 4825 | |||
4826 | npte = ma | protection_codes[prot] | PTE_P; | 4826 | npte = ma | protection_codes[prot] | PTE_P; | |
4827 | npte |= pmap_pat_flags(flags); | 4827 | npte |= pmap_pat_flags(flags); | |
4828 | if (wired) | 4828 | if (wired) | |
4829 | npte |= PTE_WIRED; | 4829 | npte |= PTE_WIRED; | |
4830 | if (va < VM_MAXUSER_ADDRESS) | 4830 | if (va < VM_MAXUSER_ADDRESS) | |
4831 | npte |= PTE_U; | 4831 | npte |= PTE_U; | |
4832 | 4832 | |||
4833 | if (pmap == pmap_kernel()) | 4833 | if (pmap == pmap_kernel()) | |
4834 | npte |= pmap_pg_g; | 4834 | npte |= pmap_pg_g; | |
4835 | if (flags & VM_PROT_ALL) { | 4835 | if (flags & VM_PROT_ALL) { | |
4836 | npte |= PTE_A; | 4836 | npte |= PTE_A; | |
4837 | if (flags & VM_PROT_WRITE) { | 4837 | if (flags & VM_PROT_WRITE) { | |
4838 | KASSERT((npte & PTE_W) != 0); | 4838 | KASSERT((npte & PTE_W) != 0); | |
4839 | npte |= PTE_D; | 4839 | npte |= PTE_D; | |
4840 | } | 4840 | } | |
4841 | } | 4841 | } | |
4842 | 4842 | |||
@@ -4891,29 +4891,29 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t | @@ -4891,29 +4891,29 @@ pmap_enter_ma(struct pmap *pmap, vaddr_t | |||
4891 | * Look up the old PV entry at this VA (if any), and insert a new PV | 4891 | * Look up the old PV entry at this VA (if any), and insert a new PV | |
4892 | * entry if required for the new mapping. Temporarily track the old | 4892 | * entry if required for the new mapping. Temporarily track the old | |
4893 | * and new mappings concurrently. Only after the old mapping is | 4893 | * and new mappings concurrently. Only after the old mapping is | |
4894 | * evicted from the pmap will we remove its PV entry. Otherwise, | 4894 | * evicted from the pmap will we remove its PV entry. Otherwise, | |
4895 | * our picture of modified/accessed state for either page could get | 4895 | * our picture of modified/accessed state for either page could get | |
4896 | * out of sync (we need any P->V operation for either page to stall | 4896 | * out of sync (we need any P->V operation for either page to stall | |
4897 | * on pmap->pm_lock until done here). | 4897 | * on pmap->pm_lock until done here). | |
4898 | */ | 4898 | */ | |
4899 | new_pve = NULL; | 4899 | new_pve = NULL; | |
4900 | old_pve = NULL; | 4900 | old_pve = NULL; | |
4901 | samepage = false; | 4901 | samepage = false; | |
4902 | new_embedded = false; | 4902 | new_embedded = false; | |
4903 | 4903 | |||
4904 | if (new_pp != NULL) { | 4904 | if (new_pp != NULL) { | |
4905 | error = pmap_enter_pv(pmap, new_pp, ptp, va, &new_pve, | 4905 | error = pmap_enter_pv(pmap, new_pp, ptp, va, &new_pve, | |
4906 | &old_pve, &samepage, &new_embedded, tree); | 4906 | &old_pve, &samepage, &new_embedded, tree); | |
4907 | 4907 | |||
4908 | /* | 4908 | /* | |
4909 | * If a new pv_entry was needed and none was available, we | 4909 | * If a new pv_entry was needed and none was available, we | |
4910 | * can go no further. | 4910 | * can go no further. | |
4911 | */ | 4911 | */ | |
4912 | if (error != 0) { | 4912 | if (error != 0) { | |
4913 | if (flags & PMAP_CANFAIL) { | 4913 | if (flags & PMAP_CANFAIL) { | |
4914 | if (getptp) { | 4914 | if (getptp) { | |
4915 | pmap_unget_ptp(pmap, &pt); | 4915 | pmap_unget_ptp(pmap, &pt); | |
4916 | } | 4916 | } | |
4917 | mutex_exit(&pmap->pm_lock); | 4917 | mutex_exit(&pmap->pm_lock); | |
4918 | return error; | 4918 | return error; | |
4919 | } | 4919 | } | |
@@ -6145,29 +6145,29 @@ pmap_ept_enter(struct pmap *pmap, vaddr_ | @@ -6145,29 +6145,29 @@ pmap_ept_enter(struct pmap *pmap, vaddr_ | |||
6145 | * Look up the old PV entry at this VA (if any), and insert a new PV | 6145 | * Look up the old PV entry at this VA (if any), and insert a new PV | |
6146 | * entry if required for the new mapping. Temporarily track the old | 6146 | * entry if required for the new mapping. Temporarily track the old | |
6147 | * and new mappings concurrently. Only after the old mapping is | 6147 | * and new mappings concurrently. Only after the old mapping is | |
6148 | * evicted from the pmap will we remove its PV entry. Otherwise, | 6148 | * evicted from the pmap will we remove its PV entry. Otherwise, | |
6149 | * our picture of modified/accessed state for either page could get | 6149 | * our picture of modified/accessed state for either page could get | |
6150 | * out of sync (we need any P->V operation for either page to stall | 6150 | * out of sync (we need any P->V operation for either page to stall | |
6151 | * on pmap->pm_lock until done here). | 6151 | * on pmap->pm_lock until done here). | |
6152 | */ | 6152 | */ | |
6153 | new_pve = NULL; | 6153 | new_pve = NULL; | |
6154 | old_pve = NULL; | 6154 | old_pve = NULL; | |
6155 | samepage = false; | 6155 | samepage = false; | |
6156 | new_embedded = false; | 6156 | new_embedded = false; | |
6157 | 6157 | |||
6158 | if (new_pp != NULL) { | 6158 | if (new_pp != NULL) { | |
6159 | error = pmap_enter_pv(pmap, new_pp, ptp, va, &new_pve, | 6159 | error = pmap_enter_pv(pmap, new_pp, ptp, va, &new_pve, | |
6160 | &old_pve, &samepage, &new_embedded, tree); | 6160 | &old_pve, &samepage, &new_embedded, tree); | |
6161 | 6161 | |||
6162 | /* | 6162 | /* | |
6163 | * If a new pv_entry was needed and none was available, we | 6163 | * If a new pv_entry was needed and none was available, we | |
6164 | * can go no further. | 6164 | * can go no further. | |
6165 | */ | 6165 | */ | |
6166 | if (error != 0) { | 6166 | if (error != 0) { | |
6167 | if (flags & PMAP_CANFAIL) { | 6167 | if (flags & PMAP_CANFAIL) { | |
6168 | if (getptp) { | 6168 | if (getptp) { | |
6169 | pmap_unget_ptp(pmap, &pt); | 6169 | pmap_unget_ptp(pmap, &pt); | |
6170 | } | 6170 | } | |
6171 | mutex_exit(&pmap->pm_lock); | 6171 | mutex_exit(&pmap->pm_lock); | |
6172 | return error; | 6172 | return error; | |
6173 | } | 6173 | } | |
@@ -6472,27 +6472,27 @@ pmap_ept_remove(struct pmap *pmap, vaddr | @@ -6472,27 +6472,27 @@ pmap_ept_remove(struct pmap *pmap, vaddr | |||
6472 | 6472 | |||
6473 | for (/* null */ ; va < eva ; va = blkendva) { | 6473 | for (/* null */ ; va < eva ; va = blkendva) { | |
6474 | int lvl; | 6474 | int lvl; | |
6475 | 6475 | |||
6476 | /* determine range of block */ | 6476 | /* determine range of block */ | |
6477 | blkendva = x86_round_pdr(va+1); | 6477 | blkendva = x86_round_pdr(va+1); | |
6478 | if (blkendva > eva) | 6478 | if (blkendva > eva) | |
6479 | blkendva = eva; | 6479 | blkendva = eva; | |
6480 | 6480 | |||
6481 | lvl = pmap_ept_pdes_invalid(pmap, va, &pde); | 6481 | lvl = pmap_ept_pdes_invalid(pmap, va, &pde); | |
6482 | if (lvl != 0) { | 6482 | if (lvl != 0) { | |
6483 | /* Skip a range corresponding to an invalid pde. */ | 6483 | /* Skip a range corresponding to an invalid pde. */ | |
6484 | blkendva = (va & ptp_frames[lvl - 1]) + nbpd[lvl - 1]; | 6484 | blkendva = (va & ptp_frames[lvl - 1]) + nbpd[lvl - 1]; | |
6485 | continue; | 6485 | continue; | |
6486 | } | 6486 | } | |
6487 | 6487 | |||
6488 | /* PA of the PTP */ | 6488 | /* PA of the PTP */ | |
6489 | ptppa = pmap_pte2pa(pde); | 6489 | ptppa = pmap_pte2pa(pde); | |
6490 | 6490 | |||
6491 | ptp = pmap_find_ptp(pmap, va, 1); | 6491 | ptp = pmap_find_ptp(pmap, va, 1); | |
6492 | KASSERTMSG(ptp != NULL, "%s: unmanaged PTP detected", | 6492 | KASSERTMSG(ptp != NULL, "%s: unmanaged PTP detected", | |
6493 | __func__); | 6493 | __func__); | |
6494 | 6494 | |||
6495 | ptes = (pt_entry_t *)PMAP_DIRECT_MAP(ptppa); | 6495 | ptes = (pt_entry_t *)PMAP_DIRECT_MAP(ptppa); | |
6496 | 6496 | |||
6497 | pmap_ept_remove_ptes(pmap, ptp, (vaddr_t)&ptes[pl1_pi(va)], va, | 6497 | pmap_ept_remove_ptes(pmap, ptp, (vaddr_t)&ptes[pl1_pi(va)], va, | |
6498 | blkendva); | 6498 | blkendva); |
--- src/sys/arch/x86/x86/procfs_machdep.c 2021/07/10 17:33:28 1.41
+++ src/sys/arch/x86/x86/procfs_machdep.c 2021/10/07 12:52:27 1.42
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: procfs_machdep.c,v 1.41 2021/07/10 17:33:28 msaitoh Exp $ */ | 1 | /* $NetBSD: procfs_machdep.c,v 1.42 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Frank van der Linden and Jason R. Thorpe for | 7 | * Written by Frank van der Linden and Jason R. Thorpe for | |
8 | * Wasabi Systems, Inc. | 8 | * Wasabi Systems, Inc. | |
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. | |
@@ -32,27 +32,27 @@ | @@ -32,27 +32,27 @@ | |||
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | /* | 39 | /* | |
40 | * NOTE: We simply use the primary CPU's cpuid_level and tsc_freq | 40 | * NOTE: We simply use the primary CPU's cpuid_level and tsc_freq | |
41 | * here. Might want to change this later. | 41 | * here. Might want to change this later. | |
42 | */ | 42 | */ | |
43 | 43 | |||
44 | #include <sys/cdefs.h> | 44 | #include <sys/cdefs.h> | |
45 | __KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.41 2021/07/10 17:33:28 msaitoh Exp $"); | 45 | __KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.42 2021/10/07 12:52:27 msaitoh Exp $"); | |
46 | 46 | |||
47 | #include <sys/param.h> | 47 | #include <sys/param.h> | |
48 | #include <sys/systm.h> | 48 | #include <sys/systm.h> | |
49 | #include <sys/mount.h> | 49 | #include <sys/mount.h> | |
50 | #include <sys/stat.h> | 50 | #include <sys/stat.h> | |
51 | #include <sys/vnode.h> | 51 | #include <sys/vnode.h> | |
52 | 52 | |||
53 | #include <miscfs/procfs/procfs.h> | 53 | #include <miscfs/procfs/procfs.h> | |
54 | 54 | |||
55 | #include <machine/cpu.h> | 55 | #include <machine/cpu.h> | |
56 | #include <machine/reg.h> | 56 | #include <machine/reg.h> | |
57 | #include <machine/specialreg.h> | 57 | #include <machine/specialreg.h> | |
58 | #include <x86/cputypes.h> | 58 | #include <x86/cputypes.h> | |
@@ -270,27 +270,27 @@ procfs_getonecpufeatures(struct cpu_info | @@ -270,27 +270,27 @@ procfs_getonecpufeatures(struct cpu_info | |||
270 | size_t last = *left; | 270 | size_t last = *left; | |
271 | size_t diff; | 271 | size_t diff; | |
272 | u_int descs[4]; | 272 | u_int descs[4]; | |
273 | 273 | |||
274 | procfs_getonefeatreg(ci->ci_feat_val[0], x86_features[0], p, left); | 274 | procfs_getonefeatreg(ci->ci_feat_val[0], x86_features[0], p, left); | |
275 | diff = last - *left; | 275 | diff = last - *left; | |
276 | 276 | |||
277 | procfs_getonefeatreg(ci->ci_feat_val[2], x86_features[1], p + diff, | 277 | procfs_getonefeatreg(ci->ci_feat_val[2], x86_features[1], p + diff, | |
278 | left); | 278 | left); | |
279 | diff = last - *left; | 279 | diff = last - *left; | |
280 | 280 | |||
281 | /* x86_features[2] is for Transmeta */ | 281 | /* x86_features[2] is for Transmeta */ | |
282 | /* x86_features[3] is Linux defined mapping */ | 282 | /* x86_features[3] is Linux defined mapping */ | |
283 | 283 | |||
284 | procfs_getonefeatreg(ci->ci_feat_val[1], x86_features[4], p + diff, | 284 | procfs_getonefeatreg(ci->ci_feat_val[1], x86_features[4], p + diff, | |
285 | left); | 285 | left); | |
286 | diff = last - *left; | 286 | diff = last - *left; | |
287 | 287 | |||
288 | procfs_getonefeatreg(ci->ci_feat_val[4], x86_features[5], p + diff, | 288 | procfs_getonefeatreg(ci->ci_feat_val[4], x86_features[5], p + diff, | |
289 | left); | 289 | left); | |
290 | diff = last - *left; | 290 | diff = last - *left; | |
291 | 291 | |||
292 | procfs_getonefeatreg(ci->ci_feat_val[3], x86_features[6], p + diff, | 292 | procfs_getonefeatreg(ci->ci_feat_val[3], x86_features[6], p + diff, | |
293 | left); | 293 | left); | |
294 | diff = last - *left; | 294 | diff = last - *left; | |
295 | 295 | |||
296 | /* x86_features[7] is Linux defined mapping */ | 296 | /* x86_features[7] is Linux defined mapping */ |
--- src/sys/arch/x86/x86/spectre.c 2020/05/02 11:37:17 1.35
+++ src/sys/arch/x86/x86/spectre.c 2021/10/07 12:52:27 1.36
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: spectre.c,v 1.35 2020/05/02 11:37:17 maxv Exp $ */ | 1 | /* $NetBSD: spectre.c,v 1.36 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2018-2019 NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018-2019 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 Maxime Villard. | 8 | * by Maxime Villard. | |
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. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
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 | /* | 32 | /* | |
33 | * Mitigations for the SpectreV2, SpectreV4, MDS and TAA CPU flaws. | 33 | * Mitigations for the SpectreV2, SpectreV4, MDS and TAA CPU flaws. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.35 2020/05/02 11:37:17 maxv Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.36 2021/10/07 12:52:27 msaitoh Exp $"); | |
38 | 38 | |||
39 | #include "opt_spectre.h" | 39 | #include "opt_spectre.h" | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/cpu.h> | 43 | #include <sys/cpu.h> | |
44 | #include <sys/sysctl.h> | 44 | #include <sys/sysctl.h> | |
45 | #include <sys/xcall.h> | 45 | #include <sys/xcall.h> | |
46 | 46 | |||
47 | #include <machine/cpufunc.h> | 47 | #include <machine/cpufunc.h> | |
48 | #include <machine/cpuvar.h> | 48 | #include <machine/cpuvar.h> | |
49 | #include <machine/specialreg.h> | 49 | #include <machine/specialreg.h> | |
50 | #include <machine/frameasm.h> | 50 | #include <machine/frameasm.h> | |
@@ -430,27 +430,27 @@ v4_detect_method(void) | @@ -430,27 +430,27 @@ v4_detect_method(void) | |||
430 | case 0x15: | 430 | case 0x15: | |
431 | v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F15H; | 431 | v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F15H; | |
432 | return; | 432 | return; | |
433 | case 0x16: | 433 | case 0x16: | |
434 | v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F16H; | 434 | v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F16H; | |
435 | return; | 435 | return; | |
436 | case 0x17: | 436 | case 0x17: | |
437 | v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F17H; | 437 | v4_mitigation_method = V4_MITIGATION_AMD_NONARCH_F17H; | |
438 | return; | 438 | return; | |
439 | default: | 439 | default: | |
440 | if (cpu_info_primary.ci_max_ext_cpuid < 0x80000008) { | 440 | if (cpu_info_primary.ci_max_ext_cpuid < 0x80000008) { | |
441 | break; | 441 | break; | |
442 | } | 442 | } | |
443 | x86_cpuid(0x80000008, descs); | 443 | x86_cpuid(0x80000008, descs); | |
444 | if (descs[1] & CPUID_CAPEX_SSB_NO) { | 444 | if (descs[1] & CPUID_CAPEX_SSB_NO) { | |
445 | /* Not vulnerable to SpectreV4. */ | 445 | /* Not vulnerable to SpectreV4. */ | |
446 | v4_mitigation_method = V4_MITIGATION_AMD_SSB_NO; | 446 | v4_mitigation_method = V4_MITIGATION_AMD_SSB_NO; | |
447 | return; | 447 | return; | |
448 | } | 448 | } | |
449 | 449 | |||
450 | break; | 450 | break; | |
451 | } | 451 | } | |
452 | } | 452 | } | |
453 | 453 | |||
454 | v4_mitigation_method = V4_MITIGATION_NONE; | 454 | v4_mitigation_method = V4_MITIGATION_NONE; | |
455 | } | 455 | } | |
456 | 456 |
--- src/sys/arch/x86/x86/svs.c 2020/07/19 07:35:08 1.39
+++ src/sys/arch/x86/x86/svs.c 2021/10/07 12:52:27 1.40
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: svs.c,v 1.39 2020/07/19 07:35:08 maxv Exp $ */ | 1 | /* $NetBSD: svs.c,v 1.40 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018-2020 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 Maxime Villard. | 8 | * by Maxime Villard. | |
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: svs.c,v 1.39 2020/07/19 07:35:08 maxv Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.40 2021/10/07 12:52:27 msaitoh Exp $"); | |
34 | 34 | |||
35 | #include "opt_svs.h" | 35 | #include "opt_svs.h" | |
36 | #include "opt_user_ldt.h" | 36 | #include "opt_user_ldt.h" | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/proc.h> | 40 | #include <sys/proc.h> | |
41 | #include <sys/cpu.h> | 41 | #include <sys/cpu.h> | |
42 | #include <sys/kauth.h> | 42 | #include <sys/kauth.h> | |
43 | #include <sys/sysctl.h> | 43 | #include <sys/sysctl.h> | |
44 | #include <sys/xcall.h> | 44 | #include <sys/xcall.h> | |
45 | #include <sys/reboot.h> | 45 | #include <sys/reboot.h> | |
46 | 46 | |||
@@ -50,27 +50,27 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.39 | @@ -50,27 +50,27 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.39 | |||
50 | #include <machine/gdt.h> | 50 | #include <machine/gdt.h> | |
51 | 51 | |||
52 | #include <uvm/uvm.h> | 52 | #include <uvm/uvm.h> | |
53 | #include <uvm/uvm_page.h> | 53 | #include <uvm/uvm_page.h> | |
54 | 54 | |||
55 | /* | 55 | /* | |
56 | * Separate Virtual Space | 56 | * Separate Virtual Space | |
57 | * | 57 | * | |
58 | * A per-cpu L4 page is maintained in ci_svs_updirpa. During each context | 58 | * A per-cpu L4 page is maintained in ci_svs_updirpa. During each context | |
59 | * switch to a user pmap, the lower half of updirpa is populated with the | 59 | * switch to a user pmap, the lower half of updirpa is populated with the | |
60 | * entries containing the userland pages. | 60 | * entries containing the userland pages. | |
61 | * | 61 | * | |
62 | * ~~~~~~~~~~ The UTLS Page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 62 | * ~~~~~~~~~~ The UTLS Page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
63 | * | 63 | * | |
64 | * We use a special per-cpu page that we call UTLS, for User Thread Local | 64 | * We use a special per-cpu page that we call UTLS, for User Thread Local | |
65 | * Storage. Each CPU has one UTLS page. This page has two VAs: | 65 | * Storage. Each CPU has one UTLS page. This page has two VAs: | |
66 | * | 66 | * | |
67 | * o When the user page tables are loaded in CR3, the VA to access this | 67 | * o When the user page tables are loaded in CR3, the VA to access this | |
68 | * page is &pcpuarea->utls, defined as SVS_UTLS in assembly. This VA is | 68 | * page is &pcpuarea->utls, defined as SVS_UTLS in assembly. This VA is | |
69 | * _constant_ across CPUs, but in the user page tables this VA points to | 69 | * _constant_ across CPUs, but in the user page tables this VA points to | |
70 | * the physical page of the UTLS that is _local_ to the CPU. | 70 | * the physical page of the UTLS that is _local_ to the CPU. | |
71 | * | 71 | * | |
72 | * o When the kernel page tables are loaded in CR3, the VA to access this | 72 | * o When the kernel page tables are loaded in CR3, the VA to access this | |
73 | * page is ci->ci_svs_utls. | 73 | * page is ci->ci_svs_utls. | |
74 | * | 74 | * | |
75 | * +----------------------------------------------------------------------+ | 75 | * +----------------------------------------------------------------------+ | |
76 | * | CPU0 Local Data (Physical Page) | | 76 | * | CPU0 Local Data (Physical Page) | | |
@@ -128,27 +128,27 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.39 | @@ -128,27 +128,27 @@ __KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.39 | |||
128 | * In the pcpu_area structure, pointed to by the "pcpuarea" variable, each CPU | 128 | * In the pcpu_area structure, pointed to by the "pcpuarea" variable, each CPU | |
129 | * has a two-page rsp0 entry (pcpuarea->ent[cid].rsp0). These two pages do | 129 | * has a two-page rsp0 entry (pcpuarea->ent[cid].rsp0). These two pages do | |
130 | * _not_ have associated physical addresses. They are only two VAs. | 130 | * _not_ have associated physical addresses. They are only two VAs. | |
131 | * | 131 | * | |
132 | * The first page is unmapped and acts as a redzone. The second page is | 132 | * The first page is unmapped and acts as a redzone. The second page is | |
133 | * dynamically kentered into the highest page of the real per-lwp kernel stack; | 133 | * dynamically kentered into the highest page of the real per-lwp kernel stack; | |
134 | * but pay close attention, it is kentered _only_ in the user page tables. | 134 | * but pay close attention, it is kentered _only_ in the user page tables. | |
135 | * That is to say, the VA of this second page is mapped when the user page | 135 | * That is to say, the VA of this second page is mapped when the user page | |
136 | * tables are loaded, but not mapped when the kernel page tables are loaded. | 136 | * tables are loaded, but not mapped when the kernel page tables are loaded. | |
137 | * | 137 | * | |
138 | * During a context switch, svs_lwp_switch() gets called first. This function | 138 | * During a context switch, svs_lwp_switch() gets called first. This function | |
139 | * does the kenter job described above, not in the kernel page tables (that | 139 | * does the kenter job described above, not in the kernel page tables (that | |
140 | * are currently loaded), but in the user page tables (that are not loaded). | 140 | * are currently loaded), but in the user page tables (that are not loaded). | |
141 | * | 141 | * | |
142 | * VIRTUAL ADDRESSES PHYSICAL ADDRESSES | 142 | * VIRTUAL ADDRESSES PHYSICAL ADDRESSES | |
143 | * | 143 | * | |
144 | * +-----------------------------+ | 144 | * +-----------------------------+ | |
145 | * | KERNEL PAGE TABLES | | 145 | * | KERNEL PAGE TABLES | | |
146 | * | +-------------------+ | +-------------------+ | 146 | * | +-------------------+ | +-------------------+ | |
147 | * | | pcb_rsp0 (page 0) | ------------------> | pcb_rsp0 (page 0) | | 147 | * | | pcb_rsp0 (page 0) | ------------------> | pcb_rsp0 (page 0) | | |
148 | * | +-------------------+ | +-------------------+ | 148 | * | +-------------------+ | +-------------------+ | |
149 | * | | pcb_rsp0 (page 1) | ------------------> | pcb_rsp0 (page 1) | | 149 | * | | pcb_rsp0 (page 1) | ------------------> | pcb_rsp0 (page 1) | | |
150 | * | +-------------------+ | +-------------------+ | 150 | * | +-------------------+ | +-------------------+ | |
151 | * | | pcb_rsp0 (page 2) | ------------------> | pcb_rsp0 (page 2) | | 151 | * | | pcb_rsp0 (page 2) | ------------------> | pcb_rsp0 (page 2) | | |
152 | * | +-------------------+ | +-------------------+ | 152 | * | +-------------------+ | +-------------------+ | |
153 | * | | pcb_rsp0 (page 3) | ------------------> | pcb_rsp0 (page 3) | | 153 | * | | pcb_rsp0 (page 3) | ------------------> | pcb_rsp0 (page 3) | | |
154 | * | +-------------------+ | +-> +-------------------+ | 154 | * | +-------------------+ | +-> +-------------------+ |
--- src/sys/arch/x86/x86/sys_machdep.c 2020/06/19 16:20:22 1.56
+++ src/sys/arch/x86/x86/sys_machdep.c 2021/10/07 12:52:27 1.57
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sys_machdep.c,v 1.56 2020/06/19 16:20:22 maxv Exp $ */ | 1 | /* $NetBSD: sys_machdep.c,v 1.57 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1998, 2007, 2009, 2017 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2007, 2009, 2017 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, by Andrew Doran, and by Maxime Villard. | 8 | * by Charles M. Hannum, by Andrew Doran, and by Maxime Villard. | |
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: sys_machdep.c,v 1.56 2020/06/19 16:20:22 maxv Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: sys_machdep.c,v 1.57 2021/10/07 12:52:27 msaitoh Exp $"); | |
34 | 34 | |||
35 | #include "opt_mtrr.h" | 35 | #include "opt_mtrr.h" | |
36 | #include "opt_user_ldt.h" | 36 | #include "opt_user_ldt.h" | |
37 | #include "opt_compat_netbsd.h" | 37 | #include "opt_compat_netbsd.h" | |
38 | #include "opt_xen.h" | 38 | #include "opt_xen.h" | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/ioctl.h> | 42 | #include <sys/ioctl.h> | |
43 | #include <sys/file.h> | 43 | #include <sys/file.h> | |
44 | #include <sys/time.h> | 44 | #include <sys/time.h> | |
45 | #include <sys/proc.h> | 45 | #include <sys/proc.h> | |
46 | #include <sys/uio.h> | 46 | #include <sys/uio.h> | |
@@ -424,27 +424,27 @@ x86_get_ioperm(struct lwp *l, void *args | @@ -424,27 +424,27 @@ x86_get_ioperm(struct lwp *l, void *args | |||
424 | } | 424 | } | |
425 | 425 | |||
426 | static int | 426 | static int | |
427 | x86_set_ioperm(struct lwp *l, void *args, register_t *retval) | 427 | x86_set_ioperm(struct lwp *l, void *args, register_t *retval) | |
428 | { | 428 | { | |
429 | #ifdef IOPERM | 429 | #ifdef IOPERM | |
430 | struct cpu_info *ci; | 430 | struct cpu_info *ci; | |
431 | int error; | 431 | int error; | |
432 | struct pcb *pcb = lwp_getpcb(l); | 432 | struct pcb *pcb = lwp_getpcb(l); | |
433 | struct x86_set_ioperm_args ua; | 433 | struct x86_set_ioperm_args ua; | |
434 | void *new; | 434 | void *new; | |
435 | void *old; | 435 | void *old; | |
436 | 436 | |||
437 | error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_IOPERM_SET, | 437 | error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_IOPERM_SET, | |
438 | NULL, NULL, NULL, NULL); | 438 | NULL, NULL, NULL, NULL); | |
439 | if (error) | 439 | if (error) | |
440 | return error; | 440 | return error; | |
441 | 441 | |||
442 | if ((error = copyin(args, &ua, sizeof(ua))) != 0) | 442 | if ((error = copyin(args, &ua, sizeof(ua))) != 0) | |
443 | return error; | 443 | return error; | |
444 | 444 | |||
445 | new = kmem_alloc(IOMAPSIZE, KM_SLEEP); | 445 | new = kmem_alloc(IOMAPSIZE, KM_SLEEP); | |
446 | error = copyin(ua.iomap, new, IOMAPSIZE); | 446 | error = copyin(ua.iomap, new, IOMAPSIZE); | |
447 | if (error) { | 447 | if (error) { | |
448 | kmem_free(new, IOMAPSIZE); | 448 | kmem_free(new, IOMAPSIZE); | |
449 | return error; | 449 | return error; | |
450 | } | 450 | } | |
@@ -469,27 +469,27 @@ x86_set_ioperm(struct lwp *l, void *args | @@ -469,27 +469,27 @@ x86_set_ioperm(struct lwp *l, void *args | |||
469 | #endif | 469 | #endif | |
470 | } | 470 | } | |
471 | 471 | |||
472 | static int | 472 | static int | |
473 | x86_get_mtrr(struct lwp *l, void *args, register_t *retval) | 473 | x86_get_mtrr(struct lwp *l, void *args, register_t *retval) | |
474 | { | 474 | { | |
475 | #ifdef MTRR | 475 | #ifdef MTRR | |
476 | struct x86_get_mtrr_args ua; | 476 | struct x86_get_mtrr_args ua; | |
477 | int error, n; | 477 | int error, n; | |
478 | 478 | |||
479 | if (mtrr_funcs == NULL) | 479 | if (mtrr_funcs == NULL) | |
480 | return ENOSYS; | 480 | return ENOSYS; | |
481 | 481 | |||
482 | error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_MTRR_GET, | 482 | error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_MTRR_GET, | |
483 | NULL, NULL, NULL, NULL); | 483 | NULL, NULL, NULL, NULL); | |
484 | if (error) | 484 | if (error) | |
485 | return error; | 485 | return error; | |
486 | 486 | |||
487 | error = copyin(args, &ua, sizeof ua); | 487 | error = copyin(args, &ua, sizeof ua); | |
488 | if (error != 0) | 488 | if (error != 0) | |
489 | return error; | 489 | return error; | |
490 | 490 | |||
491 | error = copyin(ua.n, &n, sizeof n); | 491 | error = copyin(ua.n, &n, sizeof n); | |
492 | if (error != 0) | 492 | if (error != 0) | |
493 | return error; | 493 | return error; | |
494 | 494 | |||
495 | KERNEL_LOCK(1, NULL); | 495 | KERNEL_LOCK(1, NULL); | |
@@ -504,27 +504,27 @@ x86_get_mtrr(struct lwp *l, void *args, | @@ -504,27 +504,27 @@ x86_get_mtrr(struct lwp *l, void *args, | |||
504 | #endif | 504 | #endif | |
505 | } | 505 | } | |
506 | 506 | |||
507 | static int | 507 | static int | |
508 | x86_set_mtrr(struct lwp *l, void *args, register_t *retval) | 508 | x86_set_mtrr(struct lwp *l, void *args, register_t *retval) | |
509 | { | 509 | { | |
510 | #ifdef MTRR | 510 | #ifdef MTRR | |
511 | int error, n; | 511 | int error, n; | |
512 | struct x86_set_mtrr_args ua; | 512 | struct x86_set_mtrr_args ua; | |
513 | 513 | |||
514 | if (mtrr_funcs == NULL) | 514 | if (mtrr_funcs == NULL) | |
515 | return ENOSYS; | 515 | return ENOSYS; | |
516 | 516 | |||
517 | error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_MTRR_SET, | 517 | error = kauth_authorize_machdep(l->l_cred, KAUTH_MACHDEP_MTRR_SET, | |
518 | NULL, NULL, NULL, NULL); | 518 | NULL, NULL, NULL, NULL); | |
519 | if (error) | 519 | if (error) | |
520 | return error; | 520 | return error; | |
521 | 521 | |||
522 | error = copyin(args, &ua, sizeof ua); | 522 | error = copyin(args, &ua, sizeof ua); | |
523 | if (error != 0) | 523 | if (error != 0) | |
524 | return error; | 524 | return error; | |
525 | 525 | |||
526 | error = copyin(ua.n, &n, sizeof n); | 526 | error = copyin(ua.n, &n, sizeof n); | |
527 | if (error != 0) | 527 | if (error != 0) | |
528 | return error; | 528 | return error; | |
529 | 529 | |||
530 | KERNEL_LOCK(1, NULL); | 530 | KERNEL_LOCK(1, NULL); | |
@@ -616,27 +616,27 @@ x86_set_sdbase(void *arg, char which, lw | @@ -616,27 +616,27 @@ x86_set_sdbase(void *arg, char which, lw | |||
616 | base = (vaddr_t)arg; | 616 | base = (vaddr_t)arg; | |
617 | } else { | 617 | } else { | |
618 | int error = copyin(arg, &base, sizeof(base)); | 618 | int error = copyin(arg, &base, sizeof(base)); | |
619 | if (error != 0) | 619 | if (error != 0) | |
620 | return error; | 620 | return error; | |
621 | } | 621 | } | |
622 | 622 | |||
623 | if (base >= VM_MAXUSER_ADDRESS) | 623 | if (base >= VM_MAXUSER_ADDRESS) | |
624 | return EINVAL; | 624 | return EINVAL; | |
625 | 625 | |||
626 | pcb = lwp_getpcb(l); | 626 | pcb = lwp_getpcb(l); | |
627 | 627 | |||
628 | kpreempt_disable(); | 628 | kpreempt_disable(); | |
629 | switch(which) { | 629 | switch (which) { | |
630 | case 'f': | 630 | case 'f': | |
631 | pcb->pcb_fs = base; | 631 | pcb->pcb_fs = base; | |
632 | if (l == curlwp) | 632 | if (l == curlwp) | |
633 | wrmsr(MSR_FSBASE, pcb->pcb_fs); | 633 | wrmsr(MSR_FSBASE, pcb->pcb_fs); | |
634 | break; | 634 | break; | |
635 | case 'g': | 635 | case 'g': | |
636 | pcb->pcb_gs = base; | 636 | pcb->pcb_gs = base; | |
637 | if (l == curlwp) | 637 | if (l == curlwp) | |
638 | wrmsr(MSR_KERNELGSBASE, pcb->pcb_gs); | 638 | wrmsr(MSR_KERNELGSBASE, pcb->pcb_gs); | |
639 | break; | 639 | break; | |
640 | default: | 640 | default: | |
641 | panic("x86_set_sdbase"); | 641 | panic("x86_set_sdbase"); | |
642 | } | 642 | } | |
@@ -672,73 +672,74 @@ x86_get_sdbase(void *arg, char which) | @@ -672,73 +672,74 @@ x86_get_sdbase(void *arg, char which) | |||
672 | { | 672 | { | |
673 | #ifdef i386 | 673 | #ifdef i386 | |
674 | return x86_get_sdbase32(arg, which); | 674 | return x86_get_sdbase32(arg, which); | |
675 | #else | 675 | #else | |
676 | vaddr_t base; | 676 | vaddr_t base; | |
677 | struct pcb *pcb; | 677 | struct pcb *pcb; | |
678 | 678 | |||
679 | if (curproc->p_flag & PK_32) { | 679 | if (curproc->p_flag & PK_32) { | |
680 | return x86_get_sdbase32(arg, which); | 680 | return x86_get_sdbase32(arg, which); | |
681 | } | 681 | } | |
682 | 682 | |||
683 | pcb = lwp_getpcb(curlwp); | 683 | pcb = lwp_getpcb(curlwp); | |
684 | 684 | |||
685 | switch(which) { | 685 | switch (which) { | |
686 | case 'f': | 686 | case 'f': | |
687 | base = pcb->pcb_fs; | 687 | base = pcb->pcb_fs; | |
688 | break; | 688 | break; | |
689 | case 'g': | 689 | case 'g': | |
690 | base = pcb->pcb_gs; | 690 | base = pcb->pcb_gs; | |
691 | break; | 691 | break; | |
692 | default: | 692 | default: | |
693 | panic("x86_get_sdbase"); | 693 | panic("x86_get_sdbase"); | |
694 | } | 694 | } | |
695 | 695 | |||
696 | return copyout(&base, arg, sizeof(base)); | 696 | return copyout(&base, arg, sizeof(base)); | |
697 | #endif | 697 | #endif | |
698 | } | 698 | } | |
699 | 699 | |||
700 | int | 700 | int | |
701 | sys_sysarch(struct lwp *l, const struct sys_sysarch_args *uap, register_t *retval) | 701 | sys_sysarch(struct lwp *l, const struct sys_sysarch_args *uap, | |
702 | register_t *retval) | |||
702 | { | 703 | { | |
703 | /* { | 704 | /* { | |
704 | syscallarg(int) op; | 705 | syscallarg(int) op; | |
705 | syscallarg(void *) parms; | 706 | syscallarg(void *) parms; | |
706 | } */ | 707 | } */ | |
707 | int error = 0; | 708 | int error = 0; | |
708 | 709 | |||
709 | switch(SCARG(uap, op)) { | 710 | switch (SCARG(uap, op)) { | |
710 | case X86_IOPL: | 711 | case X86_IOPL: | |
711 | error = x86_iopl(l, SCARG(uap, parms), retval); | 712 | error = x86_iopl(l, SCARG(uap, parms), retval); | |
712 | break; | 713 | break; | |
713 | 714 | |||
714 | #ifdef i386 | 715 | #ifdef i386 | |
715 | /* | 716 | /* | |
716 | * On amd64, this is done via netbsd32_sysarch. | 717 | * On amd64, this is done via netbsd32_sysarch. | |
717 | */ | 718 | */ | |
718 | case X86_GET_LDT: | 719 | case X86_GET_LDT: | |
719 | error = x86_get_ldt(l, SCARG(uap, parms), retval); | 720 | error = x86_get_ldt(l, SCARG(uap, parms), retval); | |
720 | break; | 721 | break; | |
721 | 722 | |||
722 | case X86_SET_LDT: | 723 | case X86_SET_LDT: | |
723 | error = x86_set_ldt(l, SCARG(uap, parms), retval); | 724 | error = x86_set_ldt(l, SCARG(uap, parms), retval); | |
724 | break; | 725 | break; | |
725 | #endif | 726 | #endif | |
726 | 727 | |||
727 | case X86_GET_IOPERM: | 728 | case X86_GET_IOPERM: | |
728 | error = x86_get_ioperm(l, SCARG(uap, parms), retval); | 729 | error = x86_get_ioperm(l, SCARG(uap, parms), retval); | |
729 | break; | 730 | break; | |
730 | 731 | |||
731 | case X86_SET_IOPERM: | 732 | case X86_SET_IOPERM: | |
732 | error = x86_set_ioperm(l, SCARG(uap, parms), retval); | 733 | error = x86_set_ioperm(l, SCARG(uap, parms), retval); | |
733 | break; | 734 | break; | |
734 | 735 | |||
735 | case X86_GET_MTRR: | 736 | case X86_GET_MTRR: | |
736 | error = x86_get_mtrr(l, SCARG(uap, parms), retval); | 737 | error = x86_get_mtrr(l, SCARG(uap, parms), retval); | |
737 | break; | 738 | break; | |
738 | case X86_SET_MTRR: | 739 | case X86_SET_MTRR: | |
739 | error = x86_set_mtrr(l, SCARG(uap, parms), retval); | 740 | error = x86_set_mtrr(l, SCARG(uap, parms), retval); | |
740 | break; | 741 | break; | |
741 | 742 | |||
742 | case X86_SET_FSBASE: | 743 | case X86_SET_FSBASE: | |
743 | error = x86_set_sdbase(SCARG(uap, parms), 'f', curlwp, false); | 744 | error = x86_set_sdbase(SCARG(uap, parms), 'f', curlwp, false); | |
744 | break; | 745 | break; | |
@@ -760,16 +761,16 @@ sys_sysarch(struct lwp *l, const struct | @@ -760,16 +761,16 @@ sys_sysarch(struct lwp *l, const struct | |||
760 | break; | 761 | break; | |
761 | } | 762 | } | |
762 | return error; | 763 | return error; | |
763 | } | 764 | } | |
764 | 765 | |||
765 | int | 766 | int | |
766 | cpu_lwp_setprivate(lwp_t *l, void *addr) | 767 | cpu_lwp_setprivate(lwp_t *l, void *addr) | |
767 | { | 768 | { | |
768 | 769 | |||
769 | #ifdef __x86_64__ | 770 | #ifdef __x86_64__ | |
770 | if ((l->l_proc->p_flag & PK_32) == 0) { | 771 | if ((l->l_proc->p_flag & PK_32) == 0) { | |
771 | return x86_set_sdbase(addr, 'f', l, true); | 772 | return x86_set_sdbase(addr, 'f', l, true); | |
772 | } | 773 | } | |
773 | #endif | 774 | #endif | |
774 | return x86_set_sdbase(addr, 'g', l, true); | 775 | return x86_set_sdbase(addr, 'g', l, true); | |
775 | } | 776 | } |
--- src/sys/arch/x86/x86/syscall.c 2019/04/06 11:54:21 1.18
+++ src/sys/arch/x86/x86/syscall.c 2021/10/07 12:52:27 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: syscall.c,v 1.18 2019/04/06 11:54:21 kamil Exp $ */ | 1 | /* $NetBSD: syscall.c,v 1.19 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 2000, 2009 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 2000, 2009 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. | 8 | * by Charles M. Hannum. | |
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: syscall.c,v 1.18 2019/04/06 11:54:21 kamil Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.19 2021/10/07 12:52:27 msaitoh Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/proc.h> | 37 | #include <sys/proc.h> | |
38 | #include <sys/signal.h> | 38 | #include <sys/signal.h> | |
39 | #include <sys/ktrace.h> | 39 | #include <sys/ktrace.h> | |
40 | #include <sys/syscall.h> | 40 | #include <sys/syscall.h> | |
41 | #include <sys/syscallvar.h> | 41 | #include <sys/syscallvar.h> | |
42 | #include <sys/syscall_stats.h> | 42 | #include <sys/syscall_stats.h> | |
43 | 43 | |||
44 | #include <uvm/uvm_extern.h> | 44 | #include <uvm/uvm_extern.h> | |
45 | 45 | |||
46 | #include <machine/cpu.h> | 46 | #include <machine/cpu.h> | |
@@ -66,27 +66,27 @@ md_child_return(struct lwp *l) | @@ -66,27 +66,27 @@ md_child_return(struct lwp *l) | |||
66 | 66 | |||
67 | userret(l); | 67 | userret(l); | |
68 | } | 68 | } | |
69 | 69 | |||
70 | /* | 70 | /* | |
71 | * Process the tail end of a posix_spawn() for the child. | 71 | * Process the tail end of a posix_spawn() for the child. | |
72 | */ | 72 | */ | |
73 | void | 73 | void | |
74 | cpu_spawn_return(struct lwp *l) | 74 | cpu_spawn_return(struct lwp *l) | |
75 | { | 75 | { | |
76 | 76 | |||
77 | userret(l); | 77 | userret(l); | |
78 | } | 78 | } | |
79 | 79 | |||
80 | /* | 80 | /* | |
81 | * syscall(frame): | 81 | * syscall(frame): | |
82 | * System call request from POSIX system call gate interface to kernel. | 82 | * System call request from POSIX system call gate interface to kernel. | |
83 | * Like trap(), argument is call by reference. | 83 | * Like trap(), argument is call by reference. | |
84 | */ | 84 | */ | |
85 | #ifdef KDTRACE_HOOKS | 85 | #ifdef KDTRACE_HOOKS | |
86 | void syscall(struct trapframe *); | 86 | void syscall(struct trapframe *); | |
87 | #else | 87 | #else | |
88 | static | 88 | static | |
89 | #endif | 89 | #endif | |
90 | void | 90 | void | |
91 | syscall(struct trapframe *frame) | 91 | syscall(struct trapframe *frame) | |
92 | { | 92 | { |
--- src/sys/arch/x86/x86/x86_tlb.c 2020/03/22 00:16:16 1.18
+++ src/sys/arch/x86/x86/x86_tlb.c 2021/10/07 12:52:27 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: x86_tlb.c,v 1.18 2020/03/22 00:16:16 ad Exp $ */ | 1 | /* $NetBSD: x86_tlb.c,v 1.19 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2008-2020 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2008-2020 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 Andrew Doran and Mindaugas Rasiukevicius. | 8 | * by Andrew Doran and Mindaugas Rasiukevicius. | |
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. | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * x86 pmap(9) module: TLB shootdowns. | 33 | * x86 pmap(9) module: TLB shootdowns. | |
34 | * | 34 | * | |
35 | * TLB shootdowns are hard interrupts that operate outside the SPL framework. | 35 | * TLB shootdowns are hard interrupts that operate outside the SPL framework. | |
36 | * They do not need to be blocked, provided that the pmap module gets the | 36 | * They do not need to be blocked, provided that the pmap module gets the | |
37 | * order of events correct. The calls are made by poking the LAPIC directly. | 37 | * order of events correct. The calls are made by poking the LAPIC directly. | |
38 | * The interrupt handler is short and does one of the following: invalidate | 38 | * The interrupt handler is short and does one of the following: invalidate | |
39 | * a set of pages, all user TLB entries or the entire TLB. | 39 | * a set of pages, all user TLB entries or the entire TLB. | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.18 2020/03/22 00:16:16 ad Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: x86_tlb.c,v 1.19 2021/10/07 12:52:27 msaitoh Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/kernel.h> | 46 | #include <sys/kernel.h> | |
47 | 47 | |||
48 | #include <sys/systm.h> | 48 | #include <sys/systm.h> | |
49 | #include <sys/atomic.h> | 49 | #include <sys/atomic.h> | |
50 | #include <sys/cpu.h> | 50 | #include <sys/cpu.h> | |
51 | #include <sys/intr.h> | 51 | #include <sys/intr.h> | |
52 | #include <uvm/uvm.h> | 52 | #include <uvm/uvm.h> | |
53 | 53 | |||
54 | #include <machine/cpuvar.h> | 54 | #include <machine/cpuvar.h> | |
55 | #ifdef XENPV | 55 | #ifdef XENPV | |
56 | #include <xen/xenpmap.h> | 56 | #include <xen/xenpmap.h> | |
@@ -89,38 +89,38 @@ typedef struct { | @@ -89,38 +89,38 @@ typedef struct { | |||
89 | 89 | |||
90 | #define TP_GET_COUNT(tp) ((tp)->tp_store[TP_COUNT] & PAGE_MASK) | 90 | #define TP_GET_COUNT(tp) ((tp)->tp_store[TP_COUNT] & PAGE_MASK) | |
91 | #define TP_GET_USERPMAP(tp) ((tp)->tp_store[TP_USERPMAP] & 1) | 91 | #define TP_GET_USERPMAP(tp) ((tp)->tp_store[TP_USERPMAP] & 1) | |
92 | #define TP_GET_GLOBAL(tp) ((tp)->tp_store[TP_GLOBAL] & 1) | 92 | #define TP_GET_GLOBAL(tp) ((tp)->tp_store[TP_GLOBAL] & 1) | |
93 | #define TP_GET_DONE(tp) (atomic_load_relaxed(&(tp)->tp_store[TP_DONE]) & 1) | 93 | #define TP_GET_DONE(tp) (atomic_load_relaxed(&(tp)->tp_store[TP_DONE]) & 1) | |
94 | #define TP_GET_VA(tp, i) ((tp)->tp_store[(i)] & ~PAGE_MASK) | 94 | #define TP_GET_VA(tp, i) ((tp)->tp_store[(i)] & ~PAGE_MASK) | |
95 | 95 | |||
96 | #define TP_INC_COUNT(tp) ((tp)->tp_store[TP_COUNT]++) | 96 | #define TP_INC_COUNT(tp) ((tp)->tp_store[TP_COUNT]++) | |
97 | #define TP_SET_ALLVA(tp) ((tp)->tp_store[TP_COUNT] |= TP_ALLVA) | 97 | #define TP_SET_ALLVA(tp) ((tp)->tp_store[TP_COUNT] |= TP_ALLVA) | |
98 | #define TP_SET_VA(tp, c, va) ((tp)->tp_store[(c)] |= ((va) & ~PAGE_MASK)) | 98 | #define TP_SET_VA(tp, c, va) ((tp)->tp_store[(c)] |= ((va) & ~PAGE_MASK)) | |
99 | 99 | |||
100 | #define TP_SET_USERPMAP(tp) ((tp)->tp_store[TP_USERPMAP] |= 1) | 100 | #define TP_SET_USERPMAP(tp) ((tp)->tp_store[TP_USERPMAP] |= 1) | |
101 | #define TP_SET_GLOBAL(tp) ((tp)->tp_store[TP_GLOBAL] |= 1) | 101 | #define TP_SET_GLOBAL(tp) ((tp)->tp_store[TP_GLOBAL] |= 1) | |
102 | #define TP_SET_DONE(tp) \ | 102 | #define TP_SET_DONE(tp) \ | |
103 | do { \ | 103 | do { \ | |
104 | uintptr_t v = atomic_load_relaxed(&(tp)->tp_store[TP_DONE]); \ | 104 | uintptr_t v = atomic_load_relaxed(&(tp)->tp_store[TP_DONE]); \ | |
105 | atomic_store_relaxed(&(tp)->tp_store[TP_DONE], v | 1); \ | 105 | atomic_store_relaxed(&(tp)->tp_store[TP_DONE], v | 1); \ | |
106 | } while (/* CONSTCOND */ 0); | 106 | } while (/* CONSTCOND */ 0); | |
107 | 107 | |||
108 | #define TP_CLEAR(tp) memset(__UNVOLATILE(tp), 0, sizeof(*(tp))); | 108 | #define TP_CLEAR(tp) memset(__UNVOLATILE(tp), 0, sizeof(*(tp))); | |
109 | 109 | |||
110 | /* | 110 | /* | |
111 | * TLB shootdown state. | 111 | * TLB shootdown state. | |
112 | */ | 112 | */ | |
113 | static volatile pmap_tlb_packet_t * volatile pmap_tlb_packet __cacheline_aligned; | 113 | static volatile pmap_tlb_packet_t *volatile pmap_tlb_packet __cacheline_aligned; | |
114 | static volatile u_int pmap_tlb_pendcount __cacheline_aligned; | 114 | static volatile u_int pmap_tlb_pendcount __cacheline_aligned; | |
115 | static struct evcnt pmap_tlb_evcnt __cacheline_aligned; | 115 | static struct evcnt pmap_tlb_evcnt __cacheline_aligned; | |
116 | 116 | |||
117 | /* | 117 | /* | |
118 | * TLB shootdown statistics. | 118 | * TLB shootdown statistics. | |
119 | */ | 119 | */ | |
120 | #ifdef TLBSTATS | 120 | #ifdef TLBSTATS | |
121 | static struct evcnt tlbstat_local[TLBSHOOT__MAX]; | 121 | static struct evcnt tlbstat_local[TLBSHOOT__MAX]; | |
122 | static struct evcnt tlbstat_remote[TLBSHOOT__MAX]; | 122 | static struct evcnt tlbstat_remote[TLBSHOOT__MAX]; | |
123 | static struct evcnt tlbstat_kernel[TLBSHOOT__MAX]; | 123 | static struct evcnt tlbstat_kernel[TLBSHOOT__MAX]; | |
124 | static struct evcnt tlbstat_single_req; | 124 | static struct evcnt tlbstat_single_req; | |
125 | static struct evcnt tlbstat_single_issue; | 125 | static struct evcnt tlbstat_single_issue; | |
126 | static const char * tlbstat_name[ ] = { | 126 | static const char * tlbstat_name[ ] = { | |
@@ -422,27 +422,27 @@ pmap_tlb_shootnow(void) | @@ -422,27 +422,27 @@ pmap_tlb_shootnow(void) | |||
422 | x86_pause(); | 422 | x86_pause(); | |
423 | } while (atomic_load_relaxed(&pmap_tlb_packet) != NULL); | 423 | } while (atomic_load_relaxed(&pmap_tlb_packet) != NULL); | |
424 | s = splvm(); | 424 | s = splvm(); | |
425 | 425 | |||
426 | /* | 426 | /* | |
427 | * An interrupt might have done the shootdowns for | 427 | * An interrupt might have done the shootdowns for | |
428 | * us while we spun. | 428 | * us while we spun. | |
429 | */ | 429 | */ | |
430 | if (TP_GET_COUNT(tp) == 0) { | 430 | if (TP_GET_COUNT(tp) == 0) { | |
431 | splx(s); | 431 | splx(s); | |
432 | return; | 432 | return; | |
433 | } | 433 | } | |
434 | } | 434 | } | |
435 | 435 | |||
436 | /* | 436 | /* | |
437 | * Ownership of the global pointer provides serialization of the | 437 | * Ownership of the global pointer provides serialization of the | |
438 | * update to the count and the event counter. With those values | 438 | * update to the count and the event counter. With those values | |
439 | * updated, start shootdowns on remote CPUs. | 439 | * updated, start shootdowns on remote CPUs. | |
440 | */ | 440 | */ | |
441 | pmap_tlb_pendcount = rcpucount; | 441 | pmap_tlb_pendcount = rcpucount; | |
442 | pmap_tlb_evcnt.ev_count++; | 442 | pmap_tlb_evcnt.ev_count++; | |
443 | pmap_tlb_processpacket(ts, target); | 443 | pmap_tlb_processpacket(ts, target); | |
444 | 444 | |||
445 | /* | 445 | /* | |
446 | * Clear out the local CPU's buffer for the next user. Once done, | 446 | * Clear out the local CPU's buffer for the next user. Once done, | |
447 | * we can drop the IPL. | 447 | * we can drop the IPL. | |
448 | */ | 448 | */ |
--- src/sys/arch/x86/x86/viac7temp.c 2014/08/10 16:44:34 1.8
+++ src/sys/arch/x86/x86/viac7temp.c 2021/10/07 12:52:27 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: viac7temp.c,v 1.8 2014/08/10 16:44:34 tls Exp $ */ | 1 | /* $NetBSD: viac7temp.c,v 1.9 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,45 +17,45 @@ | @@ -17,45 +17,45 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.8 2014/08/10 16:44:34 tls Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.9 2021/10/07 12:52:27 msaitoh Exp $"); | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/device.h> | 33 | #include <sys/device.h> | |
34 | #include <sys/kmem.h> | 34 | #include <sys/kmem.h> | |
35 | #include <sys/xcall.h> | 35 | #include <sys/xcall.h> | |
36 | 36 | |||
37 | #include <dev/sysmon/sysmonvar.h> | 37 | #include <dev/sysmon/sysmonvar.h> | |
38 | 38 | |||
39 | #include <machine/cpuvar.h> | 39 | #include <machine/cpuvar.h> | |
40 | #include <machine/cpufunc.h> | 40 | #include <machine/cpufunc.h> | |
41 | #include <machine/cputypes.h> | 41 | #include <machine/cputypes.h> | |
42 | #include <machine/specialreg.h> | 42 | #include <machine/specialreg.h> | |
43 | 43 | |||
44 | struct viac7temp_softc { | 44 | struct viac7temp_softc { | |
45 | device_t sc_dev; | 45 | device_t sc_dev; | |
46 | struct cpu_info *sc_ci; | 46 | struct cpu_info *sc_ci; | |
47 | struct sysmon_envsys *sc_sme; | 47 | struct sysmon_envsys *sc_sme; | |
48 | envsys_data_t sc_sensor; | 48 | envsys_data_t sc_sensor; | |
49 | }; | 49 | }; | |
50 | 50 | |||
51 | static int viac7temp_match(device_t, cfdata_t, void *); | 51 | static int viac7temp_match(device_t, cfdata_t, void *); | |
52 | static void viac7temp_attach(device_t, device_t, void *); | 52 | static void viac7temp_attach(device_t, device_t, void *); | |
53 | static int viac7temp_detach(device_t, int); | 53 | static int viac7temp_detach(device_t, int); | |
54 | static void viac7temp_refresh(struct sysmon_envsys *, envsys_data_t *); | 54 | static void viac7temp_refresh(struct sysmon_envsys *, envsys_data_t *); | |
55 | static void viac7temp_refresh_xcall(void *, void *); | 55 | static void viac7temp_refresh_xcall(void *, void *); | |
56 | 56 | |||
57 | CFATTACH_DECL_NEW(viac7temp, sizeof(struct viac7temp_softc), | 57 | CFATTACH_DECL_NEW(viac7temp, sizeof(struct viac7temp_softc), | |
58 | viac7temp_match, viac7temp_attach, viac7temp_detach, NULL); | 58 | viac7temp_match, viac7temp_attach, viac7temp_detach, NULL); | |
59 | 59 | |||
60 | static int | 60 | static int | |
61 | viac7temp_match(device_t parent, cfdata_t cf, void *aux) | 61 | viac7temp_match(device_t parent, cfdata_t cf, void *aux) |
--- src/sys/arch/x86/x86/x86_autoconf.c 2020/07/09 22:45:54 1.84
+++ src/sys/arch/x86/x86/x86_autoconf.c 2021/10/07 12:52:27 1.85
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: x86_autoconf.c,v 1.84 2020/07/09 22:45:54 jdolecek Exp $ */ | 1 | /* $NetBSD: x86_autoconf.c,v 1.85 2021/10/07 12:52:27 msaitoh 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. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | * SUCH DAMAGE. | 32 | * SUCH DAMAGE. | |
33 | * | 33 | * | |
34 | * @(#)autoconf.c 7.1 (Berkeley) 5/9/91 | 34 | * @(#)autoconf.c 7.1 (Berkeley) 5/9/91 | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.84 2020/07/09 22:45:54 jdolecek Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.85 2021/10/07 12:52:27 msaitoh Exp $"); | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | #include <sys/disklabel.h> | 43 | #include <sys/disklabel.h> | |
44 | #include <sys/conf.h> | 44 | #include <sys/conf.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | #include <sys/vnode.h> | 46 | #include <sys/vnode.h> | |
47 | #include <sys/fcntl.h> | 47 | #include <sys/fcntl.h> | |
48 | #include <sys/disk.h> | 48 | #include <sys/disk.h> | |
49 | #include <sys/proc.h> | 49 | #include <sys/proc.h> | |
50 | #include <sys/md5.h> | 50 | #include <sys/md5.h> | |
51 | #include <sys/kauth.h> | 51 | #include <sys/kauth.h> | |
@@ -85,28 +85,28 @@ static void | @@ -85,28 +85,28 @@ static void | |||
85 | dmatch(const char *func, device_t dv, const char *method) | 85 | dmatch(const char *func, device_t dv, const char *method) | |
86 | { | 86 | { | |
87 | 87 | |||
88 | printf("WARNING: %s: double match for boot device (%s:%s %s:%s)\n", | 88 | printf("WARNING: %s: double match for boot device (%s:%s %s:%s)\n", | |
89 | func, booted_method, device_xname(booted_device), | 89 | func, booted_method, device_xname(booted_device), | |
90 | method, device_xname(dv)); | 90 | method, device_xname(dv)); | |
91 | } | 91 | } | |
92 | 92 | |||
93 | static int | 93 | static int | |
94 | is_valid_disk(device_t dv) | 94 | is_valid_disk(device_t dv) | |
95 | { | 95 | { | |
96 | 96 | |||
97 | if (device_class(dv) != DV_DISK) | 97 | if (device_class(dv) != DV_DISK) | |
98 | return (0); | 98 | return 0; | |
99 | 99 | |||
100 | return (device_is_a(dv, "dk") || | 100 | return (device_is_a(dv, "dk") || | |
101 | device_is_a(dv, "sd") || | 101 | device_is_a(dv, "sd") || | |
102 | device_is_a(dv, "wd") || | 102 | device_is_a(dv, "wd") || | |
103 | device_is_a(dv, "ld") || | 103 | device_is_a(dv, "ld") || | |
104 | device_is_a(dv, "xbd") || | 104 | device_is_a(dv, "xbd") || | |
105 | device_is_a(dv, "ed")); | 105 | device_is_a(dv, "ed")); | |
106 | } | 106 | } | |
107 | 107 | |||
108 | /* | 108 | /* | |
109 | * XXX Ugly bit of code. But, this is the only safe time that the | 109 | * XXX Ugly bit of code. But, this is the only safe time that the | |
110 | * match between BIOS disks and native disks can be done. | 110 | * match between BIOS disks and native disks can be done. | |
111 | */ | 111 | */ | |
112 | static void | 112 | static void | |
@@ -282,75 +282,75 @@ match_bootdisk(device_t dv, struct btinf | @@ -282,75 +282,75 @@ match_bootdisk(device_t dv, struct btinf | |||
282 | DPRINTF(("%s: dk %s\n", __func__, device_xname(dv))); | 282 | DPRINTF(("%s: dk %s\n", __func__, device_xname(dv))); | |
283 | return 0; | 283 | return 0; | |
284 | } | 284 | } | |
285 | 285 | |||
286 | /* | 286 | /* | |
287 | * A disklabel is required here. The boot loader doesn't refuse | 287 | * A disklabel is required here. The boot loader doesn't refuse | |
288 | * to boot from a disk without a label, but this is normally not | 288 | * to boot from a disk without a label, but this is normally not | |
289 | * wanted. | 289 | * wanted. | |
290 | */ | 290 | */ | |
291 | if (bid->labelsector == -1) { | 291 | if (bid->labelsector == -1) { | |
292 | DPRINTF(("%s: no label %s\n", __func__, device_xname(dv))); | 292 | DPRINTF(("%s: no label %s\n", __func__, device_xname(dv))); | |
293 | return 0; | 293 | return 0; | |
294 | } | 294 | } | |
295 | 295 | |||
296 | if ((tmpvn = opendisk(dv)) == NULL) { | 296 | if ((tmpvn = opendisk(dv)) == NULL) { | |
297 | DPRINTF(("%s: can't open %s\n", __func__, device_xname(dv))); | 297 | DPRINTF(("%s: can't open %s\n", __func__, device_xname(dv))); | |
298 | return 0; | 298 | return 0; | |
299 | } | 299 | } | |
300 | 300 | |||
301 | error = VOP_IOCTL(tmpvn, DIOCGDINFO, &label, FREAD, NOCRED); | 301 | error = VOP_IOCTL(tmpvn, DIOCGDINFO, &label, FREAD, NOCRED); | |
302 | if (error) { | 302 | if (error) { | |
303 | /* | 303 | /* | |
304 | * XXX Can't happen -- open() would have errored out | 304 | * XXX Can't happen -- open() would have errored out | |
305 | * or faked one up. | 305 | * or faked one up. | |
306 | */ | 306 | */ | |
307 | printf("%s: can't get label for dev %s (%d)\n", __func__, | 307 | printf("%s: can't get label for dev %s (%d)\n", __func__, | |
308 | device_xname(dv), error); | 308 | device_xname(dv), error); | |
309 | goto closeout; | 309 | goto closeout; | |
310 | } | 310 | } | |
311 | 311 | |||
312 | /* Compare with our data. */ | 312 | /* Compare with our data. */ | |
313 | if (label.d_type == bid->label.type && | 313 | if (label.d_type == bid->label.type && | |
314 | label.d_checksum == bid->label.checksum && | 314 | label.d_checksum == bid->label.checksum && | |
315 | strncmp(label.d_packname, bid->label.packname, 16) == 0) | 315 | strncmp(label.d_packname, bid->label.packname, 16) == 0) | |
316 | found = 1; | 316 | found = 1; | |
317 | 317 | |||
318 | DPRINTF(("%s: %s found=%d\n", __func__, device_xname(dv), found)); | 318 | DPRINTF(("%s: %s found=%d\n", __func__, device_xname(dv), found)); | |
319 | closeout: | 319 | closeout: | |
320 | VOP_CLOSE(tmpvn, FREAD, NOCRED); | 320 | VOP_CLOSE(tmpvn, FREAD, NOCRED); | |
321 | vput(tmpvn); | 321 | vput(tmpvn); | |
322 | return (found); | 322 | return found; | |
323 | } | 323 | } | |
324 | 324 | |||
325 | /* | 325 | /* | |
326 | * Attempt to find the device from which we were booted. If we can do so, | 326 | * Attempt to find the device from which we were booted. If we can do so, | |
327 | * and not instructed not to do so, change rootdev to correspond to the | 327 | * and not instructed not to do so, change rootdev to correspond to the | |
328 | * load device. | 328 | * load device. | |
329 | */ | 329 | */ | |
330 | static void | 330 | static void | |
331 | findroot(void) | 331 | findroot(void) | |
332 | { | 332 | { | |
333 | struct btinfo_rootdevice *biv; | 333 | struct btinfo_rootdevice *biv; | |
334 | struct btinfo_bootdisk *bid; | 334 | struct btinfo_bootdisk *bid; | |
335 | struct btinfo_bootwedge *biw; | 335 | struct btinfo_bootwedge *biw; | |
336 | struct btinfo_biosgeom *big; | 336 | struct btinfo_biosgeom *big; | |
337 | device_t dv; | 337 | device_t dv; | |
338 | deviter_t di; | 338 | deviter_t di; | |
339 | static char bootspecbuf[sizeof(biv->devname)+1]; | 339 | static char bootspecbuf[sizeof(biv->devname)+1]; | |
340 | 340 | |||
341 | if (booted_device) | 341 | if (booted_device) | |
342 | return; | 342 | return; | |
343 | 343 | |||
344 | if (lookup_bootinfo(BTINFO_NETIF) != NULL) { | 344 | if (lookup_bootinfo(BTINFO_NETIF) != NULL) { | |
345 | /* | 345 | /* | |
346 | * We got netboot interface information, but device_register() | 346 | * We got netboot interface information, but device_register() | |
347 | * failed to match it to a configured device. Boot disk | 347 | * failed to match it to a configured device. Boot disk | |
348 | * information cannot be present at the same time, so give | 348 | * information cannot be present at the same time, so give | |
349 | * up. | 349 | * up. | |
350 | */ | 350 | */ | |
351 | printf("%s: netboot interface not found.\n", __func__); | 351 | printf("%s: netboot interface not found.\n", __func__); | |
352 | return; | 352 | return; | |
353 | } | 353 | } | |
354 | 354 | |||
355 | if ((biv = lookup_bootinfo(BTINFO_ROOTDEVICE)) != NULL) { | 355 | if ((biv = lookup_bootinfo(BTINFO_ROOTDEVICE)) != NULL) { | |
356 | for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); | 356 | for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); | |
@@ -399,27 +399,27 @@ findroot(void) | @@ -399,27 +399,27 @@ findroot(void) | |||
399 | * boot device. | 399 | * boot device. | |
400 | */ | 400 | */ | |
401 | for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); | 401 | for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); | |
402 | dv != NULL; | 402 | dv != NULL; | |
403 | dv = deviter_next(&di)) { | 403 | dv = deviter_next(&di)) { | |
404 | if (is_valid_disk(dv)) { | 404 | if (is_valid_disk(dv)) { | |
405 | /* | 405 | /* | |
406 | * Don't trust BIOS device numbers, try | 406 | * Don't trust BIOS device numbers, try | |
407 | * to match the information passed by the | 407 | * to match the information passed by the | |
408 | * boot loader instead. | 408 | * boot loader instead. | |
409 | */ | 409 | */ | |
410 | if ((biw->biosdev & 0x80) == 0 || | 410 | if ((biw->biosdev & 0x80) == 0 || | |
411 | match_bootwedge(dv, biw) == 0) | 411 | match_bootwedge(dv, biw) == 0) | |
412 | continue; | 412 | continue; | |
413 | goto bootwedge_found; | 413 | goto bootwedge_found; | |
414 | } | 414 | } | |
415 | 415 | |||
416 | continue; | 416 | continue; | |
417 | bootwedge_found: | 417 | bootwedge_found: | |
418 | if (booted_device) { | 418 | if (booted_device) { | |
419 | dmatch(__func__, dv, "bootinfo/bootwedge"); | 419 | dmatch(__func__, dv, "bootinfo/bootwedge"); | |
420 | continue; | 420 | continue; | |
421 | } | 421 | } | |
422 | booted_device = dv; | 422 | booted_device = dv; | |
423 | booted_method = "bootinfo/bootwedge"; | 423 | booted_method = "bootinfo/bootwedge"; | |
424 | booted_partition = bid != NULL ? bid->partition : 0; | 424 | booted_partition = bid != NULL ? bid->partition : 0; | |
425 | booted_nblks = biw->nblks; | 425 | booted_nblks = biw->nblks; | |
@@ -446,39 +446,39 @@ findroot(void) | @@ -446,39 +446,39 @@ findroot(void) | |||
446 | dv = deviter_next(&di)) { | 446 | dv = deviter_next(&di)) { | |
447 | 447 | |||
448 | if (device_is_a(dv, "fd") && | 448 | if (device_is_a(dv, "fd") && | |
449 | device_class(dv) == DV_DISK) { | 449 | device_class(dv) == DV_DISK) { | |
450 | /* | 450 | /* | |
451 | * Assume the configured unit number matches | 451 | * Assume the configured unit number matches | |
452 | * the BIOS device number. (This is the old | 452 | * the BIOS device number. (This is the old | |
453 | * behavior.) Needs some ideas how to handle | 453 | * behavior.) Needs some ideas how to handle | |
454 | * the BIOS's "swap floppy drive" options. | 454 | * the BIOS's "swap floppy drive" options. | |
455 | */ | 455 | */ | |
456 | /* XXX device_unit() abuse */ | 456 | /* XXX device_unit() abuse */ | |
457 | if ((bid->biosdev & 0x80) != 0 || | 457 | if ((bid->biosdev & 0x80) != 0 || | |
458 | device_unit(dv) != bid->biosdev) | 458 | device_unit(dv) != bid->biosdev) | |
459 | continue; | 459 | continue; | |
460 | goto bootdisk_found; | 460 | goto bootdisk_found; | |
461 | } | 461 | } | |
462 | 462 | |||
463 | if (is_valid_disk(dv)) { | 463 | if (is_valid_disk(dv)) { | |
464 | /* | 464 | /* | |
465 | * Don't trust BIOS device numbers, try | 465 | * Don't trust BIOS device numbers, try | |
466 | * to match the information passed by the | 466 | * to match the information passed by the | |
467 | * boot loader instead. | 467 | * boot loader instead. | |
468 | */ | 468 | */ | |
469 | if ((bid->biosdev & 0x80) == 0 || | 469 | if ((bid->biosdev & 0x80) == 0 || | |
470 | match_bootdisk(dv, bid) == 0) | 470 | match_bootdisk(dv, bid) == 0) | |
471 | continue; | 471 | continue; | |
472 | goto bootdisk_found; | 472 | goto bootdisk_found; | |
473 | } | 473 | } | |
474 | 474 | |||
475 | continue; | 475 | continue; | |
476 | bootdisk_found: | 476 | bootdisk_found: | |
477 | if (booted_device) { | 477 | if (booted_device) { | |
478 | dmatch(__func__, dv, "bootinfo/bootdisk"); | 478 | dmatch(__func__, dv, "bootinfo/bootdisk"); | |
479 | continue; | 479 | continue; | |
480 | } | 480 | } | |
481 | booted_device = dv; | 481 | booted_device = dv; | |
482 | booted_method = "bootinfo/bootdisk"; | 482 | booted_method = "bootinfo/bootdisk"; | |
483 | booted_partition = bid->partition; | 483 | booted_partition = bid->partition; | |
484 | booted_nblks = 0; | 484 | booted_nblks = 0; |
--- src/sys/arch/x86/x86/x86_ipmi.c 2021/07/21 23:16:09 1.2
+++ src/sys/arch/x86/x86/x86_ipmi.c 2021/10/07 12:52:27 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: x86_ipmi.c,v 1.2 2021/07/21 23:16:09 jmcneill Exp $ */ | 1 | /* $NetBSD: x86_ipmi.c,v 1.3 2021/10/07 12:52:27 msaitoh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2006 Manuel Bouyer. | 4 | * Copyright (c) 2006 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 | * | |
@@ -42,27 +42,27 @@ | @@ -42,27 +42,27 @@ | |||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR | 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR | |
45 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 45 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. | |
52 | */ | 52 | */ | |
53 | 53 | |||
54 | #include <sys/cdefs.h> | 54 | #include <sys/cdefs.h> | |
55 | __KERNEL_RCSID(0, "$NetBSD: x86_ipmi.c,v 1.2 2021/07/21 23:16:09 jmcneill Exp $"); | 55 | __KERNEL_RCSID(0, "$NetBSD: x86_ipmi.c,v 1.3 2021/10/07 12:52:27 msaitoh Exp $"); | |
56 | 56 | |||
57 | #include <sys/types.h> | 57 | #include <sys/types.h> | |
58 | #include <sys/param.h> | 58 | #include <sys/param.h> | |
59 | #include <sys/systm.h> | 59 | #include <sys/systm.h> | |
60 | #include <sys/kernel.h> | 60 | #include <sys/kernel.h> | |
61 | #include <sys/pmf.h> | 61 | #include <sys/pmf.h> | |
62 | #include <sys/bus.h> | 62 | #include <sys/bus.h> | |
63 | #include <sys/intr.h> | 63 | #include <sys/intr.h> | |
64 | 64 | |||
65 | #include <dev/smbiosvar.h> | 65 | #include <dev/smbiosvar.h> | |
66 | 66 | |||
67 | #include <dev/isa/isareg.h> | 67 | #include <dev/isa/isareg.h> | |
68 | #include <dev/isa/isavar.h> | 68 | #include <dev/isa/isavar.h> | |
@@ -135,56 +135,56 @@ ipmi_smbios_probe(struct smbios_ipmi *pi | @@ -135,56 +135,56 @@ ipmi_smbios_probe(struct smbios_ipmi *pi | |||
135 | ia->iaa_if_iotype = 'i'; | 135 | ia->iaa_if_iotype = 'i'; | |
136 | ia->iaa_if_iobase = pipmi->smipmi_base_address & ~0x1; | 136 | ia->iaa_if_iobase = pipmi->smipmi_base_address & ~0x1; | |
137 | } else { | 137 | } else { | |
138 | ia->iaa_if_iotype = 'm'; | 138 | ia->iaa_if_iotype = 'm'; | |
139 | ia->iaa_if_iobase = pipmi->smipmi_base_address & ~0xF; | 139 | ia->iaa_if_iobase = pipmi->smipmi_base_address & ~0xF; | |
140 | } | 140 | } | |
141 | if (pipmi->smipmi_base_flags & SMIPMI_FLAG_ODDOFFSET) | 141 | if (pipmi->smipmi_base_flags & SMIPMI_FLAG_ODDOFFSET) | |
142 | ia->iaa_if_iobase++; | 142 | ia->iaa_if_iobase++; | |
143 | 143 | |||
144 | platform = pmf_get_platform("system-product"); | 144 | platform = pmf_get_platform("system-product"); | |
145 | if (platform != NULL && | 145 | if (platform != NULL && | |
146 | strcmp(platform, "ProLiant MicroServer") == 0 && | 146 | strcmp(platform, "ProLiant MicroServer") == 0 && | |
147 | pipmi->smipmi_base_address != 0) { | 147 | pipmi->smipmi_base_address != 0) { | |
148 | ia->iaa_if_iospacing = 1; | 148 | ia->iaa_if_iospacing = 1; | |
149 | ia->iaa_if_iobase = pipmi->smipmi_base_address & ~0x7; | 149 | ia->iaa_if_iobase = pipmi->smipmi_base_address & ~0x7; | |
150 | ia->iaa_if_iotype = 'i'; | 150 | ia->iaa_if_iotype = 'i'; | |
151 | return; | 151 | return; | |
152 | } | 152 | } | |
153 | 153 | |||
154 | if (pipmi->smipmi_base_flags == 0x7f) { | 154 | if (pipmi->smipmi_base_flags == 0x7f) { | |
155 | /* IBM 325 eServer workaround */ | 155 | /* IBM 325 eServer workaround */ | |
156 | ia->iaa_if_iospacing = 1; | 156 | ia->iaa_if_iospacing = 1; | |
157 | ia->iaa_if_iobase = pipmi->smipmi_base_address; | 157 | ia->iaa_if_iobase = pipmi->smipmi_base_address; | |
158 | ia->iaa_if_iotype = 'i'; | 158 | ia->iaa_if_iotype = 'i'; | |
159 | return; | 159 | return; | |
160 | } | 160 | } | |
161 | } | 161 | } | |
162 | 162 | |||
163 | /* Scan memory for signature */ | 163 | /* Scan memory for signature */ | |
164 | static void * | 164 | static void * | |
165 | scan_sig(long start, long end, int skip, int len, const void *data) | 165 | scan_sig(long start, long end, int skip, int len, const void *data) | |
166 | { | 166 | { | |
167 | void *va; | 167 | void *va; | |
168 | 168 | |||
169 | while (start < end) { | 169 | while (start < end) { | |
170 | va = ISA_HOLE_VADDR(start); | 170 | va = ISA_HOLE_VADDR(start); | |
171 | if (memcmp(va, data, len) == 0) | 171 | if (memcmp(va, data, len) == 0) | |
172 | return (va); | 172 | return va; | |
173 | 173 | |||
174 | start += skip; | 174 | start += skip; | |
175 | } | 175 | } | |
176 | 176 | |||
177 | return (NULL); | 177 | return NULL; | |
178 | } | 178 | } | |
179 | 179 | |||
180 | int | 180 | int | |
181 | ipmi_probe(struct ipmi_attach_args *ia) | 181 | ipmi_probe(struct ipmi_attach_args *ia) | |
182 | { | 182 | { | |
183 | struct dmd_ipmi *pipmi; | 183 | struct dmd_ipmi *pipmi; | |
184 | struct smbtable tbl; | 184 | struct smbtable tbl; | |
185 | 185 | |||
186 | tbl.cookie = 0; | 186 | tbl.cookie = 0; | |
187 | 187 | |||
188 | if (smbios_find_table(SMBIOS_TYPE_IPMIDEV, &tbl)) | 188 | if (smbios_find_table(SMBIOS_TYPE_IPMIDEV, &tbl)) | |
189 | ipmi_smbios_probe(tbl.tblhdr, ia); | 189 | ipmi_smbios_probe(tbl.tblhdr, ia); | |
190 | else { | 190 | else { |
--- src/sys/arch/x86/x86/x86_machdep.c 2021/02/19 03:28:53 1.148
+++ src/sys/arch/x86/x86/x86_machdep.c 2021/10/07 12:52:27 1.149
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: x86_machdep.c,v 1.148 2021/02/19 03:28:53 christos Exp $ */ | 1 | /* $NetBSD: x86_machdep.c,v 1.149 2021/10/07 12:52:27 msaitoh 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.148 2021/02/19 03:28:53 christos Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.149 2021/10/07 12:52:27 msaitoh 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> | |
@@ -273,27 +273,27 @@ module_init_md(void) | @@ -273,27 +273,27 @@ module_init_md(void) | |||
273 | case BI_MODULE_FS: | 273 | case BI_MODULE_FS: | |
274 | aprint_debug("File-system image path=%s len=%d pa=%x\n", | 274 | aprint_debug("File-system image path=%s len=%d pa=%x\n", | |
275 | bi->path, bi->len, bi->base); | 275 | bi->path, bi->len, bi->base); | |
276 | KASSERT(trunc_page(bi->base) == bi->base); | 276 | KASSERT(trunc_page(bi->base) == bi->base); | |
277 | #if defined(MEMORY_DISK_HOOKS) && defined(MEMORY_DISK_DYNAMIC) | 277 | #if defined(MEMORY_DISK_HOOKS) && defined(MEMORY_DISK_DYNAMIC) | |
278 | md_root_setconf( | 278 | md_root_setconf( | |
279 | #ifdef KASLR | 279 | #ifdef KASLR | |
280 | (void *)PMAP_DIRECT_MAP((uintptr_t)bi->base), | 280 | (void *)PMAP_DIRECT_MAP((uintptr_t)bi->base), | |
281 | #else | 281 | #else | |
282 | (void *)((uintptr_t)bi->base + KERNBASE), | 282 | (void *)((uintptr_t)bi->base + KERNBASE), | |
283 | #endif | 283 | #endif | |
284 | bi->len); | 284 | bi->len); | |
285 | #endif | 285 | #endif | |
286 | break; | 286 | break; | |
287 | default: | 287 | default: | |
288 | aprint_debug("Skipping non-ELF module\n"); | 288 | aprint_debug("Skipping non-ELF module\n"); | |
289 | break; | 289 | break; | |
290 | } | 290 | } | |
291 | } | 291 | } | |
292 | } | 292 | } | |
293 | #endif /* MODULAR */ | 293 | #endif /* MODULAR */ | |
294 | 294 | |||
295 | void | 295 | void | |
296 | cpu_need_resched(struct cpu_info *ci, struct lwp *l, int flags) | 296 | cpu_need_resched(struct cpu_info *ci, struct lwp *l, int flags) | |
297 | { | 297 | { | |
298 | 298 | |||
299 | KASSERT(kpreempt_disabled()); | 299 | KASSERT(kpreempt_disabled()); | |
@@ -694,27 +694,27 @@ x86_parse_clusters(struct btinfo_memmap | @@ -694,27 +694,27 @@ x86_parse_clusters(struct btinfo_memmap | |||
694 | default: | 694 | default: | |
695 | continue; | 695 | continue; | |
696 | } | 696 | } | |
697 | 697 | |||
698 | /* If the segment is smaller than a page, skip it. */ | 698 | /* If the segment is smaller than a page, skip it. */ | |
699 | if (size < PAGE_SIZE) | 699 | if (size < PAGE_SIZE) | |
700 | continue; | 700 | continue; | |
701 | 701 | |||
702 | seg_start = addr; | 702 | seg_start = addr; | |
703 | seg_end = addr + size; | 703 | seg_end = addr + size; | |
704 | 704 | |||
705 | /* | 705 | /* | |
706 | * XXX XXX: Avoid the ISA I/O MEM. | 706 | * XXX XXX: Avoid the ISA I/O MEM. | |
707 | * | 707 | * | |
708 | * Some laptops (for example, Toshiba Satellite2550X) report | 708 | * Some laptops (for example, Toshiba Satellite2550X) report | |
709 | * this area as valid. | 709 | * this area as valid. | |
710 | */ | 710 | */ | |
711 | if (seg_start < IOM_END && seg_end > IOM_BEGIN) { | 711 | if (seg_start < IOM_END && seg_end > IOM_BEGIN) { | |
712 | printf("WARNING: memory map entry overlaps " | 712 | printf("WARNING: memory map entry overlaps " | |
713 | "with ``Compatibility Holes'': " | 713 | "with ``Compatibility Holes'': " | |
714 | "0x%"PRIx64"/0x%"PRIx64"/0x%x\n", seg_start, | 714 | "0x%"PRIx64"/0x%"PRIx64"/0x%x\n", seg_start, | |
715 | seg_end - seg_start, type); | 715 | seg_end - seg_start, type); | |
716 | 716 | |||
717 | if (x86_add_cluster(seg_start, IOM_BEGIN, type) == -1) | 717 | if (x86_add_cluster(seg_start, IOM_BEGIN, type) == -1) | |
718 | break; | 718 | break; | |
719 | if (x86_add_cluster(IOM_END, seg_end, type) == -1) | 719 | if (x86_add_cluster(IOM_END, seg_end, type) == -1) | |
720 | break; | 720 | break; | |
@@ -833,27 +833,27 @@ x86_load_region(uint64_t seg_start, uint | @@ -833,27 +833,27 @@ x86_load_region(uint64_t seg_start, uint | |||
833 | } | 833 | } | |
834 | } | 834 | } | |
835 | 835 | |||
836 | #ifdef XEN | 836 | #ifdef XEN | |
837 | static void | 837 | static void | |
838 | x86_add_xen_clusters(void) | 838 | x86_add_xen_clusters(void) | |
839 | { | 839 | { | |
840 | if (hvm_start_info->memmap_entries > 0) { | 840 | if (hvm_start_info->memmap_entries > 0) { | |
841 | struct hvm_memmap_table_entry *map_entry; | 841 | struct hvm_memmap_table_entry *map_entry; | |
842 | map_entry = (void *)((uintptr_t)hvm_start_info->memmap_paddr + KERNBASE); | 842 | map_entry = (void *)((uintptr_t)hvm_start_info->memmap_paddr + KERNBASE); | |
843 | for (int i = 0; i < hvm_start_info->memmap_entries; i++) { | 843 | for (int i = 0; i < hvm_start_info->memmap_entries; i++) { | |
844 | if (map_entry[i].size < PAGE_SIZE) | 844 | if (map_entry[i].size < PAGE_SIZE) | |
845 | continue; | 845 | continue; | |
846 | switch(map_entry[i].type) { | 846 | switch (map_entry[i].type) { | |
847 | case XEN_HVM_MEMMAP_TYPE_RAM: | 847 | case XEN_HVM_MEMMAP_TYPE_RAM: | |
848 | x86_add_cluster(map_entry[i].addr, | 848 | x86_add_cluster(map_entry[i].addr, | |
849 | map_entry[i].size, BIM_Memory); | 849 | map_entry[i].size, BIM_Memory); | |
850 | break; | 850 | break; | |
851 | case XEN_HVM_MEMMAP_TYPE_ACPI: | 851 | case XEN_HVM_MEMMAP_TYPE_ACPI: | |
852 | x86_add_cluster(map_entry[i].addr, | 852 | x86_add_cluster(map_entry[i].addr, | |
853 | map_entry[i].size, BIM_ACPI); | 853 | map_entry[i].size, BIM_ACPI); | |
854 | break; | 854 | break; | |
855 | } | 855 | } | |
856 | } | 856 | } | |
857 | } else { | 857 | } else { | |
858 | struct xen_memory_map memmap; | 858 | struct xen_memory_map memmap; | |
859 | static struct _xen_mmap { | 859 | static struct _xen_mmap { | |
@@ -1040,53 +1040,53 @@ init_x86_vm(paddr_t pa_kend) | @@ -1040,53 +1040,53 @@ init_x86_vm(paddr_t pa_kend) | |||
1040 | * [pa_kstart pa_kend] | 1040 | * [pa_kstart pa_kend] | |
1041 | * [seg_start seg_end] | 1041 | * [seg_start seg_end] | |
1042 | */ | 1042 | */ | |
1043 | if (seg_start < pa_kstart && | 1043 | if (seg_start < pa_kstart && | |
1044 | pa_kstart < seg_end && | 1044 | pa_kstart < seg_end && | |
1045 | seg_end < pa_kend) { | 1045 | seg_end < pa_kend) { | |
1046 | #ifdef DEBUG_MEMLOAD | 1046 | #ifdef DEBUG_MEMLOAD | |
1047 | printf("discard trailing kernel overlap " | 1047 | printf("discard trailing kernel overlap " | |
1048 | "%" PRIxPADDR " - %" PRIx64 "\n", | 1048 | "%" PRIxPADDR " - %" PRIx64 "\n", | |
1049 | pa_kstart, seg_end); | 1049 | pa_kstart, seg_end); | |
1050 | #endif | 1050 | #endif | |
1051 | seg_end = pa_kstart; | 1051 | seg_end = pa_kstart; | |
1052 | } | 1052 | } | |
1053 | 1053 | |||
1054 | /* First hunk */ | 1054 | /* First hunk */ | |
1055 | if (seg_start != seg_end) { | 1055 | if (seg_start != seg_end) { | |
1056 | x86_load_region(seg_start, seg_end); | 1056 | x86_load_region(seg_start, seg_end); | |
1057 | } | 1057 | } | |
1058 | 1058 | |||
1059 | /* Second hunk */ | 1059 | /* Second hunk */ | |
1060 | if (seg_start1 != seg_end1) { | 1060 | if (seg_start1 != seg_end1) { | |
1061 | x86_load_region(seg_start1, seg_end1); | 1061 | x86_load_region(seg_start1, seg_end1); | |
1062 | } | 1062 | } | |
1063 | } | 1063 | } | |
1064 | 1064 | |||
1065 | return 0; | 1065 | return 0; | |
1066 | } | 1066 | } | |
1067 | 1067 | |||
1068 | #endif /* !XENPV */ | 1068 | #endif /* !XENPV */ | |
1069 | 1069 | |||
1070 | void | 1070 | void | |
1071 | init_x86_msgbuf(void) | 1071 | init_x86_msgbuf(void) | |
1072 | { | 1072 | { | |
1073 | /* Message buffer is located at end of core. */ | 1073 | /* Message buffer is located at end of core. */ | |
1074 | psize_t sz = round_page(MSGBUFSIZE); | 1074 | psize_t sz = round_page(MSGBUFSIZE); | |
1075 | psize_t reqsz = sz; | 1075 | psize_t reqsz = sz; | |
1076 | uvm_physseg_t x; | 1076 | uvm_physseg_t x; | |
1077 | 1077 | |||
1078 | search_again: | 1078 | search_again: | |
1079 | for (x = uvm_physseg_get_first(); | 1079 | for (x = uvm_physseg_get_first(); | |
1080 | uvm_physseg_valid_p(x); | 1080 | uvm_physseg_valid_p(x); | |
1081 | x = uvm_physseg_get_next(x)) { | 1081 | x = uvm_physseg_get_next(x)) { | |
1082 | 1082 | |||
1083 | if (ctob(uvm_physseg_get_avail_end(x)) == avail_end) | 1083 | if (ctob(uvm_physseg_get_avail_end(x)) == avail_end) | |
1084 | break; | 1084 | break; | |
1085 | } | 1085 | } | |
1086 | 1086 | |||
1087 | if (uvm_physseg_valid_p(x) == false) | 1087 | if (uvm_physseg_valid_p(x) == false) | |
1088 | panic("init_x86_msgbuf: can't find end of memory"); | 1088 | panic("init_x86_msgbuf: can't find end of memory"); | |
1089 | 1089 | |||
1090 | /* Shrink so it'll fit in the last segment. */ | 1090 | /* Shrink so it'll fit in the last segment. */ | |
1091 | if (uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x) < atop(sz)) | 1091 | if (uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x) < atop(sz)) | |
1092 | sz = ctob(uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x)); | 1092 | sz = ctob(uvm_physseg_get_avail_end(x) - uvm_physseg_get_avail_start(x)); | |
@@ -1216,37 +1216,37 @@ x86_startup(void) | @@ -1216,37 +1216,37 @@ x86_startup(void) | |||
1216 | { | 1216 | { | |
1217 | #if !defined(XENPV) | 1217 | #if !defined(XENPV) | |
1218 | nmi_init(); | 1218 | nmi_init(); | |
1219 | #endif | 1219 | #endif | |
1220 | } | 1220 | } | |
1221 | 1221 | |||
1222 | const char * | 1222 | const char * | |
1223 | get_booted_kernel(void) | 1223 | get_booted_kernel(void) | |
1224 | { | 1224 | { | |
1225 | const struct btinfo_bootpath *bibp = lookup_bootinfo(BTINFO_BOOTPATH); | 1225 | const struct btinfo_bootpath *bibp = lookup_bootinfo(BTINFO_BOOTPATH); | |
1226 | return bibp ? bibp->bootpath : NULL; | 1226 | return bibp ? bibp->bootpath : NULL; | |
1227 | } | 1227 | } | |
1228 | 1228 | |||
1229 | /* | 1229 | /* | |
1230 | * machine dependent system variables. | 1230 | * machine dependent system variables. | |
1231 | */ | 1231 | */ | |
1232 | static int | 1232 | static int | |
1233 | sysctl_machdep_booted_kernel(SYSCTLFN_ARGS) | 1233 | sysctl_machdep_booted_kernel(SYSCTLFN_ARGS) | |
1234 | { | 1234 | { | |
1235 | struct btinfo_bootpath *bibp; | 1235 | struct btinfo_bootpath *bibp; | |
1236 | struct sysctlnode node; | 1236 | struct sysctlnode node; | |
1237 | 1237 | |||
1238 | bibp = lookup_bootinfo(BTINFO_BOOTPATH); | 1238 | bibp = lookup_bootinfo(BTINFO_BOOTPATH); | |
1239 | if(!bibp) | 1239 | if (!bibp) | |
1240 | return ENOENT; /* ??? */ | 1240 | return ENOENT; /* ??? */ | |
1241 | 1241 | |||
1242 | node = *rnode; | 1242 | node = *rnode; | |
1243 | node.sysctl_data = bibp->bootpath; | 1243 | node.sysctl_data = bibp->bootpath; | |
1244 | node.sysctl_size = sizeof(bibp->bootpath); | 1244 | node.sysctl_size = sizeof(bibp->bootpath); | |
1245 | return sysctl_lookup(SYSCTLFN_CALL(&node)); | 1245 | return sysctl_lookup(SYSCTLFN_CALL(&node)); | |
1246 | } | 1246 | } | |
1247 | 1247 | |||
1248 | static int | 1248 | static int | |
1249 | sysctl_machdep_bootmethod(SYSCTLFN_ARGS) | 1249 | sysctl_machdep_bootmethod(SYSCTLFN_ARGS) | |
1250 | { | 1250 | { | |
1251 | struct sysctlnode node; | 1251 | struct sysctlnode node; | |
1252 | char buf[5]; | 1252 | char buf[5]; | |
@@ -1503,32 +1503,32 @@ cpu_initclocks(void) | @@ -1503,32 +1503,32 @@ cpu_initclocks(void) | |||
1503 | /* | 1503 | /* | |
1504 | * Re-calibrate TSC on boot CPU using most accurate time source, | 1504 | * Re-calibrate TSC on boot CPU using most accurate time source, | |
1505 | * thus making accurate TSC available for x86_initclock_func(). | 1505 | * thus making accurate TSC available for x86_initclock_func(). | |
1506 | */ | 1506 | */ | |
1507 | cpu_get_tsc_freq(curcpu()); | 1507 | cpu_get_tsc_freq(curcpu()); | |
1508 | 1508 | |||
1509 | /* Now start the clocks on this CPU (the boot CPU). */ | 1509 | /* Now start the clocks on this CPU (the boot CPU). */ | |
1510 | (*x86_initclock_func)(); | 1510 | (*x86_initclock_func)(); | |
1511 | } | 1511 | } | |
1512 | 1512 | |||
1513 | int | 1513 | int | |
1514 | x86_cpu_is_lcall(const void *ip) | 1514 | x86_cpu_is_lcall(const void *ip) | |
1515 | { | 1515 | { | |
1516 | static const uint8_t lcall[] = { 0x9a, 0, 0, 0, 0 }; | 1516 | static const uint8_t lcall[] = { 0x9a, 0, 0, 0, 0 }; | |
1517 | int error; | 1517 | int error; | |
1518 | const size_t sz = sizeof(lcall) + 2; | 1518 | const size_t sz = sizeof(lcall) + 2; | |
1519 | uint8_t tmp[sizeof(lcall) + 2]; | 1519 | uint8_t tmp[sizeof(lcall) + 2]; | |
1520 | 1520 | |||
1521 | if ((error = copyin(ip, tmp, sz)) != 0) | 1521 | if ((error = copyin(ip, tmp, sz)) != 0) | |
1522 | return error; | 1522 | return error; | |
1523 | 1523 | |||
1524 | if (memcmp(tmp, lcall, sizeof(lcall)) != 0 || tmp[sz - 1] != 0) | 1524 | if (memcmp(tmp, lcall, sizeof(lcall)) != 0 || tmp[sz - 1] != 0) | |
1525 | return EINVAL; | 1525 | return EINVAL; | |
1526 | 1526 | |||
1527 | switch (tmp[sz - 2]) { | 1527 | switch (tmp[sz - 2]) { | |
1528 | case (uint8_t)0x07: /* NetBSD */ | 1528 | case (uint8_t)0x07: /* NetBSD */ | |
1529 | case (uint8_t)0x87: /* BSD/OS */ | 1529 | case (uint8_t)0x87: /* BSD/OS */ | |
1530 | return 0; | 1530 | return 0; | |
1531 | default: | 1531 | default: | |
1532 | return EINVAL; | 1532 | return EINVAL; | |
1533 | } | 1533 | } | |
1534 | } | 1534 | } |