Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2200246iof; Tue, 7 Jun 2022 23:01:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbDo9yePXcO+9nm1hE6sbYSxMKMPqaxumQ7Qj+uRSjf99t7+O0nkAhQJpfzGt8Ypq9s8wt X-Received: by 2002:a17:902:ef8f:b0:163:d61b:ec98 with SMTP id iz15-20020a170902ef8f00b00163d61bec98mr32751122plb.111.1654668098949; Tue, 07 Jun 2022 23:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668098; cv=none; d=google.com; s=arc-20160816; b=IDHncGXTf2Zrc62auDp7UwLzhGK2XZxP5ZXU5FumUuwjO76+Fm1U5VZ82IYn3f9wqn Pr0i8v2bQbOzV8OxfQo9Ga4J2lLy7BQ/hVI6RcMCaQhUxmx0+2GiI4WCKSKTf1sfD/Iz NedbXL7zrrnufEXIKSRHIOJbk5Iy3YKNLO2l24suUxvAJZDelZUmlHp0VRigCfqDLvpW 620q5eyA7MENPquRgdyO3/ZV/DjW386VvKwX8Lew5Es/5yBfWySqKWwy72zHbQPSpltL V489bEhROHoYgRa8vXS8HvQZdtcYGGHtc8mi4CnwLqYPpjeXQiekFqw8e9RUVEs6IzPM GvJw== 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=vIjDDgofrDAcxFJTbLXL3JqbHx0+JN7dlMR4ElHQd1U=; b=Bm2R+3wiGGG2jcSZ64a5XnQIenVkMK8I8OHQ3sh5df38ptkT7TrM7Sgz5vuAdvEtYf 9NYpku7PKKtVtmZY2IArR77va8QQt5/nLkW4gJElW1uyJ2ed12Ia5V1qfCsQcxUH57WT bhGvEEOx5gWjajBQYqP4bM79Fk4ewLve/RrnFAQib+E4Dj6uDmP22m1f1sVP053ECCeo 2Vyd7lSLmvWAGOOlMldzhjKJ1HWR1cnCTyGwIaz/m45ryYIHwe47T0hm7pAfedbzsYjD cW/iVi5XkSH2mS64bSi3VfLYgl2tDsPEFnB0zRZMBUg8bTkVKosLB+vdOveZM08qbw3n 1mYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xDIR0CBr; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l27-20020a63ba5b000000b003f250fc5e17si31989839pgu.793.2022.06.07.23.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:01:38 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xDIR0CBr; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5297445407E; Tue, 7 Jun 2022 22:26:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344312AbiFHAiq (ORCPT + 99 others); Tue, 7 Jun 2022 20:38:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379898AbiFGWG4 (ORCPT ); Tue, 7 Jun 2022 18:06:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8610F2534C6; Tue, 7 Jun 2022 12:16:45 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3F298B823CA; Tue, 7 Jun 2022 19:16:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BB75C385A2; Tue, 7 Jun 2022 19:16:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629403; bh=2clv+eIChWCU75Deg8PZdCXvoxeLsnNaYAdk+/FkBa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xDIR0CBrbPrZyYEnuuf6Sqtj/KyQJs9jOCiyckjAohhocKtyN9HEZPWtgbbAshA8Y Iw0MFYI339yfAaoan4deGP28B0rsBk69LG36PkBwsQgqZLX1JfCAuUPz3ro47KHrAC qAr4OX5AP3eJkb7HZwj38cRw0XQ21y5bYmhlx5E0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman , Sasha Levin Subject: [PATCH 5.18 638/879] powerpc/64: Only WARN if __pa()/__va() called with bad addresses Date: Tue, 7 Jun 2022 19:02:36 +0200 Message-Id: <20220607165021.366729178@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Michael Ellerman [ Upstream commit c4bce84d0bd3f396f702d69be2e92bbd8af97583 ] We added checks to __pa() / __va() to ensure they're only called with appropriate addresses. But using BUG_ON() is too strong, it means virt_addr_valid() will BUG when DEBUG_VIRTUAL is enabled. Instead switch them to warnings, arm64 does the same. Fixes: 4dd7554a6456 ("powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses") Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220406145802.538416-5-mpe@ellerman.id.au Signed-off-by: Sasha Levin --- arch/powerpc/include/asm/page.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index f2c5c26869f1..03ae544eb6cc 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -216,6 +216,9 @@ static inline bool pfn_valid(unsigned long pfn) #define __pa(x) ((phys_addr_t)(unsigned long)(x) - VIRT_PHYS_OFFSET) #else #ifdef CONFIG_PPC64 + +#define VIRTUAL_WARN_ON(x) WARN_ON(IS_ENABLED(CONFIG_DEBUG_VIRTUAL) && (x)) + /* * gcc miscompiles (unsigned long)(&static_var) - PAGE_OFFSET * with -mcmodel=medium, so we use & and | instead of - and + on 64-bit. @@ -223,13 +226,13 @@ static inline bool pfn_valid(unsigned long pfn) */ #define __va(x) \ ({ \ - VIRTUAL_BUG_ON((unsigned long)(x) >= PAGE_OFFSET); \ + VIRTUAL_WARN_ON((unsigned long)(x) >= PAGE_OFFSET); \ (void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET); \ }) #define __pa(x) \ ({ \ - VIRTUAL_BUG_ON((unsigned long)(x) < PAGE_OFFSET); \ + VIRTUAL_WARN_ON((unsigned long)(x) < PAGE_OFFSET); \ (unsigned long)(x) & 0x0fffffffffffffffUL; \ }) -- 2.35.1