Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp655298pxu; Tue, 1 Dec 2020 23:14:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyASmJ1WCXI9cl2oNHRw6AY1LlE7AWoC6cs6Png3caGupnPf8h1KlhTA6ZfQniJhI5X59uC X-Received: by 2002:aa7:ce94:: with SMTP id y20mr487811edv.361.1606893293026; Tue, 01 Dec 2020 23:14:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1606893293; cv=pass; d=google.com; s=arc-20160816; b=VDtirkH+2E9k+Gqcq3/6KFLd30sG+PHadRSVp+inwfvDKXm+iZ2NW9nYKEXur9ChKx 8Fr0zzBJu5vBgdN/De8bdXYkbqkSVRKyDpoekhZBAWcYcQ7rcSGKqCkC9VlVo63G7yzR yBiYoNf+DpWSib7WHc2dNBYHT2y2IrsJWrlaap48p4RKHuNVDrcXnBnBJRydrjoDCIE1 WZ5Xnj7jm9bkKewQRkyAhO8QbSfZ8DxlIcaTKg1eZu6UFUbDkuiUF1s/uyEpW78bgVds 58UKDd4F2WdsfXPjgCFyer0fYkX3lN4b+ynSZKSp+SMKL/+pLQwJDiKtcZEijjoNLLSl yH8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=h9Ff4uluzavrBanx+ZMKSgz0DRRyVzNpX56BZOKaD1E=; b=GIS8xp+Ws72DCoJRGtyzAG8jx+6FqjaW1gGVRNpD6JalRCqImMFyuhHCaxBCV7agII tZkUIFAJp58eskJ7vhnwWNkfowBeX7jgujvDhk0fTXhbrz9L2mdmjNu6SY0OqCsbdBO/ j9ErU5OnfrAiY0azMihMfoTPuvm09SbGfMXeCLrDKhEx6EPhlHzWTlWAWepg7Sod2xsZ pQeq214+lVm54I/Z5ir/9rNtiJEKEQ01aIopNP6omrk0TpBXC1Aq+N48e6mVvt5qJ2ct 2Te2Nr8iYrAv/dfMZ5OsSkuWAZEu8hyusaoKTEvZIQGlS+Atg6zEeH8IAAtc7YUYg/oa q4qw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@leica-geosystems.com header.s=selector1 header.b=GNWHt+EU; arc=pass (i=1 spf=pass spfdomain=leica-geosystems.com dkim=pass dkdomain=leica-geosystems.com dmarc=pass fromdomain=leica-geosystems.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=leica-geosystems.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si363918ejn.255.2020.12.01.23.14.27; Tue, 01 Dec 2020 23:14:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@leica-geosystems.com header.s=selector1 header.b=GNWHt+EU; arc=pass (i=1 spf=pass spfdomain=leica-geosystems.com dkim=pass dkdomain=leica-geosystems.com dmarc=pass fromdomain=leica-geosystems.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=leica-geosystems.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728569AbgLBHMA (ORCPT + 99 others); Wed, 2 Dec 2020 02:12:00 -0500 Received: from mail-eopbgr00105.outbound.protection.outlook.com ([40.107.0.105]:36930 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725912AbgLBHMA (ORCPT ); Wed, 2 Dec 2020 02:12:00 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cZKWx6zvCNY4ly2RtbAyw//wRfxHHoNRknxMULiJeEuirieNjgBAK62aOf69KYN58NrUe5OLLc8u1V9NnGl7QEfvidPZYw7EtmbTjWBA45pOzDpcg5l3aDbgwgP0QlQp31NYPdbbrOyCCvkSX2Ppuf3wkvVa/VQ7MTgOUh1ULa8m3s8wIILfcbQpWOoL85V0MNbnghMIhY2fGU2CmGrGfd2QLEma45NnCvcf5lRMxw+Iae6unh0lsOUPamXr1Qr+KtrzXEWV+ucwTv1XGNMFCjljod9XaDvjOpphSwrsznJXLHElPKmXmuWnZZumxAoDxn6laNp3NsvUOvJfDuoiig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h9Ff4uluzavrBanx+ZMKSgz0DRRyVzNpX56BZOKaD1E=; b=l1/NSZtV4LkxAspRuLmpO760PtTkGP6Htsrn54tn+BmqB7zRmrmeXhtnW7iSa7uAnwtnpwclOQ/m9mL/MYhhBeLvpiPjuyBVKAo0hXfGeE3v+/LWG6J5ayModmkvvZNFE001Pce8VnEPoEGg8a8WscC83PnxCT74jNygcoz/SykEcz5r39396MTVotPWz4hMqJFEsNVvmmbJxzEBw3k0UyLFtcwYBkG9gJDQVqp4yf4eMPIt+OV6LO1/DKOu8bs1XcUkKPV6L1eLueq4dgAfGyxZ9qvinHiFt3ey8zUjNCn0PGpsiVUx7UMfxgPFRsC5svQOvkTt1/TcoY5mbfdHow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=leica-geosystems.com; dmarc=pass action=none header.from=leica-geosystems.com; dkim=pass header.d=leica-geosystems.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leica-geosystems.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h9Ff4uluzavrBanx+ZMKSgz0DRRyVzNpX56BZOKaD1E=; b=GNWHt+EUq2ffW3UfUbHsyRBjVYzlVCg2tLuvTARSdf5Rp7R3nEERU9nZtcaHJk0LjHWYmALTFRG/WNekQGzjR8rLVWrg05/8V3119oF9dfOMEM4ClOxxJXJZ03jDN0XoCpiDsweEwF8sB0o4gJvKOUDwWRY9YJsjFPZk7aJwtHc= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=leica-geosystems.com; Received: from DB6PR0602MB2886.eurprd06.prod.outlook.com (2603:10a6:4:9b::11) by DB8PR06MB6234.eurprd06.prod.outlook.com (2603:10a6:10:10f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.25; Wed, 2 Dec 2020 07:11:11 +0000 Received: from DB6PR0602MB2886.eurprd06.prod.outlook.com ([fe80::49c3:4b5b:289c:d62c]) by DB6PR0602MB2886.eurprd06.prod.outlook.com ([fe80::49c3:4b5b:289c:d62c%12]) with mapi id 15.20.3611.025; Wed, 2 Dec 2020 07:11:11 +0000 From: Andrey Zhizhikin To: jens.wiklander@linaro.org, op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH] optee: extend normal memory check to also write-through Date: Wed, 2 Dec 2020 07:10:57 +0000 Message-Id: <20201202071057.4877-1-andrey.zhizhikin@leica-geosystems.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-Originating-IP: [193.8.40.112] X-ClientProxiedBy: ZR0P278CA0037.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::6) To DB6PR0602MB2886.eurprd06.prod.outlook.com (2603:10a6:4:9b::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from aherlnxbspsrv01.lgs-net.com (193.8.40.112) by ZR0P278CA0037.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Wed, 2 Dec 2020 07:11:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 85f97660-a0c5-4266-b312-08d8969172af X-MS-TrafficTypeDiagnostic: DB8PR06MB6234: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xkhkH2KDes4EMcI1W17BrskGOdZczqCOg/xvDKibJSE/LHSW3ds/DeSNlHK3tL7xsWawdeVy+6HhGq4S1yHsKLPJSDnlTXWYs8oDj/XoBaNxj533tRPa3ujaFPZMb4wqYShDlxGCMG3+MFUU7r29XmNte8faM8iQV21qsgUHEevaBIl3KGoWjJHaltHEWKymt+/TsHa1Ajil6NEi/WNn+Y9ra6kMEFFbOXh+y783pMiAAMtNb5qSKRjdH7X5vN8usQwPuc3fPOI5LvoMASyY+Fw0cFUle+0tI0+7zY0HlM4lLu8BLeaHKqoVlS0h9rylUh5hHqqEDxw9NutiTLXzTiyV6yFC1jy9mtezO7UzCs65ld5oUcwhL6h3cxCeK8J+hLYIQp//mSnQQ4A94AcYfQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB6PR0602MB2886.eurprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(396003)(376002)(136003)(346002)(366004)(6506007)(2906002)(1076003)(186003)(2616005)(8936002)(966005)(956004)(5660300002)(6666004)(26005)(86362001)(52116002)(6512007)(83380400001)(478600001)(16526019)(66556008)(8676002)(6486002)(66946007)(66476007)(36756003)(316002)(44832011)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?HToZMWI259zZRvtyiplWqupQxx65X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us-ascii?Q?ZaKQQjjmL6cIfp9OYjHb7qYa4VsNDhJKEqzyBUTgPzQQpzOnsWH7Fwe56gD8?= =?us-ascii?Q?b6Q2uu2ou2VVmo/jFEnSkwYn+5pqKSrIoUF1HtwFAxzJbFahArnVhtIRM7zr?= =?us-ascii?Q?zPbr?= X-OriginatorOrg: leica-geosystems.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85f97660-a0c5-4266-b312-08d8969172af X-MS-Exchange-CrossTenant-AuthSource: DB6PR0602MB2886.eurprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2020 07:11:11.4335 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 1b16ab3e-b8f6-4fe3-9f3e-2db7fe549f6a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: noE13jn8lkytckTME+Rlyo/vbQjvubBxb8lXM2uhljQvxgQaZqcGG0623JWrA1sv+DBT2JPmkybxSodF0tkGWgoRfH5gkFnUuqk1D+z9p88= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR06MB6234 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ARMv7 Architecture Reference Manual [1] section A3.5.5 details Normal memory type, together with cacheability attributes that could be applied to memory regions defined as "Normal memory". Section B2.1.2 of the Architecture Reference Manual [1] also provides details regarding the Memory attributes that could be assigned to particular memory regions, which includes the descrption of cacheability attributes and cache allocation hints. Memory type and cacheability attributes forms 2 separate definitions, where cacheability attributes defines a mechanism of coherency control rather than the type of memory itself. In other words: Normal memory type can be configured with several combination of cacheability attributes, namely: - Write-Through (WT) - Write-Back (WB) followed by cache allocation hint: - Write-Allocate - No Write-Allocate (also known as Read-Allocate) Those types are mapped in the kernel to corresponding macros: - Write-Through: L_PTE_MT_WRITETHROUGH - Write-Back Write-Allocate: L_PTE_MT_WRITEALLOC - Write-Back Read-Allocate: L_PTE_MT_WRITEBACK Current implementation of the op-tee driver takes in account only 2 last memory region types, while performing a check if the memory block is allocated as "Normal memory", leaving Write-Through allocations to be not considered. Extend verification mechanism to include also Normal memory regios, which are designated with Write-Through cacheability attributes. Link: [1]: https://developer.arm.com/documentation/ddi0406/cd Fixes: 853735e40424 ("optee: add writeback to valid memory type") Cc: stable@vger.kernel.org Signed-off-by: Andrey Zhizhikin --- drivers/tee/optee/call.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c index c981757ba0d4..8da27d02a2d6 100644 --- a/drivers/tee/optee/call.c +++ b/drivers/tee/optee/call.c @@ -535,7 +535,8 @@ static bool is_normal_memory(pgprot_t p) { #if defined(CONFIG_ARM) return (((pgprot_val(p) & L_PTE_MT_MASK) == L_PTE_MT_WRITEALLOC) || - ((pgprot_val(p) & L_PTE_MT_MASK) == L_PTE_MT_WRITEBACK)); + ((pgprot_val(p) & L_PTE_MT_MASK) == L_PTE_MT_WRITEBACK) || + ((pgprot_val(p) & L_PTE_MT_MASK) == L_PTE_MT_WRITETHROUGH)); #elif defined(CONFIG_ARM64) return (pgprot_val(p) & PTE_ATTRINDX_MASK) == PTE_ATTRINDX(MT_NORMAL); #else -- 2.17.1