Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp377828imw; Fri, 15 Jul 2022 05:12:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vs3N7BydWmf3/tVIx9+bK00j5KNmd1+WegqcRyRfMrKhsXSoiO2Dj+09vE56Q6uiOkjrTw X-Received: by 2002:a17:907:9715:b0:72b:340b:9059 with SMTP id jg21-20020a170907971500b0072b340b9059mr13255077ejc.384.1657887149279; Fri, 15 Jul 2022 05:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657887149; cv=none; d=google.com; s=arc-20160816; b=UDHcgbYgxoEbTWyTOzdE3JyRiecfaOzQ91Ss9e2qUm7eCJAqv/vKQqwLZ+KJg9wXD2 j93eoBnN+Cm4dfowRVJFseWCw6uarIeWhR+Gtn+JjRthmVXaGTCHanmcqwuaf+lvDBYz +fSIMQjGhJpp++d48HODmSmhyovfcdLuayhNhJAdPIDTza6gD2W3IA9LufI0S0x8Rl4y wXKJv0RC0wKxbMlyWZiqd/+VpbAr1mYav50Eqb/ojjGpjSmqCNYH7TZePrZ0au0ZnwEq EsN2d0hS/OhSKWJLWu8HY9jHP+PQI5yxb8KE48CO0gXOfR5YrhPEsi3A1PIv3iLK6exG uZjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KBLDDA2+Sx6MxjI7VX3+/FeVIOWjEinua4fuRLYfv54=; b=MSbqzJkFkFN2P2s3+/+fS0sLoHmijMJzDXVInqcRSM3/yc5qZG2CrLYxvW6y4gCHYE rPo9riNIREHI1Q4vtMVBwdzBJ+28BQbCHeq0WZiny33ajW9bp+LqC/TBfMBEISCPZN0I ltbU9V4wpdecxjB5vCAKfb5AWbZSQzuCynycQtD23lOw/ZjnWmfVJKWTnIecbU41qGCJ tSASQZxVqbHhpxCZ9nz5sudzxBFShZzVSjwIt+FL2Mgh4JC0UY//Khu74YY7kL5qqA7F ZDE4eIO56g8qMosxL+COMz/MEnbbo3vDOg/K6KvR/uW1DcOgnV3V9Y/ogIjMOsN+0XSX /O4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=c8dxC2om; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a05640227c700b0043a40d536d1si5388985ede.513.2022.07.15.05.11.52; Fri, 15 Jul 2022 05:12:29 -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=@gmail.com header.s=20210112 header.b=c8dxC2om; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232984AbiGOLob (ORCPT + 99 others); Fri, 15 Jul 2022 07:44:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234538AbiGOLo1 (ORCPT ); Fri, 15 Jul 2022 07:44:27 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E717729C8F; Fri, 15 Jul 2022 04:44:25 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id o7so7373384lfq.9; Fri, 15 Jul 2022 04:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=KBLDDA2+Sx6MxjI7VX3+/FeVIOWjEinua4fuRLYfv54=; b=c8dxC2omamMR0T7nrs/klONn389xq55P5WgJ+SvziRJDK3XgVMsSBjDCqJh4rKx8HN dA+9YGYL3pVROeOSpnQwYVL1pXF2PQNRImumAl1bOoQe1LxhNI7xAQWPs5vqnPtV80S0 85jMZxRCvrrS1w/8qDcaQDUq+L+C39YssXIaoawiTqi+YwVRZfmqQGkd3B5PIHvNgmRU SEzccLHrYGYiuWQFUiDQq6mIFXISddMXgMs6kBgitUySSN5sU0nlYaDHgZcd3b4cjBUz JaMkR+asrAUItea6d6hlF3IoqdQ2cNw385gOydUb/nvCfRvEkD0d4P3gCtbYR+E8T+0w wJQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KBLDDA2+Sx6MxjI7VX3+/FeVIOWjEinua4fuRLYfv54=; b=xB8w5+KaoFdU/nW0AOvXiOBTzeI5HcJvOUSYQKSNTDgpgTaoaV6lZJgzhuwFPV5r7r cQ86zzWV8ZP6p2+NcpwHoX0P6Ms0IY9LTIobXb3sImjIRSY45Tt6hLHMyj+o2vD5Zg/P fgtkKJ+wQD0p7DLBUh2AMfrweUDOwVoKIuueju+XoRxsdr+r/IzFngaPG9+Buv6Q2V5W jVPpUSFq07NOwa3y/h7aIjZ0VU9MCvdlp7U+U54q9EKl3OZkusH0Zy1C8gmLmDdPcUKB NtweL9s8BmCsxxru1lQH38GetXYkpHALMNBioItpr1T+a/cJVT4L1bXE4EV8H9xdepDn QS9g== X-Gm-Message-State: AJIora/ajWbpa1YfgWCdxeSHAYHEa/EXsdIuRDX/AkRsN3IBGV0A3a94 0KRnLz2WIGJcTM5X2/KVlOkMsD8CJdw= X-Received: by 2002:a05:6512:3f84:b0:47f:673c:31b7 with SMTP id x4-20020a0565123f8400b0047f673c31b7mr8270011lfa.473.1657885464140; Fri, 15 Jul 2022 04:44:24 -0700 (PDT) Received: from mobilestation ([95.79.140.178]) by smtp.gmail.com with ESMTPSA id d8-20020a2eb048000000b0025da65c3b75sm176187ljl.16.2022.07.15.04.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 04:44:23 -0700 (PDT) Date: Fri, 15 Jul 2022 14:44:21 +0300 From: Serge Semin To: Florian Fainelli Cc: linux-mips@vger.kernel.org, gerg@kernel.org, Thomas Bogendoerfer , open list Subject: Re: [PATCH v2] MIPS: Fixed __debug_virt_addr_valid() Message-ID: <20220715114421.4uik3bmdyhscgyag@mobilestation> References: <20220714222514.1570617-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220714222514.1570617-1-f.fainelli@gmail.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Hi Florian On Thu, Jul 14, 2022 at 03:25:12PM -0700, Florian Fainelli wrote: > 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 No objections now. Thanks. Reviewed-by: Serge Semin -Serge(y) > --- > Changes in v2: > > - handle lack of HIGHMEM and EVA > > 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.25.1 >