Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5817527ybe; Tue, 10 Sep 2019 09:13:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMvowUHrtAbMH7yxndFzqhrgUzSGl1ApKLEvu0Pkc0ZjEZ6lHkqFjMAdS4y8XmrRcuanyC X-Received: by 2002:aa7:d28d:: with SMTP id w13mr31375696edq.264.1568132014075; Tue, 10 Sep 2019 09:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568132014; cv=none; d=google.com; s=arc-20160816; b=lMJaA8ZX999I8Yv4buPKX5PfnP4iwJ0Bqmj3eYmxraL8/+t9JM7K/DqEjH10GRgsvp Gg7kpos+VAtO1/4CQBtTxlvftddnh1YrzDQVtrigePIf1wvJlaCZ+p2iwVv9IFf/CboO OC/vDDJ9BC8FVJM7e8pxDfoD46P+tA8dN2cjvjqePOt/HUusyi/sq/hXgUXEBpfg+lPi BXdK/q57rKp9rrRYU+S9cudiXGVVbtp0ayBDsGrBmVylCUXFgYQCw6RdAYMOTPCfNXbB Y9hc4rncW9v6GZntKdzFkmXiCfgipcS2Ih8ccDzn0FtW1CJOSD4YcuWG7+mYvZzUMvrF t/+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=TUvxJ7wlmXdEjdS8Ji+2ki9BT3REdqo3NpskuD2RAZE=; b=KcoN0h9NGt9z6A//WbCrXD/57HdjlzxuenD3kVeN/46NqWA1v7Zt/a0mxeXH4bfHzC 1tbcM5aDioOBpm2nmQScYWKnSH6pDdVj1J15nPdcRapMy/qXhBpIY7tneQURCTGYG2YZ 6hPpEkF1TFUFOccyIOqTZgeg6as8+uRTAVDajcF5wyTQ9Lze9k5LgrH2azonW/EtLlQj Xl7SZmPueYnwt01rAarc3KBZZKAPyJZFymS4BKolRDKqT1Qyo1w+YPNa2y+QyNv+qaPs 5F9knRFKykhFFuWC6BymntcD5AyD9Wgi+lw04dy9DXer+z0EeMRuatx/Qb29n8qZp8DZ icgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YJDh2YLe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rl2si1467737ejb.230.2019.09.10.09.13.10; Tue, 10 Sep 2019 09:13:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YJDh2YLe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436510AbfIJQJF (ORCPT + 99 others); Tue, 10 Sep 2019 12:09:05 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39481 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394139AbfIJQJF (ORCPT ); Tue, 10 Sep 2019 12:09:05 -0400 Received: by mail-pf1-f196.google.com with SMTP id i1so2952596pfa.6 for ; Tue, 10 Sep 2019 09:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TUvxJ7wlmXdEjdS8Ji+2ki9BT3REdqo3NpskuD2RAZE=; b=YJDh2YLeoTKo99EIHf/GbAcGlRVVjeHebFXD80CmOEXk6TDGBbj/Uh5lPLn3Z2Y21x gTixE7rHSZVLLXSJ6GbQCyzq9QYepRhuOnus3wPSwsY1vxwywof4CRlDE9o5bB6kFdRh L0aDQx9uJi6dcUYgOueyyIdi7vxhQ8v6gGLkc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TUvxJ7wlmXdEjdS8Ji+2ki9BT3REdqo3NpskuD2RAZE=; b=rK4tRGaZH12dvPbIUf0hozuzcC0R8ir5F20yamNYfy8ENgZFukKQ6ELazr2s/0j+Vo 669uyC4egCgQVQgdg40foA3e2ZCmx+3RSMLrkCOfWHMxDhDJz9MlWGo/Bx+mQLYUIjiO eue3uU8Cu7p9rZfUuCJV8Giym1Jcfv7QOCq3rgrH0t36eyMUil3SySDK1ZSesEi39Pvq TrDQlt2RgrVA4VJW5WtLVP7XioJ+KKdaPYnfk1nTZ4ztwv74cyC0QWp21iZzjeqSWTVh ZuaA6xZ/cJAdLCLHJRiR15I1/kBxO9DKdcROOUBYcCKnVmRcZHngDwBJZrm+htLYSJ58 TJDw== X-Gm-Message-State: APjAAAV2my9LMqXZA2WWEjYZskO9e9cv0REi8JHiVCCLDqzzjQbsqigs B0omA/bUnuu/MX6G2zszztNdrQ== X-Received: by 2002:a62:64c9:: with SMTP id y192mr37931196pfb.6.1568131744630; Tue, 10 Sep 2019 09:09:04 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id em21sm106088pjb.31.2019.09.10.09.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 09:09:04 -0700 (PDT) From: Stephen Boyd To: Dan Williams Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Evan Green , Rob Herring , Bjorn Andersson , Andy Gross , Will Deacon , Catalin Marinas Subject: [PATCH v3 0/5] Read-only memremap() Date: Tue, 10 Sep 2019 09:08:58 -0700 Message-Id: <20190910160903.65694-1-swboyd@chromium.org> X-Mailer: git-send-email 2.23.0.162.g0b9fbb3734-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch series implements a read-only version of memremap() via a new MEMREMAP_RO flag. If this is passed in the mapping call, we'll try to map the memory region as read-only if it doesn't intersect with an existing mapping. Otherwise, we'll try to fallback to other flags to try to map the memory that way. The main use case I have is to map the command-db memory region on Qualcomm devices with a read-only mapping. It's already a const marked pointer and the API returns const pointers as well, so this series makes sure that even stray writes can't modify the memory. To get there we introduce a devm version of memremap() for a reserved memory region, add a memremap() flag, and implement support for that flag on arm64. Changes from v2 (https://lkml.kernel.org/r/20190614203717.75479-1-swboyd@chromium.org): * Added a comment to kerneldoc for the new MEMREMAP_RO flag * Rebased to v5.3-rc1 Changes from v1: * Picked up tags and rebased to v5.2-rc3 Stephen Boyd (5): reserved_mem: Add a devm_memremap_reserved_mem() API soc: qcom: cmd-db: Migrate to devm_memremap_reserved_mem() memremap: Add support for read-only memory mappings arm64: Add support for arch_memremap_ro() soc: qcom: cmd-db: Map with read-only mappings Cc: Evan Green Cc: Rob Herring Cc: Bjorn Andersson Cc: Andy Gross Cc: Will Deacon Cc: Catalin Marinas arch/arm64/include/asm/io.h | 1 + drivers/of/of_reserved_mem.c | 45 +++++++++++++++++++++++++++++++++ drivers/soc/qcom/cmd-db.c | 14 +++------- include/linux/io.h | 1 + include/linux/of_reserved_mem.h | 6 +++++ kernel/iomem.c | 20 ++++++++++++--- 6 files changed, 74 insertions(+), 13 deletions(-) base-commit: 5f9e832c137075045d15cd6899ab0505cfb2ca4b -- Sent by a computer through tubes