From 3581f2e76655c5d07c998dfd12db731c4c266834 Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 27 Dec 2002 01:45:05 +0000 Subject: [PATCH] Teach libkvm to deal with direct mapped addresses. --- lib/libkvm/kvm_sparc64.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/libkvm/kvm_sparc64.c b/lib/libkvm/kvm_sparc64.c index 081ddf88859f..167d1f4fd6bb 100644 --- a/lib/libkvm/kvm_sparc64.c +++ b/lib/libkvm/kvm_sparc64.c @@ -64,6 +64,7 @@ static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93"; #include #include +#include #include #include @@ -198,17 +199,21 @@ _kvm_kvatop(kvm_t *kd, u_long va, u_long *pa) u_long pg_off, vpn; int rest; - vpn = btop(va); pg_off = va & PAGE_MASK; - tte_off = kd->vmst->vm_tsb_off + - ((vpn & kd->vmst->vm_tsb_mask) << TTE_SHIFT); - - if (!_kvm_read_phys(kd, tte_off, &tte, sizeof(tte))) - goto invalid; - if (!tte_match(&tte, va)) - goto invalid; + if (va >= VM_MIN_DIRECT_ADDRESS) + pa_off = TLB_DIRECT_TO_PHYS(va) & ~PAGE_MASK; + else { + vpn = btop(va); + tte_off = kd->vmst->vm_tsb_off + + ((vpn & kd->vmst->vm_tsb_mask) << TTE_SHIFT); + if (!_kvm_read_phys(kd, tte_off, &tte, sizeof(tte))) + goto invalid; + if (!tte_match(&tte, va)) + goto invalid; + pa_off = TTE_GET_PA(&tte); + } rest = PAGE_SIZE - pg_off; - pa_off = _kvm_find_off(kd->vmst, TTE_GET_PA(&tte), rest); + pa_off = _kvm_find_off(kd->vmst, pa_off, rest); if (pa_off == KVM_OFF_NOTFOUND) goto invalid; *pa = pa_off + pg_off;