From patchwork Thu Sep 21 02:37:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 142713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4586578vqi; Wed, 20 Sep 2023 20:42:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlewPcfQexqQsfkEPqVucfrt/3CRzgN9sAiSgGIaA3mvdhHPacbjfNGTxFdVuUgmQ3R2jl X-Received: by 2002:a9d:6a0c:0:b0:6b9:c4b1:7a86 with SMTP id g12-20020a9d6a0c000000b006b9c4b17a86mr4366721otn.3.1695267757333; Wed, 20 Sep 2023 20:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695267757; cv=none; d=google.com; s=arc-20160816; b=tyrfwCTPOP3bw4tWx9XvkuV4CuGhZG1yo159mJUNPwOI6SEscUn/CXzQUZBNpUKMJW kJSow8krfzHpQ9/2njFh2zbw83rWNkKhylyft8cdHWXRQAKuGXb4umA8qvSAmDX4A5tq XN9VvSeJrkKeMi9X7b2ta9Gd0grjUezvRi0KXHmxa2hJ/PvnojD3rpsXYDK57nTk1Vjz 81PTsGwn5e7JwwttKhIx+Tqdmi65Us56x7UTT4sT6rPDe6A/NWUudJ1sUa7MU5hxPAtG mFBiNIJsH/POedFNUeljODvY8ePuKJX0WptMywFvhQmFKyZV3x/0QEyXJAmzBVWGpJU9 fUWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=nBccwF1AJjDJHOkO9saAtELKx+a1Lz8POTJOCADT7jA=; fh=JqQ9vB33k0mgLF+8qvMDdtg+EJ5VT4RAgruajKjRjLc=; b=DzyaBIvFcF2VB7YrAbAvetLk+ZxERP69o/sM54SHPXD1mKoylQzH4ZMhZILD1N7a6t 6GH2Hf6Wd9XusVwo5qsQrf63g2EiYo+URc2OdHNmd7199SGZAHJ/lKory3kdceQWmxpJ Jb0puaeR3hc5a5Cn7tV8VOF26lvwPyihjkfVbg8gutaLWuId9n74yIOnKwGu4A4rqh73 TDXqtBczR+guFu1FhgCG76hFzNb6OpGav4ufAwvB5yCYyFGjpnDFEXvvoJ4DA+9ooGWt vBR8xMbyw8AjIOTrpcXYjYlW7tuUn8LK62czFNN5gf8yDcXcmQe+iKy+oVMYyIiWA115 JV3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UAxV89vH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id i67-20020a636d46000000b005708fb8f0bbsi532907pgc.571.2023.09.20.20.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 20:42:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=UAxV89vH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 7187180AEE0E; Wed, 20 Sep 2023 19:38:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbjIUCh7 (ORCPT + 29 others); Wed, 20 Sep 2023 22:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbjIUCh4 (ORCPT ); Wed, 20 Sep 2023 22:37:56 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A915D7; Wed, 20 Sep 2023 19:37:51 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38L1kmST024787; Thu, 21 Sep 2023 02:37:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : date : subject : mime-version : content-type : content-transfer-encoding : message-id : references : in-reply-to : to : cc; s=qcppdkim1; bh=nBccwF1AJjDJHOkO9saAtELKx+a1Lz8POTJOCADT7jA=; b=UAxV89vHiCNO9eYM5jXfkK40wREPFI2WhWcpV9gSe24KEYlG0NU0PbMJ/7aJiVnmeifF QoqjfneCoi3N4UOguC+D0GdklAPHEHAdrRewhx6Re3KQm5v/NqkUgjCSKv5mejPIG0aZ 4vX/jTsmJJAZdK1r8OqOzcmdo9MayEJj+ru2o3HV2mOIYHag53pnTA7sZjDIvJoyAr0Z qLiLxaYzn5EfMJjGjHP7TDJX55/9ZMKeeGy07T4x4M3HbDP4EeC1whI9iIHPoAJmO3Sb 6EaskQhq+MQplH6XRI7Opohzeu4c1tTAVcaWXrzj42WkNKvdyvqbtGOm5FOQPq3tmhxa 4w== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t891c0cre-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 02:37:45 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38L2bi9i020704 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 02:37:44 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 20 Sep 2023 19:37:44 -0700 From: Bjorn Andersson Date: Wed, 20 Sep 2023 19:37:30 -0700 Subject: [PATCH v3 1/3] dt-bindings: reserved-memory: rmtfs: Allow guard pages MIME-Version: 1.0 Message-ID: <20230920-rmtfs-mem-guard-pages-v3-1-305b37219b78@quicinc.com> References: <20230920-rmtfs-mem-guard-pages-v3-0-305b37219b78@quicinc.com> In-Reply-To: <20230920-rmtfs-mem-guard-pages-v3-0-305b37219b78@quicinc.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: , , , Bjorn Andersson X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1695263863; l=1847; i=quic_bjorande@quicinc.com; s=20230915; h=from:subject:message-id; bh=xlRIelsN06YllMR6zQavDKa2EffnSwCF78u2DTrHj0w=; b=GyA4H0nGIEhcJOitilg5PSb/hOQlK+YMuj77kq8z5ef+diag1/IpNh1iG9+b0y2GTeJcpeMTbE9R KU4I732mCOfUBVGkBBZEdClKIEHyO2rhCWTdAwGp1qO9ZhsoCXi0 X-Developer-Key: i=quic_bjorande@quicinc.com; a=ed25519; pk=VkhObtljigy9k0ZUIE1Mvr0Y+E1dgBEH9WoLQnUtbIM= X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: A4RG7nEGIcse6EKfjJv7rMQW7vhGoffc X-Proofpoint-ORIG-GUID: A4RG7nEGIcse6EKfjJv7rMQW7vhGoffc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-20_14,2023-09-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 mlxscore=0 mlxlogscore=814 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309210021 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 20 Sep 2023 19:38:00 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777617084097744929 X-GMAIL-MSGID: 1777617084097744929 On some Qualcomm platforms the firwmare, or hardware, does not gracefully handle memory protection of the rmtfs memory region when placed adjacent to other protected region. Some DeviceTree authors have worked around this issue by explicitly reserving the space around the region, but this prevents such author to use rely on the OS to place the region, through the use of "size" (instead of a fixed location). Introduce a flag to indicate that guard pages need be carved at the beginning and end of the memory region. The user shall account for the two 4k blocks in the defined size. Signed-off-by: Bjorn Andersson Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/reserved-memory/qcom,rmtfs-mem.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.yaml b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.yaml index bab982f00485..2d7be508c5a0 100644 --- a/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.yaml +++ b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.yaml @@ -26,6 +26,17 @@ properties: description: > identifier of the client to use this region for buffers + qcom,use-guard-pages: + type: boolean + description: > + Indicates that the firmware, or hardware, does not gracefully handle + memory protection of this region when placed adjacent to other protected + memory regions, and that padding around the used portion of the memory + region is necessary. + + When this is set, the first and last 4kB should be left unused, and the + effective size of the region will thereby shrink with 8kB. + qcom,vmid: $ref: /schemas/types.yaml#/definitions/uint32-array description: > From patchwork Thu Sep 21 02:37:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 142701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4570038vqi; Wed, 20 Sep 2023 19:52:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPDeXUmxTAOPq+maarJG8awnq4CaJPLhEShRA1VvePNEAbBkpmO1TPZbkwPIzO6+7thUTO X-Received: by 2002:a05:6358:50c6:b0:13a:4855:d885 with SMTP id m6-20020a05635850c600b0013a4855d885mr5580783rwm.10.1695264726193; Wed, 20 Sep 2023 19:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695264726; cv=none; d=google.com; s=arc-20160816; b=05ynrW5IpBcQ9rh7ZkXEVMo16PvDDlMW8QkUSKnUPV28IoIZ2i6VmEMX5eQWQAzinO zL/Q1s3UlUJ/yDXlBfCFUsow3osUXgj0dCgpsreeChm77WFe2qU0u+ibPExAvNThonsE Osq4CxBscYALs655l+OdZPNG4ylf1JYWIDFDUwaCrTNskboBKRyqapPoNm/ADeX1sFIu EFEpSC9Y0k0v2hW6vyWMuu6E8idh939sND9o6tJPe7KIdCgBvW8DvXloDajwKSd4uTna VCiwaoEvT7TjKV+g+A6p5JYG3fMuT54b/NctiprX3Cvrz1i9frIGoiIUXfCKOpe01TqV FDJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=xNyb8ZIupF+SY+3e23HEdJol+sE1HfzbPJHdC+LOLQc=; fh=JqQ9vB33k0mgLF+8qvMDdtg+EJ5VT4RAgruajKjRjLc=; b=PZX+gOtwpKQ+prYEPD7GVrUU888ZlPGOAFFDPNgL/9jWzgZ/excmffTLuG1YxBRCOA MjvVUoAaEXYdUq3ylrWRPjUI/+hX2Yg6K4lB8HnsOFEQUTyAq8Zt3zVDr/JoH1GXhvkG DXnXb0WKS+9uxU8/wqEohrfY8cp3Eh1FftjT1AEI+dX2MZ9NKRYgVB3uVgtjkyIYvi14 UKjMRzdLMf0VQBBowS5O7EmPiblqVw1A4QigSa5MJPOvSgXLZXH3OfmkMrpVK540zQMg Du63HiLDISRNvIkm13XbPZRggZ+AMbXMrcGse530Jvytu0FS2SX/EaRgOfXHHpoq9IOX B4uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=c0977gJC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id o15-20020a656a4f000000b00577f87e6210si481817pgu.332.2023.09.20.19.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 19:52:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=c0977gJC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3494F8043EF9; Wed, 20 Sep 2023 19:38:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229627AbjIUCiB (ORCPT + 29 others); Wed, 20 Sep 2023 22:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjIUCh4 (ORCPT ); Wed, 20 Sep 2023 22:37:56 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C1EE4; Wed, 20 Sep 2023 19:37:51 -0700 (PDT) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38L2ETRR004317; Thu, 21 Sep 2023 02:37:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : date : subject : mime-version : content-type : content-transfer-encoding : message-id : references : in-reply-to : to : cc; s=qcppdkim1; bh=xNyb8ZIupF+SY+3e23HEdJol+sE1HfzbPJHdC+LOLQc=; b=c0977gJCtvleggYx+qvcdtSAGVtyHyTQSr+MSsbf1PiITHpUh0VZb0YlltFKv50OCIut Qifmqn5MDrzjh5nhKVmfcySAjgq/or84mcaBeqpLJMTYAR9MjqPVuIm13Cm13+ZA1WSE fdwOki7rf9kSwtQlDpbXQ3UdF7hUpK9WbgDOU1VmcxHz1ERFn8wl8KiytWKIwDG9bJ5Z wY6e7ylHiNYn75CJVkXxJmKDWN8JC2yZ7DN6IaPxK6j6zzVHbqR8YAOC12zLQmtYeLsg F5GXGdtxSrGDg6xp+WIGrwt7lzXoFbL/nsKYy1C6F+qWol4nzp0BrqbVZW7y8Qg12fJi 0w== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t87510k7n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 02:37:45 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38L2biLB024347 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 02:37:44 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 20 Sep 2023 19:37:44 -0700 From: Bjorn Andersson Date: Wed, 20 Sep 2023 19:37:31 -0700 Subject: [PATCH v3 2/3] soc: qcom: rmtfs: Support discarding guard pages MIME-Version: 1.0 Message-ID: <20230920-rmtfs-mem-guard-pages-v3-2-305b37219b78@quicinc.com> References: <20230920-rmtfs-mem-guard-pages-v3-0-305b37219b78@quicinc.com> In-Reply-To: <20230920-rmtfs-mem-guard-pages-v3-0-305b37219b78@quicinc.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: , , , Bjorn Andersson X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1695263863; l=1416; i=quic_bjorande@quicinc.com; s=20230915; h=from:subject:message-id; bh=QJw72O7i7ZmFiiHvUXcqqtPd/U+RD0Qw3QJSkoRMKPE=; b=FLlS4/QOwYvniUnTEcOE0fU/3G4BWKz6JFzFl+XjuxpIDc1VWL1XxL0X8ZKscc4kuBPi8IznpKwD cEkMzMjWBzlD00+KSi2O+Onh2IoD0RnuNPDKSVoxnBRrkQMKTRPM X-Developer-Key: i=quic_bjorande@quicinc.com; a=ed25519; pk=VkhObtljigy9k0ZUIE1Mvr0Y+E1dgBEH9WoLQnUtbIM= X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: T7fwUtA8joYQe3ViHH0tIqzSM7z1ZP9M X-Proofpoint-ORIG-GUID: T7fwUtA8joYQe3ViHH0tIqzSM7z1ZP9M X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-20_14,2023-09-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1011 phishscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309210021 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 20 Sep 2023 19:38:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777613905533952587 X-GMAIL-MSGID: 1777613905533952587 In some configurations, the exact placement of the rmtfs shared memory region isn't so strict. The DeviceTree author can then choose to use the "size" property and rely on the OS for placement (in combination with "alloc-ranges", if desired). But on some platforms the rmtfs memory region may not be allocated adjacent to regions allocated by other clients. Add support for discarding the first and last 4k block in the region, if qcom,use-guard-pages is specified in DeviceTree. Signed-off-by: Bjorn Andersson Reviewed-by: Stephan Gerhold --- drivers/soc/qcom/rmtfs_mem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index f83811f51175..83bba9321e72 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c @@ -200,6 +200,15 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) rmtfs_mem->client_id = client_id; rmtfs_mem->size = rmem->size; + /* + * If requested, discard the first and last 4k block in order to ensure + * that the rmtfs region isn't adjacent to other protected regions. + */ + if (of_property_present(node, "qcom,use-guard-pages")) { + rmtfs_mem->addr += SZ_4K; + rmtfs_mem->size -= 2 * SZ_4K; + } + device_initialize(&rmtfs_mem->dev); rmtfs_mem->dev.parent = &pdev->dev; rmtfs_mem->dev.groups = qcom_rmtfs_mem_groups; From patchwork Thu Sep 21 02:37:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 142742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4643479vqi; Wed, 20 Sep 2023 23:26:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyAXeZecrcWnu5lRi5dOWKI22W84PCfWpgNTQGPA82V80rzmQGpASJ9qUmMnygmNwM7Yu/ X-Received: by 2002:a05:6a00:1403:b0:68f:cc67:e723 with SMTP id l3-20020a056a00140300b0068fcc67e723mr5143010pfu.17.1695277609220; Wed, 20 Sep 2023 23:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695277609; cv=none; d=google.com; s=arc-20160816; b=zIxNG5qnMxMFM6KXnKYYmWKtP3zAzKMn0lo2pSrrIM0g1rhLJywgQMWkcC6ININ57G vqrT9S8UuXEkitRtPcCMXlvQEppQ4fDojHRYB5OO4kMtxamSI/geAPcPx7HGJHQ/4bDm KHoiTa0NDsYDiUNkjxZgtcSlnn2qBnBgruK/aImWWeG71G8GHu1YueoH5JKPmOZx9FcQ p9/sR1XFNCV1gZkb/PzvNM0tCQcLvr9lNnyDLAFRV55H0SZCB6KTHw1EDvqfYeq+554I +sYJg9TSwTEvOE2/HpOkZQyjKSyE2y9WCvn1bPO+z4Uo81wKUsw9f7DEOH8exJUhG29g JBDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=DQqgahBrunVeJ2T5ssMsMl2PItK5lsgtV+m/zCZvEWc=; fh=JqQ9vB33k0mgLF+8qvMDdtg+EJ5VT4RAgruajKjRjLc=; b=GNNUoBMwQtCZHRFa1QPMjqcIBHuvwepQUDCo45S0fWfOo+cSc6HWms47iXtLMsr6wi FZMrX2GcZ5FUQwCzgNkXLy6ZlL3k/0tBjQOyvHFsqZvhDwQKsPeJonrFPi1X2oNlEov6 AZLFrhkFsJx2LZvLxp06JD0NMRVYsmvWd7D5ayAFXdTmhZlQUXqW60YCH2RJjODwLJd+ uGURtsy4GaStL9xnXWtgsV5Z2/GHxtidvarlC6kOKXUTbwdeELCiliZXvkQ8lvMZ+Y0v 7b7mBSHyWDxyxtPFRbc6yyroAzXEDGVGmcoxRb3JS7pDMUdm7tCz54Nn3Amxo1CcNqsW 3poA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Yf0s5Xl4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id e20-20020a656794000000b00565218f25c4si691813pgr.858.2023.09.20.23.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 23:26:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Yf0s5Xl4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 86D478351548; Wed, 20 Sep 2023 19:38:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbjIUCiE (ORCPT + 29 others); Wed, 20 Sep 2023 22:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjIUCh5 (ORCPT ); Wed, 20 Sep 2023 22:37:57 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7AA8E5; Wed, 20 Sep 2023 19:37:51 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38L1iEiM027364; Thu, 21 Sep 2023 02:37:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : date : subject : mime-version : content-type : content-transfer-encoding : message-id : references : in-reply-to : to : cc; s=qcppdkim1; bh=DQqgahBrunVeJ2T5ssMsMl2PItK5lsgtV+m/zCZvEWc=; b=Yf0s5Xl4rb+JkXVCurM4lZo7q2+DzSezMICBiHZDBOxPq+eTtVAlWDBRkEZJRg3N+wNZ 7W5OUNR5j2fvSfu6cNg5auX5K3+doxFDRMKGkZoudCPiJl//zv/JqnTz5e5fnkpDugle HjZvMDOk8WOZyR5MoUCLv+17p+86RNWmKeP5Z16MaKdhzWvvbsd5xUm4m9mWrGmjEfGn KnAS1SakKDcqJ7iR9ddKKSyBN8LiMwKLfV4hza8o4H2dSByoIlXeAuh+sVQG0A7Y0oi1 bqkuJNKGApv8q49ywfC2VajNC/9U1NhzvJaYLaUkwvQchIVRAsMbsyD8DbGM+a0ENJot XQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3t7sh3tm1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 02:37:45 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 38L2bjoO032304 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 02:37:45 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 20 Sep 2023 19:37:44 -0700 From: Bjorn Andersson Date: Wed, 20 Sep 2023 19:37:32 -0700 Subject: [PATCH v3 3/3] soc: qcom: rtmfs: Handle reserved-memory allocation issues MIME-Version: 1.0 Message-ID: <20230920-rmtfs-mem-guard-pages-v3-3-305b37219b78@quicinc.com> References: <20230920-rmtfs-mem-guard-pages-v3-0-305b37219b78@quicinc.com> In-Reply-To: <20230920-rmtfs-mem-guard-pages-v3-0-305b37219b78@quicinc.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: , , , Bjorn Andersson X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1695263863; l=904; i=quic_bjorande@quicinc.com; s=20230915; h=from:subject:message-id; bh=7jXz3rP8GNqMZsIHoKFFl+IwJpRuFh8oza0b3my6eAs=; b=HKuicCpF2ZYWAOR1HrVl0YJXuad3HGWt7ibs2VpT9C5bBFQEyFdqqVtLO8Syh8KZAFV74UbMKEsR XyGqjYLPCu8RK2914hN+iMYZGeH7+mcvoAy4fs/i3axKoxxZAyF9 X-Developer-Key: i=quic_bjorande@quicinc.com; a=ed25519; pk=VkhObtljigy9k0ZUIE1Mvr0Y+E1dgBEH9WoLQnUtbIM= X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: -XxDpDD5KCEqZ4iGvMDNfxJd37mWn0Jj X-Proofpoint-GUID: -XxDpDD5KCEqZ4iGvMDNfxJd37mWn0Jj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-20_14,2023-09-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=737 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309210021 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 20 Sep 2023 19:38:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777627414264869962 X-GMAIL-MSGID: 1777627414264869962 In the even that Linux failed to allocate the reserved memory range specified in the DeviceTree, the size of the reserved_mem will be 0, which results in a oops when memory remapping is attempted. Detect this and report that the memory region was not found instead. Signed-off-by: Bjorn Andersson Acked-by: Konrad Dybcio --- drivers/soc/qcom/rmtfs_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index 83bba9321e72..13823abd85c2 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c @@ -180,7 +180,7 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) int ret, i; rmem = of_reserved_mem_lookup(node); - if (!rmem) { + if (!rmem || !rmem->size) { dev_err(&pdev->dev, "failed to acquire memory region\n"); return -EINVAL; }