From nobody Tue Dec 2 02:31:06 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA13C31ED8D for ; Wed, 19 Nov 2025 22:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592161; cv=none; b=SEeFCy93f0UE+jb0YzLuJVubHq+Zn1gBXlU5eVMOggjSbkM2VenSYDSIgh8lpnCEpZp5V1I/RK6V0hRZq+0V8i86yXGExj0n6xWj9mCETzGSFOLzdoCOyjbBE4Jq8YBcZGNI1BT+lIhn6YCUM/FkvMK5V2BuFGoU7/jwE7Q9nBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592161; c=relaxed/simple; bh=e898BokG1qPdR+DZ2TG2wIV8DuBv4w9wPX1jSyQIdhY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TF4rxBX4bWrENBkaTdFvYuLnD9YgUTPZdEPw3JMfTDJyX2iurBywzCrpt6bCaOyiILPJaQCDl0hWy2IBWLson4EgqA7q4JMkjSyhBK2B4RnjyWQ2VHt3YL6mUduCV2pV/Y6IIYi435pIo9FfsQyFPX3LCPShQPQQbHWcer1da+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=HJRrLRdf; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="HJRrLRdf" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsn-006ksi-Gc; Wed, 19 Nov 2025 23:42:37 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=jLaB+RBxUfCJpH63+OYZi6YutZXQ6cqU42NpGBevRMo=; b=HJRrLRdfQ43uA2ITBg4J1EThEj Zi/XVxlVU2bzgH/kIrdCwO7V9uRWr+40fyuedQBGpQsc8+7TslekNVEu7JLnWwunAlCqjRbVd8zBK WOcl1FO24kCWaHXVIC9JXcmoP9D/qBeTU6mo4FFTqkuRbKIJY+pUhff9OIUnJe7sku7UVnoSzZaRj Ky0YIhFcU2daJF+l3ACs6kdXkkp0dxcsTB1DPqEAWx9g4Jelfi/UxvFxVi+xBgokK/l6Vx0Mus8hf caDh++RHWQLmjO47TD96JPeEotCogbYZ0uRhEHWQgPigzKJP/waXkCsFzWByLGpVCHj6adBpQBUXJ vJ9BlB4g==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsn-00006z-0A; Wed, 19 Nov 2025 23:42:37 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsg-00Fos6-0d; Wed, 19 Nov 2025 23:42:30 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Borislav Petkov , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , x86@kernel.org, David Laight Subject: [PATCH 23/44] arch/x86/mm: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:19 +0000 Message-Id: <20251119224140.8616-24-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- arch/x86/mm/pat/set_memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 970981893c9b..148c1880a823 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -1459,7 +1459,7 @@ static void unmap_pmd_range(pud_t *pud, unsigned long= start, unsigned long end) */ if (start & (PMD_SIZE - 1)) { unsigned long next_page =3D (start + PMD_SIZE) & PMD_MASK; - unsigned long pre_end =3D min_t(unsigned long, end, next_page); + unsigned long pre_end =3D min(end, next_page); =20 __unmap_pmd_range(pud, pmd, start, pre_end); =20 @@ -1503,7 +1503,7 @@ static void unmap_pud_range(p4d_t *p4d, unsigned long= start, unsigned long end) */ if (start & (PUD_SIZE - 1)) { unsigned long next_page =3D (start + PUD_SIZE) & PUD_MASK; - unsigned long pre_end =3D min_t(unsigned long, end, next_page); + unsigned long pre_end =3D min(end, next_page); =20 unmap_pmd_range(pud, start, pre_end); =20 @@ -1591,9 +1591,9 @@ static long populate_pmd(struct cpa_data *cpa, unsigned long pre_end =3D start + (num_pages << PAGE_SHIFT); unsigned long next_page =3D (start + PMD_SIZE) & PMD_MASK; =20 - pre_end =3D min_t(unsigned long, pre_end, next_page); + pre_end =3D min(pre_end, next_page); cur_pages =3D (pre_end - start) >> PAGE_SHIFT; - cur_pages =3D min_t(unsigned int, num_pages, cur_pages); + cur_pages =3D min(num_pages, cur_pages); =20 /* * Need a PTE page? @@ -1668,9 +1668,9 @@ static int populate_pud(struct cpa_data *cpa, unsigne= d long start, p4d_t *p4d, unsigned long pre_end; unsigned long next_page =3D (start + PUD_SIZE) & PUD_MASK; =20 - pre_end =3D min_t(unsigned long, end, next_page); + pre_end =3D min(end, next_page); cur_pages =3D (pre_end - start) >> PAGE_SHIFT; - cur_pages =3D min_t(int, (int)cpa->numpages, cur_pages); + cur_pages =3D min(cpa->numpages, cur_pages); =20 pud =3D pud_offset(p4d, start); =20 --=20 2.39.5