From owner-freebsd-questions@freebsd.org Mon Dec 24 03:28:54 2018 Return-Path: Delivered-To: freebsd-questions@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 E87A71354BC9 for ; Mon, 24 Dec 2018 03:28:53 +0000 (UTC) (envelope-from scwsy00@gmail.com) Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) (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 F25986CCA2 for ; Mon, 24 Dec 2018 03:28:52 +0000 (UTC) (envelope-from scwsy00@gmail.com) Received: by mail-oi1-x244.google.com with SMTP id u18so9150038oie.10 for ; Sun, 23 Dec 2018 19:28:52 -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=b+TmlMlKlN6yJ/jBFUx7AtmqZhMH0EnKW/BQLvAzBUw=; b=OwP7kgED6HX+IY6+jMfi6BHOTKkk9hgRIvjwrsyMNlIevDitr+jvg4pCbCtt+XxNAG nvfJjyOfoLlkbD4LFUiI/Yuw2Jftc7+9QdLjQXvTRagXqW1FOe0CIcVhT/LkrmLXLdAI MTQqH7ejhlJDGKsPTOARO5Rv1VUcFUesZbqI4+EZEA0UAZTd80Adk0gaoAqa2QayJlZv ill8up2dyoYU5AlGKXq/6vOQHd/AVsXfnFgQLHRZ/7s4DMynyOCe+hXIo48ou/CYP9KF xj3TrOGiccfZAeM4LOdUNc3u5WrNh3vRuwCFUS/3wthBjjqOrS+AnMdsqiP+emIC7kOP eHXw== 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=b+TmlMlKlN6yJ/jBFUx7AtmqZhMH0EnKW/BQLvAzBUw=; b=Kf3cgauCBZQ/c/w1434IRwvHvmzzomjoilPoOqLkplVt3OYN4Urme1dMFTMp/XKJpT TyHD9i/9G/0f8Ux8fBwn7TzF3pofB6kUzg7djFXYsrLgWy2N0G0j/RRPtdJso0+meoI2 zeLUSVrxVfZ/vfgS9FszrYyzH0fldqNt5fU6OL/X8odi+rzNaSam9APIFEsNknG+AoaS oJ+7wP5Rm2ZrG9ZZQsZVkELH++l+knHAqKm8xUPAa/QO0zRYee3JJDq47S4bp1meAVHi TrFTg/5dFVitr1eIZPXpyIf5rTLZ9/q5/L+xsrwFKd/6huPRgkJnnrJ0zoB8UObzdu2j aXbg== X-Gm-Message-State: AJcUukf36hzzhLQx0HVM82AtGEWptwVdJESRSbO8p0p5yWkrBzB9ntLk SzEOYKY9b0RxCeuEDoIFMTW6LCt+sM/dzpRSOlijYDIv X-Google-Smtp-Source: AFSGD/XMEd3AeJypQYpe9aGAo8my2wOjHyk7FO9amBTGF+vsrq8XDl+GpBHGQnBw5uP3p/LvEJ7wTdnSzgJMIZA3ylY= X-Received: by 2002:aca:d64d:: with SMTP id n74mr6852440oig.199.1545622132002; Sun, 23 Dec 2018 19:28:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?5a6L6L6w5Lyf?= Date: Mon, 24 Dec 2018 11:28:37 +0800 Message-ID: Subject: Re: How to access physical memory To: freebsd-questions@freebsd.org X-Rspamd-Queue-Id: F25986CCA2 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=OwP7kgED; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of scwsy00@gmail.com designates 2607:f8b0:4864:20::244 as permitted sender) smtp.mailfrom=scwsy00@gmail.com X-Spamd-Result: default: False [-3.09 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.990,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-questions@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-0.99)[-0.994,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)[4.4.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(-0.07)[ip: (3.04), ipnet: 2607:f8b0::/32(-1.85), asn: 15169(-1.47), country: US(-0.08)]; NEURAL_HAM_SHORT(-0.03)[-0.030,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] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Dec 2018 03:28:54 -0000 ``` 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 > 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. >