From owner-freebsd-hackers@freebsd.org Mon Dec 24 07:44:47 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C23AC1338687 for ; Mon, 24 Dec 2018 07:44:46 +0000 (UTC) (envelope-from scwsy00@gmail.com) Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C830074600 for ; Mon, 24 Dec 2018 07:44:45 +0000 (UTC) (envelope-from scwsy00@gmail.com) Received: by mail-oi1-x22c.google.com with SMTP id m6so9431644oig.11 for ; Sun, 23 Dec 2018 23:44:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=fvQMOL2UEo6y9LaLeax/w3dUIr+fbRfAM8n/clukm5Y=; b=UE2gyA2AweOeZu/f3f5ts8P3rkyeIlOnyR0HDUB1RCOxoLACLLIuPEsy7lUFxnuwLo LYtZ3d6MTJ/GIaSDku1fmOL7ZvpNJB9tYoCMsBQq097Eh9t+t3yc+mXP3Sip5aBnjPgY HVs5z5bySTO8pHerocHHbQFw0WCoPVc7hD1p72cXJz05YC6BVkxF1cVWFtSvn7arqiLn X7t4BMiEKiC4mTgUH3alEMBGIK8/Cx5+FbAK6t7f4x4jO4iBvyyP3GD6tXFXeseDaMuO AzS9gK4smDg8uNFX8KxMWf8eJ4p2iFHeuALGTibPK1fUkzAc9ta98SM1g0H4M+SHFyjj Ns6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=fvQMOL2UEo6y9LaLeax/w3dUIr+fbRfAM8n/clukm5Y=; b=RlybCW06XPUfm6YWgd/5t64Bz0OFKXKcx2ZNvJxXtnL4wuyPId5UBfpIS13/+qXyyI 9zpWWC80MpUcWP2Ii5ZZ6Yn15Tdt3wMylJulaCKvBd6w2nTrHbFplxbnRiS1X+alBLFU XCJQzyhAlnIoNzDi9IZ6oftUi7VAyWChyhYhCZrbGgR0dGRzRbC+W2ecrBrnktEtRKVg 63ewd7HjvRVHLRYUBqBBj6ep2kFkfX0S/GN8yCnHuclvE1q3v+Ngn9rOsED/SieeAzqi wOonpadUjSGwZP2MJH3j8R3g/8PXiIAlGbUKPJWoClNsgAIL2jCbnLI9qsWQrAZKOfav SiTg== X-Gm-Message-State: AA+aEWavxD2f6aADqabMc7PxiEIxzZj8rASVaX7KXi1jMqtgke9qt7MS zMkJEAHXSfoZZr4F9HyrWrEyiq6XJLfMlx/BwgxQug== X-Google-Smtp-Source: AFSGD/X+RV4zVEcOpPrBUrfKee+i3KHOLRkQB5qwvW6OsLxNUpdAfKtG8Dj1tgDrYGjZ2h7GIfysY9ODC1kTpjkeaUQ= X-Received: by 2002:aca:b542:: with SMTP id e63mr7088206oif.125.1545637484900; Sun, 23 Dec 2018 23:44:44 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?5a6L6L6w5Lyf?= Date: Mon, 24 Dec 2018 15:44:33 +0800 Message-ID: Subject: Fwd: How to access physical memory To: freebsd-hackers@freebsd.org X-Rspamd-Queue-Id: C830074600 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=UE2gyA2A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of scwsy00@gmail.com designates 2607:f8b0:4864:20::22c as permitted sender) smtp.mailfrom=scwsy00@gmail.com X-Spamd-Result: default: False [-6.08 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[c.2.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; IP_SCORE(-2.59)[ip: (-9.53), ipnet: 2607:f8b0::/32(-1.85), asn: 15169(-1.47), country: US(-0.08)]; NEURAL_HAM_SHORT(-0.48)[-0.482,0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] X-Mailman-Approved-At: Mon, 24 Dec 2018 11:24:21 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Dec 2018 07:44:47 -0000 Forwarded Conversation Subject: How to access physical memory ------------------------ From: =E5=AE=8B=E8=BE=B0=E4=BC=9F Date: 2018=E5=B9=B412=E6=9C=8824=E6=97=A5=E5=91=A8=E4=B8=80 =E4=B8=8A=E5=8D= =8811:23 To: Hi I'm the new here . And I have some questions with pmap. [image: 1545542790461.png] See `*pml4` is the physical address of a page with some flag. And then updated the address to the Direct Map Space. Then We calculate the offset of the real pdp we need . How could it access to `*pdp`? it is a virtual addr in Direct Map Space. Why don't change the physical space directly since we have the physical page already. ---------- From: =E5=AE=8B=E8=BE=B0=E4=BC=9F Date: 2018=E5=B9=B412=E6=9C=8824=E6=97=A5=E5=91=A8=E4=B8=80 =E4=B8=8A=E5=8D= =8811:28 To: ``` pdp =3D (pdp_entry_t *)PHYS_TO_DMAP(*pml4 & PG_FRAME); /* Now find the pdp page */ pdp =3D &pdp[pdpindex & ((1ul << NPDPEPGSHIFT) - 1)]; *pdp =3D VM_PAGE_TO_PHYS(m) | PG_U | PG_RW | PG_V | PG_A | PG_M; ``` There is the code in _pmap_allocpte. =E5=AE=8B=E8=BE=B0=E4=BC=9F =E4=BA=8E2018=E5=B9=B412=E6= =9C=8824=E6=97=A5=E5=91=A8=E4=B8=80 =E4=B8=8A=E5=8D=8811:23=E5=86=99=E9=81= =93=EF=BC=9A