Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2173034iof; Tue, 7 Jun 2022 22:09:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXoVt5CUc7xENw2hPkaqu90bjmrE7bqlzN+IxfvdUKjVnjmnuVFpUiUJwt1ps1oww3YoSo X-Received: by 2002:a17:902:700b:b0:167:736e:cfb1 with SMTP id y11-20020a170902700b00b00167736ecfb1mr16237517plk.36.1654664948052; Tue, 07 Jun 2022 22:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654664948; cv=none; d=google.com; s=arc-20160816; b=nxjPLnd6iC5cfTI016YRzyeBpVd1tBsisohb54fzkSmk5mAu6fsxWumLxh6qbYY4N/ 1djjh5o1cJ+yuM34x9bRz9dRGom0DksgwqSVHhynaAIu6zuObXvin3SDcTx7Jkd9hd7N BeT1zk5el2V24/k0elIr6fcaM7dPG2jLfilj21b+yPOrjoEI2fpyheUMd864rkY0hzet mRL3iofUclBdO8Lo8xo1Xx35qkOmCwghapFIh0o+kd9W1fr9/09eSRsqIk7ZhJybe63p DP7wqz0z/QF16MP0wLGAFMQLaPpKERZiD/i5JuzMdWWsL8FMulhFM9Yzlm4y871/GNCg dBPA== 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=dBwd3XqE5Cy5+6fJ+nztUeJvGaVQ3CBJpA8hu3KTA60=; b=YgPR5OcoLYXyDlHK5iHGousKDbURogEMFR7Dpye42PEpGXpMlNRZ0hqjTi8tPZuWEV zrAQ67GL2RTDaxzeBX8bgvezXRoCAjLbkPMA5dqIxtJ7izk/brNIvfnapgRYhYX+ttKj 0dGfgIsbVRT+Upl4IDytU/52+6qGKOnJh0p988INzVttfhPcNSLxitqX7tLNyxvI1uw3 NUPGx/7t1OHs3/xzGJPQi/0pf289kXBQVGj1YOWR9GnZhj2TU01pEsd1LjhniAwgj+4d tNv3PQUd1qh0PXdhAN5xKvcc5muKr5NINxk3SMJr2VdRFRY4QLAgQw0zLiecRNREOhSE KSjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Qrbdldv2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nl3-20020a17090b384300b001e30158abf3si7961031pjb.1.2022.06.07.22.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:09:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Qrbdldv2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 364263F893C; Tue, 7 Jun 2022 21:38:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358273AbiFGUTf (ORCPT + 99 others); Tue, 7 Jun 2022 16:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356881AbiFGT2S (ORCPT ); Tue, 7 Jun 2022 15:28:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D74351A197B; Tue, 7 Jun 2022 11:11:23 -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 6C04561903; Tue, 7 Jun 2022 18:11:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B9DDC385A2; Tue, 7 Jun 2022 18:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654625482; bh=xkQiGxoMysz9EE4tGtqoiVDGv52Ju5dOkOMx/O/9Vvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qrbdldv25eAM6opPKOpYjwdiJRfc7kgb/rxRm488AmQUkDs8JYEueJ7u4oH0j7Z6p TOIUAmU/Sk/tYK/S5olQhYdzgy5qqWXX2ebIBWWRuQhhUQ3MwKLQ4+Y7HG1qfwP0ay Kwr2XpGSrL7QKe6GO85Ld/Wm0MPnxsXjNUAv2CSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huaming Jiang , Guo Ren , Heiko Stuebner , Xianting Tian , Palmer Dabbelt , Nick Kossifidis Subject: [PATCH 5.17 005/772] RISC-V: Mark IORESOURCE_EXCLUSIVE for reserved mem instead of IORESOURCE_BUSY Date: Tue, 7 Jun 2022 18:53:17 +0200 Message-Id: <20220607164949.154512365@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@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: Xianting Tian commit e61bf5c071148c80d091f8e7220b3b9130780ae3 upstream. Commit 00ab027a3b82 ("RISC-V: Add kernel image sections to the resource tree") marked IORESOURCE_BUSY for reserved memory, which caused resource map failed in subsequent operations of related driver, so remove the IORESOURCE_BUSY flag. In order to prohibit userland mapping reserved memory, mark IORESOURCE_EXCLUSIVE for it. The code to reproduce the issue, dts: mem0: memory@a0000000 { reg = <0x0 0xa0000000 0 0x1000000>; no-map; }; &test { status = "okay"; memory-region = <&mem0>; }; code: np = of_parse_phandle(pdev->dev.of_node, "memory-region", 0); ret = of_address_to_resource(np, 0, &r); base = devm_ioremap_resource(&pdev->dev, &r); // base = -EBUSY Fixes: 00ab027a3b82 ("RISC-V: Add kernel image sections to the resource tree") Reported-by: Huaming Jiang Reviewed-by: Guo Ren Reviewed-by: Heiko Stuebner Tested-by: Heiko Stuebner Co-developed-by: Nick Kossifidis Signed-off-by: Xianting Tian Link: https://lore.kernel.org/r/20220518013428.1338983-1-xianting.tian@linux.alibaba.com Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/kernel/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -189,7 +189,7 @@ static void __init init_resources(void) res = &mem_res[res_idx--]; res->name = "Reserved"; - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res->flags = IORESOURCE_MEM | IORESOURCE_EXCLUSIVE; res->start = __pfn_to_phys(memblock_region_reserved_base_pfn(region)); res->end = __pfn_to_phys(memblock_region_reserved_end_pfn(region)) - 1; @@ -214,7 +214,7 @@ static void __init init_resources(void) if (unlikely(memblock_is_nomap(region))) { res->name = "Reserved"; - res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; + res->flags = IORESOURCE_MEM | IORESOURCE_EXCLUSIVE; } else { res->name = "System RAM"; res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;