Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4807584ooa; Tue, 14 Aug 2018 10:49:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxNTrbA9B/gtB571ir9tAH1dwBU6/BkYQ6ZmFOHyOrPiQvDnx1y1wjKbHqEQ9ZlhYSIJZsI X-Received: by 2002:a62:2c95:: with SMTP id s143-v6mr24398371pfs.3.1534268990279; Tue, 14 Aug 2018 10:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268990; cv=none; d=google.com; s=arc-20160816; b=VlQ9QDGI7LR06e/uV/cjvGnYJ4EjIjpl3OYykMzDResLh2bQKxsR5JxxFEykVDO5h1 kmQY26lpDv/uUKmXFkUZS7yzPlGqJ4bR0K6QfP2lIVzUHscflFPlF/LFQ1k6pCChKYJi M1POqoLvtGjWJmFrf5rh5aMk5full5M8l7s4tyNjvpXgVFl872wCbHcofQL50iCpl4Fp 00a1hcLuLaDC3yDBz6nF7P09igaB3VU4TUwX0836/JsPTU2Dbqmp/bvzZcbW903BUsy6 PphBpKDE1Y57iNoPnclhrVx+9v1NDn8tuWMt95Efdd0HvPvuai5gQjnQloUt0EtywerA uVAw== 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=JW4lWnBYTGO/tOxbFTmr4imiX9Xg4VDRjPCJOELdwws=; b=ti+ki4ubKF/fXY1KA9tw1x4Bx5wpsLm+Z/pj+5LURGqvcWqqV3c+X4NYpYs00Qmktq XBQPdi9OA5VqW+yPkqVeRUcPpCAMH/6bRc9hte+njVY0pQIaZEvrj7OFRNe43H+1XVjs ZzK5nP74xygsRMWV0R+18p5RlyUtvGaQnA3JaS4+TYm4VAwfeF9Bl5LysYpiWALNo7f4 D/QpFUpfZIKbWIb1dB0fszgLEWm5mwJfzz8HLpTV8RzBkqPCgQfEXSdtRc8tJyHrS9/l VpUvxiAG+T5eXH974h2T2HP0fR45Rk7SeYaoSuVwbTxsdexoj24Axcg0pqvReLun0SJ3 Q1xA== 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 35-v6si18747138pla.453.2018.08.14.10.49.35; Tue, 14 Aug 2018 10:49:50 -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 S2391341AbeHNUgi (ORCPT + 99 others); Tue, 14 Aug 2018 16:36:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32986 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390501AbeHNUgi (ORCPT ); Tue, 14 Aug 2018 16:36:38 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B1FADC8D; Tue, 14 Aug 2018 17:48:25 +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 , Guenter Roeck Subject: [PATCH 4.4 35/43] x86/speculation/l1tf: Extend 64bit swap file size limit Date: Tue, 14 Aug 2018 19:18:11 +0200 Message-Id: <20180814171519.410521293@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171517.014285600@linuxfoundation.org> References: <20180814171517.014285600@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.4-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: Guenter Roeck 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 @@ -778,7 +778,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; }