kctl_isadep.c (c7d88479) | kctl_isadep.c (ae115bc7) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 6 unchanged lines hidden (view full) --- 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* |
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. | 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <kmdb/kmdb_auxv.h> 30#include <kmdb/kctl/kctl.h> 31 32#include <sys/bootconf.h> 33#include <sys/kobj.h> 34#include <sys/kobj_impl.h> 35#include <sys/cpuvar.h> 36#include <sys/kdi_impl.h> 37#include <sys/x86_archext.h> 38#include <sys/controlregs.h> 39#include <sys/archsystm.h> 40 | 24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <kmdb/kmdb_auxv.h> 30#include <kmdb/kctl/kctl.h> 31 32#include <sys/bootconf.h> 33#include <sys/kobj.h> 34#include <sys/kobj_impl.h> 35#include <sys/cpuvar.h> 36#include <sys/kdi_impl.h> 37#include <sys/x86_archext.h> 38#include <sys/controlregs.h> 39#include <sys/archsystm.h> 40 |
41#if defined(__i386) 42/* Copied from stand/i386/sys/bootdef.h */ 43#define GS_GDT 0x38 /* dummy cpu_t pointer descriptor */ 44#endif 45 | |
46static int 47kctl_boot_prop_read(char *pname, char *prop_buf, int buf_len) 48{ | 41static int 42kctl_boot_prop_read(char *pname, char *prop_buf, int buf_len) 43{ |
49 int len; | |
50 struct bootops *ops = kctl.kctl_boot_ops; | 44 struct bootops *ops = kctl.kctl_boot_ops; |
45 int len; |
|
51 52 len = BOP_GETPROPLEN(ops, pname); 53 if (len > 0 && len <= buf_len) { 54 (void) BOP_GETPROP(ops, pname, (void *)prop_buf); 55 return (1); 56 } 57 58 return (0); --- 80 unchanged lines hidden (view full) --- 139} 140 141static void 142kctl_pcache_destroy(kmdb_auxv_nv_t *pnv) 143{ 144 kobj_free(pnv, sizeof (kmdb_auxv_nv_t) * KCTL_PROPNV_NENT); 145} 146 | 46 47 len = BOP_GETPROPLEN(ops, pname); 48 if (len > 0 && len <= buf_len) { 49 (void) BOP_GETPROP(ops, pname, (void *)prop_buf); 50 return (1); 51 } 52 53 return (0); --- 80 unchanged lines hidden (view full) --- 134} 135 136static void 137kctl_pcache_destroy(kmdb_auxv_nv_t *pnv) 138{ 139 kobj_free(pnv, sizeof (kmdb_auxv_nv_t) * KCTL_PROPNV_NENT); 140} 141 |
147/*ARGSUSED*/ 148static void 149kctl_cpu_init(void) 150{ 151} 152 | |
153void 154kctl_auxv_init_isadep(kmdb_auxv_t *kav, void *romp) 155{ 156 kav->kav_pcache = kctl_pcache_create(&kav->kav_nprops); 157 kav->kav_romp = romp; 158} 159 160void --- 5 unchanged lines hidden (view full) --- 166 167int 168kctl_preactivate_isadep(void) 169{ 170 return (0); 171} 172 173/*ARGSUSED*/ | 142void 143kctl_auxv_init_isadep(kmdb_auxv_t *kav, void *romp) 144{ 145 kav->kav_pcache = kctl_pcache_create(&kav->kav_nprops); 146 kav->kav_romp = romp; 147} 148 149void --- 5 unchanged lines hidden (view full) --- 155 156int 157kctl_preactivate_isadep(void) 158{ 159 return (0); 160} 161 162/*ARGSUSED*/ |
174int | 163void |
175kctl_activate_isadep(kdi_debugvec_t *dvec) 176{ | 164kctl_activate_isadep(kdi_debugvec_t *dvec) 165{ |
177 dvec->dv_kctl_cpu_init = kctl_cpu_init; | |
178 dvec->dv_kctl_vmready = hat_kdi_init; 179 180 if (!kctl.kctl_boot_loaded) 181 hat_kdi_init(); | 166 dvec->dv_kctl_vmready = hat_kdi_init; 167 168 if (!kctl.kctl_boot_loaded) 169 hat_kdi_init(); |
182 183 return (0); | |
184} 185 186void 187kctl_depreactivate_isadep(void) 188{ 189} 190 | 170} 171 172void 173kctl_depreactivate_isadep(void) 174{ 175} 176 |
191void 192kctl_deactivate_isadep(void) 193{ 194 hat_kdi_fini(); 195} 196 197#if defined(__amd64) | 177/* 178 * Many common kernel functions assume that %gs can be deferenced, and 179 * fail horribly if it cannot. Ask the kernel to set up a temporary 180 * mapping to a fake cpu_t so that we can call such functions during 181 * initialization. 182 */ |
198void * 199kctl_boot_tmpinit(void) 200{ | 183void * 184kctl_boot_tmpinit(void) 185{ |
201 /* 202 * Many common kernel functions assume that GSBASE has been initialized, 203 * and fail horribly if it hasn't. We'll install a pointer to a dummy 204 * cpu_t for use during our initialization. 205 */ 206 cpu_t *old = (cpu_t *)rdmsr(MSR_AMD_GSBASE); 207 208 wrmsr(MSR_AMD_GSBASE, (uint64_t)kobj_zalloc(sizeof (cpu_t), KM_TMP)); 209 return (old); | 186 return (boot_kdi_tmpinit()); |
210} 211 212void 213kctl_boot_tmpfini(void *old) 214{ | 187} 188 189void 190kctl_boot_tmpfini(void *old) 191{ |
215 wrmsr(MSR_AMD_GSBASE, (uint64_t)old); | 192 boot_kdi_tmpfini(old); |
216} | 193} |
217 218#else 219 220void * 221kctl_boot_tmpinit(void) 222{ 223 /* 224 * Many common kernel functions assume that %gs has been initialized, 225 * and fail horribly if it hasn't. Boot has reserved a descriptor for 226 * us (GS_GDT) in its GDT, a descriptor which we'll use to describe our 227 * dummy cpu_t. We then set %gs to refer to this descriptor. 228 */ 229 cpu_t *cpu = kobj_zalloc(sizeof (cpu_t), KM_TMP); 230 uintptr_t old; 231 desctbr_t bgdt; 232 user_desc_t *gsdesc; 233 234 rd_gdtr(&bgdt); 235 gsdesc = (user_desc_t *)(bgdt.dtr_base + GS_GDT); 236 237 USEGD_SETBASE(gsdesc, (uintptr_t)cpu); 238 USEGD_SETLIMIT(gsdesc, sizeof (cpu_t)); 239 240 old = getgs(); 241 setgs(GS_GDT); 242 243 return ((void *)old); 244} 245 246void 247kctl_boot_tmpfini(void *old) 248{ 249 setgs((uintptr_t)old); 250} 251#endif | |