From patchwork Sat Jun 15 00:35:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Korotin X-Patchwork-Id: 10996915 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 7079F1395 for ; Sat, 15 Jun 2019 00:35:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5218F287AE for ; Sat, 15 Jun 2019 00:35:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4442B287B1; Sat, 15 Jun 2019 00:35:58 +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 A9833287AE for ; Sat, 15 Jun 2019 00:35:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725889AbfFOAf5 (ORCPT ); Fri, 14 Jun 2019 20:35:57 -0400 Received: from mail-eopbgr760098.outbound.protection.outlook.com ([40.107.76.98]:63921 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725809AbfFOAf4 (ORCPT ); Fri, 14 Jun 2019 20:35:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavesemi-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MtyODL06gkmTfkzdYbi/wXOAXPrFJTVpwR2UoctfAlA=; b=lcxBgVNeTDV8Sa8qkHRFYx/ndDUXaU7Qu1oahstSvqFWJwrvacxyr1qmVrgqvkKfJbZ4vvGvoJG+iote7dtUDiS/N3ZypfQq0FlBz2VZ0Z+cF1X2J96dHk/EbTxvk1DLyEtVJbBLCCqS16ckewYYitKxy8gsHcShGOQfqcD4Njo= Received: from CY4PR22MB0245.namprd22.prod.outlook.com (10.169.184.140) by CY4PR22MB0055.namprd22.prod.outlook.com (10.169.181.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Sat, 15 Jun 2019 00:35:40 +0000 Received: from CY4PR22MB0245.namprd22.prod.outlook.com ([fe80::485f:8a3b:54d1:5bce]) by CY4PR22MB0245.namprd22.prod.outlook.com ([fe80::485f:8a3b:54d1:5bce%4]) with mapi id 15.20.1987.013; Sat, 15 Jun 2019 00:35:39 +0000 From: Dmitry Korotin To: Paul Burton CC: "linux-mips@vger.kernel.org" , "stable@vger.kernel.org" , Dmitry Korotin Subject: [PATCH] Added missing EHB in mtc0 -> mfc0 sequence. Thread-Topic: [PATCH] Added missing EHB in mtc0 -> mfc0 sequence. Thread-Index: AQHVIxJBW2AHYf1PYUy4ub6PviN/IQ== Date: Sat, 15 Jun 2019 00:35:39 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR11CA0074.namprd11.prod.outlook.com (2603:10b6:a03:f4::15) To CY4PR22MB0245.namprd22.prod.outlook.com (2603:10b6:903:11::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=dkorotin@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [216.35.128.4] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 288bc447-f138-4e69-8c5c-08d6f129638f x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:CY4PR22MB0055; x-ms-traffictypediagnostic: CY4PR22MB0055: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2043; x-forefront-prvs: 0069246B74 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(366004)(346002)(39850400004)(376002)(136003)(189003)(199004)(3846002)(99286004)(6116002)(52116002)(8936002)(74316002)(8676002)(2906002)(478600001)(14454004)(305945005)(66066001)(81156014)(7696005)(86362001)(68736007)(7736002)(81166006)(476003)(386003)(450100002)(4326008)(66946007)(102836004)(73956011)(486006)(71190400001)(14444005)(256004)(66556008)(6506007)(66446008)(64756008)(186003)(66476007)(6636002)(6436002)(52536014)(9686003)(33656002)(54906003)(26005)(107886003)(25786009)(316002)(55016002)(71200400001)(6862004)(53936002)(5660300002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR22MB0055;H:CY4PR22MB0245.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: 544H2ivo4V5R60tnfSGvFFZiH8cgoc5f97A0KFdXMI+pmGa31hsqxIQxeJ2yS6rVFiWIBjEDyXxeUpqD0C1qc/EfnXnwp5+GLjGgidbuEkJnOwl/UVqFV4rZuQc+YSKOM5sdmlHifIajvXQBpjc6iOkElXYayM1881UayCkMX7iwBTJz47iAN9b/7kxDFkh8UDKXN+VaG8tfmj+FC+W6d5eRIHXcr4EaQDkVmm6Zwlj5H6oK+zQqKya8rUB2bpRoRUExTGf62vU5Dph5kJNPE7nykvBWmXKe8vi55+esEadAgwOeOnv9S5gsQ4wGaK1BwwHgdbNXdX3nP4qRaKQSufRZJRosL0u2893lvnqHfSLwpx7//pJ9Vv370T3IAVfMritP8/Ea97s/eSsQxxZSPpD3JtOWIO0Jz5C3NNUjBLg= MIME-Version: 1.0 X-OriginatorOrg: wavecomp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 288bc447-f138-4e69-8c5c-08d6f129638f X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jun 2019 00:35:39.9109 (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-CrossTenant-userprincipalname: dkorotin@wavecomp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR22MB0055 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 Added missing EHB (Execution Hazard Barrier) in mtc0 -> mfc0 sequence. Mips documentation Volume III (rev 6.03) table 8.1. Signed-off-by: Dmitry Korotin --- arch/mips/mm/tlbex.c | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c index 65b6e85..bf7f131 100644 --- a/arch/mips/mm/tlbex.c +++ b/arch/mips/mm/tlbex.c @@ -391,6 +391,7 @@ static struct work_registers build_get_work_registers(u32 **p) static void build_restore_work_registers(u32 **p) { if (scratch_reg >= 0) { + uasm_i_ehb(p); UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); return; } @@ -668,10 +669,12 @@ static void build_restore_pagemask(u32 **p, struct uasm_reloc **r, uasm_i_mtc0(p, 0, C0_PAGEMASK); uasm_il_b(p, r, lid); } - if (scratch_reg >= 0) + if (scratch_reg >= 0) { + uasm_i_ehb(p); UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); - else + } else { UASM_i_LW(p, 1, scratchpad_offset(0), 0); + } } else { /* Reset default page size */ if (PM_DEFAULT_MASK >> 16) { @@ -938,10 +941,12 @@ void build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r, uasm_i_jr(p, ptr); if (mode == refill_scratch) { - if (scratch_reg >= 0) + if (scratch_reg >= 0) { + uasm_i_ehb(p); UASM_i_MFC0(p, 1, c0_kscratch(), scratch_reg); - else + } else { UASM_i_LW(p, 1, scratchpad_offset(0), 0); + } } else { uasm_i_nop(p); } @@ -1258,6 +1263,7 @@ struct mips_huge_tlb_info { UASM_i_MTC0(p, odd, C0_ENTRYLO1); /* load it */ if (c0_scratch_reg >= 0) { + uasm_i_ehb(p); UASM_i_MFC0(p, scratch, c0_kscratch(), c0_scratch_reg); build_tlb_write_entry(p, l, r, tlb_random); uasm_l_leave(l, *p); @@ -1603,15 +1609,19 @@ static void build_setup_pgd(void) uasm_i_dinsm(&p, a0, 0, 29, 64 - 29); uasm_l_tlbl_goaround1(&l, p); UASM_i_SLL(&p, a0, a0, 11); - uasm_i_jr(&p, 31); UASM_i_MTC0(&p, a0, C0_CONTEXT); + uasm_i_ehb(&p); + uasm_i_jr(&p, 31); + uasm_i_nop(&p); } else { /* PGD in c0_KScratch */ - uasm_i_jr(&p, 31); if (cpu_has_ldpte) UASM_i_MTC0(&p, a0, C0_PWBASE); else UASM_i_MTC0(&p, a0, c0_kscratch(), pgd_reg); + uasm_i_ehb(&p); + uasm_i_jr(&p, 31); + uasm_i_nop(&p); } #else #ifdef CONFIG_SMP @@ -1625,13 +1635,15 @@ static void build_setup_pgd(void) UASM_i_LA_mostly(&p, a2, pgdc); UASM_i_SW(&p, a0, uasm_rel_lo(pgdc), a2); #endif /* SMP */ - uasm_i_jr(&p, 31); /* if pgd_reg is allocated, save PGD also to scratch register */ - if (pgd_reg != -1) + if (pgd_reg != -1) { UASM_i_MTC0(&p, a0, c0_kscratch(), pgd_reg); - else - uasm_i_nop(&p); + uasm_i_ehb(&p); + } + + uasm_i_jr(&p, 31); + uasm_i_nop(&p); #endif if (p >= (u32 *)tlbmiss_handler_setup_pgd_end) panic("tlbmiss_handler_setup_pgd space exceeded");