Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1546602ybz; Sat, 18 Apr 2020 03:19:57 -0700 (PDT) X-Google-Smtp-Source: APiQypJyDE/hzDJCayCFAHUVwDcYwFAVlvwNd4RQs13jMtJMd90fPxAh/xo24TrVUfSWYKaWE7Bi X-Received: by 2002:a17:906:5918:: with SMTP id h24mr7264622ejq.210.1587205197837; Sat, 18 Apr 2020 03:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587205197; cv=none; d=google.com; s=arc-20160816; b=X9XWYO1nlZWtGOc98Jn0NQwRXvQfW7vhLacbuckAsnU+VT709XKn0rUhTcJFqEOp7Z tXP4qAok9XBnzzqbhzFYTxIyEQrEOOeAiJv4tog1madjaY2WpJqwImjkSeqyEczonxIK sI56/GYxYslNxGvap4PFqmb0BZwnHFq7wZS4HlFlDbd6FKKgj4LzS2VWU4gEC54LKSZf 5MAJMTRvBz4viEuBYdH1WwoOJcXImppByWwtNjbXJkgb755N3t49QuklKkRYhI9tFWIX hyVxyUvrc/m4N54I/JMNq1XaH69j1ss5BVHPVb4bXpzus0XiPMk/89HtrTQDOsIachn1 Zqeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=RPaV1qM4ZKgL3S2ntbIkvSzjXNs6ercHxgjZMQ5LUyc=; b=ZGN1Pn+x8F8GMkztJJbyKD2aukq9MHg6MCdVWiL37fszxsrAWxozIoIgtZ1Y1qfewb +KRhY9buAiUpDBSGc0G1Dy4/UsOxJwlt8+6o696Xkf7o8TLJ6sBJS8CaHq77XYDEN5Zw Lic5kYuEWGglibO8pb5fqS2vYDaASYXpZRpP1WmFrNv4F0mIcMCPKeRvsvHAVsJ0/0wN OiY0gKKYtGEko82mxpVgKOitHYpUUX2PBUIVB7Al97zZr7Bt7xCDdn2JEvPXDKLkZckT nFHU7PYTO96fdLlGExBvsU5zOFlt7AhBaiNs0BFrU3+pWe5a49GBJeltTVyHHx8Siifb jqdA== 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 qn4si8908424ejb.209.2020.04.18.03.19.33; Sat, 18 Apr 2020 03:19:57 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725879AbgDRKRz (ORCPT + 99 others); Sat, 18 Apr 2020 06:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725799AbgDRKRz (ORCPT ); Sat, 18 Apr 2020 06:17:55 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2719BC061A0C for ; Sat, 18 Apr 2020 03:17:55 -0700 (PDT) Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jPkXg-00073w-Oy; Sat, 18 Apr 2020 12:17:44 +0200 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 31C62101304; Sat, 18 Apr 2020 12:17:44 +0200 (CEST) From: Thomas Gleixner To: "Singh\, Balbir" , "linux-kernel\@vger.kernel.org" Cc: "keescook\@chromium.org" , "tony.luck\@intel.com" , "benh\@kernel.crashing.org" , "jpoimboe\@redhat.com" , "x86\@kernel.org" , "dave.hansen\@intel.com" Subject: Re: [PATCH v3 4/5] arch/x86: Optionally flush L1D on context switch In-Reply-To: References: <20200408090229.16467-1-sblbir@amazon.com> <20200408090229.16467-5-sblbir@amazon.com> <87mu7akwdx.fsf@nanos.tec.linutronix.de> Date: Sat, 18 Apr 2020 12:17:44 +0200 Message-ID: <87mu79xflj.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Singh, Balbir" writes: > On Fri, 2020-04-17 at 16:41 +0200, Thomas Gleixner wrote: >> Balbir Singh writes: >> static void *l1d_flush_pages; >> static DEFINE_MUTEX(l1d_flush_mutex); >> >> int l1d_flush_init(void) >> { >> int ret; >> >> if (static_cpu_has(X86_FEATURE_FLUSH_L1D) || l1d_flush_pages) >> return 0; >> >> mutex_lock(&l1d_flush_mutex); >> if (!l1d_flush_pages) >> l1d_flush_pages = l1d_flush_alloc_pages(); >> ret = l1d_flush_pages ? 0 : -ENOMEM; >> mutex_unlock(&l1d_flush_mutex); >> return ret; >> } >> EXPORT_SYMBOL_GPL(l1d_flush_init); >> >> which removes the export of l1d_flush_alloc_pages() and gets rid of the >> cleanup counterpart. In a real world deployment unloading of VMX if used >> once is unlikely and with the task based one you end up with these pages >> 'leaked' anyway if used once. >> > I don't want the patches to be enforce that one cannot unload the kvm module, > but I can refactor those bits a bit more Not freeing the l1d flush pages does not prevent unloading the kvm module. It just keeps the around. It's the same problem with your L1D flush for tasks. If one tasks uses it then the pages stay around until the system reboots. >> If any other architecture enables this, then it will have _ALL_ of this >> code duplicated. So we should rather have: > > But that is being a bit prescriptive to arch's to implement their L1D flushing > using TIF flags, arch's should be free to use bits in struct_mm for their arch > if they feel so. >> - All architectures have to use TIF_SPEC_FLUSH_L1D if they want to >> support the prctl. >> > > That is a concern (see above), should we enforce this? Fair enough, but it's trivial enough to have: static inline void arch_task_l1d_flush_update(bool enable) static inline bool arch_task_l1d_flush_state(void) and the rest of the logic is just identical. Thanks, tglx