# HG changeset patch # User Francisco J Ballesteros # Date 1331290091 0 # Node ID 44eb037cdac3d186e9aa604a2ba3b2f6638c58bd # Parent 32e6e288e3830a3a729ca8babd615fab0c16c5e1 mmu: report a bug R=nixiedev, nemo, charles.forsyth CC=nix-dev http://codereview.appspot.com/5757062 diff -r 32e6e288e383 -r 44eb037cdac3 sys/src/nix/k10/mmu.c --- a/sys/src/nix/k10/mmu.c Wed Mar 07 15:39:06 2012 +0100 +++ b/sys/src/nix/k10/mmu.c Fri Mar 09 10:48:11 2012 +0000 @@ -343,6 +343,25 @@ } } +static uint +pteflags(uint attr) +{ + uint flags; + + flags = 0; + if(attr & ~(PTEVALID|PTEWRITE|PTERONLY|PTEUSER|PTEUNCACHED)) + panic("mmuput: wrong attr bits: %#ux\n", attr); + if(attr&PTEVALID) + flags |= PteP; + if(attr&PTEWRITE) + flags |= PteRW; + if(attr&PTEUSER) + flags |= PteU; + if(attr&PTEUNCACHED) + flags |= PtePCD; + return flags; +} + /* * pg->pgszi indicates the page size in m->pgsz[] used for the mapping. * For the user, it can be either 2*MiB or 1*GiB pages. @@ -373,9 +392,7 @@ pgsz = m->pgsz[pg->pgszi]; if(pa & (pgsz-1)) panic("mmuput: pa offset non zero: %#ullx\n", pa); - if(attr & ~(PTEVALID|PTEWRITE|PTERONLY|PTEUSER|PTEUNCACHED)) - panic("mmuput: wrong attr bits: %#ux\n", attr); - pa |= attr; + pa |= pteflags(attr); pl = splhi(); if(DBGFLG)