| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: idt.c,v 1.11 2019/06/17 06:38:30 msaitoh Exp $ */ | | 1 | /* $NetBSD: idt.c,v 1.12 2020/07/04 09:03:54 bouyer Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996, 1997, 1998, 2000, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996, 1997, 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, by Jason R. Thorpe of the Numerical Aerospace | | 8 | * by Charles M. Hannum, 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 |
| @@ -55,27 +55,27 @@ | | | @@ -55,27 +55,27 @@ |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
62 | * SUCH DAMAGE. | | 62 | * SUCH DAMAGE. |
63 | * | | 63 | * |
64 | * @(#)machdep.c 7.4 (Berkeley) 6/3/91 | | 64 | * @(#)machdep.c 7.4 (Berkeley) 6/3/91 |
65 | */ | | 65 | */ |
66 | | | 66 | |
67 | #include <sys/cdefs.h> | | 67 | #include <sys/cdefs.h> |
68 | __KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.11 2019/06/17 06:38:30 msaitoh Exp $"); | | 68 | __KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.12 2020/07/04 09:03:54 bouyer Exp $"); |
69 | | | 69 | |
70 | #include <sys/param.h> | | 70 | #include <sys/param.h> |
71 | #include <sys/systm.h> | | 71 | #include <sys/systm.h> |
72 | #include <sys/mutex.h> | | 72 | #include <sys/mutex.h> |
73 | #include <sys/cpu.h> | | 73 | #include <sys/cpu.h> |
74 | #include <sys/atomic.h> | | 74 | #include <sys/atomic.h> |
75 | | | 75 | |
76 | #include <uvm/uvm.h> | | 76 | #include <uvm/uvm.h> |
77 | | | 77 | |
78 | #include <machine/segments.h> | | 78 | #include <machine/segments.h> |
79 | | | 79 | |
80 | /* | | 80 | /* |
81 | * XEN PV and native have a different idea of what idt entries should | | 81 | * XEN PV and native have a different idea of what idt entries should |
| @@ -122,27 +122,27 @@ set_idtgate(struct trap_info *xen_idd, v | | | @@ -122,27 +122,27 @@ set_idtgate(struct trap_info *xen_idd, v |
122 | */ | | 122 | */ |
123 | xen_idd->vector = xen_idd - (struct trap_info *)xen_idt_vaddr; | | 123 | xen_idd->vector = xen_idd - (struct trap_info *)xen_idt_vaddr; |
124 | | | 124 | |
125 | /* Back to read-only, as it should be. */ | | 125 | /* Back to read-only, as it should be. */ |
126 | #if defined(__x86_64__) | | 126 | #if defined(__x86_64__) |
127 | pmap_changeprot_local(xen_idt_vaddr, VM_PROT_READ); | | 127 | pmap_changeprot_local(xen_idt_vaddr, VM_PROT_READ); |
128 | #endif /* __x86_64 */ | | 128 | #endif /* __x86_64 */ |
129 | //kpreempt_enable(); | | 129 | //kpreempt_enable(); |
130 | } | | 130 | } |
131 | void | | 131 | void |
132 | unset_idtgate(struct trap_info *xen_idd) | | 132 | unset_idtgate(struct trap_info *xen_idd) |
133 | { | | 133 | { |
134 | #if defined(__x86_64__) | | 134 | #if defined(__x86_64__) |
135 | vaddr_t xen_idt_vaddr = ((vaddr_t) xen_idd) & PAGE_MASK; | | 135 | vaddr_t xen_idt_vaddr = ((vaddr_t) xen_idd) & ~PAGE_MASK; |
136 | | | 136 | |
137 | /* Make it writeable, so we can update the values. */ | | 137 | /* Make it writeable, so we can update the values. */ |
138 | pmap_changeprot_local(xen_idt_vaddr, VM_PROT_READ | VM_PROT_WRITE); | | 138 | pmap_changeprot_local(xen_idt_vaddr, VM_PROT_READ | VM_PROT_WRITE); |
139 | #endif /* __x86_64 */ | | 139 | #endif /* __x86_64 */ |
140 | | | 140 | |
141 | /* Zero it */ | | 141 | /* Zero it */ |
142 | memset(xen_idd, 0, sizeof (*xen_idd)); | | 142 | memset(xen_idd, 0, sizeof (*xen_idd)); |
143 | | | 143 | |
144 | #if defined(__x86_64__) | | 144 | #if defined(__x86_64__) |
145 | /* Back to read-only, as it should be. */ | | 145 | /* Back to read-only, as it should be. */ |
146 | pmap_changeprot_local(xen_idt_vaddr, VM_PROT_READ); | | 146 | pmap_changeprot_local(xen_idt_vaddr, VM_PROT_READ); |
147 | #endif /* __x86_64 */ | | 147 | #endif /* __x86_64 */ |
148 | } | | 148 | } |