Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3094109rwb; Mon, 15 Aug 2022 17:59:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR5UDXHQQz2vFp7TXTLeFYRWG5VKBLRmoLNCCAJKgTTa+01OiQMXuNXC3fq7QlD0uUcdPxxU X-Received: by 2002:a05:6402:510a:b0:43d:ab25:7d68 with SMTP id m10-20020a056402510a00b0043dab257d68mr16549036edd.102.1660611563902; Mon, 15 Aug 2022 17:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611563; cv=none; d=google.com; s=arc-20160816; b=uz8H+wk3lX54wwDXbZ0V3zow47rRAiVGVybXtMu/1ETHD6Okq7MTjWDcKiVnw4bwtU r/+ScmRHCGLf8RfTz0GRKf2iB/OaZ8X9zOg3AhNVfSxDPrsns81WsDMxsUpPKOAg6Ta4 hDc60L2gfAubzLZNPQjut8FF6fLp6ImWPRiwkzJMOahpoqNNKCeuFi2bybG3T7hWKUay /Z3uV2kdN0tbfBR8DI5ZHyoUW8r7yeveexUNiStvJ4fd10MQC8E79+UU8Ey250vQNtJi MK+LsC3Ddjz6AMMhI5ivsin18ZylbNt87yvLgb9svMKgOocBSE5ShRrYSsCBLgmkan33 M4SQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tI1x5XPajkXaXgWQfhPsJA1WAm6cuurGFGGfQizHX48=; b=Xqo+6Cv4KCdmGpNpHFnsGq6BRBEqH+hkepN069c+eTlljKQjNgaJ5zmCMpZrUHYJVS FruXnVDmuLGEYvIAByTsF/G3ihw0u6sH598zvzaxU+QiZVdqaWkSSV8OrT+dvMCFZDfK ILrmMj5pjMgr09vvN4HaRyk34X/K6efUb2l/uwbN3qZHpGL5jsAgZ32NM6E2hJSETx5W 3pb+kfShLfobE+hLQovo4lJqSJMadKE+E3FhoMfWd4zN9aWttEANikgltpE9YxeaAHj7 fPOYPeoVCBrTCo8jNlMqDGv9CZRNhCu6+zbR71YaZLmJUq9pYIkpybGZHUXHca8i5qI3 +gOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hCg77N3u; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg5-20020a1709072cc500b007386a8b4cfesi2108309ejc.827.2022.08.15.17.58.53; Mon, 15 Aug 2022 17:59:23 -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=@linuxfoundation.org header.s=korg header.b=hCg77N3u; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245426AbiHPAtA (ORCPT + 99 others); Mon, 15 Aug 2022 20:49:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346765AbiHPApr (ORCPT ); Mon, 15 Aug 2022 20:45:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAA5DAE9CC; Mon, 15 Aug 2022 13:41:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 66BC160F60; Mon, 15 Aug 2022 20:41:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D947C433C1; Mon, 15 Aug 2022 20:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596062; bh=f1yBoZdlxrrj+e56t5SpYyY3+I6Cwa8ohg4maem5XqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hCg77N3uWRv3i5OGBIU+BlsJtnt8CkfmnVPoY9zWAnx8YkPnu6dexyO9UAD9PRY1C Wf0oKfKJQtbOg88WtucKDrh8RwXXgkdBI49mAGkpRX1lZRAhYpnbWCTGysDBTyDsFp 5U6cQHWhBuAfLhOmRPTY6mkbW1LZdJ5pJEGuIp0Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Serge Semin , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.19 0961/1157] MIPS: Fixed __debug_virt_addr_valid() Date: Mon, 15 Aug 2022 20:05:17 +0200 Message-Id: <20220815180518.081863333@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Florian Fainelli [ Upstream commit 8a2b456665d1e797123669581524cbb095fb003b ] It is permissible for kernel code to call virt_to_phys() against virtual addresses that are in KSEG0 or KSEG1 and we need to be dealing with both types. Rewrite the test condition to ensure that the kernel virtual addresses are above PAGE_OFFSET which they must be, and below KSEG2 where the non-linear mapping starts. For EVA, there is not much that we can do given the linear address range that is offered, so just return any virtual address as being valid. Finally, when HIGHMEM is not enabled, all virtual addresses are assumed to be valid as well. Fixes: dfad83cb7193 ("MIPS: Add support for CONFIG_DEBUG_VIRTUAL") Signed-off-by: Florian Fainelli Reviewed-by: Serge Semin Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/mm/physaddr.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/mips/mm/physaddr.c b/arch/mips/mm/physaddr.c index a1ced5e44951..f9b8c85e9843 100644 --- a/arch/mips/mm/physaddr.c +++ b/arch/mips/mm/physaddr.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -12,15 +13,6 @@ static inline bool __debug_virt_addr_valid(unsigned long x) { - /* high_memory does not get immediately defined, and there - * are early callers of __pa() against PAGE_OFFSET - */ - if (!high_memory && x >= PAGE_OFFSET) - return true; - - if (high_memory && x >= PAGE_OFFSET && x < (unsigned long)high_memory) - return true; - /* * MAX_DMA_ADDRESS is a virtual address that may not correspond to an * actual physical address. Enough code relies on @@ -30,7 +22,9 @@ static inline bool __debug_virt_addr_valid(unsigned long x) if (x == MAX_DMA_ADDRESS) return true; - return false; + return x >= PAGE_OFFSET && (KSEGX(x) < KSEG2 || + IS_ENABLED(CONFIG_EVA) || + !IS_ENABLED(CONFIG_HIGHMEM)); } phys_addr_t __virt_to_phys(volatile const void *x) -- 2.35.1