From patchwork Thu Jun 13 10:30:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 166696 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp908699ilk; Thu, 13 Jun 2019 08:35:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyl5At8MMvCWsej8GCVhF4pWIc/sEVpYuVGRb9iMkf4RsSuZ2N3nRrbCVjkuPtN3Q8xBQid X-Received: by 2002:a65:500d:: with SMTP id f13mr30841019pgo.151.1560440109537; Thu, 13 Jun 2019 08:35:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560440109; cv=none; d=google.com; s=arc-20160816; b=A5MY1t06genYo4atRsdxKbj4qKdQxKAQq0IVJmOAhIw1EcNx4yJtfZNVGCB3tJe0XS 0DSoiu3jAZc/z0WO78P1gTB0orOKb7paa0mZQ95+2gwUUHpdPgED57+3FJl9hZrKii9m jDu3pknRH90n3EjEM/z1889c/eUyusz5fTxiFTB0MF7AVwUX3R8V/qKO7pOjDWp+0wEK TxXBUd3yS6IJscVzS2tOXm6PN+CopoZEOkGXhMvQ+O7Y2WmMPNuRHqhnw2Jeo9dnjfID PNAlyye6PABq3g7T31Yswtqy2cGAwzeq5REVVDyWoeT644pEaaPAYFZy8JcbkqHBKF/s dwtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=zNYSDlioe1/7qDzUymWdeZ+QFAflos+mlnY8eEGg+0o=; b=zQa6l1g9bwSjccXfgRfkE60WRKY3YaxfLFM8T9PQ5n7ENap61N7ZRk70CMDrkyta44 g9+sa2txTJw3yGnVD6lQJLs6cMPLv7V1dxRAxH22WtLqF6nIWTT+5VkGfJV9xNVOWcYV tel8jjr6QyHgWAfHAcS5gWRCENYcaPlxZQb9THRFbTO2TlvIPeFLRFB7oEyqluo7mlWi zjwg42Av1GLXZX1NRr5DxFaeCAuW87wJnSjJE/Ccc7SKmwMTYyhlgelP5PN9RyYIX3qF E8mjxvqyYOTbXjKHB1/GeAhHpjZCZ5AL/YWzSl+nNczvGaEACSBEUChGqxPvi3mnasN4 TaPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yGqrc+Py; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si98289pgg.386.2019.06.13.08.35.09; Thu, 13 Jun 2019 08:35:09 -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=@linaro.org header.s=google header.b=yGqrc+Py; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731647AbfFMPfI (ORCPT + 25 others); Thu, 13 Jun 2019 11:35:08 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46609 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727968AbfFMKbf (ORCPT ); Thu, 13 Jun 2019 06:31:35 -0400 Received: by mail-pl1-f194.google.com with SMTP id e5so7954403pls.13 for ; Thu, 13 Jun 2019 03:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zNYSDlioe1/7qDzUymWdeZ+QFAflos+mlnY8eEGg+0o=; b=yGqrc+PyiSy4n5qr9NdwCtvk10NU0RuIEZpKtR38SSnXyuNE9KtNc4LOsjqZwwRHrh PQjFPkSB3hzxovhRjl67Bjzjq+MyaDq8caifL9XcLBUffnDo6fKiNVZJMaRJqYYrTpLD 236tIR/c1HHyhBzC+DbYQbzknd6nXkp2yR69CfUSomWNfHZq7zDwLo6CtP6Rcz9jQoyU t+UUwCGOlMlfHHdRXEbat32VLMC64YiRRvC+ES6Lwz/POGU5yfdzTRVFTEJkScAUUYU3 CLOA6wc/os0XTJLHRiURlUUYawm0WGmE6fu8bzeXwSSiF2jgcH82LXA8DmqI9CW5kKWM JwmA== 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:in-reply-to :references; bh=zNYSDlioe1/7qDzUymWdeZ+QFAflos+mlnY8eEGg+0o=; b=Mh+58yV/Ft92++lJBeTtBFmc5LtcHoCzU5QIPlq4kNmMFn3RW51zBLv/GnHPPgwbTY mIiKFCi7dd+2ObwTV1SERwwlJ+bdGP+EWsii1tsL3bkrSwXnLLddingmpc7C5wql5M2W p61cGAk7BJ0ueOp97tB9SthRnOCkHSQDANCYvEizMBc5a+O/DF1mQakpz7R4WMi3hkf+ EKlmOzr6R3SOh1zEhpddMg8cQc0l4mDANK99ODV8JCPAHDKZ3WS/hIbboVkQC/pU1ESj 36bfI5+CHXU4fvRI1zfHJ4mdVVQr+z61sguHbwPzEt3vsxrQF4R7asjFMKz5NnNcXR6n O7uQ== X-Gm-Message-State: APjAAAVgQyc10AxQivXnUj+JsfvdTl9rfwcGCryQlllO4IRn6xXTy98e gh51ItvFjOFnKWiqeFkI7SRz4g== X-Received: by 2002:a17:902:1e6:: with SMTP id b93mr43575179plb.295.1560421895353; Thu, 13 Jun 2019 03:31:35 -0700 (PDT) Received: from localhost.localdomain ([117.196.234.139]) by smtp.gmail.com with ESMTPSA id a12sm2265078pgq.0.2019.06.13.03.31.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Jun 2019 03:31:34 -0700 (PDT) From: Sumit Garg To: keyrings@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Cc: jens.wiklander@linaro.org, corbet@lwn.net, dhowells@redhat.com, jejb@linux.ibm.com, jarkko.sakkinen@linux.intel.com, zohar@linux.ibm.com, jmorris@namei.org, serge@hallyn.com, ard.biesheuvel@linaro.org, daniel.thompson@linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, tee-dev@lists.linaro.org, Sumit Garg Subject: [RFC 1/7] tee: optee: allow kernel pages to register as shm Date: Thu, 13 Jun 2019 16:00:27 +0530 Message-Id: <1560421833-27414-2-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560421833-27414-1-git-send-email-sumit.garg@linaro.org> References: <1560421833-27414-1-git-send-email-sumit.garg@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kernel pages are marked as normal type memory only so allow kernel pages to be registered as shared memory with OP-TEE. Signed-off-by: Sumit Garg --- drivers/tee/optee/call.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.7.4 Reviewed-by: Jens Wiklander diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c index aa94270..bce45b1 100644 --- a/drivers/tee/optee/call.c +++ b/drivers/tee/optee/call.c @@ -553,6 +553,13 @@ static int check_mem_type(unsigned long start, size_t num_pages) struct mm_struct *mm = current->mm; int rc; + /* + * Allow kernel address to register with OP-TEE as kernel + * pages are configured as normal memory only. + */ + if (virt_addr_valid(start)) + return 0; + down_read(&mm->mmap_sem); rc = __check_mem_type(find_vma(mm, start), start + num_pages * PAGE_SIZE);