Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp444149iog; Mon, 13 Jun 2022 06:07:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiF5jUICfjGoh33Wvam8ETkMqM7ncTsDXhSm1gF4nhmiltDOiaEbzUq9xCNNKyed0/C0OL X-Received: by 2002:a05:6402:21a:b0:431:5c52:82bb with SMTP id t26-20020a056402021a00b004315c5282bbmr44512305edv.70.1655125550944; Mon, 13 Jun 2022 06:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125550; cv=none; d=google.com; s=arc-20160816; b=oQeWMPEevRvoGdok3grAcyFzwmIasFdLJDBq185gCkmtB4Na6VGwFZn2CrjCkPWUtx odlsZ6boNKkIrHm+0fD0envh4LQbNj1te35QilLeJNdJZw95YkycccZo4LPsrZfjIHYn Q9ABrmC4585zNeE8+W1XPrdTT1PCTgo6R+ipx5gX563CbQV2l+v0TM6Vtaq0NjyxGBhA t+owQkTvIjVWe+SU7od6f8o+b2iywb1nz9eu9pYVlhyRbe4krmdydTw7fsswubI+flx1 e1uuaCYW0F9K15+foagFh8pRQ0uKqcMZevCtQ2S+cb5/zRfs6b7cTwO5GNCSyF7fAfEP ObMQ== 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=a3aZHEDYw+w63jJr+nz7W/rRLjHxEzXJ4HBBvJfsRAI=; b=DhEryBSSdqlGnZ6QaAP46TEgbWyLrS7CtMETot3G7cd8+K67j02arcWwYLsEHzJ8p2 4FKXIHU+c8a9S0s15Pg/9WLbrKbIxbxXF8Iootmyxyk0sBoO7Rcpp5O02EfY5CtUy3tF TItmAXtIFypx1QI5elWq+QAxvzxx+5OC6BMxpI1w0aHdQVkjreuY2CJP6Vvp4vj6+jPK iRsCcbsO8ZJYIpHyAyqXb481Y+1tHeYrY4eBryIOH5EWkvJeLw+0olUeCAKOS40XQAuS 1hLEy3JG36ffIZMjlTbeyCd9cMhpIgWt3skCIuhr5q5PYwxuoNs/UaOicv8H6EbAMrs5 4VfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lpVYYorX; 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 t15-20020a1709064f0f00b006df76385ca1si7170907eju.321.2022.06.13.06.05.19; Mon, 13 Jun 2022 06:05:50 -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=lpVYYorX; 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 S1354030AbiFML1S (ORCPT + 99 others); Mon, 13 Jun 2022 07:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352573AbiFMLSQ (ORCPT ); Mon, 13 Jun 2022 07:18:16 -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 785B5393C8; Mon, 13 Jun 2022 03:40:31 -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 A5C35610A0; Mon, 13 Jun 2022 10:40:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F151C34114; Mon, 13 Jun 2022 10:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116830; bh=slrudWxAuh1fLW0htW8NsiYcuiCfkfg8Ra9j9/LrVrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lpVYYorXM8fCxPNMY0fuNzc36WXrVmk+9t6luABdlRD4rN3vJMBwhGkW2c9UH8yqI +nr9gKf0vCKcI11IN3S6KrV/ousjcbVZ/ZvE9ZIfb24UNUmjy8/4wPCct+nzMqAiUK MpvVUg4LG9VdJEzoRakDmbsvI4em5/dw+xE7aaC0= 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.4 188/411] powerpc/64: Only WARN if __pa()/__va() called with bad addresses Date: Mon, 13 Jun 2022 12:07:41 +0200 Message-Id: <20220613094934.297852226@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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=-8.3 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: 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 0d8f9246ce15..d92353a96f81 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) ((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