Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen/x86 Zero out page table memory for IDT before use.



details:   https://anonhg.NetBSD.org/src/rev/b718914c20a9
branches:  trunk
changeset: 836437:b718914c20a9
user:      cherry <cherry%NetBSD.org@localhost>
date:      Thu Oct 18 04:17:18 2018 +0000

description:
Zero out page table memory for IDT before use.
To copy the IDT entry before registration, de-reference the indexed
value, not the first entry.
Add a MAX_XEN_IDT value for max entries we expect and KASSERT() for
this as a sanity check.

diffstat:

 sys/arch/xen/x86/xenfunc.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (49 lines):

diff -r 19aa8efcfad7 -r b718914c20a9 sys/arch/xen/x86/xenfunc.c
--- a/sys/arch/xen/x86/xenfunc.c        Thu Oct 18 04:14:07 2018 +0000
+++ b/sys/arch/xen/x86/xenfunc.c        Thu Oct 18 04:17:18 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xenfunc.c,v 1.21 2018/09/23 15:28:49 cherry Exp $      */
+/*     $NetBSD: xenfunc.c,v 1.22 2018/10/18 04:17:18 cherry Exp $      */
 
 /*
  * Copyright (c) 2004 Christian Limpach.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.21 2018/09/23 15:28:49 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.22 2018/10/18 04:17:18 cherry Exp $");
 
 #include <sys/param.h>
 
@@ -41,6 +41,8 @@
 #include <xen/xenpmap.h>
 #include <machine/pte.h>
 
+#define MAX_XEN_IDT 128
+
 void xen_set_ldt(vaddr_t, uint32_t);
 
 void 
@@ -59,7 +61,8 @@
         * will be available at the boot stage when this is called.
         */
        static char xen_idt_page[PAGE_SIZE] __attribute__((__aligned__ (PAGE_SIZE)));
-
+       memset(xen_idt_page, 0, PAGE_SIZE);
+       
        struct trap_info *xen_idt = (void * )xen_idt_page;
        int xen_idt_idx = 0;
        
@@ -73,9 +76,9 @@
         * back in the requestor array.
         */
        for (i = 0; i < nidt; i++) {
-               if (idd->address == 0) /* Skip gap */
+               if (idd[i].address == 0) /* Skip gap */
                        continue;
-
+               KASSERT(xen_idt_idx < MAX_XEN_IDT);
                /* Copy over entry */
                xen_idt[xen_idt_idx++] = idd[i];
        }



Home | Main Index | Thread Index | Old Index