Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4781332ooa; Tue, 14 Aug 2018 10:27:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy5Bndahsfu8e1NJeRL2Ll+TMwThjykuIaQUzA1UaKZlJkYqzd2PimDfiLpqGfJn4y3DifL X-Received: by 2002:a62:13ca:: with SMTP id 71-v6mr24629227pft.34.1534267652623; Tue, 14 Aug 2018 10:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534267652; cv=none; d=google.com; s=arc-20160816; b=ZlAg5NCRf7sfyjwNkfcnaGTOcdXLMxctF0PHfcKm/OztLpzgNq50wusGVcm4RYbAJg hA/WhDslpqklOfGTzQ+8yqGUNfmQ0Rs56iyqj73A7GYPfqHD7xgpbbLRIUr7fVMuL6oY sF2YS2oU13mPa83SWdDfNj1DS71FyLva2EktTBk4Ep8D68LRZ5jIiZAimjAwLy3PMfCF /zSMMzxB3yL54noGeOs07FuI8B0JeiDggJpH5/7U7GApXLSKCod/dkNbSEdBuNzpHFeV u73A3jEiG3Dl5sfuQ9pQx38Xq1wtZPYao3Tjseu/JIXg/GvLX6H+Y5nPY5iRow+YkUUe Cb+Q== 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=HF/4Ukt2+VHOOM6cX7gEjLq8vswaodcFG76CSmqAA+k=; b=jiuKHNrJ0i/HRg0nMfO3X9Rw9cND/orO964Cug1Zc5bz4W7Le358Prnf4di8e0Uukc PE0W2tDVWqfxbKCYZJEtFOmBklNmtFH6dRsyR1VTvn7DSy5nJhR1bPBtpkwXU0qH6WhW OJX/giTbKx4PIzVnji+HV9RAvjfwm0zBmqbQt2QIw4xL1KdtfgieMh3gIgjU167D+ixK qU0zCNV9UDoHgCa1tg3v85VnGQNKJQy9TsT9zpABnQbHftEgRGliCPawKuqJnTEbLrPe eFE0dKi/9+HZd9CUgz1B2MrzcbHit5KjpTyicb1d8AbyZz6nKfCqrsiwP/Syjh9Bkai6 9cSQ== 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 i123-v6si20993420pfe.145.2018.08.14.10.27.17; Tue, 14 Aug 2018 10:27:32 -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 S2388124AbeHNUNQ (ORCPT + 99 others); Tue, 14 Aug 2018 16:13:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51554 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387804AbeHNUNQ (ORCPT ); Tue, 14 Aug 2018 16:13:16 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id F1B37D1D; Tue, 14 Aug 2018 17:25:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vlastimil Babka , Thomas Gleixner Subject: [PATCH 4.18 28/79] x86/speculation/l1tf: Extend 64bit swap file size limit Date: Tue, 14 Aug 2018 19:16:47 +0200 Message-Id: <20180814171337.873950726@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171336.799314117@linuxfoundation.org> References: <20180814171336.799314117@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vlastimil Babka 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: 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 @@ -891,7 +891,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; }