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 AF989740038 for ; Thu, 18 Jan 2024 19:27:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=TeIQ9iSH5mLgDLlzF/F/tPqkXqiWWbZFqc9frZ7NQ4Y=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:Message-ID:Date:MIME-Version:User-Agent:Subject:From:To:Cc:Reply-To:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1705606019; v=1; b=XSnKQR0TLjKF32KwARtPbfF97Y5pF3o1Ktn3OCP3Myx0+uFkrkDaAcEjFzkGRGI3rsnSM0v+ sLvJuNWruhUZhhm557bxcJCqtKa3AR1ZAUzhymZ8yE74qIrNDTB8OpHXbqwDJL842fkJMlRJB4l yeMAqRc8BwuRJHpuVNWu5adM= X-Received: by 127.0.0.2 with SMTP id RuntYY7687511xTwo5UiP5lF; Thu, 18 Jan 2024 11:26:59 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.2313.1705606018971039315 for ; Thu, 18 Jan 2024 11:26:59 -0800 X-Received: from [10.137.194.171] (unknown [131.107.160.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 762E120DFD82; Thu, 18 Jan 2024 11:26:58 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 762E120DFD82 Message-ID: <0a589fed-02f1-4598-bbbc-98bad0e8b04f@linux.microsoft.com> Date: Thu, 18 Jan 2024 11:26:58 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] AArch64 with HeapGuard: page allocations wrongly aligned From: "Oliver Smith-Denny" To: devel@edk2.groups.io, rebecca@os.amperecomputing.com Cc: Leif Lindholm , Ard Biesheuvel , Jian J Wang , Liming Gao , Dandan Bi Reply-To: devel@edk2.groups.io,osde@linux.microsoft.com References: <05f6388b-155e-427d-8e34-0ac571e97fb8@os.amperecomputing.com> <24affef7-eb96-4a82-b9d4-b616eb90024d@os.amperecomputing.com> <17AB84FD31479E00.28523@groups.io> In-Reply-To: <17AB84FD31479E00.28523@groups.io> 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 List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: TvBRocYd8ptk4TkfNyd32nAOx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed 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=XSnKQR0T; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.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/18/2024 10:38 AM, Oliver Smith-Denny wrote: > I am suspicious that we are checking for the alignment before we > adjust the memory for the guard. I'm wondering if we actually > should do AdjustMemoryF (recalling function from memory) before > we check the alignment. >=20 Following up on this, this is very suspicious to me. If you change the CoreInternalFreePages alignment check to something like: EFI_PHYSICAL_ADDRESS CheckMemory =3D Memory; UINTN CheckPages =3D NumberOfPages; AdjustMemoryF (&CheckMemory, &CheckPages); if ((CheckMemory & (Alignment - 1)) !=3D 0) { Status =3D EFI_INVALID_PARAMETER; goto Done; } Does this solve your issue? I have to run to a meeting, but I can write this in actual patch form (and give it a quick test) later. Thanks, Oliver -=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 (#114008): https://edk2.groups.io/g/devel/message/114008 Mute This Topic: https://groups.io/mt/103810212/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-