Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1346655rwd; Thu, 18 May 2023 10:49:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CJa7ILTTUQNg1YTPAjmMO/xhD/y51spXFTNKoQ8zh/HWnUAR1wgWiPNCT5r2oKEE6/rqN X-Received: by 2002:a17:902:6509:b0:1ae:52e9:ddb8 with SMTP id b9-20020a170902650900b001ae52e9ddb8mr2480226plk.26.1684432184144; Thu, 18 May 2023 10:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684432184; cv=none; d=google.com; s=arc-20160816; b=SInP7lI0kauz1aMpkF0FJZn/4J824OZeZw1Jth9L0TnnhMWDkH2umDZMBx1OTzwhDA nioxsA4C67UDXYPQa1uifZtr8OaLy3r5thfG5LGVl0ptdSalQ3n7OBehyvGjdjqxrHU2 LTmxTsolbvR2fg/DyKhCOKdAJ/6nHUwMgdoC4i/Zkt1SHoRZHG2OgtVnMoT/p+njpuf+ Sk1+RQPWFJSbIhn8yEpQKGOed6Lir5q8pnZFXbt8x8CRF70FlQMxklGW4BlcVFtVnSOu IHOMRIy/dGoN5eWZZa3MziQu+eXA+BbevHZ12lPtUBB/BYkHlpehZVZ6/b4TvBcNQo2g rKaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3KNIEHbT6ULtrRp710z/V7h41NICMsq9ZMt8Y3JG+/4=; b=rm3vMDxx1RwTpLX1sk29ocXVIGH2npXDjWW91fLqDYXUaozOsRGh2Hn5uumU9vNl3p bfhD4JpkFEKM+o8Lzft1yYQc7xXjTLCvQRC7S4t6qvmmCBHiKE0xiX+BY1qwsELKi9Fd rVFxNFxo+7wMX21SlEv+KNuJfc2R7mPwPZC/oG+uhAS3nlDXV3R2BZhFxMj+rXveFDEh EQ6LavtS/U/Mi5xIOcaqZ2oeVbHF9X//jxhffswO+4N24q7JYUzxM4916oUTVJe5c6fe 0TpXTlQ18b+2OUSTcOxB/eFKaW4W/XCgh1U2aQRBgZcGC7qggKCuOfagJl4Oyj7ro7q6 7A0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vN8+uS5o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020a170902ba8c00b001ab18790b0fsi1803092pls.95.2023.05.18.10.49.32; Thu, 18 May 2023 10:49:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vN8+uS5o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230090AbjERRqM (ORCPT + 99 others); Thu, 18 May 2023 13:46:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbjERRqI (ORCPT ); Thu, 18 May 2023 13:46:08 -0400 Received: from out-9.mta0.migadu.com (out-9.mta0.migadu.com [IPv6:2001:41d0:1004:224b::9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F10D10C1 for ; Thu, 18 May 2023 10:46:03 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684431961; 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=3KNIEHbT6ULtrRp710z/V7h41NICMsq9ZMt8Y3JG+/4=; b=vN8+uS5oQ0ItDKQTiAd8lOtzkr3RMAp/USuwUXWRf3dQW49PFPco10my3Wgh2jJfyomlsU t9VUSBtUq5LEsSTCJUK9mYFEP9bAZz3BSj71mIl3u0Zw2mKb9DHK3f0DQikHjs+fti3Udi AQH3LqHx+d8foxLgPPIkJjooOu+1dgM= From: Oliver Upton To: Gavin Shan , Marc Zyngier , Catalin Marinas , Shaoqin Huang , Ricardo Koller , Will Deacon , Arnd Bergmann Cc: Oliver Upton , Arnd Bergmann , kvmarm@lists.linux.dev, Cornelia Huck , linux-kernel@vger.kernel.org, Zenghui Yu , Suzuki K Poulose , James Morse , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] arm64: kvm: avoid overflow in integer division Date: Thu, 18 May 2023 17:45:47 +0000 Message-ID: <168443190240.3857986.13123115778800174028.b4-ty@linux.dev> In-Reply-To: <20230517202352.793673-1-arnd@kernel.org> References: <20230517202352.793673-1-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 17 May 2023 22:23:39 +0200, Arnd Bergmann wrote: > From: Arnd Bergmann > > The newly added kvm_mmu_split_nr_page_tables() function uses DIV_ROUND_DOWN_ULL() > to divide 64-bit addresses, but this requires a 32-bit divisior, and PUD_SIZE > may exceed that when 64KB pages are used: > > arch/arm64/kvm/mmu.c: In function 'kvm_mmu_split_nr_page_tables': > include/linux/math.h:42:64: error: conversion from 'long unsigned int' to 'u32' {aka 'unsigned int'} changes value from '68719476736' to '0' [-Werror=overflow] > 42 | DIV_ROUND_DOWN_ULL((unsigned long long)(ll) + (d) - 1, (d)) > | ^~~ > include/linux/math.h:39:47: note: in definition of macro 'DIV_ROUND_DOWN_ULL' > 39 | #define DIV_ROUND_DOWN_ULL(ll, d) div_u64(ll, d) > | ^ > arch/arm64/kvm/mmu.c:95:22: note: in expansion of macro 'DIV_ROUND_UP_ULL' > 95 | n += DIV_ROUND_UP_ULL(range, PUD_SIZE); > | ^~~~~~~~~~~~~~~~ > > [...] Applied to kvmarm/next, thanks! [1/1] arm64: kvm: avoid overflow in integer division https://git.kernel.org/kvmarm/kvmarm/c/14c3555f055d -- Best, Oliver