Use the new sparc64 kcore cpu segment extensions to properly map VA/PAs
on kernels with more then 4 MB text/rodata segment.
This commit is contained in:
parent
b050fccbb2
commit
36097b1de9
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kvm_sparc64.c,v 1.10 2003/08/07 16:44:40 agc Exp $ */
|
||||
/* $NetBSD: kvm_sparc64.c,v 1.11 2007/11/05 00:46:23 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)kvm_sparc.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: kvm_sparc64.c,v 1.10 2003/08/07 16:44:40 agc Exp $");
|
||||
__RCSID("$NetBSD: kvm_sparc64.c,v 1.11 2007/11/05 00:46:23 martin Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -112,29 +112,51 @@ _kvm_kvatop(kd, va, pa)
|
|||
cpu_kcore_hdr_t *cpup = kd->cpu_data;
|
||||
u_long kernbase = cpup->kernbase;
|
||||
uint64_t *pseg, *pdir, *ptbl;
|
||||
struct cpu_kcore_4mbseg *ktlb;
|
||||
int64_t data;
|
||||
int i;
|
||||
|
||||
if (va < kernbase)
|
||||
goto lose;
|
||||
|
||||
/* Handle the wired 4MB TTEs */
|
||||
if (va > cpup->ktextbase && va < (cpup->ktextbase + cpup->ktextsz)) {
|
||||
u_long vaddr;
|
||||
if (cpup->memsegoffset > sizeof(cpu_kcore_hdr_t) &&
|
||||
cpup->newmagic == SPARC64_KCORE_NEWMAGIC) {
|
||||
/*
|
||||
* new format: we have a list of 4 MB mappings
|
||||
*/
|
||||
ktlb = (struct cpu_kcore_4mbseg *)
|
||||
((uintptr_t)kd->cpu_data + cpup->off4mbsegs);
|
||||
for (i = 0; i < cpup->num4mbsegs; i++) {
|
||||
uint64_t start = ktlb[i].va;
|
||||
if (va < start || va >= start+PAGE_SIZE_4M)
|
||||
continue;
|
||||
*pa = ktlb[i].pa + va - start;
|
||||
return (int)(start+PAGE_SIZE_4M - va);
|
||||
}
|
||||
|
||||
vaddr = va - cpup->ktextbase;
|
||||
*pa = cpup->ktextp + vaddr;
|
||||
return (cpup->ktextsz - vaddr);
|
||||
} else {
|
||||
/*
|
||||
* old format: just a textbase/size and database/size
|
||||
*/
|
||||
if (va > cpup->ktextbase && va <
|
||||
(cpup->ktextbase + cpup->ktextsz)) {
|
||||
u_long vaddr;
|
||||
|
||||
vaddr = va - cpup->ktextbase;
|
||||
*pa = cpup->ktextp + vaddr;
|
||||
return (int)(cpup->ktextsz - vaddr);
|
||||
}
|
||||
if (va > cpup->kdatabase && va <
|
||||
(cpup->kdatabase + cpup->kdatasz)) {
|
||||
u_long vaddr;
|
||||
|
||||
vaddr = va - cpup->kdatabase;
|
||||
*pa = cpup->kdatap + vaddr;
|
||||
return (int)(cpup->kdatasz - vaddr);
|
||||
}
|
||||
}
|
||||
|
||||
if (va > cpup->kdatabase && va < (cpup->kdatabase + cpup->kdatasz)) {
|
||||
u_long vaddr;
|
||||
|
||||
vaddr = va - cpup->kdatabase;
|
||||
*pa = cpup->kdatap + vaddr;
|
||||
return (cpup->kdatasz - vaddr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Parse kernel page table.
|
||||
*/
|
||||
|
@ -188,10 +210,10 @@ _kvm_kvatop(kd, va, pa)
|
|||
* Parse and trnslate our TTE.
|
||||
*/
|
||||
|
||||
return (kd->nbpg - va);
|
||||
return (int)(kd->nbpg - va);
|
||||
|
||||
lose:
|
||||
*pa = -1;
|
||||
*pa = (u_long)-1;
|
||||
_kvm_err(kd, 0, "invalid address (%lx)", va);
|
||||
return (0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue