Received: by 10.223.164.202 with SMTP id h10csp538356wrb; Wed, 22 Nov 2017 11:04:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMaQgdaA7Yv/A2UaHskVXqyYoUuHWSd0q5svKJWanf1PTiCA3vDvQ6SiN9oBARbGLN8b+xWX X-Received: by 10.99.7.143 with SMTP id 137mr21218504pgh.158.1511377483595; Wed, 22 Nov 2017 11:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511377483; cv=none; d=google.com; s=arc-20160816; b=PJB9ymEdLAIIg9mHY5EgnrtTb9Niba1+0A6mEVcfgbpb361VrAFMVbOVE1D+URlAP8 AMWoCb/Cbhztxh/lHM3OOjquVjO0zgV2JWoTkKONcrTYs2u3XScL+sGyvZrJlXC7uhiO ccQjlpXbDI46/bnebhgAukGidLS2HgTSbcNPcCBCMJzmRy4RYi7u6lXa2/8UxDG1wLzd e661c3vE1dyGkU8wKEnOjdnvUYBMqT7pMyDEGtQRpDfGlRUdyabbVYVQ+efCRyj9296t T+wvz2XtEuTYnmjWpa9AEufcuW0iWZNq9QtEvE1XTOJE9aKKcNup8KOEfLILof1mXOz2 84EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=m+7R6Fl7DpgSUtRT0AYp6ExqKVwkzqFirWf5G7BxjP0=; b=tyDy+shavrEle7itMainE825KzfbcEN7fbWhcKUJkA0Z6uzocQhrFk3/p82fLv29/h HAyWSe0KeIIRstL4EdyLjup/nOLjDZss0AghhCl/RFRHBOTX+KDLtU1srOSb4/immGN/ UzyQc07/P3+L3fzal5SnfGZxwMTtalKbdlz/OdNIcEELvuciL6JetRDcmQdaKiAFC6Gx VtaB1FFwuWa5SvI9IPw/sGz7ZJm+c7P2idd4jbkd0M5Hd++ykp2TY0jeRFqQt3E6BPZ2 wkiWk+0Z316tAtjp7xCEHBO4hpFWUvMHLou6sYgttSfnVTPZxjjda7aAF4h1Ik/eZNrd ETgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QmLQCjrJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f80si14518948pfa.193.2017.11.22.11.04.32; Wed, 22 Nov 2017 11:04:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QmLQCjrJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045AbdKVTDw (ORCPT + 78 others); Wed, 22 Nov 2017 14:03:52 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35325 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbdKVTDv (ORCPT ); Wed, 22 Nov 2017 14:03:51 -0500 Received: by mail-wm0-f66.google.com with SMTP id y80so12242630wmd.0 for ; Wed, 22 Nov 2017 11:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=m+7R6Fl7DpgSUtRT0AYp6ExqKVwkzqFirWf5G7BxjP0=; b=QmLQCjrJea+ezjNkMfa3EUYwYe/sE3OwaAH5EVJ+9U+LegzJRk2E7HRVt3jiE3Wlll TMBxB6ObRG8CBYm/N72NJlnBViOnWq14cv3DmZCCEBpBYOK8UfEkpwOhU5ox2sA2Y4dm W94vPVUA4odzbix3Ig9qfYbS4IhnKtuhb7deIvnzrkEZ/YjigoB2r52SIQjrYLbQ0G/X m68Q+GAw+QtIu3OaR7QsIAW73EY1HxDOca0GbNLXHI8YhQyUKzQQgG1/+nrksQUjuJ3Z yodkVe+9SD7pr3NQdahkIoJcVePRpjATURB+D/uJiIC+xNdMsoyPhl+RBIyl5EnQMYV3 6/wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=m+7R6Fl7DpgSUtRT0AYp6ExqKVwkzqFirWf5G7BxjP0=; b=KvLgoMxpjVn2HZwqTjzWFPC7Y6NUqc2M5YN5fRvXw9Fh7Yx9CJ58s1FKV+7pFLNx1/ WAXmUQbNXgi/UITyOt3TIAuu7a/nu/jfpjnaqj5wyz6GYyxVpHADbTu8AQUhxRZp1u3f wciytY37i8MDfrDecpDPiJh0Na28aAkDZYnXmq8kt4kA4ZTPLO/24h5uiB9YTLhU4WVw X2YUTCbIwbXtFTbS87HWQ9GineyMzkocYaN9kg2M46E3eFK7o7+ug57mbPWyOAYBGvU4 GwyvKEX5Ml5FxtZAFP0fKNW4tw7pREDzaK8SQuFYP//pjSbpsl1lRrFDzQtlQKel9dNB ifVw== X-Gm-Message-State: AJaThX4brPaJWSamm2Q+KAjoeBrkx7GNP76Mq9caaqoQ4tYqwg2XzHWA Td3VNtubH4T2vlfXjHs8RCUdBpPnXJk= X-Received: by 10.80.185.68 with SMTP id m62mr31459544ede.239.1511377430125; Wed, 22 Nov 2017 11:03:50 -0800 (PST) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com. [74.125.82.53]) by smtp.gmail.com with ESMTPSA id v20sm7581842edm.10.2017.11.22.11.03.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Nov 2017 11:03:49 -0800 (PST) Received: by mail-wm0-f53.google.com with SMTP id b189so12411916wmd.0 for ; Wed, 22 Nov 2017 11:03:49 -0800 (PST) X-Received: by 10.28.174.78 with SMTP id x75mr5543799wme.27.1511377429119; Wed, 22 Nov 2017 11:03:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.99.215 with HTTP; Wed, 22 Nov 2017 11:03:28 -0800 (PST) In-Reply-To: References: <9acaf467a587413a9aa1529ab8cc904e@AcuMS.aculab.com> From: Andrew Waterman Date: Wed, 22 Nov 2017 11:03:28 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patches] RE: [PATCH 3/4] RISC-V: Flush I$ when making a dirty page executable To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 22, 2017 at 9:38 AM, Palmer Dabbelt wrote: > On Tue, 21 Nov 2017 08:57:07 PST (-0800), David.Laight@ACULAB.COM wrote: >> >> From: Palmer Dabbelt >>> >>> Sent: 20 November 2017 18:58 >>> >>> The RISC-V ISA allows for instruction caches that are not coherent WRT >>> stores, even on a single hart. As a result, we need to explicitly flush >>> the instruction cache whenever marking a dirty page as executable in >>> order to preserve the correct system behavior. >> >> >> Isn't the I-flush only needed if there has been an unmap since the >> previous I-flush? >> Since code is rarely unmapped (exec and driver unload come to mind) >> the I-flush won't be needed very often. > > > There's nothing in the RISC-V ISA that prevents the instruction cache from > caching read-only (or even unmapped!) pages. Instructions fetched this > manner could never commit, but they could fill up the icache with garbage. > I believe that means we need to flush on dirty->execute, but if I'm wrong > I'm happy to change it. Palmer is right about the ISA semantics; a FENCE.I needs to be executed before executing any code that has been (physically) modified, because any physical address could reside stale in the I$, regardless of past virtual-memory permissions. The approach we took to handle this (executing FENCE.I when a phsyically dirty page becomes executable) is also used by the arm64 port. From 1584788865072460731@xxx Wed Nov 22 17:40:37 +0000 2017 X-GM-THRID: 1584612605235196569 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread