From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 966DEC27C4F for ; Sun, 23 Jun 2024 14:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=x+bDjx0y+iP8Abxe/MnYhrrwchlPmdfzSW+YmImXYM8=; b=jzCI56HRoPEjbQ8wgrRrW0KBft 2pmtnoUx8aBT3nMQ91bVZH6oxRwXc4WAcEIoqXGys4S2id0X3Am78JUhuOOeih4Vs2DTzQ6t7xS99 Abm6crcI0jIr9y8ZNYjbGczt3QCHHW8DdZnprUzXdQ4V1M06APtHC7ZfNCp0N1XzAQsLL+UlHRbVv 3AVPcWZfiYGbEgVO13akc873IK1KKKwNvmYYpjkjPy2f936qxtL0AQC9782gk+dOto5u5UeuRqld0 m/8LgTTRjavV9PaS/OFlVg8hn4TxhQVtGQm/gzTU9OlM5kN6XgacfafSIh9CEx3mgQRNNfORWSD9O gdP2pl8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLO5T-0000000EB56-2R3K; Sun, 23 Jun 2024 14:20:59 +0000 Received: from out-173.mta1.migadu.com ([2001:41d0:203:375::ad]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLO5N-0000000EB4F-3Gqw for linux-arm-kernel@lists.infradead.org; Sun, 23 Jun 2024 14:20:56 +0000 X-Envelope-To: ardb@kernel.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719152446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x+bDjx0y+iP8Abxe/MnYhrrwchlPmdfzSW+YmImXYM8=; b=EmJ0eceb+4SR/sfCaTjF5gjhjGE87dlsEX4jKGfRq46lSlOErZVX300SafdPleR1el+/SP MRZkfF5Dk+C9KDpsR6/WIs8bvsgNulcn4GDZry2Cf/lYbhALXf4w5sJPanCYAPpbouHE82 5E+8IiJ18XqS0xUo1vsXbq6Rgi44H9c= X-Envelope-To: yuzenghui@huawei.com X-Envelope-To: linux-arm-kernel@lists.infradead.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: catalin.marinas@arm.com X-Envelope-To: will@kernel.org X-Envelope-To: wanghaibin.wang@huawei.com X-Envelope-To: zenghui.yu@linux.dev Message-ID: <19f05d6a-7b96-472a-919d-56292596e8bb@linux.dev> Date: Sun, 23 Jun 2024 22:20:29 +0800 MIME-Version: 1.0 Subject: Re: [PATCH] arm64: Clear the initial ID map correctly before remapping To: Ard Biesheuvel Cc: Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, wanghaibin.wang@huawei.com References: <20240621092809.162-1-yuzenghui@huawei.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zenghui Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240623_072054_280347_514E65FA X-CRM114-Status: GOOD ( 18.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2024/6/21 17:52, Ard Biesheuvel wrote: > On Fri, 21 Jun 2024 at 11:28, Zenghui Yu wrote: > > > > In the attempt to clear and recreate the initial ID map for LPA2, we > > wrongly use 'start - end' as the map size and make the memset() almost a > > nop. > > > > Fix it by passing the correct map size. > > > > Fixes: 9684ec186f8f ("arm64: Enable LPA2 at boot if supported by the system") > > Signed-off-by: Zenghui Yu > > --- > > > > Found by code inspection (don't have the appropriate HW to test it). > > > > Good catch! > > Even though memset() takes an unsigned size_t, the zeroing path in > arm64's memset.S does a signed compare on the provided size, and will > zero at most 63 bytes if the size has the sign bit set. So in the end, > it does not clear anything. Yup! It took me a while to figure out why memset() with a VERY large size doesn't corrupt the memory. ;-) > Note that in this particular case, that > doesn't actually matter - the memory is reused immediately to create > another copy of the ID map, and any unused regions containing garbage > will just be ignored. Agreed. I can fold it into the commit message if Will/Catalin ask for a respin. And it looks like an alternate "fix" would be just removing the memset(). > Nonetheless, > > Reviewed-by: Ard Biesheuvel Thanks! Zenghui