From patchwork Sat Feb 2 01:43:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B32F76C2 for ; Sat, 2 Feb 2019 01:43:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4D5D32F13 for ; Sat, 2 Feb 2019 01:43:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9831032F25; Sat, 2 Feb 2019 01:43:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DEA132F13 for ; Sat, 2 Feb 2019 01:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbfBBBnV (ORCPT ); Fri, 1 Feb 2019 20:43:21 -0500 Received: from mail-eopbgr770128.outbound.protection.outlook.com ([40.107.77.128]:62080 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726183AbfBBBnU (ORCPT ); Fri, 1 Feb 2019 20:43:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LVQNadAPndkRJn/PhE3WqHDIveZZxyuwrIQ7jmtqqfs=; b=DVHhCS9FzjvxcrmgjxPIKNwMH9NgGRWkQpMATDhsc6s53V7ASlOh8B6u6tNXKcDT9lpWx/D0suwG2A50RHlYAt2G32Pn09MByATNCeYyCqpRwz+kAyU36liRrauiMMafxkzVupMIZ6FUF4+ePuJbpa9YtnAIxs4JTqTjrJSDeeA= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:16 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:16 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 01/14] MIPS: mm: Define activate_mm() using switch_mm() Thread-Topic: [PATCH 01/14] MIPS: mm: Define activate_mm() using switch_mm() Thread-Index: AQHUupiqp1Sra5g7vEKmmfY4jNBCDA== Date: Sat, 2 Feb 2019 01:43:15 +0000 Message-ID: <20190202014242.30680-2-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:3JnP0V6y+EyVK4Rqjvzyz96dVN1H7+k/gMuZoymRPmmk7OkbX26MTIPC85ZMiSWmhH4FRu3gFafRjWW8+VKdyqBNbQw3D/rtxifimQu+Vk9VK8NXblwmK+BezIUjzueIOEkdRpbmO3pZzkEh19mkawr0KeZfNgFxV1Nzq7l8y3utmEgMArc8OsYPFfCmRcyBpL0isRjpatNGjoJ46ckv7NLRH6MhEin66F2Ucxrd6of6vMih9qTY2jX+dCgx7ep5qaZWW3vJVMPmN7C5Br+WdNGnRVQ43jNCItOlnAXK2UznlmlCVaOOHMcKM60zHmp39Ho/mc6XKhmjfUt7CBWuMUOt+0JC4g+iAWKTRunM2Wojw+wQXy7AhObWkpfGwsk2drNq4Gq0NkMc8JV3SgUGnqXBy50c+ihBwV1M1md4lrptt0LmUnry4tJKcDFSoYlS2PvwGlyuu3PFFgzoiQC9Rg==;5:eaGCPgVdKAXr/2OkaNe65S4BlYpCAPeEouWTbIJqy1Z5yNfddPjQUlIQe7y/2eHzYXku2vhgsaoyOGDg+BLL0BOA0CSrtVP/K40tF8QS56CPTlpo/JT/UDlSXiZjs9adxqgG1CAKHhXjs80rJq5/OwkCUty0h+oQejf3eAR4Q6sdkfh5obi9zcLySJ6AfMGZaJVes13bPrlXMzXtjRNaWg==;7:gNkG+5GVn+LWRbldK6TXrNnBVOslpwKrvxHxuSL0yCI3GNIrk2pmwUvGkZTwtKxSeTiJe0SAoy27UhzOTj9l6WhEtn27CRKV6t4uG1zLzF0LcmQCu24+zzqQPm4BZ6TJIV4xxNJzij1U+qCKDm6dBQ== x-ms-office365-filtering-correlation-id: af5bc491-d48e-4ec0-2d52-08d688afccc3 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 18V4NFIQRPazZkj2yCStctw8vDWYe54wNNJQj7zOQfsiQAXA1H/W45/vypwXg2+ANzzNOJ3c7rc0SPOpY79jOPwNiAdkRMmx9lAog5QW+BSzMb1zu1M9YN+gGzfdM1L366/PWeruPZDaH4WOKWUOarZI8Hqv3yfOawmo+HMrDBRdfh9DIfhAPWEuzVxKsC8/Ld3v7mv1QLe4qO1MWmizextgL4erHwlKR0QStyIfjOZr6Qr6U2gsSP+NUiOjiaxBsIzx66TYlcnLFN837nEbblA8BMhr557ZojDtuxDqDZS1mzWHU2ndp6gdEwwOBcuLl49yrU//1B/SLZRs6y9eecc8fkLQH+mLDXZ+PI6BS3xP8pGFM6/b0ijJ179G1VXGVvXbLBXsikpkP5akOaa2S/1n/CbusdpfUqgZM3dCxYQ= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: af5bc491-d48e-4ec0-2d52-08d688afccc3 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:15.4440 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP MIPS has separate definitions of activate_mm() & switch_mm() which are identical apart from switch_mm() checking that the ASID is valid before acquiring a new one. We know that when activate_mm() is called cpu_context(X, mm) will be zero, and this will never be considered a valid ASID because we never allow the ASID version number to be zero, instead beginning with version 1 using asid_first_version(). Therefore switch_mm() will always allocate a new ASID when called for a new task, meaning that it will behave identically to activate_mm(). Take advantage of this to remove the duplication & define activate_mm() using switch_mm() just like many other architectures do. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index a589585be21b..6731fa5ec4b9 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -166,35 +166,9 @@ static inline void destroy_context(struct mm_struct *mm) dsemul_mm_cleanup(mm); } +#define activate_mm(prev, next) switch_mm(prev, next, current) #define deactivate_mm(tsk, mm) do { } while (0) -/* - * After we have set current->mm to a new value, this activates - * the context for the new mm so we see the new mappings. - */ -static inline void -activate_mm(struct mm_struct *prev, struct mm_struct *next) -{ - unsigned long flags; - unsigned int cpu = smp_processor_id(); - - local_irq_save(flags); - - htw_stop(); - /* Unconditionally get a new ASID. */ - get_new_mmu_context(next, cpu); - - write_c0_entryhi(cpu_asid(cpu, next)); - TLBMISS_HANDLER_SETUP_PGD(next->pgd); - - /* mark mmu ownership change */ - cpumask_clear_cpu(cpu, mm_cpumask(prev)); - cpumask_set_cpu(cpu, mm_cpumask(next)); - htw_start(); - - local_irq_restore(flags); -} - /* * If mm is currently active_mm, we can't really drop it. Instead, * we will get a new one for it. From patchwork Sat Feb 2 01:43:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDF5D159A for ; Sat, 2 Feb 2019 01:44:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C026B28578 for ; Sat, 2 Feb 2019 01:44:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B47FB29C18; Sat, 2 Feb 2019 01:44:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35F4028578 for ; Sat, 2 Feb 2019 01:44:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726449AbfBBBoC (ORCPT ); Fri, 1 Feb 2019 20:44:02 -0500 Received: from mail-eopbgr770128.outbound.protection.outlook.com ([40.107.77.128]:62080 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726183AbfBBBoB (ORCPT ); Fri, 1 Feb 2019 20:44:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B1OhJwsXPaMNHk7z2LFnSceXj0JvYFm20w4IaA87+oY=; b=nCE/35C/JlqJJ4G+kt+KOfm9qRe9CzFnv01fUhALPosHYlaZY80CgTlhNgy5fMKh0ZwqipnyFt/vRIjwEbVbVe4+zG+dh/nvL7Vna2SJ6jHyalDSeNyTTPFhITYJTkhFxyy3f+jw4XfPOS5W2oO2FcIT5P63E8e5fZ7YAXiLvYw= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:17 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:17 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 02/14] MIPS: mm: Remove redundant drop_mmu_context() cpu argument Thread-Topic: [PATCH 02/14] MIPS: mm: Remove redundant drop_mmu_context() cpu argument Thread-Index: AQHUupirPniLJJJn5kmqKYKosWoo8Q== Date: Sat, 2 Feb 2019 01:43:16 +0000 Message-ID: <20190202014242.30680-3-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:9sOOrncfE+SY+Wb7mNLTm5ZPY24bN//ixCZIkO2GNDfdc5TCxiRMEDNz60Q+svKy5r6K+FxolZVwLPe44znjhcvSOWWUmGIujo+SKEBkKx1fdiSMZrZZ3DkT3oeiLkrXds5PyfV0TfTOr7brwLz32UUTaYprPBf7wqYZrbke0rSCYPakY/27ZDqvXz8Znr7+cEOx++A4jrzlfEPUKCYUhnXdq9A6qk/7JMBPXK9o58OpBmnlYwESzcwJcAhZScUHl0Cq/ZWo4UMim4K1ttnVRulOD2+1ZMPURg7vBsbPEiveSKCa5BMczY9x/fju6zC47W/gmuls2mYvZd2pyffLVyScbVfBSJx1vYl6uLPuHMN/Q+ekJ0LhY9+wOLdYqo5+P2LU9JA0Adyr6/rPxbpUk8dPS4xhTMcSw3GKNUWmG+9P7yIoUPpIt5rHHMqsaSyHknxXbTb8z6j4NBeW5u3IZA==;5:oudhNnuo+d+EDOqsSvNxB+vFUU6+DYf8L4iI6ivi2INOjB5yVSTzd8icYgsH/9SdmB1MPmHzInE/39lMhNQQuGQkma5RrPXUneCihKcFObDZ2HGOla9ZJ+FJabDBnsA6a/R3kdZSzDQF0jcscLDskkAxPhsey1GXs/4xIH/9OLjcCgtDXHb4x88WV9OhnGMZKp2Wew4GZ/u8Kog6eXvEhQ==;7:ErtEPKHnWjLjVdcACnuKlJazsWqubzjhutNgzrF3kvkhpQaXIHCdCe0Qvy8Q6HCC2zbCOKxLyVgg0yKl1SM4N7lC2KTbpkBTeRzIjIkBGE7z9k6gItQ2ook3x6DQZjhg9At7gz+9Dj78I9XccoqFEw== x-ms-office365-filtering-correlation-id: e7a73901-ef0d-4768-96e4-08d688afcd50 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: hPJo4ePgLawPE8C92ybi2DIMNawBfbglz1+XJIh/0i+lriw2cZ7f6NZQmCnb4qnUM/ufUQHLZ1L0XeFL3tWwExtCSuKfb5sseERdVwNfH+SdUVtzKl5AXReCHJO0OAv4xZwKy+Bak/7fgXmHczqyqeMOpb4I9GC+kf+S7hFLz2f8kKueXpZmv+JH8zOCfXBjtzqzSkrUKtBZ1DM67X6C0FTlpU+iEHP+LBR0/oRK2CBCaofi89Qj09YOaGIABUXwhmAPHp2zIUUmLIGf2/IlPQ4PeiZbOswKxs6vCoIeL83ANjwtM/DrC/wYza2//eP+whUJFe8e/aJV2XUjSYwgnNZCMJARoUhGGRvkT1VqnSaoWqd2ua1EboBxMtPvDguQ5g/GnOAJhlVv035G2GVniIldtQstMKepbgA6JpZnN9o= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7a73901-ef0d-4768-96e4-08d688afcd50 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:16.3698 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The drop_mmu_context() function accepts a cpu argument, but it implicitly expects that this is always equal to smp_processor_id() by allocating & configuring an ASID on the local CPU when the mm is active on the CPU indicated by the cpu argument. All callers do provide the value of smp_processor_id() to the cpu argument. Remove the redundant argument and have drop_mmu_context() call smp_processor_id() itself, making it clearer that the cpu variable always represents the local CPU. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 4 +++- arch/mips/mm/c-r4k.c | 2 +- arch/mips/mm/tlb-r3k.c | 4 ++-- arch/mips/mm/tlb-r4k.c | 4 ++-- arch/mips/mm/tlb-r8k.c | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index 6731fa5ec4b9..dc45690cbbf5 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -174,13 +174,15 @@ static inline void destroy_context(struct mm_struct *mm) * we will get a new one for it. */ static inline void -drop_mmu_context(struct mm_struct *mm, unsigned cpu) +drop_mmu_context(struct mm_struct *mm) { unsigned long flags; + unsigned int cpu; local_irq_save(flags); htw_stop(); + cpu = smp_processor_id(); if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { get_new_mmu_context(mm, cpu); write_c0_entryhi(cpu_asid(cpu, mm)); diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index d0b64df51eb2..1eca2b7e8a28 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -700,7 +700,7 @@ static inline void local_r4k_flush_cache_page(void *args) int cpu = smp_processor_id(); if (cpu_context(cpu, mm) != 0) - drop_mmu_context(mm, cpu); + drop_mmu_context(mm); } else vaddr ? r4k_blast_icache_page(addr) : r4k_blast_icache_user_page(addr); diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c index 6f589e0112ce..05a5ddccd9da 100644 --- a/arch/mips/mm/tlb-r3k.c +++ b/arch/mips/mm/tlb-r3k.c @@ -75,7 +75,7 @@ void local_flush_tlb_mm(struct mm_struct *mm) #ifdef DEBUG_TLB printk("[tlbmm<%lu>]", (unsigned long)cpu_context(cpu, mm)); #endif - drop_mmu_context(mm, cpu); + drop_mmu_context(mm); } } @@ -117,7 +117,7 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, } write_c0_entryhi(oldpid); } else { - drop_mmu_context(mm, cpu); + drop_mmu_context(mm); } local_irq_restore(flags); } diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 0596505770db..6c99dfff71b2 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -115,7 +115,7 @@ void local_flush_tlb_mm(struct mm_struct *mm) cpu = smp_processor_id(); if (cpu_context(cpu, mm) != 0) { - drop_mmu_context(mm, cpu); + drop_mmu_context(mm); } preempt_enable(); @@ -163,7 +163,7 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, write_c0_entryhi(oldpid); htw_start(); } else { - drop_mmu_context(mm, cpu); + drop_mmu_context(mm); } flush_micro_tlb(); local_irq_restore(flags); diff --git a/arch/mips/mm/tlb-r8k.c b/arch/mips/mm/tlb-r8k.c index e86e2e55ad3e..20fa35d21776 100644 --- a/arch/mips/mm/tlb-r8k.c +++ b/arch/mips/mm/tlb-r8k.c @@ -55,7 +55,7 @@ void local_flush_tlb_mm(struct mm_struct *mm) int cpu = smp_processor_id(); if (cpu_context(cpu, mm) != 0) - drop_mmu_context(mm, cpu); + drop_mmu_context(mm); } void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, @@ -75,7 +75,7 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, local_irq_save(flags); if (size > TFP_TLB_SIZE / 2) { - drop_mmu_context(mm, cpu); + drop_mmu_context(mm); goto out_restore; } From patchwork Sat Feb 2 01:43:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9DDE6C2 for ; Sat, 2 Feb 2019 01:43:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBDF732F13 for ; Sat, 2 Feb 2019 01:43:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C072E32F25; Sat, 2 Feb 2019 01:43:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E87A32F13 for ; Sat, 2 Feb 2019 01:43:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbfBBBnd (ORCPT ); Fri, 1 Feb 2019 20:43:33 -0500 Received: from mail-eopbgr770108.outbound.protection.outlook.com ([40.107.77.108]:47642 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726246AbfBBBnc (ORCPT ); Fri, 1 Feb 2019 20:43:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WUEeYxYPuAdNu86RAms/S7U3Qn4grV3G67M8j4FhsYQ=; b=feBoHz86/1Ny2hZhbOaHAc02rVFokj8+eZErXLkUT6Tz/t8B9+WIROjHBWIzH6aY8GXvHsoD+3vdLPOafyg0n4sBXkP9PdHQY8Nyap8zupcPD3GvAzD4AnDql0ivEACskH1T8XmZM+Dtb2sw+YOeQtImf6chRINO9FZeI5Tpuzg= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:19 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:18 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 03/14] MIPS: mm: Remove redundant get_new_mmu_context() cpu argument Thread-Topic: [PATCH 03/14] MIPS: mm: Remove redundant get_new_mmu_context() cpu argument Thread-Index: AQHUupirm8zF2D9DNUyMJJ+DDypXHQ== Date: Sat, 2 Feb 2019 01:43:17 +0000 Message-ID: <20190202014242.30680-4-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:qi68PoY0bc0LhB5Uf+6Zg9bUq6YID7RLo6AWd8JPfPOFZX0LcIkrnSiEsg/GRZHvN5BER30mWhZSGbPSJPOBCTgboXiggEeRZyPAryIw86NUYnzRLfjJxYNU0NFR7RujIbd1DMw/cORltxwGwTVO0UO7b7uPlmoj24lfYR1OU3UWChGtsJ86Rq0SFseCXQbTLbXAMcBIu21IzSXIhrPD3MYeex91FE7Mfb46WPIQMSDtDyJ9023vN3vlolxcRFCsh6yUmUZPSr2vFxmBDCBf1x0VyltWy0XhCjC4Hl3UTLhVz1snDgLZTqYHiKDK/qMgEZpc8kspD67u303yMwUYTNTbazwhDsV4aXKgkI3v1nB6mv2Czd3Xuscgr67xhafa2KHCXGZeJ6Bh2NHid/DEfp8+yP2qHdBDvm61EL04QXoCi3pGiVtxwkrwyBxv5Jjpj9RX6j+8S82H36DMi1LE4A==;5:Blt2iKGgKkJtZhUM2FGP+jYtWiLpnzKGbtpfHOtpiR9yF0RpWXaw+Qxb6rvnWqhl1v02jC8XnepEJgx5Gj0SUgryREE+bu4ehfN9dO9XefTsVqOeXk8uhh7XWC1ZnW7hHniZMtjCYuENtDiZHcJ9VQIhFERR/fkgDwNx+ZzKswpr0VTbilvunG9Zu0VLa2p52RPA052SMDQSCSr0UpbHsQ==;7:7laJkCwYY47hIgJIBtf7cIIshBIyQNIex3qtt1lVOgyM5DdAfymWPQ+XnOBikWC0hkITcT1Bg8PjRxcFaElKG1wXZ31CimHuhr8KyadNOhvwFYxPc2JYeQCxP2Qrb5euzshDgoKyk4tODEoer1EP0g== x-ms-office365-filtering-correlation-id: cc8f921b-5606-4a95-876d-08d688afcddf x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: dlNJUIKrbLuSqo9lnn2EpM8qDyji/FzIo6yJiHWYAudV6D4w1T8IbjfKL30ktv1DQNIjcIawd5cwkseuBCQRB0u03UFYrlVQLx4TCnTfWOpx3STuh7OTDqyW+hLkjODZkosc2YAa27kb/leMyFmM2RX1/RGMRHps4bl9hy2tXlCurqw3R1tSHNOq3GcBBzDxfK6wQZQWWbKGaut+kiF6kd2osZYxRPtF+Y5UrbEQiOB2WkPR2EfvkxkrknJzpJ+ihM/WMeNHL9JZPff2oV2IgTdtpSh9Xr35s4MjcwtWM/m5rZw6O4+lUNsRcipJAJ+OAgFLlrpslTFMZbuSKKXOPFP3zcyRv3FDHAfQW18SJSd6HaBRgzEO0whxANzPp8nSXDE3IlaTouEX2ZnuM264Q8qdIYQBcDbO6E8hw+7qOL0= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc8f921b-5606-4a95-876d-08d688afcddf X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:17.3085 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP get_new_mmu_context() accepts a cpu argument, but implicitly assumes that this is always equal to smp_processor_id() by operating on the local CPU's TLB & icache. Remove the cpu argument and have get_new_mmu_context() call smp_processor_id() instead. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 12 ++++++++---- arch/mips/kvm/emulate.c | 2 +- arch/mips/kvm/trap_emul.c | 10 +++++----- arch/mips/kvm/vz.c | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index dc45690cbbf5..0d050d781737 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -100,9 +100,13 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) /* Normal, classic MIPS get_new_mmu_context */ static inline void -get_new_mmu_context(struct mm_struct *mm, unsigned long cpu) +get_new_mmu_context(struct mm_struct *mm) { - u64 asid = asid_cache(cpu); + unsigned int cpu; + u64 asid; + + cpu = smp_processor_id(); + asid = asid_cache(cpu); if (!((asid += cpu_asid_inc()) & cpu_asid_mask(&cpu_data[cpu]))) { if (cpu_has_vtag_icache) @@ -142,7 +146,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, htw_stop(); /* Check if our ASID is of an older version and thus invalid */ if ((cpu_context(cpu, next) ^ asid_cache(cpu)) & asid_version_mask(cpu)) - get_new_mmu_context(next, cpu); + get_new_mmu_context(next); write_c0_entryhi(cpu_asid(cpu, next)); TLBMISS_HANDLER_SETUP_PGD(next->pgd); @@ -184,7 +188,7 @@ drop_mmu_context(struct mm_struct *mm) cpu = smp_processor_id(); if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { - get_new_mmu_context(mm, cpu); + get_new_mmu_context(mm); write_c0_entryhi(cpu_asid(cpu, mm)); } else { /* will get a new context next time */ diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c index ec9ed23bca7f..ca8347372427 100644 --- a/arch/mips/kvm/emulate.c +++ b/arch/mips/kvm/emulate.c @@ -1016,7 +1016,7 @@ static void kvm_mips_change_entryhi(struct kvm_vcpu *vcpu, */ preempt_disable(); cpu = smp_processor_id(); - get_new_mmu_context(kern_mm, cpu); + get_new_mmu_context(kern_mm); for_each_possible_cpu(i) if (i != cpu) cpu_context(i, kern_mm) = 0; diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c index 6a0d7040d882..503c2fb7e4da 100644 --- a/arch/mips/kvm/trap_emul.c +++ b/arch/mips/kvm/trap_emul.c @@ -1058,7 +1058,7 @@ static int kvm_trap_emul_vcpu_load(struct kvm_vcpu *vcpu, int cpu) mm = KVM_GUEST_KERNEL_MODE(vcpu) ? kern_mm : user_mm; if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) & asid_version_mask(cpu)) - get_new_mmu_context(mm, cpu); + get_new_mmu_context(mm); write_c0_entryhi(cpu_asid(cpu, mm)); TLBMISS_HANDLER_SETUP_PGD(mm->pgd); kvm_mips_suspend_mm(cpu); @@ -1076,7 +1076,7 @@ static int kvm_trap_emul_vcpu_put(struct kvm_vcpu *vcpu, int cpu) /* Restore normal Linux process memory map */ if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) & asid_version_mask(cpu))) - get_new_mmu_context(current->mm, cpu); + get_new_mmu_context(current->mm); write_c0_entryhi(cpu_asid(cpu, current->mm)); TLBMISS_HANDLER_SETUP_PGD(current->mm->pgd); kvm_mips_resume_mm(cpu); @@ -1113,7 +1113,7 @@ static void kvm_trap_emul_check_requests(struct kvm_vcpu *vcpu, int cpu, /* Generate new ASID for current mode */ if (reload_asid) { mm = KVM_GUEST_KERNEL_MODE(vcpu) ? kern_mm : user_mm; - get_new_mmu_context(mm, cpu); + get_new_mmu_context(mm); htw_stop(); write_c0_entryhi(cpu_asid(cpu, mm)); TLBMISS_HANDLER_SETUP_PGD(mm->pgd); @@ -1230,7 +1230,7 @@ static void kvm_trap_emul_vcpu_reenter(struct kvm_run *run, */ if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) & asid_version_mask(cpu)) - get_new_mmu_context(mm, cpu); + get_new_mmu_context(mm); } static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu) @@ -1268,7 +1268,7 @@ static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu) /* Restore normal Linux process memory map */ if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) & asid_version_mask(cpu))) - get_new_mmu_context(current->mm, cpu); + get_new_mmu_context(current->mm); write_c0_entryhi(cpu_asid(cpu, current->mm)); TLBMISS_HANDLER_SETUP_PGD(current->mm->pgd); kvm_mips_resume_mm(cpu); diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c index 74805035edc8..d98c12a22eac 100644 --- a/arch/mips/kvm/vz.c +++ b/arch/mips/kvm/vz.c @@ -2457,7 +2457,7 @@ static void kvm_vz_vcpu_load_tlb(struct kvm_vcpu *vcpu, int cpu) if (cpumask_test_and_clear_cpu(cpu, &kvm->arch.asid_flush_mask) || (cpu_context(cpu, gpa_mm) ^ asid_cache(cpu)) & asid_version_mask(cpu)) - get_new_mmu_context(gpa_mm, cpu); + get_new_mmu_context(gpa_mm); } } From patchwork Sat Feb 2 01:43:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDB34159A for ; Sat, 2 Feb 2019 01:43:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD60432F13 for ; Sat, 2 Feb 2019 01:43:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDF3F32F25; Sat, 2 Feb 2019 01:43:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7ADE932F13 for ; Sat, 2 Feb 2019 01:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbfBBBne (ORCPT ); Fri, 1 Feb 2019 20:43:34 -0500 Received: from mail-eopbgr770108.outbound.protection.outlook.com ([40.107.77.108]:47642 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726246AbfBBBne (ORCPT ); Fri, 1 Feb 2019 20:43:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TUVCiA+W5cDJYlJkkUIpQTxOsT37cCv+s304O2TP4yQ=; b=H7RhJwt7f7T8czVU9Xpxd6Uws6EmyUDESKTgkIG1pOzHp5hOOk8UZKeeT8Nu+ecH5bGaCawJWeGl5ybSpOOc9qA56c55R9k+Nbq8EbTOc5XD1FuakmLjL9s4oJmx+ZjGP5RYjQbmPkdpmzH6SlzSZWni4r+BZwDC4GJuXCv65Q4= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:20 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:20 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 04/14] MIPS: mm: Avoid HTW stop/start when dropping an inactive mm Thread-Topic: [PATCH 04/14] MIPS: mm: Avoid HTW stop/start when dropping an inactive mm Thread-Index: AQHUupisV3Jm+Q5KfEiJf5WBtrtBxg== Date: Sat, 2 Feb 2019 01:43:18 +0000 Message-ID: <20190202014242.30680-5-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:xhAhpiiOCQ/EM8FcTCBYHa3RAJ9uQGdDqPntrXqSY5WFlPGc2a8kLgrO+nj2urk4X1DwYT4J2W0tnCF+IS4d3n40rjtRYIScDFxprNcwNBqkJNdKjHPW1vCEKSTpCkMlQuvGywiS/EK3sToRaOjF5DX8+PgnVcSp7rKVCWyBAzt2l+scAmHykY6aP0Z8HKXzKBUNFvwoRYNEApRO/e4AvYDsayUo9WBZj1WQPIjRZ1kxrl6fkKuHwu1a1tL/ZRp1VboqEzomG3RPkKRQ1dZyz8X1kxlAko9J4W0Q8ED02yn2skzqHRagOvU6HzBLNqnNqnpw12c07TK2Fetd/AXNVKK2AhXQ3x0P9u5t3jcg5i13PCcSEyRi/d9v2i3Q9CgdbgO5yYZXC5L3TdMmfzjKiYpEjJ+Tb42Ogo4KxkE7f5B+VPpsvhdt9WaJrTmnx5H4q4BGwh2XnwtFzdKfSPkjyA==;5:lvMsjvcPT8JWtJLPMOtu9Z/3+5zMbwuTPzs8Wax6/gmPvkHFUahAt7JC16ZP3yU0FPYJTwB5Tpgy/7st8k0eLzgW9a5R2v36qcX97JOFna4A2i1M+LyKxnY5TVlr/s9YQhj47pt1Gdj57Re5RGRRWbnVrkfiAvOic+CDMGOqBUKFMF9w4krIerctPBsnpHXiT1rRpXHQzaZdJvOB8oS1OA==;7:U4QeVOHN9id6DV/52ixwNckI4h+Ih3rEH6ETm3eNzfzWkUMwMpTuJMzygu745B6xNLerQEy944LKvjwXmHXIKNvF0xC9ipZcJ+/est1HWbCSfW4qpE9eZxRmAX9PiKAopyvVyFm+fS2rCIwIZ+L8NA== x-ms-office365-filtering-correlation-id: 4883a327-ec5b-4dd7-55cf-08d688afce61 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: zCZQbjMWVooJLwHrn3v1oG7YykgEHENsvQ61ZRpT1IJQ6BOjYQY9or60ZPbGzlH5dqYokqNFAvFmJeopvUaE2kJMBLeMvVR3NoUtyzQB/kzCy74Nl4UtTtlabT/VtIE0kHOQ1Ss61iUfGEKw1edXvXuxVgi1MNhozU6ta1wSjQ7rSWRENoE2RCVe1kqbLhjysHm/JPSUIi0u4QvwMP66izUCSD3oYuQqpzmGYxS6jdz6xLeDGqSYNk0CGb/+32oerGTHjspafOtcmOPTLGjYZwf0UT94YwC7sq+y3IlWRbFwg9aeP9x4h0JGYWsA1m0anC3CanvmlUVaQ3LWthgqwDtkm/jMwe0wXQt/a4Z9xxioAxg0Ld/AtMRyuf7RDmo0vgz0CYza+X6Yb+5tTfGnQfnAcYN/g8x4y7O3SOHGoAk= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4883a327-ec5b-4dd7-55cf-08d688afce61 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:18.1602 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If drop_mmu_context() is called with an mm that is not currently active on the local CPU then there's no need for us to stop & start a hardware page table walker because it can't be fetching entries for the ASID corresponding to the mm we're operating on. Move the htw_stop() & htw_start() calls into the block which we run only if the mm is currently active, in order to avoid the redundant work. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index 0d050d781737..5d0a73a5cf40 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -184,17 +184,18 @@ drop_mmu_context(struct mm_struct *mm) unsigned int cpu; local_irq_save(flags); - htw_stop(); cpu = smp_processor_id(); if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { + htw_stop(); get_new_mmu_context(mm); write_c0_entryhi(cpu_asid(cpu, mm)); + htw_start(); } else { /* will get a new context next time */ cpu_context(cpu, mm) = 0; } - htw_start(); + local_irq_restore(flags); } From patchwork Sat Feb 2 01:43:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C286159A for ; Sat, 2 Feb 2019 01:43:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E06632F13 for ; Sat, 2 Feb 2019 01:43:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3254D3304A; Sat, 2 Feb 2019 01:43:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2C8332F13 for ; Sat, 2 Feb 2019 01:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726488AbfBBBnf (ORCPT ); Fri, 1 Feb 2019 20:43:35 -0500 Received: from mail-eopbgr810108.outbound.protection.outlook.com ([40.107.81.108]:62863 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726449AbfBBBnf (ORCPT ); Fri, 1 Feb 2019 20:43:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jZLQYO7Kna0oOxB9Oxzc0bxgpDu658l7OFUPw7bDHL4=; b=EwsUMLXkpBzDZn+n4lmMD/1aajXkMDe6zokIZ3V6lLrgbwmFtEF4vgchakN0A27dtallZyzxVuaOkD/CSKxKV1vAHcEIUjbeVA2zesr4i4SvIjruGtY0WV1C52wKynwDhd9S7UZb6YJ1iCrei7RdtucWWDWconORc0Oo7yVrhWg= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:23 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:23 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 05/14] MIPS: mm: Consolidate drop_mmu_context() has-ASID checks Thread-Topic: [PATCH 05/14] MIPS: mm: Consolidate drop_mmu_context() has-ASID checks Thread-Index: AQHUupis8W8LOrjv3EuxCruob30+/w== Date: Sat, 2 Feb 2019 01:43:19 +0000 Message-ID: <20190202014242.30680-6-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:BtmowXMP4T0SdFmILQeNUmkHASedPq2MmGzspG8Z8UkxbPPKsGGvZDM3rMcA+n+o9NWc25G6kXND7TxbDDrDXSw0/Rw6iSoZd9dIHcyc+R2hZUfegUz5WZ7Fy9M6VGPQIsZ/HA5HfroWtX2Q52yaFeozjZ4e4pG3nXHAGxK+pbbzFcCPmK+p0sZx8GuJSOtCdi/eHJUIzN7vz+qeB4N/Kx+dEAWMaKa8tXIkQYikS/7fMaj4QzPiudGgmq/aNgp7Pg0wpG+q+JDBwq6fBhjsfz43giLdXwxjzZb3STtqBty7jPU+hKSxIBcVwGpbibSCK7SC8gurKzCskwRDwh+hKLWRou6dneRhIDmvBiabdSNF2vzcHaFK7kkhfXF7u0NrOc3JE6whoROc2prv0IwOJcZ67SuDrSQmdz+9cvrN04vxnf1k4weizWFQOexmT8gPqqyNGxLezTbBRjLcTwlCRg==;5:svcnaWmJM1eb5VXhwxSqysKbgamuYSNwbTd+5v+a2CsraRviDVzapEio1QAyTusigF7y+FU79xsWW70X7H/JJSbk34XL/KdY4W16l8ytWguAOxjRx0AWZXUuOFpr1eNa+qO+na4vK4g2p/JovGvrNsOT5GOwHc3pcTedoD1lD43zvlpqFg0L8a/jt1X2kK00TcDaWj/311dw1DzYSHyoZA==;7:Ol9sN3v8WpfWoDpoZPxbWRzPzPwq+nVIRq8F4SZBUttDWzQ+Sa2uWS0zbmp1jd5HJQj0V8A85k6faRTmZjLYvbcGNvHVtpetUjtue4cqx/+CtiwJW7OE8P9WitFaTAi7/kfHQs1LztciSHhucREN3Q== x-ms-office365-filtering-correlation-id: 662fecae-6b2b-4439-621c-08d688afcef6 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(6666004)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 1pw5oa+A4C/nDNSgwCgoDqWNSTjhXHCQRX7EfR4PiNtCSktV5HzaYWjAzyKmQ4KL6ga3kHIEb/Fuzn791XXZ96oKVz9H3STcm709AOooXEzVgRtEuD14CJJ4e+CAxEDM7AkJU12EUIqb2wntPD00TtAvjFEMtjgGHg81eqoMUXqpxpc3WBszIaOk+wgss8Qs2zGBKkXcD2EZYspiStmuAxLjzawjOAqp42zzFCLrwBLM9biQC4hhMG0M50VC39QK4NgGqm1A6kP7iQKcwsduaiU88JTR056HQ/vx3e8WfOmikg7PPl2bDk4nevOOw8UF3g5lcP8A2tGd8CPm7Qs9dLyk6ey7moiagpFVYv1dFvijBkHgNrRIhvIuHBF73/fXglJFd+G6ze51wSEztWCOj11wywDvjcUpM3YmLgqFr1M= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 662fecae-6b2b-4439-621c-08d688afcef6 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:19.1360 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If an mm does not have an ASID on the local CPU then drop_mmu_context() is always redundant, since there's no context to "drop". Various callers of drop_mmu_context() check whether the mm has been allocated an ASID before making the call. Move that check into drop_mmu_context() and remove it from callers to simplify them. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 4 +++- arch/mips/mm/c-r4k.c | 5 +---- arch/mips/mm/tlb-r3k.c | 8 ++++---- arch/mips/mm/tlb-r4k.c | 10 +--------- arch/mips/mm/tlb-r8k.c | 5 +---- 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index 5d0a73a5cf40..1b8392dcd354 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -186,7 +186,9 @@ drop_mmu_context(struct mm_struct *mm) local_irq_save(flags); cpu = smp_processor_id(); - if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { + if (!cpu_context(cpu, mm)) { + /* no-op */ + } else if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { htw_stop(); get_new_mmu_context(mm); write_c0_entryhi(cpu_asid(cpu, mm)); diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index 1eca2b7e8a28..248d9e8263cf 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -697,10 +697,7 @@ static inline void local_r4k_flush_cache_page(void *args) } if (exec) { if (vaddr && cpu_has_vtag_icache && mm == current->active_mm) { - int cpu = smp_processor_id(); - - if (cpu_context(cpu, mm) != 0) - drop_mmu_context(mm); + drop_mmu_context(mm); } else vaddr ? r4k_blast_icache_page(addr) : r4k_blast_icache_user_page(addr); diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c index 05a5ddccd9da..60eb7a114440 100644 --- a/arch/mips/mm/tlb-r3k.c +++ b/arch/mips/mm/tlb-r3k.c @@ -69,14 +69,14 @@ void local_flush_tlb_all(void) void local_flush_tlb_mm(struct mm_struct *mm) { +#ifdef DEBUG_TLB int cpu = smp_processor_id(); - if (cpu_context(cpu, mm) != 0) { -#ifdef DEBUG_TLB + if (cpu_context(cpu, mm) != 0) printk("[tlbmm<%lu>]", (unsigned long)cpu_context(cpu, mm)); #endif - drop_mmu_context(mm); - } + + drop_mmu_context(mm); } void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 6c99dfff71b2..ba76b0c11d38 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -108,16 +108,8 @@ EXPORT_SYMBOL(local_flush_tlb_all); these entries, we just bump the asid. */ void local_flush_tlb_mm(struct mm_struct *mm) { - int cpu; - preempt_disable(); - - cpu = smp_processor_id(); - - if (cpu_context(cpu, mm) != 0) { - drop_mmu_context(mm); - } - + drop_mmu_context(mm); preempt_enable(); } diff --git a/arch/mips/mm/tlb-r8k.c b/arch/mips/mm/tlb-r8k.c index 20fa35d21776..c938d6b497ef 100644 --- a/arch/mips/mm/tlb-r8k.c +++ b/arch/mips/mm/tlb-r8k.c @@ -52,10 +52,7 @@ void local_flush_tlb_all(void) void local_flush_tlb_mm(struct mm_struct *mm) { - int cpu = smp_processor_id(); - - if (cpu_context(cpu, mm) != 0) - drop_mmu_context(mm); + drop_mmu_context(mm); } void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, From patchwork Sat Feb 2 01:43:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B9C26C2 for ; Sat, 2 Feb 2019 01:43:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D7BF32F25 for ; Sat, 2 Feb 2019 01:43:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61F6E32F28; Sat, 2 Feb 2019 01:43:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D369332F17 for ; Sat, 2 Feb 2019 01:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726449AbfBBBnf (ORCPT ); Fri, 1 Feb 2019 20:43:35 -0500 Received: from mail-eopbgr770108.outbound.protection.outlook.com ([40.107.77.108]:47642 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726246AbfBBBnf (ORCPT ); Fri, 1 Feb 2019 20:43:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eW2ksCaE5mDikXhXOclHUNVcxX09ADbu4/m9+lJaOUo=; b=IV23nV/GGqtgcUj0jzQsjMq6k6QfwIGgZsFmRPylao6RjYOafLn9gfdEnrY0Zm0k8md9lRI0dWhar8K9w/13dNho4mKQhW4+f/I2uoHObQ0wWMKjUDRkGpaYkqByoAuoUaCUztUWyCtgc+7E2InEu6jfItBvUzT1+zXnUj3kdrU= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:23 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:23 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 06/14] MIPS: mm: Move drop_mmu_context() comment into appropriate block Thread-Topic: [PATCH 06/14] MIPS: mm: Move drop_mmu_context() comment into appropriate block Thread-Index: AQHUupitw3ETzl0Kikumtfk/uytlWQ== Date: Sat, 2 Feb 2019 01:43:20 +0000 Message-ID: <20190202014242.30680-7-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:uSsbiElbHzLrwWAfxcnXi8lSVFNWAUOIy203knd/AIAqWYdMTQ4dJktjk1mkbUjIGHh4njLIdRyHieQpUJRdkzvUpYe3tzi+4OwzPVni2mAJLskiUQz/1cqnXCmgDmPP8pp5vZgRu6NG44dw3gTDTANpiUPJoGY7JWMrRuKT72m0Ld88CRii+jrk9alll/ZRtluWQKh672vxrUFIvqrHuZau8sxwxVPRX0cp3yOuU+A/l9OSCwTwkeY6IBH8JjqN28S9GR6YwJHC8wU9ojdKn8+SZuzDOAqArRNG0u1H0ZDg5IcKibBQUNwqXVMx2/aw4hD1ncPUVRZXjLRB2wJqo4YJ4n6ISNKoiUSSkvZufh6aDHTaqqr0OTZyZUDjLoAhwXR81RyVpjoz9BIIuqm/UKL+lxkKtJYVUv0jJ6sknKzHEg0UTit2qUmntkPfo7ZXsIjuWLoYsAWSi4yqo8KGug==;5:ZgWZ7sFAVsMUuS5bVicBu3tJia/WY+nVYHwV3MSVkmLo6CVkQqQVLhwQQ+U5A0FYJ4GdoMHzGW41taqValZ2fPXAHd3Gi8i1cARCdjIgBGxh1kYXsRYy9gQjUhLIXYogD0YDxPMYhbiSJk/0xdbcf3hosMHZ6O4JMFTZGBplGq95/oT9IbMC/nVhm3L4imxcwEpKpJ9HXQK0Z1ANQ7Oonw==;7:PQxo7ofmnXN52Rv3b207q9J+tjqpB6aRT/WpODE4r/48Z39RSRjbK9SyDkCDqlUlo/s9ZBAbBHimpV08FT62bbrMdwpQxrl0eh7IB2S4/oZ/2tObhyUl683R1RdfheW3Pr9lOpkSqqRAo+yhuS6a/w== x-ms-office365-filtering-correlation-id: cb42c04a-165d-4796-657b-08d688afcf7b x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: EWGkCNiUmVOzqvPriDKJoNTNyEcoqfvvA1XbBeUDEBdBXy3+k4xMMgeJz/0jNnPtEzAknOPEt3WDb1UcbfW/7wfKpuoUPb65d3LnC2jWz/7DJxKXXmRJkOw1MFXhqC3tDQXYFYo+tmFki0epwOEKVFJJ2YxGBw3JBCT+JvRTOpVpk8+vS5/ecMYevaFXLX/Hx9Z2/lYe1SGBo1UCbTcHxlJ4UNlmsbmyJ0vMHYm9e3vmpY0V3PDLKv/D8sqjFpWo+r6oTgK/y5ejd9fUwGuTLhJxQN6xgKwAaryO127VzIiH5itZaJyH16qGEKgecE5kS9xEZXelMTQqShaiTgEEc+nFLpdLWfg7sgllDi8ojzXu7MJJvM/TSmLXYG/VOGAsGcRiO44XqFmAR5lq1E+hOBfJDuznRCHphpl2pvPb21s= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb42c04a-165d-4796-657b-08d688afcf7b X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:20.0067 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP drop_mmu_context() is preceded by a comment indicating what happens if the mm provided is currently active on the local CPU. Move that comment into the block that executes in this case, adjusting slightly to reflect its new location. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index 1b8392dcd354..752ebda82cdd 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -173,10 +173,6 @@ static inline void destroy_context(struct mm_struct *mm) #define activate_mm(prev, next) switch_mm(prev, next, current) #define deactivate_mm(tsk, mm) do { } while (0) -/* - * If mm is currently active_mm, we can't really drop it. Instead, - * we will get a new one for it. - */ static inline void drop_mmu_context(struct mm_struct *mm) { @@ -188,7 +184,11 @@ drop_mmu_context(struct mm_struct *mm) cpu = smp_processor_id(); if (!cpu_context(cpu, mm)) { /* no-op */ - } else if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { + } else if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { + /* + * mm is currently active, so we can't really drop it. + * Instead we bump the ASID. + */ htw_stop(); get_new_mmu_context(mm); write_c0_entryhi(cpu_asid(cpu, mm)); From patchwork Sat Feb 2 01:43:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 031DE159A for ; Sat, 2 Feb 2019 01:43:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E830D32F13 for ; Sat, 2 Feb 2019 01:43:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCB573304A; Sat, 2 Feb 2019 01:43:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BACEA32F13 for ; Sat, 2 Feb 2019 01:43:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbfBBBng (ORCPT ); Fri, 1 Feb 2019 20:43:36 -0500 Received: from mail-eopbgr810108.outbound.protection.outlook.com ([40.107.81.108]:62863 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726506AbfBBBng (ORCPT ); Fri, 1 Feb 2019 20:43:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=08M9DvEqjVw/kk7l4sYM71dKbNepFroYMdizxMZcu+Y=; b=rzFumBywmcKAizl4YiPI3ewazPyHn4mOCfXH/zGcsoKt/yJmmqDTT5Rto09VzA1zSq6vlgbwZip0wSkr0H4N7WWsya3iJPvACHixphTVbWKcfn5POMll7y/Eknc09a2U0FtBMlydpgZQosVbZKMRRiH9TxEhgR0n8q3wyvbamnM= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:24 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:24 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 07/14] MIPS: mm: Remove redundant preempt_disable in local_flush_tlb_mm() Thread-Topic: [PATCH 07/14] MIPS: mm: Remove redundant preempt_disable in local_flush_tlb_mm() Thread-Index: AQHUupitlEdYKgFZBk+A78mGWOv45Q== Date: Sat, 2 Feb 2019 01:43:21 +0000 Message-ID: <20190202014242.30680-8-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:SDfnSGi+gf5bL0ztau8B+qxNWCFXUnNSdUjt0eoCPfS3PQvFAnTTS5/UiiwcQGaDqh2+RFfQX6KNu8wKQGZ7l66XiXN1JJxw4kUwyHW+4MOdG2jJFv9VCuyMotWPVbRYLetapbOX3AKOZhjPBYvzJ9ESKaT/9U2Fkc6LSRZ4XC0uk5m9efgHu4IKAUZ55KKioeCLn8b2+vViENb2zr7sDFaLBQWXda1I0r6z2Fzt5yTUdkcfHg3pWlZ/ADgV0U8tCXzAe5OWKvXr5ALOZH8JDBHVeCb5hfjlpumen3mjXJlM5M5pdmkonwRcd2UcDD1aiJxWxWrmqbxcN0rwd7HxRMZonigSpWo0fZAO7H+BfJOrVMtp70hoSg5SAFoKHiBfy8cw6+ZCh1+L9B9NdxbnErJrszaYY9GcC8HFFt0NwIq6C0kKlNAFieOBNmMjQSd5NIUQmWIc6W3MuCfUfH4ECQ==;5:5YUsMgMgKqZdbGW1mZcwaKuYL1IC/uDojb+wPzByqoWUIUWCXMueeZTCPUVoaBlqKg9fZeRw1YzuMDPt97VtNOsP3dlkJOdfHv8QhMUSc10CtZuY0PsZoSknVLxpbatYMElKBqBJ0Esq4tus+WXGA4IvAne6/EDmrurs8hHyrIeZMVf/pOcIyFN9LfTdV5iYctnE6RGafeUuzUTqMJtyvQ==;7:K8CLKm6Gpb3E9r7JygpNjqNbCNDNWhjjFz54Okr5bzZckt/t0TIzx3Gp7eJSoViTWwsGLtL15o1mkgYE2c8qpBoCwuXV73n/lBwCg29YnD724CTv8QHxWUSbmNHUdy0mzoDIoU5QOrqlFjIkK40IKA== x-ms-office365-filtering-correlation-id: 05a1e3d8-c0f2-4588-5374-08d688afd001 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(6666004)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: DKjq4Vuo46NFr1mKzzw2l/pG2XArq9LOvxhu9ndcfQpfV7j8qKQ5CigkOtoxZKwPAtz0J/yH/ekaFFqRj6A7vkyz2dvBcr1p67nUfbmx0bCJ8ETfRjMf5C9xkm+uvcGXyCivTKyl8Zy5R7fzBFERL+gknziCwBQc00SyihOz5vfs9ZCzB+w2Rh0MnmXy67IW3Jiq9T9unRfzo/lc0R0z74mv+1CfYIKnlcOZhM2MByYYr8rwYUl9E4JpSd29Q2LNQyDWJayLrJmk76Xo58FXRASR4H1YpfnYxPKKVjUaDbaeFT15UZ/dj+1pl6+T5wkfQkv11eVvfDcmfVsN/p4AoVgGtoUDDl2nwyt4YblETp2iDFgFy00q5O365bU/QHt3FWa+TNYE2Prj6WeUC1n90L7Gtj6P1mSfElv1iR69wgs= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05a1e3d8-c0f2-4588-5374-08d688afd001 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:20.8855 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The r4k variant of local_flush_tlb_mm() wraps its call to drop_mmu_context() with a preempt_disable() & preempt_enable() pair, but this is redundant since drop_mmu_context() disables interrupts and from Documentation/preempt-locking.txt: Note that you do not need to explicitly prevent preemption if you are holding any locks or interrupts are disabled, since preemption is implicitly disabled in those cases. Remove the redundant preempt_disable() & preempt_enable() calls. Signed-off-by: Paul Burton --- arch/mips/mm/tlb-r4k.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index ba76b0c11d38..9fff08eabe8f 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -108,9 +108,7 @@ EXPORT_SYMBOL(local_flush_tlb_all); these entries, we just bump the asid. */ void local_flush_tlb_mm(struct mm_struct *mm) { - preempt_disable(); drop_mmu_context(mm); - preempt_enable(); } void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, From patchwork Sat Feb 2 01:43:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56D3C6C2 for ; Sat, 2 Feb 2019 01:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 492CC32F13 for ; Sat, 2 Feb 2019 01:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DD9232F25; Sat, 2 Feb 2019 01:43:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD9B932F13 for ; Sat, 2 Feb 2019 01:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbfBBBnk (ORCPT ); Fri, 1 Feb 2019 20:43:40 -0500 Received: from mail-eopbgr770108.outbound.protection.outlook.com ([40.107.77.108]:47642 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726246AbfBBBnk (ORCPT ); Fri, 1 Feb 2019 20:43:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YHtdhcYVuxQPedW31QVdTYUEn6EK1br8N8rNOJ7VnQk=; b=CmzBtN9GRdk5RLCuLbItbMGOF8/K0UI6s19oCiLfeXseW9o4X9jwErAFIPoLDBmPCXvffiV2U4H0CIzDqJ6hi/Gj35shkSXnO2E2XQNYnmpbunk8uRp4+yrGb8k2ZDoHMk0j0oJ9bWzbG6BLmU6YLJolD6poZ2jHmOmOZBeSZEk= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:25 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:24 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 08/14] MIPS: mm: Remove local_flush_tlb_mm() Thread-Topic: [PATCH 08/14] MIPS: mm: Remove local_flush_tlb_mm() Thread-Index: AQHUupiuR2H+RUsJgkiblC7kIOH/bQ== Date: Sat, 2 Feb 2019 01:43:22 +0000 Message-ID: <20190202014242.30680-9-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:XeJ0gw0+p4wYUkcWsCYDjquQm3j55YySZtvfRnxa5QGvRWw5QSWlbfocUOvCbzwAbh6VUFGn+ugnxDrkb/Y7azjIa8smc+quZPXWyG/sSz5o7tGYehmI1o80MfnPT/7+vCvB94GwEdRfh18JbKFbYGNXKhZoS5CzLeus4R8XqjV7sswhfJK/V0ulCZjbkxrLj6N0OcHL+AKD1C5a6ZW/kmIvuZraN1xTlxJKYKtFu4xnnKLpYmfAKc5f5dKdyStXV/npIzgbN2EqCCDAq8O1h2EJtfILjjZhHukq4FwA0wpMcxT1a55rZpJlXGq7sJbmzDmOCffvtUiXKWeP64Gw942v6ocGOisUXMGnIih/mq9Xj1eCM0v6Wa7FxZ7hOuDDAyOi1lFlAY8zfhBCel6qNgXECU+g7sF2BspI2QWlPGFDpqvQRRrEhQg3btEYzv2k8GODHbiizZwUXtL4ylu9LA==;5:5L9mbEc2pcg0wvt3tns5MMKobn77+/Msj3vKl5BbTDrOXBwxbZwysnCHk6cqtuPr8+zVHoxJef+8OnPlOSyYjctd7XtQrCSAPdxnZoTfe85HoYLdKCmjLiu/dfmH3OIq2b6KJOfi4wljjbBpQwnqfvYnEQrKw/i3V4HV5m87OyoWapQQk1I86IKb2H6fKRts+NfU/85O4Jksy2Y5w/IzPw==;7:OeniQz9PyWTGNm3d3EhDLidIEXGLzWl++HdkwC4jtjgUfkZH7OfUQKWyCU5qyt65Sm6C+Q/dNuL9Kh1SVp/4mqqBx7lSJCBw20Zo83p+vYuTWHqj57fEfY4UXfB59oAFZh7PuWJM0VLe8G4hzrN0YQ== x-ms-office365-filtering-correlation-id: 0f665f75-5156-4a4e-9d70-08d688afd08a x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: F7C+79pi7dmzBCBrpPT1gHYjVxHBLrWR8WdLGf/Ofs9O9s5WgiL1n1UCpKg1KXzPUL9HS6sBoW/+87BverMvq29uil+3N66GV+5tm8RLr1HjVTelQFhzlwrdmmE3vN2A3Mz6MbfN21ltUPtY60iq3BdKeBA7btJkP45uegtyASRwETqrXBVKPxJzIBOwGoF+ulI7+4u+1GzbO/FqqcUkGMc6SGJ2SMJh450BwwvHV8UbsD2v2xI/KnlEyoHSXko3fojA54f8ecta5LSpS7f7I4PD/PJA5TGO4Cy8C8geegZhN1uy4WUKI1sE1bv8PWi9WtoSlFHqMy6SGnOIsQQmiFkRHNXLy7u5iBNuhN+OCvNZrhl8qq2/TMIHSHYooRAUTwwCzaILhaocaJvJOosYWBQf6riGwXhR+XMphBSDnBM= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f665f75-5156-4a4e-9d70-08d688afd08a X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:21.7872 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All 3 variants of local_flush_tlb_mm() are now effectively simple calls to drop_mmu_context(). Remove them and use drop_mmu_context() directly. Signed-off-by: Paul Burton --- arch/mips/include/asm/tlbflush.h | 5 +++-- arch/mips/kernel/smp.c | 4 ++-- arch/mips/mm/tlb-r3k.c | 12 ------------ arch/mips/mm/tlb-r4k.c | 7 ------- arch/mips/mm/tlb-r8k.c | 5 ----- 5 files changed, 5 insertions(+), 28 deletions(-) diff --git a/arch/mips/include/asm/tlbflush.h b/arch/mips/include/asm/tlbflush.h index 40a361092491..9789e7a32def 100644 --- a/arch/mips/include/asm/tlbflush.h +++ b/arch/mips/include/asm/tlbflush.h @@ -14,7 +14,6 @@ * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages */ extern void local_flush_tlb_all(void); -extern void local_flush_tlb_mm(struct mm_struct *mm); extern void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end); extern void local_flush_tlb_kernel_range(unsigned long start, @@ -23,6 +22,8 @@ extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page); extern void local_flush_tlb_one(unsigned long vaddr); +#include + #ifdef CONFIG_SMP extern void flush_tlb_all(void); @@ -36,7 +37,7 @@ extern void flush_tlb_one(unsigned long vaddr); #else /* CONFIG_SMP */ #define flush_tlb_all() local_flush_tlb_all() -#define flush_tlb_mm(mm) local_flush_tlb_mm(mm) +#define flush_tlb_mm(mm) drop_mmu_context(mm) #define flush_tlb_range(vma, vmaddr, end) local_flush_tlb_range(vma, vmaddr, end) #define flush_tlb_kernel_range(vmaddr,end) \ local_flush_tlb_kernel_range(vmaddr, end) diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index d84b9066b465..d7088ca31e43 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -487,7 +487,7 @@ void flush_tlb_all(void) static void flush_tlb_mm_ipi(void *mm) { - local_flush_tlb_mm((struct mm_struct *)mm); + drop_mmu_context((struct mm_struct *)mm); } /* @@ -540,7 +540,7 @@ void flush_tlb_mm(struct mm_struct *mm) cpu_context(cpu, mm) = 0; } } - local_flush_tlb_mm(mm); + drop_mmu_context(mm); preempt_enable(); } diff --git a/arch/mips/mm/tlb-r3k.c b/arch/mips/mm/tlb-r3k.c index 60eb7a114440..50f207591b6d 100644 --- a/arch/mips/mm/tlb-r3k.c +++ b/arch/mips/mm/tlb-r3k.c @@ -67,18 +67,6 @@ void local_flush_tlb_all(void) local_irq_restore(flags); } -void local_flush_tlb_mm(struct mm_struct *mm) -{ -#ifdef DEBUG_TLB - int cpu = smp_processor_id(); - - if (cpu_context(cpu, mm) != 0) - printk("[tlbmm<%lu>]", (unsigned long)cpu_context(cpu, mm)); -#endif - - drop_mmu_context(mm); -} - void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) { diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 9fff08eabe8f..0114c43398f3 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -104,13 +104,6 @@ void local_flush_tlb_all(void) } EXPORT_SYMBOL(local_flush_tlb_all); -/* All entries common to a mm share an asid. To effectively flush - these entries, we just bump the asid. */ -void local_flush_tlb_mm(struct mm_struct *mm) -{ - drop_mmu_context(mm); -} - void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) { diff --git a/arch/mips/mm/tlb-r8k.c b/arch/mips/mm/tlb-r8k.c index c938d6b497ef..c1e9e144007e 100644 --- a/arch/mips/mm/tlb-r8k.c +++ b/arch/mips/mm/tlb-r8k.c @@ -50,11 +50,6 @@ void local_flush_tlb_all(void) local_irq_restore(flags); } -void local_flush_tlb_mm(struct mm_struct *mm) -{ - drop_mmu_context(mm); -} - void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) { From patchwork Sat Feb 2 01:43:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B99166C2 for ; Sat, 2 Feb 2019 01:43:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC63532F13 for ; Sat, 2 Feb 2019 01:43:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0BB232F25; Sat, 2 Feb 2019 01:43:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C9AA32F17 for ; Sat, 2 Feb 2019 01:43:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbfBBBnh (ORCPT ); Fri, 1 Feb 2019 20:43:37 -0500 Received: from mail-eopbgr810108.outbound.protection.outlook.com ([40.107.81.108]:62863 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726516AbfBBBnh (ORCPT ); Fri, 1 Feb 2019 20:43:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s513NnosSwvNZ8i3tyf0SYbVNOfmMQpnCdeTulAUK3w=; b=GsReWy12EkxPmg5yhkiDofymKbEKPL7W9X5Xn7RYv0Pv6eDyQRzmZ2gRUM00SC0bI1kmqEU/HET4LkYjiBGyHC+aWBOS9nbGAkubzawWji99NNNRc3a0Pj1fuhq7xnDFwogj7W93YS2KRcenGvpnhjpE/gQoqYOPW82p7OasZGs= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:25 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:25 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 09/14] MIPS: mm: Split obj-y to a file per line Thread-Topic: [PATCH 09/14] MIPS: mm: Split obj-y to a file per line Thread-Index: AQHUupiufaQEj55dJUi+bYUfDGVfDA== Date: Sat, 2 Feb 2019 01:43:23 +0000 Message-ID: <20190202014242.30680-10-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:r3pYdUzAj5J6Vqh6/IIAurauB+5ib6iwPi/62Xvjov4EEu+j03no0dR13NvOtlIu6U6iJwmC1OV9pAiq+6+Rhcu+09PjfeIvYT8q+2a6ViJZZfZDkqWNg5Nv/UwrqapP9YElM6Trz6R6l+BG+aGBtCppXX0QZStNeyjF7uqPTUZerSe/3dT+IAgYVztB4kJSj4EvID2Do/ylyUIqcUPlsogTtI9kftzY9Nz1M9R8N2wVHyZ73h5QVpwL81I6YXmhhlhcIuaM5avi/z5+a+sVN7ZOW8BsSPJQG1n6pvPjdj/4ugyC13UVyODPAW+rFQ1gwrC198fDtyTcGofWC08IM/lviIZRqcDGoLYepiTTkVOppqT4ZgYAzwFUFnTe/rDzYJwMVPhYgz/4q4wKq8SoRqnsOl3K6F/bKhnqHkvapTCyJWOH2yTx12Ow4pe+VPe+mL60RMYk2eLU/qNRbkZGoQ==;5:AZzk0yIpnGgfocKkkTIU5fE4l2rYhnxEjfPO5l8QmQhlJdJ+inri5fXLFsGiDB5wxpqXwm4MBV7ZLDsjW2JfWpS3a8OzUGSGNv6GbgS7pGm7IVtqN/pgbJ124L3YVGVNKDWiRHolXvWSWrp3bvEpm3dRR/Pbo+2Pi6yQGmlGUMW/REPEAIJjuvwjFYwHCWIpHq0B4SBkl3H8nSk9fxf5jg==;7:eME7TN0m5OcuIA5jhBXN3H062mPJVsICfBkADQP7+Xyk9bcQOdR5JeqNHuTIVyN37oKBXrO/C7vA+gwYSji8kRu1Fz+qC7Y+ZZX5NeiUg8wbyaxvCoHSF7MjOj99CdEsaWUN645rZSnzpFacJC7o9g== x-ms-office365-filtering-correlation-id: f794e5cd-e5fa-4524-a1ff-08d688afd104 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(4744005)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: MWl8Bi+boRLOj+V/7aEtAWzvb87LZ2IZZsJq9Tt2Vz8brTgmRxjyhnLrfBKE2pdYEGHwLxhQYr0OpzqoZZyfhpGNMQaSsyWkq8yxzLT8fQ4Rgafg9Gcr7GDfHyJlp/CCVjS8uoV31k708GkPiCyF818SA3nSoRI1TQcwrwwXEAamo3/XggILYSvnR+JV0sYLC9OmkHnUiRX8+oerkqwdseNtdW9W5uGpZ4vIJcWLC4d4DEM/prICK9uJoNLPWgM/2uvwHy459cVcLROTszbyB/tE8rg5DwK9vRBS4EABID7NvlFICNSQK/XbVGplxQI8tyRBuqiAtYaYbMYY0CVYQU2jJzDbEEDlkPp2OMFk0aUh6S3gd1o/IpSpjBClxdqGVC9rXheTi1QjgvRxiZRWFrnLwIPJseTHFhVZIHIBL7E= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: f794e5cd-e5fa-4524-a1ff-08d688afd104 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:22.5859 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Split always-included objects to one per line in order to make it easier to modify the list of included objects. Signed-off-by: Paul Burton --- arch/mips/mm/Makefile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile index 3e5bb203c95a..25d492736848 100644 --- a/arch/mips/mm/Makefile +++ b/arch/mips/mm/Makefile @@ -3,9 +3,18 @@ # Makefile for the Linux/MIPS-specific parts of the memory manager. # -obj-y += cache.o extable.o fault.o \ - gup.o init.o mmap.o page.o page-funcs.o \ - pgtable.o tlbex.o tlbex-fault.o tlb-funcs.o +obj-y += cache.o +obj-y += extable.o +obj-y += fault.o +obj-y += gup.o +obj-y += init.o +obj-y += mmap.o +obj-y += page.o +obj-y += page-funcs.o +obj-y += pgtable.o +obj-y += tlbex.o +obj-y += tlbex-fault.o +obj-y += tlb-funcs.o ifdef CONFIG_CPU_MICROMIPS obj-y += uasm-micromips.o From patchwork Sat Feb 2 01:43:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D159159A for ; Sat, 2 Feb 2019 01:43:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E9512990C for ; Sat, 2 Feb 2019 01:43:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8164529C57; Sat, 2 Feb 2019 01:43:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 143AA2990C for ; Sat, 2 Feb 2019 01:43:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726193AbfBBBnu (ORCPT ); Fri, 1 Feb 2019 20:43:50 -0500 Received: from mail-eopbgr810108.outbound.protection.outlook.com ([40.107.81.108]:62863 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726516AbfBBBnu (ORCPT ); Fri, 1 Feb 2019 20:43:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q+qT4TukQ7c+l9mSECXE/tgVQKuX9CpKeSCAY34obhQ=; b=fHvQTDkFGYMEeZ08GV6yope3H36tKTITse2LXmuSj/urCfnBSDXOCyoppnnWsRzLNBJ9eJWObZ6uBeTlz0vCVksGsL1//p/Smw8y0Fo3I0gIwpLrqfkJMk5/iCNG04eGRlmQd0rMPGd48xq731IbWt3PVxurkKPnm0N7HNEmYJ0= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:26 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:26 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 10/14] MIPS: mm: Un-inline get_new_mmu_context Thread-Topic: [PATCH 10/14] MIPS: mm: Un-inline get_new_mmu_context Thread-Index: AQHUupiv++FjsF0VgEqyhVD8T1+nsQ== Date: Sat, 2 Feb 2019 01:43:24 +0000 Message-ID: <20190202014242.30680-11-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:5CFFcX8Tjjazzv0KxQjWAr6dllsG+FhF0PoEI0G2M2LZZN4H6YDglZ40X+t1Qs75NLjHKjqp3PymR2f7ijwjOAF0b+13W6IeFMNAnAGl9G2IzehGIhtJLjCniKzAbm5lhLa6kaOVP23NwZvuet75pI5/fiH9qoKbQ917KMNlUhMChXVV1KmA7AE4nZVz/gsQ0I6JXBLGkaypb+dbSjUQ5PqDlXblPm8+dmWRT47gVv60xbyJiMqohRZGn7fr/9Z91R5x0AANP5XMDWu6FV47E/0MwjZDTalkuHxuYCQ5NP1tIUHJo0D9NLjL0vsV/AubFJUyROHqIKus8XnoG8Gl5y3YdCnACX1XyskgnnJ/XLBuv9bHzsGGL21cZqQ4QMsIVSzmOfYYgGTFV8BY1EXrk6Z7Alv/AXSXw57PLAyF3teAaTJcBMKQALe8xxbXSELIhEE+BwW3pUgnSHCkH3vahA==;5:9yWgywL2+N8NesMJ8RYvZN2NOv3nQ/NyDZsPLcs5gDB2L8dLm7Rqnm5wRCZ84QGvNSw0vFAU4Ny3IGSpy4magzZssdJ/yM3o2KgOuoYKzZto2kmmvaKbQ4UbVzN0NcTb2PWAL6MZ7ivxyuBWo14NveyBucIkihumJTmVuc90fycsd6Bxeqbl5jvNqKMPe1PEcoLaHfGfR+pyjfn8oDrqnQ==;7:0PpVERJQnqa7R4+Ho2G3wZSQqWc4XTNeoUwU0d0fId+mdS6PR2OxDD3eY5c+oizgXQ6gcsejZWGN6mEHnHlhp4FLLk+B7fhMJ7LR9Zpnl4KtotD2nBZFOdIgpfXVzZbGLXMnOdVA3xHnXm3zPCr3Sw== x-ms-office365-filtering-correlation-id: cb9d976f-a606-4856-80d6-08d688afd192 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: pn8kNcdf8DqTRIwtKrFceA+a/Z8i3ZGIWAKpnWaDasMc92Ti5eimGFR75zIE+KSttHgFl78SEJSByvQ2t5RFtT82eTN6GCE3sgNMvk+zdifDIJZMUDR/0/x27PRwZFS5uQsZt0cXSQG6dmcNSe0A/spa6kOfjZfPu68lZGvUmQUmsJRhH8njzrpXOK3EveHBnjSycWaCK0qxPklX8IG4wrCEkOmN/M6ccuIBZ21D0VkEBYifN7sDzxCOh2GVPSFrLbK335Zov3V9gwGchvo+AiNFfuF35oawPxxVUQKL7WruYEdSM4LoMhxGM3fMQ7YxG8l6L42RcYxEz7G3XSmFILga4HfRKzku6LAXMELkXwZDWCLLjW9s35npq41c18ffRI4AP3XyiLBHLbN2Ls4YMDmVTmm7dXk12+lYPQtb6Kk= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb9d976f-a606-4856-80d6-08d688afd192 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:23.5166 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for adding MMID support to get_new_mmu_context() which will increase the size of the function somewhat, move it from asm/mmu_context.h into a C file. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 20 +------------------- arch/mips/mm/Makefile | 1 + arch/mips/mm/context.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 19 deletions(-) create mode 100644 arch/mips/mm/context.c diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index 752ebda82cdd..cb39a39d02f6 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -97,25 +97,7 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) { } - -/* Normal, classic MIPS get_new_mmu_context */ -static inline void -get_new_mmu_context(struct mm_struct *mm) -{ - unsigned int cpu; - u64 asid; - - cpu = smp_processor_id(); - asid = asid_cache(cpu); - - if (!((asid += cpu_asid_inc()) & cpu_asid_mask(&cpu_data[cpu]))) { - if (cpu_has_vtag_icache) - flush_icache_all(); - local_flush_tlb_all(); /* start new asid cycle */ - } - - cpu_context(cpu, mm) = asid_cache(cpu) = asid; -} +extern void get_new_mmu_context(struct mm_struct *mm); /* * Initialize the context related info for a new mm_struct diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile index 25d492736848..f34d7ff5eb60 100644 --- a/arch/mips/mm/Makefile +++ b/arch/mips/mm/Makefile @@ -4,6 +4,7 @@ # obj-y += cache.o +obj-y += context.o obj-y += extable.o obj-y += fault.o obj-y += gup.o diff --git a/arch/mips/mm/context.c b/arch/mips/mm/context.c new file mode 100644 index 000000000000..b5af471006f0 --- /dev/null +++ b/arch/mips/mm/context.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +void get_new_mmu_context(struct mm_struct *mm) +{ + unsigned int cpu; + u64 asid; + + cpu = smp_processor_id(); + asid = asid_cache(cpu); + + if (!((asid += cpu_asid_inc()) & cpu_asid_mask(&cpu_data[cpu]))) { + if (cpu_has_vtag_icache) + flush_icache_all(); + local_flush_tlb_all(); /* start new asid cycle */ + } + + cpu_context(cpu, mm) = asid_cache(cpu) = asid; +} From patchwork Sat Feb 2 01:43:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 916EF13B5 for ; Sat, 2 Feb 2019 01:45:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CC5A31C68 for ; Sat, 2 Feb 2019 01:45:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B2CC32F25; Sat, 2 Feb 2019 01:45:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBD7031C68 for ; Sat, 2 Feb 2019 01:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725803AbfBBBpd (ORCPT ); Fri, 1 Feb 2019 20:45:33 -0500 Received: from mail-eopbgr770108.outbound.protection.outlook.com ([40.107.77.108]:47642 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726246AbfBBBpd (ORCPT ); Fri, 1 Feb 2019 20:45:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C2//c+d9bRIkmx50EhvH7NYfrqdgGwJzOCOtwF3CduQ=; b=oxaCWQpCi1m4ECCKGWvpuxLvN/s8vElbp55Vg2A7Pxw4XS6eUvvN+eXUEtAS9aROC4BlKD47zYBYX0Cxni0+80LovLV1oJLeIQ9F01Ta3HMXYOHLxZpPv4sYMXoaKFvmmSwrrFXZuR6XzZKW9P8u1wnZ3zJd9uOeAsJVqyfoei0= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:26 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:26 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 11/14] MIPS: mm: Unify ASID version checks Thread-Topic: [PATCH 11/14] MIPS: mm: Unify ASID version checks Thread-Index: AQHUupivZZWNvn16E0eR7VwgBTrhdg== Date: Sat, 2 Feb 2019 01:43:25 +0000 Message-ID: <20190202014242.30680-12-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:1IfP8XZcfCrMiqL+WkkyYz3++pRaLyUOKjC74ViaeKJvdBRSN6WVIzp1AXkU45tK/YxXOsDzWS0AKDmTgnseN1mVxIMrXjiTzR4p7RBeaYkJzoJs/0FQbp4W2nDNxKt1z4w4K5np/nhfTMv0u+zKgAHEGF0qTpbaxJBvgbEn7VwKAHwazmOooO/1CINIgl4qAIN5rzVkZkAZW2MH7yQpg6sQ134FuEY1CvH0qIl/SWPBPksIkz5UN9vg1BEgIhAH99vbfdedAgjpIES6e9AbLHR/RWWFSJ5Aw1+mgXdO6aBvsA1cr4/dM7zrx8Ms+jPifhAc+xeOue1txP0rFoJi+sayzzdRPy97LTe8ZYVI9uwD6vCTOPOCQ/o99suduEnHFAmRcXRRZQK7503ckerBHjXAxIfY+WuxLKvhDNNT6JRhxVc76Ab509qWGFH2ft84LJAI6iJ54jzNjcvfKe0dXw==;5:G/AQtQaftFvDz2c3DtVTSEVkcbzYPLK0XqNlwUDO0l4l6ybzI9YWXI3Ckei3S+XoRWwpciWiF066yEDZ/+cguA2nnPyooe+5X00atFBYVTyHFzYAtX0+8Cgt5wYNZDFmSJRTBMHBWjBsJJzw7r0ztEnTaXiVUe73sDD5Qw8mUFiDRTck/PmFrusMVmootXviIE2oeaoxeKpjuEZrI0YIsQ==;7:rucf92skUyMltnHSkVjIHoe1TG54WQy/BAuASxJNJ4G6111nfWcE90Ut6klJAmQNqcXLMS/XBgyElPegGHEWJC1deHmjqk3e5qzmdtfvnC1C0nCakr+vyirf58fs6UUYfMO2aWykS4Bouv4zn3bs5A== x-ms-office365-filtering-correlation-id: 05d28b07-cbfb-4f0b-b076-08d688afd229 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: X5RSVf9uE4jN+pKO6vY0c6RhCzcyUhU1tzMA7O9kOITyz5rpRDZxmHuEmkaOpmfeiSGMkJtOXsdHpcND84Ffk/VG6OY6w99P86WiECXj6zOI7WqpEvrzO4SlA4RSuB4Zfvqkps1V2TFk756JDKreH1B0ak8mQhtJfIAif+2M2zP958HXOCgCWhPEfhTiwHnZfoE72sdaZQ1F/uhZkmPaC129KRzG1vWC+qlSMQMJoY2hUHM+AH+m14DXB0TfZJqljdPGhCiu20nEkIo75CZpufRvDON8zxIenPpJSoB4F8KoJSN9b/LsGQJ+c+e4iPGUABZtalkdQ9hXwBxhXwPW4oM4tQa64wRp7I8gG6P8lBY+tpQ1wg7K11pE5NYqMbaMGp625waIhh54/X5U8g3Csi0KdmfrTOF1h6N2SDc7jK0= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05d28b07-cbfb-4f0b-b076-08d688afd229 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:24.5064 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new check_mmu_context() function to check an mm's ASID version & get a new one if it's outdated, and a check_switch_mmu_context() function which additionally sets up the new ASID & page directory. Simplify switch_mm() & various get_new_mmu_context() callsites in MIPS KVM by making use of the new functions, which will help reduce the amount of code that requires modification to gain MMID support. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 8 +++----- arch/mips/kvm/trap_emul.c | 22 ++++------------------ arch/mips/kvm/vz.c | 6 +++--- arch/mips/mm/context.c | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index cb39a39d02f6..336682fb48de 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -98,6 +98,8 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) } extern void get_new_mmu_context(struct mm_struct *mm); +extern void check_mmu_context(struct mm_struct *mm); +extern void check_switch_mmu_context(struct mm_struct *mm); /* * Initialize the context related info for a new mm_struct @@ -126,11 +128,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, local_irq_save(flags); htw_stop(); - /* Check if our ASID is of an older version and thus invalid */ - if ((cpu_context(cpu, next) ^ asid_cache(cpu)) & asid_version_mask(cpu)) - get_new_mmu_context(next); - write_c0_entryhi(cpu_asid(cpu, next)); - TLBMISS_HANDLER_SETUP_PGD(next->pgd); + check_switch_mmu_context(next); /* * Mark current->active_mm as not "active" anymore. diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c index 503c2fb7e4da..22ffe72a9e4b 100644 --- a/arch/mips/kvm/trap_emul.c +++ b/arch/mips/kvm/trap_emul.c @@ -1056,11 +1056,7 @@ static int kvm_trap_emul_vcpu_load(struct kvm_vcpu *vcpu, int cpu) */ if (current->flags & PF_VCPU) { mm = KVM_GUEST_KERNEL_MODE(vcpu) ? kern_mm : user_mm; - if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) & - asid_version_mask(cpu)) - get_new_mmu_context(mm); - write_c0_entryhi(cpu_asid(cpu, mm)); - TLBMISS_HANDLER_SETUP_PGD(mm->pgd); + check_switch_mmu_context(mm); kvm_mips_suspend_mm(cpu); ehb(); } @@ -1074,11 +1070,7 @@ static int kvm_trap_emul_vcpu_put(struct kvm_vcpu *vcpu, int cpu) if (current->flags & PF_VCPU) { /* Restore normal Linux process memory map */ - if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) & - asid_version_mask(cpu))) - get_new_mmu_context(current->mm); - write_c0_entryhi(cpu_asid(cpu, current->mm)); - TLBMISS_HANDLER_SETUP_PGD(current->mm->pgd); + check_switch_mmu_context(current->mm); kvm_mips_resume_mm(cpu); ehb(); } @@ -1228,9 +1220,7 @@ static void kvm_trap_emul_vcpu_reenter(struct kvm_run *run, * Check if ASID is stale. This may happen due to a TLB flush request or * a lazy user MM invalidation. */ - if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) & - asid_version_mask(cpu)) - get_new_mmu_context(mm); + check_mmu_context(mm); } static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu) @@ -1266,11 +1256,7 @@ static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu) cpu = smp_processor_id(); /* Restore normal Linux process memory map */ - if (((cpu_context(cpu, current->mm) ^ asid_cache(cpu)) & - asid_version_mask(cpu))) - get_new_mmu_context(current->mm); - write_c0_entryhi(cpu_asid(cpu, current->mm)); - TLBMISS_HANDLER_SETUP_PGD(current->mm->pgd); + check_switch_mmu_context(current->mm); kvm_mips_resume_mm(cpu); htw_start(); diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c index d98c12a22eac..dde20887a70d 100644 --- a/arch/mips/kvm/vz.c +++ b/arch/mips/kvm/vz.c @@ -2454,10 +2454,10 @@ static void kvm_vz_vcpu_load_tlb(struct kvm_vcpu *vcpu, int cpu) * Root ASID dealiases guest GPA mappings in the root TLB. * Allocate new root ASID if needed. */ - if (cpumask_test_and_clear_cpu(cpu, &kvm->arch.asid_flush_mask) - || (cpu_context(cpu, gpa_mm) ^ asid_cache(cpu)) & - asid_version_mask(cpu)) + if (cpumask_test_and_clear_cpu(cpu, &kvm->arch.asid_flush_mask)) get_new_mmu_context(gpa_mm); + else + check_mmu_context(gpa_mm); } } diff --git a/arch/mips/mm/context.c b/arch/mips/mm/context.c index b5af471006f0..4dd976acf41d 100644 --- a/arch/mips/mm/context.c +++ b/arch/mips/mm/context.c @@ -17,3 +17,21 @@ void get_new_mmu_context(struct mm_struct *mm) cpu_context(cpu, mm) = asid_cache(cpu) = asid; } + +void check_mmu_context(struct mm_struct *mm) +{ + unsigned int cpu = smp_processor_id(); + + /* Check if our ASID is of an older version and thus invalid */ + if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) & asid_version_mask(cpu)) + get_new_mmu_context(mm); +} + +void check_switch_mmu_context(struct mm_struct *mm) +{ + unsigned int cpu = smp_processor_id(); + + check_mmu_context(mm); + write_c0_entryhi(cpu_asid(cpu, mm)); + TLBMISS_HANDLER_SETUP_PGD(mm->pgd); +} From patchwork Sat Feb 2 01:43:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E63FF159A for ; Sat, 2 Feb 2019 01:43:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D59EA2990C for ; Sat, 2 Feb 2019 01:43:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C698E29C57; Sat, 2 Feb 2019 01:43:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 389022990C for ; Sat, 2 Feb 2019 01:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbfBBBnx (ORCPT ); Fri, 1 Feb 2019 20:43:53 -0500 Received: from mail-eopbgr810108.outbound.protection.outlook.com ([40.107.81.108]:62863 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726410AbfBBBnw (ORCPT ); Fri, 1 Feb 2019 20:43:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BqyAvCcAMR5/diJoqIstnpEyK1V1gK4GOlK7nWKXAIM=; b=CY82Coo6PsqMGySnQXRflAbk16/Or2qL6bpURqVozEfACOc5Pka+m6m61v81X+KirWI3jPbbnUW2nw9rWBZda7OyR/theVs9boMD8hlm5BNz2NdQH6hiwslT69V6eeyks/Mzx/mlAqFXjAmI3JHHppLYhjEecnqNvx5MP2kzBq0= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:27 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:27 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 12/14] MIPS: mm: Add set_cpu_context() for ASID assignments Thread-Topic: [PATCH 12/14] MIPS: mm: Add set_cpu_context() for ASID assignments Thread-Index: AQHUupiwK95Bfgsi7kSbR+TcZObCBQ== Date: Sat, 2 Feb 2019 01:43:25 +0000 Message-ID: <20190202014242.30680-13-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:dTalk/AeOdoFY3a2o9ttFxUYB7h0WNgDEp1ofnlHDkaC8Z9ok6ZlH9yrhe4PYtAc/fX1Jxl9QexI2OHkUHGdrVa3yyszavNKgMGuuBrBJks7xXdAUI6oucx+vlKYaN0QJ/o04Ss/Nlk6H0HMtnRdbu+xvvmlRO+tZ1ZoPQfNix6x2ozS/yXri8L2Tjz1zmXa34nCUcAm8qSn9cSgoZRYwNx5ZL1q/a0baL3YOLrhyT10b5gENgLIcTZFAUihMW1G9JpzKLxo7GXcnkD3ldAdxWoPbglLZTKNGvPy36X8neAhp01X0TatP7+CSoecgMfbdTSsfzd0Dy8g50kpcvKx+37DE1Kj/qFahtPylsM0fEpsZTCX6O1G37vTYeAUjjuyuaz03g8aORenrt5+0m5XG+hOKlCkSt5L3GNYWWbASDHapdRI2+359LA9bLL3EBVdzJVfPHVOE7wnQNfQIKioJA==;5:Yxa30RwHu+MReZx0iurLxP8Vc/jG4TfKXqv4npDv2PuXv4d+k2J9m1jOF86PbdmXiCFC4tyfw9AtsxQJXSaDFIVNaLN48ujFIHetk6zalXi1TFr7wPtdjjbAQplRQuh6cOn5NaLnGBFVQzgHDx6+iGixdHlrhvd9Z/8+EjiJ2TWSmcwdKRhv42vQyw5pIliPSWDTsQmhpnVGVsgXenDCwQ==;7:gL0N/owb7lK2j5g9+wP8xNxRkIZfcV6zQmGc0JjJ5AeWyU7p0AtgU6uxG0Y49Wr3+OscyWJ87oAMR+1mVL+Uvbd+Wb9TP5e4gXN3kaKLU0vM4S8icIOyJlZ1ScBEBO9In14L/unPlHAKfnTb+choEA== x-ms-office365-filtering-correlation-id: 6093d552-795b-4e7a-f585-08d688afd2bf x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: OfVHdEqWsxEEODCxHRuSd+PwNTdntlmnXFNvVJgpyjoZ39dBAMJ8pIZkiukAIDECwEeiVocuIPoq90IyijikkU9vGDRTHGK+TD3aiHkVxovEauGn2+0j2eyeJwMOVCfuALUFPPKDdtIjHzTJNFdZwi4zS7yPhXiRFUgodQt7BptOCh8nHEUWLd54uQo83vrmZWIC+y9UrQrEf3aF2fGlla0gn26SaQHwRzKqp3EjG0apjHCIvfvdj5kNtd0F58fV9IjumySCrjSeAi/LXU/NBTZUyajeJgF9FWEVwCS7X+losxq1LVNzBeyp1o2ccxCudihVWy9FCbzkSI7ObxThVjzR7rtTnabuHKPjAV8BgZZn9dSAF6h0amHmYFoGa5qijhHmbTu1BAxMRJftXVmaEyl92ksXhuVfiG5r9tOifPs= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6093d552-795b-4e7a-f585-08d688afd2bf X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:25.4892 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we gain MMID support we'll be storing MMIDs as atomic64_t values and accessing them via atomic64_* functions. This necessitates that we don't use cpu_context() as the left hand side of an assignment, ie. as a modifiable lvalue. In preparation for this introduce a new set_cpu_context() function & replace all assignments with cpu_context() on their left hand side with an equivalent call to set_cpu_context(). To enforce that cpu_context() should not be used for assignments, we rewrite it as a static inline function. Signed-off-by: Paul Burton --- arch/mips/include/asm/mmu_context.h | 16 +++++++++++++--- arch/mips/kernel/smp.c | 6 +++--- arch/mips/kvm/emulate.c | 6 +++--- arch/mips/kvm/trap_emul.c | 6 +++--- arch/mips/mm/context.c | 3 ++- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index 336682fb48de..a0f29df8ced8 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -88,7 +88,17 @@ static inline u64 asid_first_version(unsigned int cpu) return ~asid_version_mask(cpu) + 1; } -#define cpu_context(cpu, mm) ((mm)->context.asid[cpu]) +static inline u64 cpu_context(unsigned int cpu, const struct mm_struct *mm) +{ + return mm->context.asid[cpu]; +} + +static inline void set_cpu_context(unsigned int cpu, + struct mm_struct *mm, u64 ctx) +{ + mm->context.asid[cpu] = ctx; +} + #define asid_cache(cpu) (cpu_data[cpu].asid_cache) #define cpu_asid(cpu, mm) \ (cpu_context((cpu), (mm)) & cpu_asid_mask(&cpu_data[cpu])) @@ -111,7 +121,7 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm) int i; for_each_possible_cpu(i) - cpu_context(i, mm) = 0; + set_cpu_context(i, mm, 0); mm->context.bd_emupage_allocmap = NULL; spin_lock_init(&mm->context.bd_emupage_lock); @@ -175,7 +185,7 @@ drop_mmu_context(struct mm_struct *mm) htw_start(); } else { /* will get a new context next time */ - cpu_context(cpu, mm) = 0; + set_cpu_context(cpu, mm, 0); } local_irq_restore(flags); diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index d7088ca31e43..f9dbd95e1d68 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -537,7 +537,7 @@ void flush_tlb_mm(struct mm_struct *mm) for_each_online_cpu(cpu) { if (cpu != smp_processor_id() && cpu_context(cpu, mm)) - cpu_context(cpu, mm) = 0; + set_cpu_context(cpu, mm, 0); } } drop_mmu_context(mm); @@ -583,7 +583,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned l * mm has been completely unused by that CPU. */ if (cpu != smp_processor_id() && cpu_context(cpu, mm)) - cpu_context(cpu, mm) = !exec; + set_cpu_context(cpu, mm, !exec); } } local_flush_tlb_range(vma, start, end); @@ -635,7 +635,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long page) * by that CPU. */ if (cpu != smp_processor_id() && cpu_context(cpu, vma->vm_mm)) - cpu_context(cpu, vma->vm_mm) = 1; + set_cpu_context(cpu, vma->vm_mm, 1); } } local_flush_tlb_page(vma, page); diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c index ca8347372427..0074427b04fb 100644 --- a/arch/mips/kvm/emulate.c +++ b/arch/mips/kvm/emulate.c @@ -1019,7 +1019,7 @@ static void kvm_mips_change_entryhi(struct kvm_vcpu *vcpu, get_new_mmu_context(kern_mm); for_each_possible_cpu(i) if (i != cpu) - cpu_context(i, kern_mm) = 0; + set_cpu_context(i, kern_mm, 0); preempt_enable(); } kvm_write_c0_guest_entryhi(cop0, entryhi); @@ -1090,8 +1090,8 @@ static void kvm_mips_invalidate_guest_tlb(struct kvm_vcpu *vcpu, if (i == cpu) continue; if (user) - cpu_context(i, user_mm) = 0; - cpu_context(i, kern_mm) = 0; + set_cpu_context(i, user_mm, 0); + set_cpu_context(i, kern_mm, 0); } preempt_enable(); diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c index 22ffe72a9e4b..73daa6ad33af 100644 --- a/arch/mips/kvm/trap_emul.c +++ b/arch/mips/kvm/trap_emul.c @@ -1098,8 +1098,8 @@ static void kvm_trap_emul_check_requests(struct kvm_vcpu *vcpu, int cpu, kvm_mips_flush_gva_pt(kern_mm->pgd, KMF_GPA | KMF_KERN); kvm_mips_flush_gva_pt(user_mm->pgd, KMF_GPA | KMF_USER); for_each_possible_cpu(i) { - cpu_context(i, kern_mm) = 0; - cpu_context(i, user_mm) = 0; + set_cpu_context(i, kern_mm, 0); + set_cpu_context(i, user_mm, 0); } /* Generate new ASID for current mode */ @@ -1211,7 +1211,7 @@ static void kvm_trap_emul_vcpu_reenter(struct kvm_run *run, if (gasid != vcpu->arch.last_user_gasid) { kvm_mips_flush_gva_pt(user_mm->pgd, KMF_USER); for_each_possible_cpu(i) - cpu_context(i, user_mm) = 0; + set_cpu_context(i, user_mm, 0); vcpu->arch.last_user_gasid = gasid; } } diff --git a/arch/mips/mm/context.c b/arch/mips/mm/context.c index 4dd976acf41d..dcaceee179f7 100644 --- a/arch/mips/mm/context.c +++ b/arch/mips/mm/context.c @@ -15,7 +15,8 @@ void get_new_mmu_context(struct mm_struct *mm) local_flush_tlb_all(); /* start new asid cycle */ } - cpu_context(cpu, mm) = asid_cache(cpu) = asid; + set_cpu_context(cpu, mm, asid); + asid_cache(cpu) = asid; } void check_mmu_context(struct mm_struct *mm) From patchwork Sat Feb 2 01:43:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5FBA6C2 for ; Sat, 2 Feb 2019 01:43:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 972472990C for ; Sat, 2 Feb 2019 01:43:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B70B29C57; Sat, 2 Feb 2019 01:43:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 090332990C for ; Sat, 2 Feb 2019 01:43:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbfBBBnx (ORCPT ); Fri, 1 Feb 2019 20:43:53 -0500 Received: from mail-eopbgr810108.outbound.protection.outlook.com ([40.107.81.108]:62863 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726488AbfBBBnx (ORCPT ); Fri, 1 Feb 2019 20:43:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WKRrooD68HPno71kQzZ1FXVOkRYCYGZtlmuu0Gf1CRE=; b=K6QyC02XqyuJk2iK8viqqb/vS+KNYWqin2PHS4/yReBb+QjyIAYaFP1jW783YseATIEsEfI95tNKSpc/FDuhcZ2tKZXjNEsyD8Kuj1wjF98MxTcc57iPRM4G92ERGwTPyXIakFsuMOIJgNmxRmNA8KBT659RblCdMM9NbR7egYc= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:27 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:27 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 13/14] MIPS: Add GINVT instruction helpers Thread-Topic: [PATCH 13/14] MIPS: Add GINVT instruction helpers Thread-Index: AQHUupix8N/Nkd9j/k2/ZLfps71AkQ== Date: Sat, 2 Feb 2019 01:43:27 +0000 Message-ID: <20190202014242.30680-14-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:4pTp9x9jEmR61bpD33i2P/mGbsnMEPlH4W8bzVMVAnb87ds0CN93e3FOOVHOFoffG4C9JzgsPo1zqF464aAkkqbV6JiulWBrx7Vk6pXa4XdX2NLiFQJ9qQzixN8lwzIlUq0/RlYwiPcxCnWSQO4BicbC2LOKE2C5pJeJL4/BH/ZLKTSz49yGVbyWtNWpuGfsQRyKi856GlgHjqXNNUsFrSlOyduZ3btUfVdHFTyOIqbi/j/HpYLcoH4oSQviNX4LfoFVXQiJXO3Lsd5Lln0+VoeFhbkAABWzkRFrvvdp6kJkET8PHiwqHBosRW+6Pl2gnrf/ep1POtHlitsiwWjDcLwdEa7mOwqEuzRE4NCPMgVOsJEXjS7oHn2r5Ana7butM8YBXzRbbKAy9FCXQ1y2iNrHlL1o9tKVQh9c1l/jbATzpHLZXidaovY3AOQvA+cgJLDxmxCRt/0Ia4AykAjuYw==;5:Zw1ZfW26LcAgEVW0GFdh+MFGQucfvB2frj3qZrE06yhg1No8aMv6cq8pvdE9qPAxevvMJIGEuOHO7AjKN9vjWpJfT2Q5Jzh9Ylgd5ca0nN1tdFIkYROFKsVr9ECnh0efnULboAcqVrBOjScH3DvWS4tr0/tnwAunaY6vxPqf4J8xXfvyUWf4IDI5ckao9IGKuguDbkv+fn2YJ/bNjzj9mg==;7:zFrbTuyYcKgQua3EjsxBumm5OTZtfvzcAlKOtY8AFIsGgWRlXEOjLpbAbbbpD6RRVdMepLQiC/J3nwstkka3m6c0A/ZGeBIWteHMj1WW1letPkm+t9QD1wbLLH+oXNDPAvwKqv4/t+cUPh0vds7Pyg== x-ms-office365-filtering-correlation-id: b88619f9-47fd-4e63-630a-08d688afd36a x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: PSyZ9GYJ/0QVqaGwoXYhUes3U5TksbBvBc9wvxwp8DVGcBxXbs/uEH3EE+KG2CkNQR+9O8GPy4+wwbIsltj9rOqAs40gtndAUiOxHBf123Gi19lDm45KMeN2FszTvesdNYiFAgDuBKl0Uwa8ol1LDDzcr1KAU9AAdlM9to3MkCVFn6BUZwsnpD20b3EMxSex8S0EGbiWLcGXUsVHkFRiQBeXBQ7291/jyjz7S1qn1OaLXTXa52+QodH+uaYWMYxRHbfLs/rUEQUw5N3AtNyiXw/WBxTxT8nO5dkK/t6bAhe8DXXRQVETk7K+vi2h7BksVvb1WVV7d2teyltes6d1JlxnrYPbe31TZoDsat+DjVE3wgfv8LygB2/dTDs+atKoOSxKkctmqhkMnLcNpqxKWFqdgSAlfXdBwXZFzeCpbg0= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: b88619f9-47fd-4e63-630a-08d688afd36a X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:26.6072 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a family of ginvt_* functions making it easy to emit a GINVT instruction to globally invalidate TLB entries. We make use of the _ASM_MACRO infrastructure to support emitting the instructions even if the assembler isn't new enough to support them natively. An associated STYPE_GINV definition & sync_ginv() function are added to emit a sync instruction of type 0x14, which operates as a completion barrier for these new GINVT (and GINVI) instructions. Signed-off-by: Paul Burton --- arch/mips/Makefile | 2 ++ arch/mips/include/asm/barrier.h | 19 +++++++++++ arch/mips/include/asm/ginvt.h | 56 ++++++++++++++++++++++++++++++++ arch/mips/include/asm/mipsregs.h | 7 ++++ 4 files changed, 84 insertions(+) create mode 100644 arch/mips/include/asm/ginvt.h diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 5b174c3d0de3..8f4486c4415b 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -233,6 +233,8 @@ toolchain-crc := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mcrc) cflags-$(toolchain-crc) += -DTOOLCHAIN_SUPPORTS_CRC toolchain-dsp := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mdsp) cflags-$(toolchain-dsp) += -DTOOLCHAIN_SUPPORTS_DSP +toolchain-ginv := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mginv) +cflags-$(toolchain-ginv) += -DTOOLCHAIN_SUPPORTS_GINV # # Firmware support diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h index a5eb1bb199a7..b48ee2caf78d 100644 --- a/arch/mips/include/asm/barrier.h +++ b/arch/mips/include/asm/barrier.h @@ -105,6 +105,20 @@ */ #define STYPE_SYNC_MB 0x10 +/* + * stype 0x14 - A completion barrier specific to global invalidations + * + * When a sync instruction of this type completes any preceding GINVI or GINVT + * operation has been globalized & completed on all coherent CPUs. Anything + * that the GINV* instruction should invalidate will have been invalidated on + * all coherent CPUs when this instruction completes. It is implementation + * specific whether the GINV* instructions themselves will ensure completion, + * or this sync type will. + * + * In systems implementing global invalidates (ie. with Config5.GI == 2 or 3) + * this sync type also requires that previous SYNCI operations have completed. + */ +#define STYPE_GINV 0x14 #ifdef CONFIG_CPU_HAS_SYNC #define __sync() \ @@ -222,6 +236,11 @@ #define __smp_mb__before_atomic() __smp_mb__before_llsc() #define __smp_mb__after_atomic() smp_llsc_mb() +static inline void sync_ginv(void) +{ + asm volatile("sync\t%0" :: "i"(STYPE_GINV)); +} + #include #endif /* __ASM_BARRIER_H */ diff --git a/arch/mips/include/asm/ginvt.h b/arch/mips/include/asm/ginvt.h new file mode 100644 index 000000000000..49c6dbe37338 --- /dev/null +++ b/arch/mips/include/asm/ginvt.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __MIPS_ASM_GINVT_H__ +#define __MIPS_ASM_GINVT_H__ + +#include + +enum ginvt_type { + GINVT_FULL, + GINVT_VA, + GINVT_MMID, +}; + +#ifdef TOOLCHAIN_SUPPORTS_GINV +# define _ASM_SET_GINV ".set ginv\n" +#else +_ASM_MACRO_1R1I(ginvt, rs, type, + _ASM_INSN_IF_MIPS(0x7c0000bd | (__rs << 21) | (\\type << 8)) + _ASM_INSN32_IF_MM(0x0000717c | (__rs << 16) | (\\type << 9))); +# define _ASM_SET_GINV +#endif + +static inline void ginvt(unsigned long addr, enum ginvt_type type) +{ + asm volatile( + ".set push\n" + _ASM_SET_GINV + " ginvt %0, %1\n" + ".set pop" + : /* no outputs */ + : "r"(addr), "i"(type) + : "memory"); +} + +static inline void ginvt_full(void) +{ + ginvt(0, GINVT_FULL); +} + +static inline void ginvt_va(unsigned long addr) +{ + addr &= PAGE_MASK << 1; + ginvt(addr, GINVT_VA); +} + +static inline void ginvt_mmid(void) +{ + ginvt(0, GINVT_MMID); +} + +static inline void ginvt_va_mmid(unsigned long addr) +{ + addr &= PAGE_MASK << 1; + ginvt(addr, GINVT_VA | GINVT_MMID); +} + +#endif /* __MIPS_ASM_GINVT_H__ */ diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h index 402b80af91aa..900a47581dd1 100644 --- a/arch/mips/include/asm/mipsregs.h +++ b/arch/mips/include/asm/mipsregs.h @@ -1247,6 +1247,13 @@ __asm__(".macro parse_r var r\n\t" ENC \ ".endm") +/* Instructions with 1 register operand & 1 immediate operand */ +#define _ASM_MACRO_1R1I(OP, R1, I2, ENC) \ + __asm__(".macro " #OP " " #R1 ", " #I2 "\n\t" \ + "parse_r __" #R1 ", \\" #R1 "\n\t" \ + ENC \ + ".endm") + /* Instructions with 2 register operands */ #define _ASM_MACRO_2R(OP, R1, R2, ENC) \ __asm__(".macro " #OP " " #R1 ", " #R2 "\n\t" \ From patchwork Sat Feb 2 01:43:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10794033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 843C86C2 for ; Sat, 2 Feb 2019 01:44:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70C5A28578 for ; Sat, 2 Feb 2019 01:44:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63B6F29C18; Sat, 2 Feb 2019 01:44:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AA2028578 for ; Sat, 2 Feb 2019 01:43:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726488AbfBBBn6 (ORCPT ); Fri, 1 Feb 2019 20:43:58 -0500 Received: from mail-eopbgr810108.outbound.protection.outlook.com ([40.107.81.108]:62863 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726449AbfBBBn6 (ORCPT ); Fri, 1 Feb 2019 20:43:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OopQOQBwU/7u5iSF4jJ9D5u7ubrPA2J7vBsy102Ejoc=; b=q5I/kVWZS1Q3DSNMjzjJwT4qcs/NiSHXWPzFf7bSmUKp89F5PFMP0usk6vg31oQ0Ev1HJ+7KdcKXtQXbfvQRFovbNWM49XTUotKN8xPr6r1Gr2GbMAUfil0BHyIvVoDQ0hu5VhtMGVC20PeFIhN0w8RmV2/pM0far1jX837RqW0= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1439.namprd22.prod.outlook.com (10.174.169.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.21; Sat, 2 Feb 2019 01:43:28 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1580.019; Sat, 2 Feb 2019 01:43:28 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Paul Burton Subject: [PATCH 14/14] MIPS: MemoryMapID (MMID) Support Thread-Topic: [PATCH 14/14] MIPS: MemoryMapID (MMID) Support Thread-Index: AQHUupiywx4/gueQGUC4WTD4p7yoZg== Date: Sat, 2 Feb 2019 01:43:28 +0000 Message-ID: <20190202014242.30680-15-paul.burton@mips.com> References: <20190202014242.30680-1-paul.burton@mips.com> In-Reply-To: <20190202014242.30680-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0021.prod.exchangelabs.com (2603:10b6:a02:80::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR2201MB1439;6:X+XKIBg46xHoj5K6LlnrhYu7SEyKUz0heihnmgPmy+45bFEL1x1FIani7aZZaDHmOsv+P4+C9dG77sGMEsffIuVadwpx/NCxhciSdCdN7s93DfO97WozMuRQf5Lt2UG/gCJbqIOCbawikp4lqrPkH0SgK0oVVsjwfeI2+0Bf3kPlzU9rCpcyIeRHw81S8DrDoT5jjmM+k3J/gHk8SGDLlAymQ6ZqWb073xT6Evt+UtLOsLGEyRicEASIn6fOO7TgoYhCaFsVS4wptAmdauM4lqoO9+gpbaV50E7r9YnN0lwXOATpCMDHqAQ91flWorU5tVY028vqXFBCWNcEPKf1KN+mf47ClABjowYwpWV0C+3GVX9xrbOr1/385P7LRMUA8hxHj06PQuY4rQR5N4zyol5aOi9CfmeiuGh8EPxk31+dDwZWChfMMGzeSo+yYRPH3dPJlMDTQqZIACkRYfnqNA==;5:vfxQxuwifdo27xssks6C2Lz+8B71Sb2KSQIuiZzxNULYaJDkGW3jToXP5+x/Pq3HewrisEdk+e0zfnABtaJ9tYCwuHqRX8pnf8NOHAOJ+8td3QSBd5zt0tfF+P3ylLTSBCH4WAml3jWSa/nPdkJ/LPqPZP6M1M3M2tGPTf2DaxNMg64T4WCoBOCFoyN1FtfZaWnUF9KFDtuQn9EzbwgZ5w==;7:x05S9LYWjr+dVUqjFAeIPrf8vD28b/bUFcP2WpGIUi8d4cUP9cHV74k4bsfFbqO7HrOtQq05QQYP/GtKvUbGldYVwhXh/FZvr5saopFHJ5v0bok20ryJ/ZfuOIpdFjJTNvro6cUsDEYcfj4ueAzZYA== x-ms-office365-filtering-correlation-id: 7827f1c9-b8f1-49f6-bc92-08d688afd429 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1439; x-ms-traffictypediagnostic: MWHPR2201MB1439: x-microsoft-antispam-prvs: x-forefront-prvs: 09368DB063 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39850400004)(376002)(346002)(199004)(189003)(2616005)(6436002)(446003)(42882007)(106356001)(1076003)(386003)(2501003)(6506007)(305945005)(476003)(107886003)(316002)(25786009)(97736004)(105586002)(11346002)(30864003)(7736002)(26005)(186003)(36756003)(3846002)(102836004)(6116002)(44832011)(50226002)(53946003)(486006)(5640700003)(6916009)(68736007)(99286004)(4326008)(2906002)(8936002)(6486002)(76176011)(8676002)(71190400001)(256004)(14444005)(14454004)(2351001)(71200400001)(66066001)(52116002)(6512007)(478600001)(81156014)(81166006)(53936002)(87944003)(569006);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1439;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 5ipuTyS6hw8qN5s+ftzHIL/mAaMq03vKAU9fuhQ+nkDYrmirH1srEUz6QpRslrKoV592Ml7L4FYfrW5iq++GODhuAmTu+lrAPt9xwCGgwRmNmXbQ3WLu1VukhsJbA51Tmrp7KGM1fluAlOWtIC2weCpiZYelkuEsXQZDVNhVB1vFvT5O/sKTH03KL7lMmHQqfz9nAvMTboX+HOqzF11DX2GoRF19G14oQWchHPvv591JfLC2Y8viyiAgy8ltYO4yGNa9fLrLaBCs4kTUJTSMS8jOWlM6aKxlI+obDRLDiIlya6l8C7lr+x/idXBnLyzNfSOMk5V2wb7Bmw6xdnQYAhyeYSmY2KuG3vcecbmYSYNktezgcO30r4KYZE5BxzOnmQKEh7gkoZxOtCHO7lj43kBmIVjrO9hVlLKcL1KQXM4= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7827f1c9-b8f1-49f6-bc92-08d688afd429 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Feb 2019 01:43:27.8612 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1439 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce support for using MemoryMapIDs (MMIDs) as an alternative to Address Space IDs (ASIDs). The major difference between the two is that MMIDs are global - ie. an MMID uniquely identifies an address space across all coherent CPUs. In contrast ASIDs are non-global per-CPU IDs, wherein each address space is allocated a separate ASID for each CPU upon which it is used. This global namespace allows a new GINVT instruction be used to globally invalidate TLB entries associated with a particular MMID across all coherent CPUs in the system, removing the need for IPIs to invalidate entries with separate ASIDs on each CPU. The allocation scheme used here is largely borrowed from arm64 (see arch/arm64/mm/context.c). In essence we maintain a bitmap to track available MMIDs, and MMIDs in active use at the time of a rollover to a new MMID version are preserved in the new version. The allocation scheme requires efficient 64 bit atomics in order to perform reasonably, so this support depends upon CONFIG_GENERIC_ATOMIC64=n (ie. currently it will only be included in MIPS64 kernels). The first, and currently only, available CPU with support for MMIDs is the MIPS I6500. This CPU supports 16 bit MMIDs, and so for now we cap our MMIDs to 16 bits wide in order to prevent the bitmap growing to absurd sizes if any future CPU does implement 32 bit MMIDs as the architecture manuals suggest is recommended. When MMIDs are in use we also make use of GINVT instruction which is available due to the global nature of MMIDs. By executing a sequence of GINVT & SYNC 0x14 instructions we can avoid the overhead of an IPI to each remote CPU in many cases. One complication is that GINVT will invalidate wired entries (in all cases apart from type 0, which targets the entire TLB). In order to avoid GINVT invalidating any wired TLB entries we set up, we make sure to create those entries using a reserved MMID (0) that we never associate with any address space. Also of note is that KVM will require further work in order to support MMIDs & GINVT, since KVM is involved in allocating IDs for guests & in configuring the MMU. That work is not part of this patch, so for now when MMIDs are in use KVM is disabled. Signed-off-by: Paul Burton --- arch/mips/include/asm/cpu-features.h | 13 ++ arch/mips/include/asm/cpu.h | 1 + arch/mips/include/asm/mipsregs.h | 4 + arch/mips/include/asm/mmu.h | 6 +- arch/mips/include/asm/mmu_context.h | 54 +++++- arch/mips/kernel/cpu-probe.c | 55 +++++- arch/mips/kernel/smp.c | 57 +++++- arch/mips/kernel/traps.c | 4 +- arch/mips/kernel/unaligned.c | 1 + arch/mips/kvm/mips.c | 5 + arch/mips/lib/dump_tlb.c | 22 ++- arch/mips/mm/c-r4k.c | 3 + arch/mips/mm/context.c | 256 ++++++++++++++++++++++++++- arch/mips/mm/init.c | 7 + arch/mips/mm/tlb-r4k.c | 52 ++++-- 15 files changed, 509 insertions(+), 31 deletions(-) diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 701e525641b8..6998a9796499 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -590,6 +590,19 @@ # define cpu_has_mipsmt_pertccounters 0 #endif /* CONFIG_MIPS_MT_SMP */ +/* + * We only enable MMID support for configurations which natively support 64 bit + * atomics because getting good performance from the allocator relies upon + * efficient atomic64_*() functions. + */ +#ifndef cpu_has_mmid +# ifdef CONFIG_GENERIC_ATOMIC64 +# define cpu_has_mmid 0 +# else +# define cpu_has_mmid __isa_ge_and_opt(6, MIPS_CPU_MMID) +# endif +#endif + /* * Guest capabilities */ diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h index 532b49b1dbb3..6ad7d3cabd91 100644 --- a/arch/mips/include/asm/cpu.h +++ b/arch/mips/include/asm/cpu.h @@ -422,6 +422,7 @@ enum cpu_type_enum { MBIT_ULL(55) /* CPU shares FTLB entries with another */ #define MIPS_CPU_MT_PER_TC_PERF_COUNTERS \ MBIT_ULL(56) /* CPU has perf counters implemented per TC (MIPSMT ASE) */ +#define MIPS_CPU_MMID MBIT_ULL(57) /* CPU supports MemoryMapIDs */ /* * CPU ASE encodings diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h index 900a47581dd1..1e6966e8527e 100644 --- a/arch/mips/include/asm/mipsregs.h +++ b/arch/mips/include/asm/mipsregs.h @@ -667,6 +667,7 @@ #define MIPS_CONF5_FRE (_ULCAST_(1) << 8) #define MIPS_CONF5_UFE (_ULCAST_(1) << 9) #define MIPS_CONF5_CA2 (_ULCAST_(1) << 14) +#define MIPS_CONF5_MI (_ULCAST_(1) << 17) #define MIPS_CONF5_CRCP (_ULCAST_(1) << 18) #define MIPS_CONF5_MSAEN (_ULCAST_(1) << 27) #define MIPS_CONF5_EVA (_ULCAST_(1) << 28) @@ -1610,6 +1611,9 @@ do { \ #define read_c0_xcontextconfig() __read_ulong_c0_register($4, 3) #define write_c0_xcontextconfig(val) __write_ulong_c0_register($4, 3, val) +#define read_c0_memorymapid() __read_32bit_c0_register($4, 5) +#define write_c0_memorymapid(val) __write_32bit_c0_register($4, 5, val) + #define read_c0_pagemask() __read_32bit_c0_register($5, 0) #define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val) diff --git a/arch/mips/include/asm/mmu.h b/arch/mips/include/asm/mmu.h index 88a108ce62c1..5df0238f639b 100644 --- a/arch/mips/include/asm/mmu.h +++ b/arch/mips/include/asm/mmu.h @@ -7,7 +7,11 @@ #include typedef struct { - u64 asid[NR_CPUS]; + union { + u64 asid[NR_CPUS]; + atomic64_t mmid; + }; + void *vdso; /* lock to be held whilst modifying fp_bd_emupage_allocmap */ diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h index a0f29df8ced8..cddead91acd4 100644 --- a/arch/mips/include/asm/mmu_context.h +++ b/arch/mips/include/asm/mmu_context.h @@ -17,8 +17,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -72,6 +74,19 @@ extern unsigned long pgd_current[]; TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir) #endif /* CONFIG_MIPS_PGD_C0_CONTEXT*/ +/* + * The ginvt instruction will invalidate wired entries when its type field + * targets anything other than the entire TLB. That means that if we were to + * allow the kernel to create wired entries with the MMID of current->active_mm + * then those wired entries could be invalidated when we later use ginvt to + * invalidate TLB entries with that MMID. + * + * In order to prevent ginvt from trashing wired entries, we reserve one MMID + * for use by the kernel when creating wired entries. This MMID will never be + * assigned to a struct mm, and we'll never target it with a ginvt instruction. + */ +#define MMID_KERNEL_WIRED 0 + /* * All unused by hardware upper bits will be considered * as a software asid extension. @@ -90,13 +105,19 @@ static inline u64 asid_first_version(unsigned int cpu) static inline u64 cpu_context(unsigned int cpu, const struct mm_struct *mm) { + if (cpu_has_mmid) + return atomic64_read(&mm->context.mmid); + return mm->context.asid[cpu]; } static inline void set_cpu_context(unsigned int cpu, struct mm_struct *mm, u64 ctx) { - mm->context.asid[cpu] = ctx; + if (cpu_has_mmid) + atomic64_set(&mm->context.mmid, ctx); + else + mm->context.asid[cpu] = ctx; } #define asid_cache(cpu) (cpu_data[cpu].asid_cache) @@ -120,8 +141,12 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm) { int i; - for_each_possible_cpu(i) - set_cpu_context(i, mm, 0); + if (cpu_has_mmid) { + set_cpu_context(0, mm, 0); + } else { + for_each_possible_cpu(i) + set_cpu_context(i, mm, 0); + } mm->context.bd_emupage_allocmap = NULL; spin_lock_init(&mm->context.bd_emupage_lock); @@ -168,12 +193,33 @@ drop_mmu_context(struct mm_struct *mm) { unsigned long flags; unsigned int cpu; + u32 old_mmid; + u64 ctx; local_irq_save(flags); cpu = smp_processor_id(); - if (!cpu_context(cpu, mm)) { + ctx = cpu_context(cpu, mm); + + if (!ctx) { /* no-op */ + } else if (cpu_has_mmid) { + /* + * Globally invalidating TLB entries associated with the MMID + * is pretty cheap using the GINVT instruction, so we'll do + * that rather than incur the overhead of allocating a new + * MMID. The latter would be especially difficult since MMIDs + * are global & other CPUs may be actively using ctx. + */ + htw_stop(); + old_mmid = read_c0_memorymapid(); + write_c0_memorymapid(ctx & cpu_asid_mask(&cpu_data[cpu])); + mtc0_tlbw_hazard(); + ginvt_mmid(); + sync_ginv(); + write_c0_memorymapid(old_mmid); + instruction_hazard(); + htw_start(); } else if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { /* * mm is currently active, so we can't really drop it. diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index 95b18a194f53..d5e335e6846a 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -872,10 +872,19 @@ static inline unsigned int decode_config4(struct cpuinfo_mips *c) static inline unsigned int decode_config5(struct cpuinfo_mips *c) { - unsigned int config5; + unsigned int config5, max_mmid_width; + unsigned long asid_mask; config5 = read_c0_config5(); config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE); + + if (cpu_has_mips_r6) { + if (!__builtin_constant_p(cpu_has_mmid) || cpu_has_mmid) + config5 |= MIPS_CONF5_MI; + else + config5 &= ~MIPS_CONF5_MI; + } + write_c0_config5(config5); if (config5 & MIPS_CONF5_EVA) @@ -894,6 +903,50 @@ static inline unsigned int decode_config5(struct cpuinfo_mips *c) if (config5 & MIPS_CONF5_CRCP) elf_hwcap |= HWCAP_MIPS_CRC32; + if (cpu_has_mips_r6) { + /* Ensure the write to config5 above takes effect */ + back_to_back_c0_hazard(); + + /* Check whether we successfully enabled MMID support */ + config5 = read_c0_config5(); + if (config5 & MIPS_CONF5_MI) + c->options |= MIPS_CPU_MMID; + + /* + * Warn if we've hardcoded cpu_has_mmid to a value unsuitable + * for the CPU we're running on, or if CPUs in an SMP system + * have inconsistent MMID support. + */ + WARN_ON(!!cpu_has_mmid != !!(config5 & MIPS_CONF5_MI)); + + if (cpu_has_mmid) { + write_c0_memorymapid(~0ul); + back_to_back_c0_hazard(); + asid_mask = read_c0_memorymapid(); + + /* + * We maintain a bitmap to track MMID allocation, and + * need a sensible upper bound on the size of that + * bitmap. The initial CPU with MMID support (I6500) + * supports 16 bit MMIDs, which gives us an 8KiB + * bitmap. The architecture recommends that hardware + * support 32 bit MMIDs, which would give us a 512MiB + * bitmap - that's too big in most cases. + * + * Cap MMID width at 16 bits for now & we can revisit + * this if & when hardware supports anything wider. + */ + max_mmid_width = 16; + if (asid_mask > GENMASK(max_mmid_width - 1, 0)) { + pr_info("Capping MMID width at %d bits", + max_mmid_width); + asid_mask = GENMASK(max_mmid_width - 1, 0); + } + + set_cpu_asid_mask(c, asid_mask); + } + } + return config5 & MIPS_CONF_M; } diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index f9dbd95e1d68..6fd9e94fc87e 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -482,6 +483,15 @@ static void flush_tlb_all_ipi(void *info) void flush_tlb_all(void) { + if (cpu_has_mmid) { + htw_stop(); + ginvt_full(); + sync_ginv(); + instruction_hazard(); + htw_start(); + return; + } + on_each_cpu(flush_tlb_all_ipi, NULL, 1); } @@ -530,7 +540,12 @@ void flush_tlb_mm(struct mm_struct *mm) { preempt_disable(); - if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) { + if (cpu_has_mmid) { + /* + * No need to worry about other CPUs - the ginvt in + * drop_mmu_context() will be globalized. + */ + } else if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) { smp_on_other_tlbs(flush_tlb_mm_ipi, mm); } else { unsigned int cpu; @@ -561,9 +576,26 @@ static void flush_tlb_range_ipi(void *info) void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) { struct mm_struct *mm = vma->vm_mm; + unsigned long addr; + u32 old_mmid; preempt_disable(); - if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) { + if (cpu_has_mmid) { + htw_stop(); + old_mmid = read_c0_memorymapid(); + write_c0_memorymapid(cpu_asid(0, mm)); + mtc0_tlbw_hazard(); + addr = round_down(start, PAGE_SIZE * 2); + end = round_up(end, PAGE_SIZE * 2); + do { + ginvt_va_mmid(addr); + sync_ginv(); + addr += PAGE_SIZE * 2; + } while (addr < end); + write_c0_memorymapid(old_mmid); + instruction_hazard(); + htw_start(); + } else if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) { struct flush_tlb_data fd = { .vma = vma, .addr1 = start, @@ -571,6 +603,7 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned l }; smp_on_other_tlbs(flush_tlb_range_ipi, &fd); + local_flush_tlb_range(vma, start, end); } else { unsigned int cpu; int exec = vma->vm_flags & VM_EXEC; @@ -585,8 +618,8 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned l if (cpu != smp_processor_id() && cpu_context(cpu, mm)) set_cpu_context(cpu, mm, !exec); } + local_flush_tlb_range(vma, start, end); } - local_flush_tlb_range(vma, start, end); preempt_enable(); } @@ -616,14 +649,28 @@ static void flush_tlb_page_ipi(void *info) void flush_tlb_page(struct vm_area_struct *vma, unsigned long page) { + u32 old_mmid; + preempt_disable(); - if ((atomic_read(&vma->vm_mm->mm_users) != 1) || (current->mm != vma->vm_mm)) { + if (cpu_has_mmid) { + htw_stop(); + old_mmid = read_c0_memorymapid(); + write_c0_memorymapid(cpu_asid(0, vma->vm_mm)); + mtc0_tlbw_hazard(); + ginvt_va_mmid(page); + sync_ginv(); + write_c0_memorymapid(old_mmid); + instruction_hazard(); + htw_start(); + } else if ((atomic_read(&vma->vm_mm->mm_users) != 1) || + (current->mm != vma->vm_mm)) { struct flush_tlb_data fd = { .vma = vma, .addr1 = page, }; smp_on_other_tlbs(flush_tlb_page_ipi, &fd); + local_flush_tlb_page(vma, page); } else { unsigned int cpu; @@ -637,8 +684,8 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long page) if (cpu != smp_processor_id() && cpu_context(cpu, vma->vm_mm)) set_cpu_context(cpu, vma->vm_mm, 1); } + local_flush_tlb_page(vma, page); } - local_flush_tlb_page(vma, page); preempt_enable(); } diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index c91097f7b32f..995249be64f1 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2223,7 +2223,9 @@ void per_cpu_trap_init(bool is_boot_cpu) cp0_fdc_irq = -1; } - if (!cpu_data[cpu].asid_cache) + if (cpu_has_mmid) + cpu_data[cpu].asid_cache = 0; + else if (!cpu_data[cpu].asid_cache) cpu_data[cpu].asid_cache = asid_first_version(cpu); mmgrab(&init_mm); diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c index 595ca9c85111..22485f26b10a 100644 --- a/arch/mips/kernel/unaligned.c +++ b/arch/mips/kernel/unaligned.c @@ -89,6 +89,7 @@ #include #include #include +#include #include #define STR(x) __STR(x) diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 3734cd58895e..6d0517ac18e5 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -1723,6 +1723,11 @@ static int __init kvm_mips_init(void) { int ret; + if (cpu_has_mmid) { + pr_warn("KVM does not yet support MMIDs. KVM Disabled\n"); + return -EOPNOTSUPP; + } + ret = kvm_mips_entry_setup(); if (ret) return ret; diff --git a/arch/mips/lib/dump_tlb.c b/arch/mips/lib/dump_tlb.c index 781ad96b78c4..83ed37298e66 100644 --- a/arch/mips/lib/dump_tlb.c +++ b/arch/mips/lib/dump_tlb.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -73,12 +74,13 @@ static inline const char *msk2str(unsigned int mask) static void dump_tlb(int first, int last) { - unsigned long s_entryhi, entryhi, asid; + unsigned long s_entryhi, entryhi, asid, mmid; unsigned long long entrylo0, entrylo1, pa; unsigned int s_index, s_pagemask, s_guestctl1 = 0; unsigned int pagemask, guestctl1 = 0, c0, c1, i; unsigned long asidmask = cpu_asid_mask(¤t_cpu_data); int asidwidth = DIV_ROUND_UP(ilog2(asidmask) + 1, 4); + unsigned long uninitialized_var(s_mmid); #ifdef CONFIG_32BIT bool xpa = cpu_has_xpa && (read_c0_pagegrain() & PG_ELPA); int pwidth = xpa ? 11 : 8; @@ -92,7 +94,12 @@ static void dump_tlb(int first, int last) s_pagemask = read_c0_pagemask(); s_entryhi = read_c0_entryhi(); s_index = read_c0_index(); - asid = s_entryhi & asidmask; + + if (cpu_has_mmid) + asid = s_mmid = read_c0_memorymapid(); + else + asid = s_entryhi & asidmask; + if (cpu_has_guestid) s_guestctl1 = read_c0_guestctl1(); @@ -105,6 +112,12 @@ static void dump_tlb(int first, int last) entryhi = read_c0_entryhi(); entrylo0 = read_c0_entrylo0(); entrylo1 = read_c0_entrylo1(); + + if (cpu_has_mmid) + mmid = read_c0_memorymapid(); + else + mmid = entryhi & asidmask; + if (cpu_has_guestid) guestctl1 = read_c0_guestctl1(); @@ -124,8 +137,7 @@ static void dump_tlb(int first, int last) * leave only a single G bit set after a machine check exception * due to duplicate TLB entry. */ - if (!((entrylo0 | entrylo1) & ENTRYLO_G) && - (entryhi & asidmask) != asid) + if (!((entrylo0 | entrylo1) & ENTRYLO_G) && (mmid != asid)) continue; /* @@ -138,7 +150,7 @@ static void dump_tlb(int first, int last) pr_cont("va=%0*lx asid=%0*lx", vwidth, (entryhi & ~0x1fffUL), - asidwidth, entryhi & asidmask); + asidwidth, mmid); if (cpu_has_guestid) pr_cont(" gid=%02lx", (guestctl1 & MIPS_GCTL1_RID) diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index 248d9e8263cf..cc4e17caeb26 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -540,6 +540,9 @@ static inline int has_valid_asid(const struct mm_struct *mm, unsigned int type) unsigned int i; const cpumask_t *mask = cpu_present_mask; + if (cpu_has_mmid) + return cpu_context(0, mm) != 0; + /* cpu_sibling_map[] undeclared when !CONFIG_SMP */ #ifdef CONFIG_SMP /* diff --git a/arch/mips/mm/context.c b/arch/mips/mm/context.c index dcaceee179f7..a6adae550788 100644 --- a/arch/mips/mm/context.c +++ b/arch/mips/mm/context.c @@ -1,11 +1,35 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include +#include +#include + +static DEFINE_RAW_SPINLOCK(cpu_mmid_lock); + +static atomic64_t mmid_version; +static unsigned int num_mmids; +static unsigned long *mmid_map; + +static DEFINE_PER_CPU(u64, reserved_mmids); +static cpumask_t tlb_flush_pending; + +static bool asid_versions_eq(int cpu, u64 a, u64 b) +{ + return ((a ^ b) & asid_version_mask(cpu)) == 0; +} void get_new_mmu_context(struct mm_struct *mm) { unsigned int cpu; u64 asid; + /* + * This function is specific to ASIDs, and should not be called when + * MMIDs are in use. + */ + if (WARN_ON(IS_ENABLED(CONFIG_DEBUG_VM) && cpu_has_mmid)) + return; + cpu = smp_processor_id(); asid = asid_cache(cpu); @@ -23,16 +47,242 @@ void check_mmu_context(struct mm_struct *mm) { unsigned int cpu = smp_processor_id(); + /* + * This function is specific to ASIDs, and should not be called when + * MMIDs are in use. + */ + if (WARN_ON(IS_ENABLED(CONFIG_DEBUG_VM) && cpu_has_mmid)) + return; + /* Check if our ASID is of an older version and thus invalid */ - if ((cpu_context(cpu, mm) ^ asid_cache(cpu)) & asid_version_mask(cpu)) + if (!asid_versions_eq(cpu, cpu_context(cpu, mm), asid_cache(cpu))) get_new_mmu_context(mm); } +static void flush_context(void) +{ + u64 mmid; + int cpu; + + /* Update the list of reserved MMIDs and the MMID bitmap */ + bitmap_clear(mmid_map, 0, num_mmids); + + /* Reserve an MMID for kmap/wired entries */ + __set_bit(MMID_KERNEL_WIRED, mmid_map); + + for_each_possible_cpu(cpu) { + mmid = xchg_relaxed(&cpu_data[cpu].asid_cache, 0); + + /* + * If this CPU has already been through a + * rollover, but hasn't run another task in + * the meantime, we must preserve its reserved + * MMID, as this is the only trace we have of + * the process it is still running. + */ + if (mmid == 0) + mmid = per_cpu(reserved_mmids, cpu); + + __set_bit(mmid & cpu_asid_mask(&cpu_data[cpu]), mmid_map); + per_cpu(reserved_mmids, cpu) = mmid; + } + + /* + * Queue a TLB invalidation for each CPU to perform on next + * context-switch + */ + cpumask_setall(&tlb_flush_pending); +} + +static bool check_update_reserved_mmid(u64 mmid, u64 newmmid) +{ + bool hit; + int cpu; + + /* + * Iterate over the set of reserved MMIDs looking for a match. + * If we find one, then we can update our mm to use newmmid + * (i.e. the same MMID in the current generation) but we can't + * exit the loop early, since we need to ensure that all copies + * of the old MMID are updated to reflect the mm. Failure to do + * so could result in us missing the reserved MMID in a future + * generation. + */ + hit = false; + for_each_possible_cpu(cpu) { + if (per_cpu(reserved_mmids, cpu) == mmid) { + hit = true; + per_cpu(reserved_mmids, cpu) = newmmid; + } + } + + return hit; +} + +static u64 get_new_mmid(struct mm_struct *mm) +{ + static u32 cur_idx = MMID_KERNEL_WIRED + 1; + u64 mmid, version, mmid_mask; + + mmid = cpu_context(0, mm); + version = atomic64_read(&mmid_version); + mmid_mask = cpu_asid_mask(&boot_cpu_data); + + if (!asid_versions_eq(0, mmid, 0)) { + u64 newmmid = version | (mmid & mmid_mask); + + /* + * If our current MMID was active during a rollover, we + * can continue to use it and this was just a false alarm. + */ + if (check_update_reserved_mmid(mmid, newmmid)) { + mmid = newmmid; + goto set_context; + } + + /* + * We had a valid MMID in a previous life, so try to re-use + * it if possible. + */ + if (!__test_and_set_bit(mmid & mmid_mask, mmid_map)) { + mmid = newmmid; + goto set_context; + } + } + + /* Allocate a free MMID */ + mmid = find_next_zero_bit(mmid_map, num_mmids, cur_idx); + if (mmid != num_mmids) + goto reserve_mmid; + + /* We're out of MMIDs, so increment the global version */ + version = atomic64_add_return_relaxed(asid_first_version(0), + &mmid_version); + + /* Note currently active MMIDs & mark TLBs as requiring flushes */ + flush_context(); + + /* We have more MMIDs than CPUs, so this will always succeed */ + mmid = find_first_zero_bit(mmid_map, num_mmids); + +reserve_mmid: + __set_bit(mmid, mmid_map); + cur_idx = mmid; + mmid |= version; +set_context: + set_cpu_context(0, mm, mmid); + return mmid; +} + void check_switch_mmu_context(struct mm_struct *mm) { unsigned int cpu = smp_processor_id(); + u64 ctx, old_active_mmid; + unsigned long flags; - check_mmu_context(mm); - write_c0_entryhi(cpu_asid(cpu, mm)); + if (!cpu_has_mmid) { + check_mmu_context(mm); + write_c0_entryhi(cpu_asid(cpu, mm)); + goto setup_pgd; + } + + /* + * MMID switch fast-path, to avoid acquiring cpu_mmid_lock when it's + * unnecessary. + * + * The memory ordering here is subtle. If our active_mmids is non-zero + * and the MMID matches the current version, then we update the CPU's + * asid_cache with a relaxed cmpxchg. Racing with a concurrent rollover + * means that either: + * + * - We get a zero back from the cmpxchg and end up waiting on + * cpu_mmid_lock in check_mmu_context(). Taking the lock synchronises + * with the rollover and so we are forced to see the updated + * generation. + * + * - We get a valid MMID back from the cmpxchg, which means the + * relaxed xchg in flush_context will treat us as reserved + * because atomic RmWs are totally ordered for a given location. + */ + ctx = cpu_context(cpu, mm); + old_active_mmid = READ_ONCE(cpu_data[cpu].asid_cache); + if (!old_active_mmid || + !asid_versions_eq(cpu, ctx, atomic64_read(&mmid_version)) || + !cmpxchg_relaxed(&cpu_data[cpu].asid_cache, old_active_mmid, ctx)) { + raw_spin_lock_irqsave(&cpu_mmid_lock, flags); + + ctx = cpu_context(cpu, mm); + if (!asid_versions_eq(cpu, ctx, atomic64_read(&mmid_version))) + ctx = get_new_mmid(mm); + + WRITE_ONCE(cpu_data[cpu].asid_cache, ctx); + raw_spin_unlock_irqrestore(&cpu_mmid_lock, flags); + } + + /* + * Invalidate the local TLB if needed. Note that we must only clear our + * bit in tlb_flush_pending after this is complete, so that the + * cpu_has_shared_ftlb_entries case below isn't misled. + */ + if (cpumask_test_cpu(cpu, &tlb_flush_pending)) { + if (cpu_has_vtag_icache) + flush_icache_all(); + local_flush_tlb_all(); + cpumask_clear_cpu(cpu, &tlb_flush_pending); + } + + write_c0_memorymapid(ctx & cpu_asid_mask(&boot_cpu_data)); + + /* + * If this CPU shares FTLB entries with its siblings and one or more of + * those siblings hasn't yet invalidated its TLB following a version + * increase then we need to invalidate any TLB entries for our MMID + * that we might otherwise pick up from a sibling. + * + * We ifdef on CONFIG_SMP because cpu_sibling_map isn't defined in + * CONFIG_SMP=n kernels. + */ +#ifdef CONFIG_SMP + if (cpu_has_shared_ftlb_entries && + cpumask_intersects(&tlb_flush_pending, &cpu_sibling_map[cpu])) { + /* Ensure we operate on the new MMID */ + mtc0_tlbw_hazard(); + + /* + * Invalidate all TLB entries associated with the new + * MMID, and wait for the invalidation to complete. + */ + ginvt_mmid(); + sync_ginv(); + } +#endif + +setup_pgd: TLBMISS_HANDLER_SETUP_PGD(mm->pgd); } + +static int mmid_init(void) +{ + if (!cpu_has_mmid) + return 0; + + /* + * Expect allocation after rollover to fail if we don't have at least + * one more MMID than CPUs. + */ + num_mmids = asid_first_version(0); + WARN_ON(num_mmids <= num_possible_cpus()); + + atomic64_set(&mmid_version, asid_first_version(0)); + mmid_map = kcalloc(BITS_TO_LONGS(num_mmids), sizeof(*mmid_map), + GFP_KERNEL); + if (!mmid_map) + panic("Failed to allocate bitmap for %u MMIDs\n", num_mmids); + + /* Reserve an MMID for kmap/wired entries */ + __set_bit(MMID_KERNEL_WIRED, mmid_map); + + pr_info("MMID allocator initialised with %u entries\n", num_mmids); + return 0; +} +early_initcall(mmid_init); diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index b521d8e2d359..c3b45e248806 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -84,6 +84,7 @@ void setup_zero_pages(void) static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot) { enum fixed_addresses idx; + unsigned int uninitialized_var(old_mmid); unsigned long vaddr, flags, entrylo; unsigned long old_ctx; pte_t pte; @@ -110,6 +111,10 @@ static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot) write_c0_entryhi(vaddr & (PAGE_MASK << 1)); write_c0_entrylo0(entrylo); write_c0_entrylo1(entrylo); + if (cpu_has_mmid) { + old_mmid = read_c0_memorymapid(); + write_c0_memorymapid(MMID_KERNEL_WIRED); + } #ifdef CONFIG_XPA if (cpu_has_xpa) { entrylo = (pte.pte_low & _PFNX_MASK); @@ -124,6 +129,8 @@ static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot) tlb_write_indexed(); tlbw_use_hazard(); write_c0_entryhi(old_ctx); + if (cpu_has_mmid) + write_c0_memorymapid(old_mmid); local_irq_restore(flags); return (void*) vaddr; diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 0114c43398f3..c13e46ced425 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -120,14 +120,23 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, if (size <= (current_cpu_data.tlbsizeftlbsets ? current_cpu_data.tlbsize / 8 : current_cpu_data.tlbsize / 2)) { - int oldpid = read_c0_entryhi(); + unsigned long old_entryhi, uninitialized_var(old_mmid); int newpid = cpu_asid(cpu, mm); + old_entryhi = read_c0_entryhi(); + if (cpu_has_mmid) { + old_mmid = read_c0_memorymapid(); + write_c0_memorymapid(newpid); + } + htw_stop(); while (start < end) { int idx; - write_c0_entryhi(start | newpid); + if (cpu_has_mmid) + write_c0_entryhi(start); + else + write_c0_entryhi(start | newpid); start += (PAGE_SIZE << 1); mtc0_tlbw_hazard(); tlb_probe(); @@ -143,7 +152,9 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, tlb_write_indexed(); } tlbw_use_hazard(); - write_c0_entryhi(oldpid); + write_c0_entryhi(old_entryhi); + if (cpu_has_mmid) + write_c0_memorymapid(old_mmid); htw_start(); } else { drop_mmu_context(mm); @@ -203,15 +214,21 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) int cpu = smp_processor_id(); if (cpu_context(cpu, vma->vm_mm) != 0) { - unsigned long flags; - int oldpid, newpid, idx; + unsigned long uninitialized_var(old_mmid); + unsigned long flags, old_entryhi; + int idx; - newpid = cpu_asid(cpu, vma->vm_mm); page &= (PAGE_MASK << 1); local_irq_save(flags); - oldpid = read_c0_entryhi(); + old_entryhi = read_c0_entryhi(); htw_stop(); - write_c0_entryhi(page | newpid); + if (cpu_has_mmid) { + old_mmid = read_c0_memorymapid(); + write_c0_entryhi(page); + write_c0_memorymapid(cpu_asid(cpu, vma->vm_mm)); + } else { + write_c0_entryhi(page | cpu_asid(cpu, vma->vm_mm)); + } mtc0_tlbw_hazard(); tlb_probe(); tlb_probe_hazard(); @@ -227,7 +244,9 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) tlbw_use_hazard(); finish: - write_c0_entryhi(oldpid); + write_c0_entryhi(old_entryhi); + if (cpu_has_mmid) + write_c0_memorymapid(old_mmid); htw_start(); flush_micro_tlb_vm(vma); local_irq_restore(flags); @@ -290,9 +309,13 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) local_irq_save(flags); htw_stop(); - pid = read_c0_entryhi() & cpu_asid_mask(¤t_cpu_data); address &= (PAGE_MASK << 1); - write_c0_entryhi(address | pid); + if (cpu_has_mmid) { + write_c0_entryhi(address); + } else { + pid = read_c0_entryhi() & cpu_asid_mask(¤t_cpu_data); + write_c0_entryhi(address | pid); + } pgdp = pgd_offset(vma->vm_mm, address); mtc0_tlbw_hazard(); tlb_probe(); @@ -358,12 +381,17 @@ void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, #ifdef CONFIG_XPA panic("Broken for XPA kernels"); #else + unsigned int uninitialized_var(old_mmid); unsigned long flags; unsigned long wired; unsigned long old_pagemask; unsigned long old_ctx; local_irq_save(flags); + if (cpu_has_mmid) { + old_mmid = read_c0_memorymapid(); + write_c0_memorymapid(MMID_KERNEL_WIRED); + } /* Save old context and create impossible VPN2 value */ old_ctx = read_c0_entryhi(); htw_stop(); @@ -381,6 +409,8 @@ void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1, tlbw_use_hazard(); write_c0_entryhi(old_ctx); + if (cpu_has_mmid) + write_c0_memorymapid(old_mmid); tlbw_use_hazard(); /* What is the hazard here? */ htw_start(); write_c0_pagemask(old_pagemask);