From patchwork Tue Jul 30 12:23:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 170052 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2574376ile; Tue, 30 Jul 2019 05:24:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbN3TFJfF1Cgbb5b3GGi4Nkvlb92bmHSzubAtuotKU/Ejt8QVZiVZcnDCT3zcU8Ee/IcO2 X-Received: by 2002:a63:cb4b:: with SMTP id m11mr34884771pgi.49.1564489476196; Tue, 30 Jul 2019 05:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564489476; cv=none; d=google.com; s=arc-20160816; b=A6rjs9Sf/8Ew8mErWwaraU+rI91+GV+zDWBXNRT6LNj6bNwrefEXf4qqY+4p3THK+f 7030fbiO2Mi9/JwsSL6oVQjHLLBpHSCi6r5y8GPseAjUlYJfS3LnD4jV5JGrLJIsv01K lh0CwZL57GzeLDmy2j21k04lIDuYd2s+voMqTNJeBmIY/t1iLW6NTYNfxMl3jlBzSEvp K0TQpUS7Hfckv6fOuUEGKL9AFNJZPWPq4vUyvJCjzeL7Pe42E8PNVLqMQC0hOSaKFzBZ SKdROTrV6re6CxWk8J9MOxEw/SBtbGF+0296IMD4+XBnDiiZQlL5E75AWsF8pi5mWj1R toVA== 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=Ub4kuUSnrD2CiYyKKwaDCU7WlCc+MjZGT8+i8BhCGSM=; b=L7VPdKgXUfWP6YLYi3YRhBIVvS5XA33PCGM3d07PPMcXve+CuN4L5JHl46nap5ezhl cXYJ/0/ZG9WtEZP9ViGfEByXL3X4yi58XIPnXc/jQLr9PYap69vIYK7E+koCd3wmj9Ns FePzLrxR/3JqRwGYiGgvE35Alfn0h/jJgsuQVANnDRzpad5rA4Vx9T7cEC8e2p0mrNJP q9k5rh0yS53LEiIhwqZPjX56FzET79czK8BjPV0WSg04Jf+GFe6rFF96deZWOqTRiQ4H ydPNIORbI6Ly8N2cQ+mBuIfdT4zhlKwmDbfxOMTDWtieVHx/Ge987udJ3ua+xsi6vfOP 2Q9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MfQvx2dh; 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 k14si25450400pjq.53.2019.07.30.05.24.35; Tue, 30 Jul 2019 05:24:36 -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=MfQvx2dh; 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 S1729537AbfG3MYe (ORCPT + 29 others); Tue, 30 Jul 2019 08:24:34 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34037 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729365AbfG3MYe (ORCPT ); Tue, 30 Jul 2019 08:24:34 -0400 Received: by mail-pf1-f196.google.com with SMTP id b13so29766205pfo.1 for ; Tue, 30 Jul 2019 05:24:34 -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=Ub4kuUSnrD2CiYyKKwaDCU7WlCc+MjZGT8+i8BhCGSM=; b=MfQvx2dhjGV4/bSe60l+LebksrED1y3ZIlrOHn7KEst3uYq0lbZGY0vsMCXlHdvqTW Ye8auI8LrPtuk1JjxXNnkdo+hZ+99keG4VGsdhwKAsEXIsOsIUECaXlU8hbVHLFk9cLT HO8nBnDu0xGtOjVBUUGFJzgjgr3leWNo194UxYVJeI2Y+0v/K+qeQpXyF0PGeONbMN+i gW62oUUDBfxqW/m3zRut5eraL0BhFNM47K2DQzNbSup/f6DVATK2umRIZlAbmj5eTK+g Ie2+FR2iyP4pVV9kGjOO0QK2a+lbpVtyMzeY+CEhSSw2QwFdLdH8EHmR5UmLIl/CCH4Z mvwg== 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=Ub4kuUSnrD2CiYyKKwaDCU7WlCc+MjZGT8+i8BhCGSM=; b=aTF+n7CYr2THMjRczZEnL1LsoPKrMfEg7MlODum7puYHPqTmTXYhnSf71hOiSmOEKH sUUHnlzZ2UHWeKQxej84mkCUSODVHfifJm9PTdpQXF8EZ5nYRTJRBjj2mVIkCEIwgJaI Ktt+TjghHHJijiPCn1jR99FZ+tlyRPVW8weAhGVyMnrRHn9i6Lwq96Iv2+IyvcJq4bm2 Zmvp3kY9RAejEJnMs+w0yTq+6C41E05D/utKvdWNSr+VUymaCkYA7EnLcOVZUYVod1e6 NhsNzC0e1yZ0XcFwneSiCps3e7TWpwl7spKp1gBz9ryFIrhoSO3fs/TQklwiKdJ4D5N1 sFlw== X-Gm-Message-State: APjAAAWTUdaB1gtjh6UC7WQVcI4XITaRkC6/iBwnrtO5gnxHdBO5p8IN hZ3qOn+DkWN9JnQJKxcqhaji6g== X-Received: by 2002:a63:125c:: with SMTP id 28mr55618644pgs.255.1564489473744; Tue, 30 Jul 2019 05:24:33 -0700 (PDT) Received: from localhost.localdomain ([45.114.72.197]) by smtp.gmail.com with ESMTPSA id v8sm54895462pgs.82.2019.07.30.05.24.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jul 2019 05:24:33 -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, casey@schaufler-ca.com, ard.biesheuvel@linaro.org, daniel.thompson@linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tee-dev@lists.linaro.org, Sumit Garg Subject: [RFC v2 1/6] tee: optee: allow kernel pages to register as shm Date: Tue, 30 Jul 2019 17:53:35 +0530 Message-Id: <1564489420-677-2-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564489420-677-1-git-send-email-sumit.garg@linaro.org> References: <1564489420-677-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 Reviewed-by: Jarkko Sakkinen Reviewed-by: Jens Wiklander --- drivers/tee/optee/call.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.7.4 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);