Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1768302pxb; Mon, 13 Sep 2021 05:14:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6D4YbF8N9sSgLxEHiwJrmBmWe9ieGcZzR5j41CaTCkRp9xBYb8ZkjvfviMcREQbjecco5 X-Received: by 2002:a5d:9253:: with SMTP id e19mr8699559iol.35.1631535262984; Mon, 13 Sep 2021 05:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631535262; cv=none; d=google.com; s=arc-20160816; b=RB/Cx5u4gq6en/FMyJEjGoIuL20/SCzjBun1g4KyGXnmmdnHFKrJ2PVXs1+s8ZV2qf G4CgNp1oNmrOlh1vew+C1EMD3nymdqXdnwLFgtq4NRxVKnBAiLF6I8Kt8GxCZt9JO2fP XYA0xFhRex4ZIuSgYcCjK+lbzmgB81Ql66xvwzulUV/JjqeObddt8mRpyEbdjvzUWIEu 3lHI+hbeKVl+YTOJJ6lzEA5+V93nAYDxcDsYawDUyLU5i02B1D8SKUc6vdFqe5H9cfMU VB6v9x0xBjPAmUJK9PIsgHelNc5PrpCW2dJGvZGAskvwwNW73EF3Q8oQJlsA6LOWd7eG Aqrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ZwdMn2VamukvmBa6OhMmouH7hsz4tczDYt1dvlipUPo=; b=dD0hkjOcEYl++1nlZxFeyfzl+jU13RFAhSm8HRNFxBoOr1PQFvp6wlnRUw+PNaK3Ex 73gicMT4HIAW2bzrR40Crcm0YIPhcOcbrZDgB0+zOOj0puOIe4gP5A1R0gePLrshHJJk 4YncxYq0K/wI8wBIFQQ9RDz63QSfvOyUOECgyk8aLhTvUv4oaHErhTOdIAdYSlsoblla +DqQViCW4EsUEBXrI5U/hWoaQZ9DupRxH7aE7p672DgdPO2Bpv7EuJ3AmGdQ8GPSTHZY /Ikn1YgeXPlJcKgd4kQCPHvCbpesJzQIQ2J9+viGqw39/rvm9rUdpIEcNvOqBgZ1aqt2 0TPA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si6753499jaa.119.2021.09.13.05.14.08; Mon, 13 Sep 2021 05:14:22 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239873AbhIMMMj (ORCPT + 99 others); Mon, 13 Sep 2021 08:12:39 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:9035 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239865AbhIMMMi (ORCPT ); Mon, 13 Sep 2021 08:12:38 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4H7QKW52MHzW2Lq; Mon, 13 Sep 2021 20:10:23 +0800 (CST) Received: from dggema756-chm.china.huawei.com (10.1.198.198) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Mon, 13 Sep 2021 20:11:22 +0800 Received: from localhost.localdomain (10.175.112.125) by dggema756-chm.china.huawei.com (10.1.198.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Mon, 13 Sep 2021 20:11:21 +0800 From: Chen Huang To: Paul Walmsley , Palmer Dabbelt , Albert Ou CC: Chen Huang , Kefeng Wang , , Subject: [PATCH 2/2] riscv: Support DCACHE_WORD_ACCESS Date: Mon, 13 Sep 2021 12:19:56 +0000 Message-ID: <20210913121956.1776656-3-chenhuang5@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20210913121956.1776656-1-chenhuang5@huawei.com> References: <20210913121956.1776656-1-chenhuang5@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggema756-chm.china.huawei.com (10.1.198.198) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch selects DCACHE_WORD_ACCESS on riscv and implements support for load_unaligned_zeropad. DCACHE_WORD_ACCESS uses the word-at-a-time API for optimised string comparisons in the vfs layer. Signed-off-by: Chen Huang Signed-off-by: Kefeng Wang --- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/word-at-a-time.h | 36 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 6e70bf50b02a..f6f0da0f436b 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -44,6 +44,7 @@ config RISCV select CLONE_BACKWARDS select CLINT_TIMER if !MMU select COMMON_CLK + select DCACHE_WORD_ACCESS select EDAC_SUPPORT select GENERIC_ARCH_TOPOLOGY if SMP select GENERIC_ATOMIC64 if !64BIT diff --git a/arch/riscv/include/asm/word-at-a-time.h b/arch/riscv/include/asm/word-at-a-time.h index 7c086ac6ecd4..0b77ce654f56 100644 --- a/arch/riscv/include/asm/word-at-a-time.h +++ b/arch/riscv/include/asm/word-at-a-time.h @@ -11,6 +11,8 @@ #include +#include + struct word_at_a_time { const unsigned long one_bits, high_bits; }; @@ -45,4 +47,38 @@ static inline unsigned long find_zero(unsigned long mask) /* The mask we created is directly usable as a bytemask */ #define zero_bytemask(mask) (mask) +/* + * Load an unaligned word from kernel space. + * + * In the (very unlikely) case of the word being a page-crosser + * and the next page not being mapped, take the exception and + * return zeroes in the non-existing part. + */ +static inline unsigned long load_unaligned_zeropad(const void *addr) +{ + unsigned long ret, tmp; + + /* Load word from unaligned pointer addr */ + asm( + "1: " REG_L " %0, %3\n" + "2:\n" + " .section .fixup,\"ax\"\n" + " .balign 2\n" + "3: andi %1, %2, ~0x7\n" + " " REG_L " %0, (%1)\n" + " andi %1, %2, 0x7\n" + " slli %1, %1, 0x3\n" + " srl %0, %0, %1\n" + " jump 2b, %1\n" + " .previous\n" + " .section __ex_table,\"a\"\n" + " .balign " RISCV_SZPTR "\n" + " " RISCV_PTR " 1b, 3b\n" + " .previous" + : "=&r" (ret), "=&r" (tmp) + : "r" (addr), "m" (*(unsigned long *)addr)); + + return ret; +} + #endif /* _ASM_RISCV_WORD_AT_A_TIME_H */ -- 2.18.0.huawei.25