Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp946331pxu; Thu, 3 Dec 2020 17:15:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9qmArxvGb+H/5uyZ3RH/rLS2w44PIJHyBPi7aMxKi54KzQnqe5K4PToIgWYGiHwx7ZiaL X-Received: by 2002:a05:6402:4d2:: with SMTP id n18mr5267694edw.169.1607044513017; Thu, 03 Dec 2020 17:15:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607044513; cv=none; d=google.com; s=arc-20160816; b=w3YLyFcPr09vkfLd7GzULMi8Gx7IaafZShc9yw3SWAYkr5Q3OuqwcWIiihxK80+zTO 3EzZco30ay7QBXK+1RB9u/NOLd7ZbFhDFIsQxNAIsFjq/gLUTkH2h/EWh+t3j8NwmIm3 WCre84yJtzSwqNPuzS26C+gyA1t/YZBdn7+3TVGAF32d9nJCp30FaDj4DAndZm02Vegh DSv7jIkPc3ImMPW+CcwwtsBWxX3cJ+ZqOteyZ010f1RdH41NILCr+yWxd5Z/lR1DlXw9 wczar2EbQTjnTDsZ/AMWbo3S+VRVyirabqUckL25XNzxma3qXR59IugaHH6SWUkrMmKi oW4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=No2JG2Y0arW6QnH0+fK6BqGVnlZYe1V+n5S0kmfT0CU=; b=HW4HGQSYkCBJIGfzxYqUfihG7JSVqCVra39NTZFfS4L6BB0WSnBYUR/plO2UuTn4z7 WADxpt0YsiRt+HTsOZ8Bb49CT/IPrsaGwR4oOCezrHakn3FfI9V+X42Kmritdpnsg0K6 gNG+btWWTFz9njeJOwABR/qvrDMCWWFNZm6hkmZK/f1fyzqgIxdzKVX5+Jn/Qoe9Maek mRLDbYctJpf6myQU4o5idu6nOM/MLDVsRLvu61YJPJzoyzwgFnMZXpC4vDv14xdkODSE 1JyiAsqeaaOj8RpmR3KUGJHZb78BIISjAeJahGFFX5uDzo/I0U8Tbr8Zqk5a/1oq2A7P 1URg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i33si1971413edi.93.2020.12.03.17.14.47; Thu, 03 Dec 2020 17:15:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387774AbgLDBMe (ORCPT + 99 others); Thu, 3 Dec 2020 20:12:34 -0500 Received: from mail.loongson.cn ([114.242.206.163]:51154 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387531AbgLDBMe (ORCPT ); Thu, 3 Dec 2020 20:12:34 -0500 Received: from bogon.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxr9PTjMlfrogZAA--.50887S2; Fri, 04 Dec 2020 09:11:47 +0800 (CST) From: Jinyang He To: Thomas Bogendoerfer Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] MIPS: KASLR: Avoid endless loop in sync_icache when synci_step is zero Date: Fri, 4 Dec 2020 09:11:46 +0800 Message-Id: <1607044306-4800-1-git-send-email-hejinyang@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9Dxr9PTjMlfrogZAA--.50887S2 X-Coremail-Antispam: 1UD129KBjvJXoW7AFykXF48Gr4UKr4DZryUGFg_yoW8GF1xpr sxGw1xKrs8Ww48ta48J3yku343Cas8u3y7GF4Ut3sYvasxZryDtFy5Kw1FgFZavrW8K3Wa vryjvrWrZa17A3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkIb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I 8E87Iv6xkF7I0E14v26r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xv F2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r 4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCY02Avz4vE14v_KwCF04k2 0xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI 8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jrv_JF1lIxkGc2Ij64vIr41l IxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIx AIcVCF04k26cxKx2IYs7xG6rWUJVWrZr1UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvE x4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU5mQ6tUUUUU== X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Avoid endless loop if synci_step was zero read by rdhwr instruction. Most platforms do not need to do synci instruction operations when synci_step is 0. But for example, the synci implementation on Loongson64 platform has some changes. On the one hand, it ensures that the memory access instructions have been completed. On the other hand, it guarantees that all prefetch instructions need to be fetched again. And its address information is useless. Thus, only one synci operation is required when synci_step is 0 on Loongson64 platform. I guess that some other platforms have similar implementations on synci, so add judgment conditions in `while` to ensure that at least all platforms perform synci operations once. For those platforms that do not need synci, they just do one more operation similar to nop. Signed-off-by: Jinyang He --- arch/mips/kernel/relocate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/kernel/relocate.c b/arch/mips/kernel/relocate.c index 57bdd276..47aeb33 100644 --- a/arch/mips/kernel/relocate.c +++ b/arch/mips/kernel/relocate.c @@ -64,7 +64,7 @@ static void __init sync_icache(void *kbase, unsigned long kernel_length) : "r" (kbase)); kbase += step; - } while (kbase < kend); + } while (step && kbase < kend); /* Completion barrier */ __sync(); -- 2.1.0