πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fa.netbsd.tech.kern
Article #132

Re: [Milkymist-devel] [Milkymist port] virtual memory management

#132
From: Eduardo Horvath
Date: Mon, 03 Jun 2013 20:34
61 lines
4288 bytes
On Mon, 3 Jun 2013, Yann Sionneau wrote:

> Thank you all for your answers :)

No prob.
 
> Le 30/05/13 22:45, Eduardo Horvath a οΏ½crit :
> > On Wed, 29 May 2013, Yann Sionneau wrote:
> > 
> > > Hello NetBSD fellows,
> > > 
> > > As I mentioned in my previous e-mail, I may need from time to time a
> > > little
> > > bit of help since this is my first "full featured OS" port.
> > > 
> > > I am wondering how I can manage virtual memory (especially how to avoid
> > > tlb
> > > miss, or deal with them) in exception handlers.
> > There are essentially three ways to do this.  Which one you chose depends
> > on the hardware.
> > 
> > 1) Turn off the MMU on exception
> That sounds like the better thing to do from my point of view, I don't see any
> big downside apart from having to duplicate a few pointers in a few structures
> to have both virtual and physical addresses of some data structures like PCB,
> trapframes, page tables.
> 
> Is there any big downside I don't see there?

Donno.  Depends on your hardware.  I'm aware of some hardware designs 
where caches where you need to have the MMU enabled to use the caches.  If 
your hardware doesn't have any weird quirks like that then turning off the 
MMU may well be a good solution.

> If not, I would pick this solution to implement the virtual memory subsystem.
> > 2) Keep parts of the address space untranslated
> I could modify the MMU to do that, but I would prefer keeping the entire 4 GB
> address space for user space :)

Yeah.  Well.  Thing is, some architectures, like MIPS, implicitly assume 
this sort of thing, so thier ports implement things like 
copyin()/copyout() using that feature.

> > 3) Lock important pages into the TLB
> That's pretty easy to do for locking exception vectors in ITLB since vectors
> are contiguous in memory.
> Locating every data I need to access to from exception vectors in the same
> couple of pages is not so easy I guess.
> Moreover, locking a few TLB entries would mean that those virtual addresses (
> a few pages ) would not be mappable for user space use since I could not eject
> those entries from the TLB.
> I would prefer not locking any TLB entry to have it all available for mapping
> things for user space.

So your MMU doesn't support multiple address space IDs?  That sux.  That 
means you need to blow away the entire MMU each time you switch processes.

If you do have ASIDs, I like to reserve one for the kernel.  That way you 
don't need to share the address space with userland.  

Eduardo
Technical Details
Message-ID: <fa.xFi646Yivr/iujxTfhG3+Bpb1K4@ifi.uio.no>
Path: arc1-ca.pugleaf.net!hv6ni33151wib.1!nntp.google.com!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
References: <fa.P+LZ+1jPGPfiK1II+UjtSSikPxk@ifi.uio.no> <fa.a/Nr8kFgmeefrHl8CNZayzk+Fkk@ifi.uio.no> <fa.QqmOHe+XhnQId6rhouHmwoFi5Es@ifi.uio.no>

Show Full Headers
Complete Article Headers
X-Google-Thread: b7e13b6095,8afd96964b6c90d9
X-Google-Attributes: gidb7e13b6095,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII
X-Received: by 10.180.189.74 with SMTP id gg10mr5694049wic.4.1370291690196;
        Mon, 03 Jun 2013 13:34:50 -0700 (PDT)
Path: arc1-ca.pugleaf.net!hv6ni33151wib.1!nntp.google.com!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: Eduardo Horvath <eeh@NetBSD.org>
Newsgroups: fa.netbsd.tech.kern
Subject: Re: [Milkymist-devel] [Milkymist port] virtual memory management
Date: Mon, 03 Jun 2013 20:34:49 UTC
Organization: Internet mailing list
Lines: 69
Sender: tech-kern-owner@NetBSD.org
Message-ID: <fa.xFi646Yivr/iujxTfhG3+Bpb1K4@ifi.uio.no>
References: <fa.P+LZ+1jPGPfiK1II+UjtSSikPxk@ifi.uio.no> <fa.a/Nr8kFgmeefrHl8CNZayzk+Fkk@ifi.uio.no> <fa.QqmOHe+XhnQId6rhouHmwoFi5Es@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1370291689 17856 129.240.7.9 (3 Jun 2013 20:34:49 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Mon, 3 Jun 2013 20:34:49 +0000 (UTC)
Cc: Milkymist developers' list <devel@lists.milkymist.org>, 
    Radoslaw Kujawa <radoslaw.kujawa@c0ff33.net>, tech-kern@netbsd.org
To: Yann Sionneau <yann.sionneau@gmail.com>
Delivered-To: tech-kern@netbsd.org
In-Reply-To: <51ACF862.9060607@gmail.com>
List-Id: tech-kern.NetBSD.org
Original-Date: Mon, 3 Jun 2013 20:34:37 +0000 (UTC)
Original-Message-Id: <Pine.NEB.4.64.1306032022480.9828@mail.netbsd.org>
Original-References: <51A64013.8030603@gmail.com> <Pine.NEB.4.64.1305302015370.9828@mail.netbsd.org>
 <51ACF862.9060607@gmail.com>
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit