From patchwork Tue Apr 30 22:53:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10924313 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 2C3EB1398 for ; Tue, 30 Apr 2019 22:53:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CCC228ABE for ; Tue, 30 Apr 2019 22:53:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 107FA28D4C; Tue, 30 Apr 2019 22:53: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 A19A928ABE for ; Tue, 30 Apr 2019 22:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727012AbfD3Wxf (ORCPT ); Tue, 30 Apr 2019 18:53:35 -0400 Received: from mail-eopbgr800137.outbound.protection.outlook.com ([40.107.80.137]:36205 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727341AbfD3Wxf (ORCPT ); Tue, 30 Apr 2019 18:53:35 -0400 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=eHheTCa2/fHIVf1dPrBgm4mO/6qR/YdcpjibyC8ZHas=; b=cFvHj283wUQ0FQEcEeyKknFhcixzlCtwhsmv/BlbFAAJTh7kcbonVTvjQY5ZRwJPJwI3EtDoRRg2Tw1VUekZDXAmxRzW03mXSpaG3ADktSj62nGyEVCpkRNjGIqW4NTG2ZMPUmz0RXgK+5bYkU6mOjf5LZyDhq54XSwrji2uttM= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1197.namprd22.prod.outlook.com (10.174.169.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1835.18; Tue, 30 Apr 2019 22:53:30 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::b9d6:bf19:ec58:2765]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::b9d6:bf19:ec58:2765%7]) with mapi id 15.20.1835.018; Tue, 30 Apr 2019 22:53:30 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Serge Semin , Paul Burton Subject: [PATCH 1/4] MIPS: Use memblock_phys_alloc() for exception vector Thread-Topic: [PATCH 1/4] MIPS: Use memblock_phys_alloc() for exception vector Thread-Index: AQHU/6eHQ/g7IE/wjkmbMM+qxRJ3+Q== Date: Tue, 30 Apr 2019 22:53:30 +0000 Message-ID: <20190430225216.7164-2-paul.burton@mips.com> References: <20190430225216.7164-1-paul.burton@mips.com> In-Reply-To: <20190430225216.7164-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0076.namprd07.prod.outlook.com (2603:10b6:a03:12b::17) 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.21.0 x-originating-ip: [12.94.197.246] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 228d3ee5-1a64-4378-befb-08d6cdbea9f0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020);SRVR:MWHPR2201MB1197; x-ms-traffictypediagnostic: MWHPR2201MB1197: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1417; x-forefront-prvs: 00235A1EEF x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(136003)(376002)(39840400004)(346002)(396003)(366004)(189003)(199004)(53936002)(305945005)(486006)(11346002)(186003)(42882007)(446003)(2616005)(7736002)(6512007)(6916009)(107886003)(44832011)(476003)(76176011)(99286004)(6436002)(5640700003)(14454004)(3846002)(25786009)(52116002)(2906002)(102836004)(2501003)(6116002)(6506007)(386003)(66446008)(66556008)(26005)(2351001)(66946007)(73956011)(66476007)(50226002)(64756008)(316002)(6486002)(66066001)(54906003)(4326008)(81156014)(8936002)(71190400001)(81166006)(256004)(8676002)(1076003)(36756003)(71200400001)(68736007)(5660300002)(478600001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1197;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A: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: YkkWACjrbHZlf3V4bwpnRGHBxQupRzVQk+Dj92yP+Qo0rC+qn1tINkcqUQh4aBXvVGgIkk57jNoRFarRSquLqx+v08InTrwIKY6wRcm5HASBUGWc0G+ts0eBnSXy3CoYaYSoUlwtDKFsrl8krKX9LzAlZR+eM7IkONvuc/WD1P5kXS4NHKB0Iwi2CHvI1ansQb3kHDNqrx8uliiV8AJ7cZUzIlL1u4Vyi0ikVaBTMqCit+2H8fNH+AQln2DjLAL80Q0xLovHZJ26Vzxuoei1j97ISJGk79KvFLTV+zLJM8WbiZMCBvj519D957ivs/a+JzbqFPp1rGPLlb84WYob46m6wTq106cKUHFHgw/IelRvx/j2bb8n8OWrMx3fMnIiWDgVQ8YhxppamOAKaWecUJKUZ5xH/UXHadGLMvyia9Q= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 228d3ee5-1a64-4378-befb-08d6cdbea9f0 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Apr 2019 22:53:30.1073 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1197 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 Allocate the exception vector using memblock_phys_alloc() which gives us a physical address, rather than the previous convoluted setup which obtained a virtual address using memblock_alloc(), converted it to a physical address & then back to a virtual address. Signed-off-by: Paul Burton Reviewed-by: Philippe Mathieu-Daudé --- arch/mips/kernel/traps.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 98ca55d62201..00f44b16385e 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2292,9 +2292,8 @@ void __init trap_init(void) unsigned long size = 0x200 + VECTORSPACING*64; phys_addr_t ebase_pa; - ebase = (unsigned long) - memblock_alloc(size, 1 << fls(size)); - if (!ebase) + ebase_pa = memblock_phys_alloc(size, 1 << fls(size)); + if (!ebase_pa) panic("%s: Failed to allocate %lu bytes align=0x%x\n", __func__, size, 1 << fls(size)); @@ -2309,9 +2308,10 @@ void __init trap_init(void) * EVA is special though as it allows segments to be rearranged * and to become uncached during cache error handling. */ - ebase_pa = __pa(ebase); if (!IS_ENABLED(CONFIG_EVA) && !WARN_ON(ebase_pa >= 0x20000000)) ebase = CKSEG0ADDR(ebase_pa); + else + ebase = (unsigned long)phys_to_virt(ebase_pa); } else { ebase = CAC_BASE; From patchwork Tue Apr 30 22:53:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10924319 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 C05111398 for ; Tue, 30 Apr 2019 22:54:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABA0328ABE for ; Tue, 30 Apr 2019 22:54:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F38128D4C; Tue, 30 Apr 2019 22:54:14 +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 2F38928ABE for ; Tue, 30 Apr 2019 22:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726181AbfD3WyO (ORCPT ); Tue, 30 Apr 2019 18:54:14 -0400 Received: from mail-eopbgr730135.outbound.protection.outlook.com ([40.107.73.135]:10752 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727329AbfD3WyN (ORCPT ); Tue, 30 Apr 2019 18:54:13 -0400 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=yMVi4FVJEBfMsD1OyvzqC1p+9/tDvvideOn1qHlLqNw=; b=bmnNlmmc1HwN5Me4M+UmapPjqUFz7Pqp1HQfiCxrAeI2jbJZkyTMru9/Y2cfMewmH+KXhtKoznp74iTtYcTyAqZULs9XVsgg02UNclYpTbUjzhOdVhA+uIXkxGU9zebx/0HaPmLE5qu8zVY8uqztLqVqfb71sDDLpftccksafc8= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1744.namprd22.prod.outlook.com (10.164.206.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1835.13; Tue, 30 Apr 2019 22:53:31 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::b9d6:bf19:ec58:2765]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::b9d6:bf19:ec58:2765%7]) with mapi id 15.20.1835.018; Tue, 30 Apr 2019 22:53:31 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Serge Semin , Paul Burton Subject: [PATCH 2/4] MIPS: Always allocate exception vector for MIPSr2+ Thread-Topic: [PATCH 2/4] MIPS: Always allocate exception vector for MIPSr2+ Thread-Index: AQHU/6eHq3rsHFWee0K5mWbWUirPiQ== Date: Tue, 30 Apr 2019 22:53:30 +0000 Message-ID: <20190430225216.7164-3-paul.burton@mips.com> References: <20190430225216.7164-1-paul.burton@mips.com> In-Reply-To: <20190430225216.7164-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0076.namprd07.prod.outlook.com (2603:10b6:a03:12b::17) 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.21.0 x-originating-ip: [12.94.197.246] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e448b7a7-b2da-478d-e535-08d6cdbeaa39 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020);SRVR:MWHPR2201MB1744; x-ms-traffictypediagnostic: MWHPR2201MB1744: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 00235A1EEF x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(136003)(376002)(396003)(39850400004)(366004)(199004)(189003)(3846002)(81166006)(81156014)(8676002)(2351001)(71190400001)(68736007)(50226002)(71200400001)(5660300002)(6512007)(53936002)(6486002)(107886003)(6916009)(6116002)(5640700003)(4326008)(8936002)(2906002)(6436002)(36756003)(256004)(44832011)(54906003)(76176011)(66476007)(66946007)(64756008)(6506007)(66556008)(73956011)(99286004)(42882007)(52116002)(478600001)(476003)(186003)(66066001)(11346002)(2501003)(102836004)(305945005)(25786009)(7736002)(26005)(316002)(14454004)(446003)(1076003)(2616005)(66446008)(486006)(386003);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1744;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: XKVY6RKFTQTMHG9uhMFKk7p7G0WaHaNr3qIXCdwLpSvyWb+trLNXv/XzAyBUvrbhLF5QR9vCenGLTLx2a4jxeIbkMDE3ClqBUXrgryDtXE5STQONoBpoeX4equ79IZ+aN3AGELtmjVSIW/W9mCRg6q1sj+YqkySDuDBr7HB8YldXaQTntqbgQlXU8buuA1SO/sd8RlHWLomo7a7+ASznPiTsocM6dczQXcEd8QqaQ7lHc8JK8qadTqdI0q+go2il8RszKZkXl6Wi4N7UENxEHjJonnJOcTrON8lkW1lefsbY27IzA8icZJb297m7JdYw6T8UY93GLNYIOhwbvZtKY9bMK5IWc71IAZUXnfdOX8aT7kndTwMJ1gAbfGPfE9Lu3by+4yevv4C+EHeXiA8NZ+vWoe8k4B7O/t27oldsHpA= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: e448b7a7-b2da-478d-e535-08d6cdbeaa39 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Apr 2019 22:53:30.5287 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1744 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 Currently we allocate the exception vector on systems which use a vectored interrupt mode, but otherwise attempt to reuse whatever exception vector the bootloader uses. This can be problematic for a number of reasons: 1) The memory isn't properly marked reserved in the memblock allocator. We've relied on the fact that EBase is generally in the memory below the kernel image which we don't free, but this is about to change. 2) Recent versions of U-Boot place their exception vector high in kseg0, in memory which isn't protected by being lower than the kernel anyway & can end up being clobbered. 3) We are unnecessarily reliant upon there being memory at the address EBase points to upon entry to the kernel. This is often the case, but if the bootloader doesn't configure EBase & leaves it with its default value then we rely upon there being memory at physical address 0 for no good reason. Improve this situation by allocating the exception vector in all cases when running on MIPSr2 or higher, and reserving the memory for MIPSr1 or lower. This ensures we don't clobber the exception vector in any configuration, and for MIPSr2 & higher removes the need for memory at physical address 0. Signed-off-by: Paul Burton --- arch/mips/kernel/traps.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 00f44b16385e..9b565ed51662 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2284,18 +2284,27 @@ void __init trap_init(void) extern char except_vec3_generic; extern char except_vec4; extern char except_vec3_r4000; - unsigned long i; + unsigned long i, vec_size; + phys_addr_t ebase_pa; check_wait(); - if (cpu_has_veic || cpu_has_vint) { - unsigned long size = 0x200 + VECTORSPACING*64; - phys_addr_t ebase_pa; + if (!cpu_has_mips_r2_r6) { + ebase = CAC_BASE; + ebase_pa = virt_to_phys((void *)ebase); + vec_size = 0x400; + + memblock_reserve(ebase_pa, vec_size); + } else { + if (cpu_has_veic || cpu_has_vint) + vec_size = 0x200 + VECTORSPACING*64; + else + vec_size = PAGE_SIZE; - ebase_pa = memblock_phys_alloc(size, 1 << fls(size)); + ebase_pa = memblock_phys_alloc(vec_size, 1 << fls(vec_size)); if (!ebase_pa) panic("%s: Failed to allocate %lu bytes align=0x%x\n", - __func__, size, 1 << fls(size)); + __func__, vec_size, 1 << fls(vec_size)); /* * Try to ensure ebase resides in KSeg0 if possible. @@ -2312,20 +2321,6 @@ void __init trap_init(void) ebase = CKSEG0ADDR(ebase_pa); else ebase = (unsigned long)phys_to_virt(ebase_pa); - } else { - ebase = CAC_BASE; - - if (cpu_has_mips_r2_r6) { - if (cpu_has_ebase_wg) { -#ifdef CONFIG_64BIT - ebase = (read_c0_ebase_64() & ~0xfff); -#else - ebase = (read_c0_ebase() & ~0xfff); -#endif - } else { - ebase += (read_c0_ebase() & 0x3ffff000); - } - } } if (cpu_has_mmips) { From patchwork Tue Apr 30 22:53:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10924315 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 B020692A for ; Tue, 30 Apr 2019 22:54:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0AE628ABE for ; Tue, 30 Apr 2019 22:54:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93F6B28D4C; Tue, 30 Apr 2019 22:54:08 +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 3D3F528ABE for ; Tue, 30 Apr 2019 22:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726974AbfD3WyH (ORCPT ); Tue, 30 Apr 2019 18:54:07 -0400 Received: from mail-eopbgr730126.outbound.protection.outlook.com ([40.107.73.126]:52512 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726102AbfD3WyH (ORCPT ); Tue, 30 Apr 2019 18:54:07 -0400 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=jOVOClPsaYOvNrs4HjbWcacOMZzOBwZz5RYJ6ECMzJU=; b=GBnRGDstubUCMt9pCumkKeZafAeqSc1LBOX+3CLqCJ/wnulNk0N+2e49+AsvNJXUljo+MuM9Fmp3y36gxvTMDHmKd5EfXK+d0yDw5IgOMLaBYTEixUvWvCNd53d6E5FHh+iuWGVFGeHs2mgChM+mFKxs9BdScYHrPsKZZeMlgps= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1744.namprd22.prod.outlook.com (10.164.206.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1835.13; Tue, 30 Apr 2019 22:53:31 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::b9d6:bf19:ec58:2765]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::b9d6:bf19:ec58:2765%7]) with mapi id 15.20.1835.018; Tue, 30 Apr 2019 22:53:31 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Serge Semin , Paul Burton Subject: [PATCH 3/4] MIPS: Sync icache for whole exception vector Thread-Topic: [PATCH 3/4] MIPS: Sync icache for whole exception vector Thread-Index: AQHU/6eIsEP9mm7E+E+1tnr7zP0YIw== Date: Tue, 30 Apr 2019 22:53:31 +0000 Message-ID: <20190430225216.7164-4-paul.burton@mips.com> References: <20190430225216.7164-1-paul.burton@mips.com> In-Reply-To: <20190430225216.7164-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0076.namprd07.prod.outlook.com (2603:10b6:a03:12b::17) 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.21.0 x-originating-ip: [12.94.197.246] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0c8f69d0-6e86-4f73-bab0-08d6cdbeaa79 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020);SRVR:MWHPR2201MB1744; x-ms-traffictypediagnostic: MWHPR2201MB1744: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4502; x-forefront-prvs: 00235A1EEF x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(346002)(136003)(376002)(396003)(39850400004)(366004)(199004)(189003)(3846002)(81166006)(81156014)(8676002)(2351001)(71190400001)(68736007)(50226002)(71200400001)(5660300002)(6512007)(53936002)(6486002)(14444005)(107886003)(6916009)(6116002)(5640700003)(4326008)(8936002)(2906002)(6436002)(36756003)(256004)(44832011)(54906003)(76176011)(66476007)(66946007)(64756008)(6506007)(66556008)(73956011)(99286004)(42882007)(52116002)(478600001)(476003)(4744005)(186003)(66066001)(11346002)(2501003)(102836004)(305945005)(25786009)(7736002)(26005)(316002)(14454004)(446003)(1076003)(2616005)(66446008)(486006)(386003)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1744;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: 2D5hKcJ13yn8COx0tzUT31Y/ZtuldgcMLbCr0fLanrCJF0Y2KATKm2Vu4CUzK1ce+fDRp6TiM2nEKv48zkkvLy6Q72XgEt3/viLUJL7fiLs50D6G7neOSha+WYOIXkmA9Ku81Bn6Fy1CNZMjt0ph920Igq61IROXDPOBQJSUeznVDaQZ99wWcqGMnXseJ06JmV1kLN15b+tu1kKfEKogwSisTQmDOKdrmntaeuWSwzhavdrXeNNBUdNkjaUsC2LJiPH8fj8qwAa3rz7xItt2nghXUB8HFZpHMqHeOg2lWTFSZpOC4XiFpN806BF/ZDDSfem83HA3IXRuWXgmfenO5mXEI5plpZa5+nmUXkY/wk9CVxbQh29Ntv3in77YS3DLsFGyL96GSCPCX3RTPqmiHj6IASR/DXdutFIkMsEx/oM= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c8f69d0-6e86-4f73-bab0-08d6cdbeaa79 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Apr 2019 22:53:31.2533 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1744 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 Rather than performing cache flushing for a fixed 0x400 bytes, use the actual size of the vector in order to ensure we cover all emitted code on systems that make use of vectored interrupts. Signed-off-by: Paul Burton Reviewed-by: Philippe Mathieu-Daudé --- arch/mips/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 9b565ed51662..2775190adbe7 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2454,7 +2454,7 @@ void __init trap_init(void) else set_handler(0x080, &except_vec3_generic, 0x80); - local_flush_icache_range(ebase, ebase + 0x400); + local_flush_icache_range(ebase, ebase + vec_size); sort_extable(__start___dbe_table, __stop___dbe_table); From patchwork Tue Apr 30 22:53:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 10924317 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 D4FEC1398 for ; Tue, 30 Apr 2019 22:54:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C646128ABE for ; Tue, 30 Apr 2019 22:54:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA89328D4C; Tue, 30 Apr 2019 22:54:09 +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 6203028ABE for ; Tue, 30 Apr 2019 22:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726102AbfD3WyJ (ORCPT ); Tue, 30 Apr 2019 18:54:09 -0400 Received: from mail-eopbgr730126.outbound.protection.outlook.com ([40.107.73.126]:52512 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726412AbfD3WyJ (ORCPT ); Tue, 30 Apr 2019 18:54:09 -0400 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=Qtbz6mE49FpnGim7EJath83x1e4VFruX9FPcZup/oR4=; b=HkJQR3846M/2DHy9XeeHoJRMSXA61Aj55Yl+H3tRnXVwlTaxwzRl6xt6R7bZGD8FyFZBmQkfSJePlGVvgegHTm5aX7w7sjx6sh0nsmZXVZxi71cA110lpOHDsPfoWmxBMwedXUgA/WfD0WPQynT3b0X6LWRMDk/tt+mB6r70RbU= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1744.namprd22.prod.outlook.com (10.164.206.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1835.13; Tue, 30 Apr 2019 22:53:32 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::b9d6:bf19:ec58:2765]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::b9d6:bf19:ec58:2765%7]) with mapi id 15.20.1835.018; Tue, 30 Apr 2019 22:53:32 +0000 From: Paul Burton To: "linux-mips@vger.kernel.org" CC: Serge Semin , Paul Burton Subject: [PATCH 4/4] MIPS: Remove duplicate EBase configuration Thread-Topic: [PATCH 4/4] MIPS: Remove duplicate EBase configuration Thread-Index: AQHU/6eIV2nSYKWR60CEA4kuJGhSYA== Date: Tue, 30 Apr 2019 22:53:31 +0000 Message-ID: <20190430225216.7164-5-paul.burton@mips.com> References: <20190430225216.7164-1-paul.burton@mips.com> In-Reply-To: <20190430225216.7164-1-paul.burton@mips.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR07CA0076.namprd07.prod.outlook.com (2603:10b6:a03:12b::17) 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.21.0 x-originating-ip: [12.94.197.246] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 85bac6ef-4f85-406d-d5ca-08d6cdbeaae7 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(2017052603328)(7193020);SRVR:MWHPR2201MB1744; x-ms-traffictypediagnostic: MWHPR2201MB1744: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 00235A1EEF x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(346002)(136003)(376002)(396003)(39850400004)(366004)(199004)(189003)(3846002)(81166006)(81156014)(8676002)(2351001)(71190400001)(68736007)(50226002)(71200400001)(5660300002)(6512007)(53936002)(6486002)(107886003)(6916009)(6116002)(5640700003)(4326008)(8936002)(2906002)(6436002)(36756003)(256004)(44832011)(54906003)(76176011)(66476007)(66946007)(64756008)(6506007)(66556008)(73956011)(99286004)(42882007)(52116002)(478600001)(476003)(186003)(66066001)(11346002)(2501003)(102836004)(305945005)(25786009)(7736002)(26005)(316002)(14454004)(446003)(1076003)(2616005)(66446008)(486006)(386003)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1744;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: FqXbmZDpotBxwXqOzsCFjVADDndoRVUDJLKXukXHBQdIzSmyy3vykvRp+gNClTtasTI/lOLIBEsjE5T5ILrsITPRIZSNryQJtSkVDEl4rlW1MQdLHb33ux7H6YyYPpG1wCK3vlGM1kj4PpxTj245AuWQs67c8JnctZ6JK98yo4i26Y4TVyK0yzmUHWJlWroE0Di4IBnOZwv04VeGaDm5e/ef46kC1zyfRLYp4mWbcEH6hg0xvPwR+8oVehAdfynqceEgXl0owEEoU1gFQaZQO1rBCMkbvRiaXm1euBbDaz/zFNHzLDI5tR79kWExK8PVZfm+SamOgqI56xsIHV8EYG7kaPhKKe7nkFiTAW+3npusXwLLDv64KckmR8SJ4VUuE7wd+zcMvZ6eC3ZjQWutocbGBOEtzIcmEdZFFMdyRtM= MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85bac6ef-4f85-406d-d5ca-08d6cdbeaae7 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Apr 2019 22:53:31.7376 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1744 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 Clean up our configuration of the EBase register by making configure_exception_vector() write to it unconditionally on systems implementing MIPSr2 or higher, and removing the duplicate code in per_cpu_trap_init(). The latter would have duplicated work on systems with vectored interrupts, and didn't set BEV for safety like the configure_exception_vector() version of the code does. Signed-off-by: Paul Burton --- arch/mips/kernel/traps.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 2775190adbe7..c52766a5b85f 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2151,7 +2151,7 @@ static void configure_hwrena(void) static void configure_exception_vector(void) { - if (cpu_has_veic || cpu_has_vint) { + if (cpu_has_mips_r2_r6) { unsigned long sr = set_c0_status(ST0_BEV); /* If available, use WG to set top bits of EBASE */ if (cpu_has_ebase_wg) { @@ -2163,6 +2163,8 @@ static void configure_exception_vector(void) } write_c0_ebase(ebase); write_c0_status(sr); + } + if (cpu_has_veic || cpu_has_vint) { /* Setting vector spacing enables EI/VI mode */ change_c0_intctl(0x3e0, VECTORSPACING); } @@ -2193,22 +2195,6 @@ void per_cpu_trap_init(bool is_boot_cpu) * o read IntCtl.IPFDC to determine the fast debug channel interrupt */ if (cpu_has_mips_r2_r6) { - /* - * We shouldn't trust a secondary core has a sane EBASE register - * so use the one calculated by the boot CPU. - */ - if (!is_boot_cpu) { - /* If available, use WG to set top bits of EBASE */ - if (cpu_has_ebase_wg) { -#ifdef CONFIG_64BIT - write_c0_ebase_64(ebase | MIPS_EBASE_WG); -#else - write_c0_ebase(ebase | MIPS_EBASE_WG); -#endif - } - write_c0_ebase(ebase); - } - cp0_compare_irq_shift = CAUSEB_TI - CAUSEB_IP; cp0_compare_irq = (read_c0_intctl() >> INTCTLB_IPTI) & 7; cp0_perfcount_irq = (read_c0_intctl() >> INTCTLB_IPPCI) & 7;