Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4817395ooa; Tue, 14 Aug 2018 10:58:21 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyF9OYhhZMT4WPHWp0PwIEGhmlhncLThpyllmmjbt2KHzyWjJA0oqlo6HFPUdN0ZVONGJCF X-Received: by 2002:a62:15c8:: with SMTP id 191-v6mr24108245pfv.194.1534269501690; Tue, 14 Aug 2018 10:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534269501; cv=none; d=google.com; s=arc-20160816; b=YQm2CBsPkQZNArSFEWkNEkKTppg4uIIih87S2kEh2vvXnTtrG3ZdU3qDiQkV33vT+K F25qisOFsolJWj3pb3+z2lencTX5kyktptNo1ayHF9qxbfFNuntG4FLcGR4O4hWZkUtE o2AUR/I2/1Keq4Dx+awPLLHY2BQXZifmEHr0RHUzpiL0Acz9zdu5ws5DGwQB7av60Wg8 1lQ+4jhGIAygw+dixYl2CaIdcJvVUBw0dhnwnvyVvd/tqhC7zRL3oN0Ib5unfg0vugl3 GT1ug3e6rTVhAHGL1+tkM1AvjNKz1n4dMQsXHZA6hOstDnhJYaf13raTkFjg+aU1t01j /2yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2O1xTxSe2yc6xFqsC+deq7pC3IAYfXgLMQ1xCJkOcHY=; b=jUWmjuTOyX1+Dv/COo0HjdDa2aSO+gvVfG5q4b7kuFegoX7QeQZ/Rn1GGP80k//OhT niVN5oOx0cWfrYuvLExEDyG21iIJGCV1WL+8w8TIqwo5e9yy79KBXfCDakMwph/3xfPC LgRHwe98S4waOCTSh3C8DWMlZCQL3qkgnUKoi/exSbP/j11dIvPe/iM1efKMOH2Dul4l 4pp8ZIkWkO/My1pAo+0fM/k83lF3+upT0nQvP6UHS/dFnRDIHv3XphJEX7N5D7e0Q0xV 7jN+qV62SNljHdmZeDE2HKV0PRVr4MvtAveS7PoOkTnME3+IJ8PphIV4uqdZxHzheR81 0CTg== ARC-Authentication-Results: i=1; mx.google.com; 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 q18-v6si16536376plr.134.2018.08.14.10.58.06; Tue, 14 Aug 2018 10:58:21 -0700 (PDT) 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; 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 S2390031AbeHNUaE (ORCPT + 99 others); Tue, 14 Aug 2018 16:30:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59084 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730139AbeHNUaE (ORCPT ); Tue, 14 Aug 2018 16:30:04 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 879E8D20; Tue, 14 Aug 2018 17:41:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vlastimil Babka , Thomas Gleixner , David Woodhouse Subject: [PATCH 4.9 050/107] x86/speculation/l1tf: Extend 64bit swap file size limit Date: Tue, 14 Aug 2018 19:17:13 +0200 Message-Id: <20180814171524.266239103@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171520.883143803@linuxfoundation.org> References: <20180814171520.883143803@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vlastimil Babka commit 1a7ed1ba4bba6c075d5ad61bb75e3fbc870840d6 upstream The previous patch has limited swap file size so that large offsets cannot clear bits above MAX_PA/2 in the pte and interfere with L1TF mitigation. It assumed that offsets are encoded starting with bit 12, same as pfn. But on x86_64, offsets are encoded starting with bit 9. Thus the limit can be raised by 3 bits. That means 16TB with 42bit MAX_PA and 256TB with 46bit MAX_PA. Fixes: 377eeaa8e11f ("x86/speculation/l1tf: Limit swap file size to MAX_PA/2") Signed-off-by: Vlastimil Babka Signed-off-by: Thomas Gleixner Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman --- arch/x86/mm/init.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -791,7 +791,15 @@ unsigned long max_swapfile_size(void) if (boot_cpu_has_bug(X86_BUG_L1TF)) { /* Limit the swap file size to MAX_PA/2 for L1TF workaround */ - pages = min_t(unsigned long, l1tf_pfn_limit() + 1, pages); + unsigned long l1tf_limit = l1tf_pfn_limit() + 1; + /* + * We encode swap offsets also with 3 bits below those for pfn + * which makes the usable limit higher. + */ +#ifdef CONFIG_X86_64 + l1tf_limit <<= PAGE_SHIFT - SWP_OFFSET_FIRST_BIT; +#endif + pages = min_t(unsigned long, l1tf_limit, pages); } return pages; }