Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3261752pxf; Sun, 28 Mar 2021 18:58:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYgx2G7q8D4TN9n9fNxvJ884Ff9+XFffG+w/AK+EZztTdxg5/KdWuS2dlOtYW5CJRB5zcu X-Received: by 2002:a05:6402:268c:: with SMTP id w12mr25953757edd.280.1616983097432; Sun, 28 Mar 2021 18:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616983097; cv=none; d=google.com; s=arc-20160816; b=l5H6Pxe5+sWeDzj2wa1yVplqpzUed0QAkIoudWk6Dj6+Sseu6UMlBv/bUHvhvr0uYO SeHQRFeC/1rYB9HAOXBM0o8A1Z2DcmlO/KrwV1TfZNzt0PlKTVhE9ru8RBrE6NYha+t8 nTNXHRSaWYd8K3hGgfQAf+aq15BZWDNeTyWFX+mjewNp1KvXrVk/9MA3ykyBLKihMs5X IAZlhzmpIRnRRtIunPV1XM37ZuQRv/RtzMUg55rcUHwp4O+ROOyCX9S+Ju2686rF8XZ3 iiv6ST8tthAOgJ0ROloMjnz++kElD3wjYEmoT2dTsC0dxJ5pLPmnLgtq0WWh+pa2rv31 Ak+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ZpbsboO00+NGpd7nPfABOl4VUqqJUF8OMrvGKrRJGlk=; b=A8e8CWx7UyFK4nOmybv9pB72rzXtoRbJhRuvSwJCa9Zq0LGER+sWumWpLCER8Gw8IJ V4VWvum1xCndh0YNfsqdaZT9ivRMfw/6h2G6/075HHLH7ILwAy2Z6Ca51SH1hWfM8YKh SNl1WMLYxfQU904E6MkajuO04tpi1Em4IDWPhVOAYZWh3Ognr0rasszU1ZPhB2jvhcRS uz0tVn3IY0bK28QDdEdGT6IRxP+mqZvo2wDj7mL45V+xrj5vbpBGTm3Smnk27X5cQ2qc qBa8mndrVftPK+04US1gvJm+r1Sn9DpMCQcKAoz0MyOtqrv0C5kIz5vXy1Z34AtN5rcm Jmsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jiuyang-me.20150623.gappssmtp.com header.s=20150623 header.b=DNY7oU5A; 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 g15si12510448edk.323.2021.03.28.18.57.55; Sun, 28 Mar 2021 18:58:17 -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; dkim=pass header.i=@jiuyang-me.20150623.gappssmtp.com header.s=20150623 header.b=DNY7oU5A; 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 S230346AbhC2B44 (ORCPT + 99 others); Sun, 28 Mar 2021 21:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbhC2B43 (ORCPT ); Sun, 28 Mar 2021 21:56:29 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2A2C061574 for ; Sun, 28 Mar 2021 18:56:23 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id ay2so3655774plb.3 for ; Sun, 28 Mar 2021 18:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jiuyang-me.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZpbsboO00+NGpd7nPfABOl4VUqqJUF8OMrvGKrRJGlk=; b=DNY7oU5AuNEygQnIMijS7RCHjJwRewCPsfUSQFe2h5cCOuJ+ifFY8DW4QRTPk93+If bMHPE7IjFB2U6W+c2yzimU9uZt5TfHUjRGaUvDkm7npWoRMfZGKNzDIf6xDMUX5bu6oe wpl/fN+0Q+n2ziyPey6y1Noy3ufYTE6y0a88c2J322sjbuMaPrr4UIvVI1fHpQaFvcDZ POjsafTleR+VKvsssby9efnaPkcq66PSyONjY23mW37FtglEdAMacem4urvS6iWN7Bfs YfjIjm80E6/m+aMwFYPD0FvKecvaGJEarz8dNzhv0aY4SNsq+aUeLZQFdhWMZUoKgq3c AyFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZpbsboO00+NGpd7nPfABOl4VUqqJUF8OMrvGKrRJGlk=; b=GrET5oArjWzZWEfYzt5wz1Xu511+21gTS4GGhW3il4yAn1f+KZSaSWP8cPMElQ6fkq SxI5/oUa52f1JzdbAAYNhWLMm0QjqsmykbPkKGsaLXoyK1JnEUbpQz0pyse2/STrdkgd ZB2hb0Us/fgb4RfazynAIv14hcgerUsdBQez1Y+WJJW9OJ8SL96BJpKJprwLUXyVVjhz t6Gc8+ZrMz6dEf3MMAJIomeJ2o3P1og1uTPs49/8RXzKY0fp/cD5gxjFmlc1+QZokJhi lbR+mJbFa4KI3WEdKIP+JxamkHM8fzSLm4ckihN1zel1W/JBFzMQmW2XUUheDWgOPBUM Ro1w== X-Gm-Message-State: AOAM530ysmZCFSym/vWeGCdHExJ/ibetjzFuyL4psWYdTdlR+QN2Ji3l +KaS1h/ILUo52eRbzNGipPyz34MpUHOC3DEhjAvQgA== X-Received: by 2002:a17:90a:f98e:: with SMTP id cq14mr23359357pjb.60.1616982983564; Sun, 28 Mar 2021 18:56:23 -0700 (PDT) Received: from nuc.. ([193.110.201.196]) by smtp.gmail.com with ESMTPSA id x11sm18202652pjh.0.2021.03.28.18.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 18:56:23 -0700 (PDT) From: Jiuyang Liu To: Alex Ghiti Cc: Jiuyang Liu , Andrew Waterman , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , Geert Uytterhoeven , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] implement flush_cache_vmap and flush_cache_vunmap for RISC-V Date: Mon, 29 Mar 2021 01:55:09 +0000 Message-Id: <20210329015510.44110-1-liu@jiuyang.me> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch implements flush_cache_vmap and flush_cache_vunmap for RISC-V, since these functions might modify PTE. Without this patch, SFENCE.VMA won't be added to related codes, which might introduce a bug in some out-of-order micro-architecture implementations. Signed-off-by: Jiuyang Liu --- arch/riscv/include/asm/cacheflush.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h index 23ff70350992..4adf25248c43 100644 --- a/arch/riscv/include/asm/cacheflush.h +++ b/arch/riscv/include/asm/cacheflush.h @@ -8,6 +8,14 @@ #include +/* + * flush_cache_vmap and flush_cache_vunmap might modify PTE, needs SFENCE.VMA. + * - flush_cache_vmap is invoked after map_kernel_range() has installed the page table entries. + * - flush_cache_vunmap is invoked before unmap_kernel_range() deletes the page table entries + */ +#define flush_cache_vmap(start, end) flush_tlb_all() +#define flush_cache_vunmap(start, end) flush_tlb_all() + static inline void local_flush_icache_all(void) { asm volatile ("fence.i" ::: "memory"); -- 2.31.1