From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 7183BAC1D57 for ; Wed, 31 Jan 2024 15:21:39 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=I+Ytsug66s6wciaXZhENIkjksmNVPteW0coYRq+LMw4=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706714498; v=1; b=BITNgv4VsHs6ue6agxnQlisHnS7dubYHQO/aQKOkSYLLk/lk7GUiK2mVA4wWDFqSI5Yw2aDo iSY8K5S6+yKw0kgjU49J110j3uPdgVkcq4Yimv2zVgp4loeXC1ikD3DS+EFFGL6jyP01kLLFAhq NBGSJj6knO0kQ7hEuN+tdwSY= X-Received: by 127.0.0.2 with SMTP id 9emnYY7687511xZrfCbD723c; Wed, 31 Jan 2024 07:21:38 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.16535.1706714497370149619 for ; Wed, 31 Jan 2024 07:21:37 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-CW0w-XRvNa--zegj2tMrig-1; Wed, 31 Jan 2024 10:21:32 -0500 X-MC-Unique: CW0w-XRvNa--zegj2tMrig-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D6E4A3812005; Wed, 31 Jan 2024 15:21:28 +0000 (UTC) X-Received: from [10.39.192.35] (unknown [10.39.192.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F1C5492BE2; Wed, 31 Jan 2024 15:21:27 +0000 (UTC) Message-ID: <74ccb355-7d71-150b-7258-305149699c0d@redhat.com> Date: Wed, 31 Jan 2024 16:21:26 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH 2/3] OvmfPkg/PlatformPei: rewrite page table calculation From: "Laszlo Ersek" To: devel@edk2.groups.io, kraxel@redhat.com Cc: Oliver Steffen , Jiewen Yao , Ard Biesheuvel References: <20240131120000.358090-1-kraxel@redhat.com> <20240131120000.358090-3-kraxel@redhat.com> In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: l2X1K6yZjXNhnQBpsV0K1Skrx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=BITNgv4V; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 1/31/24 16:13, Laszlo Ersek wrote: > (3) I'm sorry, these +1 additions *really* annoy me, not to mention the > fact that we *include* those increments in the further shifting. Can we d= o: >=20 > UINT64 End; > UINT64 Level2Pages, Level3Pages, Level4Pages, Level5Pages; >=20 > End =3D 1LLU << PlatformInfoHob->PhysMemAddressWidth; > Level2Pages =3D Page1GSupport ? 0LLU : End >> 30; > Level3Pages =3D MAX (End >> 39, 1LLU); > Level4Pages =3D MAX (End >> 48, 1LLU); > Level5Pages =3D 1; >=20 > This doesn't seem any more complicated, and it's exact, I believe. Sorry, I forgot about an edk2 portability rule here. We shouldn't do 64-bit wide "native" shifts in code that may be compiled for 32-bit. Instead, we're supposed to use LShiftU64() and RShiftU64(), from BaseLib. Thus: UINT64 End; UINT64 Level2Pages, Level3Pages, Level4Pages, Level5Pages; End =3D LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth); Level2Pages =3D Page1GSupport ? 0LLU : RShiftU64 (End, 30); Level3Pages =3D MAX (RShiftU64 (End, 39), 1LLU); Level4Pages =3D MAX (RShiftU64 (End, 48), 1LLU); Level5Pages =3D 1; Laszlo -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114906): https://edk2.groups.io/g/devel/message/114906 Mute This Topic: https://groups.io/mt/104073300/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-