Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp480363rdb; Tue, 31 Oct 2023 12:48:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpTDV2nM7RyfOFPJwx5Qxl4q77jl4XiZWI88vWkbW3KGM2qoeB1WDdAUXlgvsLKSzYpBKS X-Received: by 2002:a17:903:32c3:b0:1cc:45d0:470b with SMTP id i3-20020a17090332c300b001cc45d0470bmr9054263plr.7.1698781683882; Tue, 31 Oct 2023 12:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698781683; cv=none; d=google.com; s=arc-20160816; b=sBY4YRPt4rYgnV5PO2QtFDXwbWandOZ0ydWfzZiecTeqL+hdqu8g7NjURqU1w39G6l OC9ntKsBFlRzK00TjBesz4lm+UZaUQ5AjJxFT4DFt2rFDmYS/ZIUFxMs2VSr6YlH4lQb miASCeTapC0Ehpdg5YY9rB1C5mU5tko1MV0b4sb3YwxPUyJYUc1UCXB4zXQq9YQFg4o9 qBCN105/UXmJxkLfFcF6FlKsVAyy1dSL6hZtTZPBneMyneImeeeWrlzzI/K5i+OUE/hd M5pEcn8/XM6kxAu4cdYkVJUXSHMEKwzrkajlzq6cP6H6GnVYFUPLiJQNHjGHlT31LgZY X4CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=fuoe8SHo17mdtUlOr2e06tNTUEKZlOmQh+uTt7gFLoo=; fh=WIWQNI4KQR1CK7EF2pl8sVTiZ7VXjibUi9AV3wKPpeI=; b=hZjvnI49r+5Cla2jIUV7YBCGyvD40motDweeg4V30e9er0bP1sG+UhSkVIcD9vLpCx ZL8fHYidtL7tkWNJrAQzx9Er2FcprFnFej/5fWsex9Q0NBtPMRy95T9wwdlyAMp0Y8/e JnFrMElBNeVkzjYLPExeTEKqvI3Rj8YGpuIJr+SEmH6ZKM0UbI+KySkSxYtLpLlTKNS9 yIRvxv3JWvFhcwo5YmlXjBxKU+JFI6Tdl+q5JqYybVZvj8MVgn+8maqVSHSHn5nps8GC ojKFqCIKTHxLY426OWyS+gqC7Ye+MACL7egoI2nuzuSS28CISKzdojU1L6ZB2GZKDUMb 3Wlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=H6OnVwfu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hpe.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id x15-20020a170902ec8f00b001c5c344a425si1488184plg.418.2023.10.31.12.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 12:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=H6OnVwfu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hpe.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 38C6D8029334; Tue, 31 Oct 2023 12:48:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235129AbjJaTr5 (ORCPT + 99 others); Tue, 31 Oct 2023 15:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbjJaTr4 (ORCPT ); Tue, 31 Oct 2023 15:47:56 -0400 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F1C2F4 for ; Tue, 31 Oct 2023 12:47:53 -0700 (PDT) Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39VJ2QE7028066; Tue, 31 Oct 2023 19:47:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : mime-version : content-transfer-encoding; s=pps0720; bh=fuoe8SHo17mdtUlOr2e06tNTUEKZlOmQh+uTt7gFLoo=; b=H6OnVwfuMvF1bflLWi/LVg/pQ4DoGnEkwtHFUVZa1fUswxiMClHfR5tgM1n8YfmtvrHo epjMIv9DTt9jdqRzHXcqw14fommPpZLclmgoxIMMytvSiKP20edeqG1INYFxNgE7t02G hbfs5fPIfAXSTmz0pUPyDAuVcV/wDpjK+YdzFrmPTnIBuo3xkG3AgRikjKH6+z0T/HOB vf2U2oPqrUzigdXrRs3z06/nd2lyZFEABXRizLK+813VWoAhBUc8UsX/HhHlJemOakng VPOjGD8GCOYtKyEswiY7D/UbxHP+MQ2z4Y1VVrc5Vp9ziEYQaCIlQDglM7QMWk2i6O3y Gg== Received: from p1lg14879.it.hpe.com ([16.230.97.200]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3u342n3h8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Oct 2023 19:46:59 +0000 Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id 1AB95131AD; Tue, 31 Oct 2023 19:46:59 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id 01E8C812BA6; Tue, 31 Oct 2023 19:46:56 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id 4EC79302F47FB; Tue, 31 Oct 2023 14:46:56 -0500 (CDT) From: Steve Wahl To: Steve Wahl , rja_direct@groups.int.hpe.com, Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH] x86/mm/ident_map: Use gbpages only where full GB page should be mapped. Date: Tue, 31 Oct 2023 14:46:56 -0500 Message-Id: <20231031194656.2046316-1-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: zYutFqCVYG13dDDpz8FmPBW9utMrKl0C X-Proofpoint-ORIG-GUID: zYutFqCVYG13dDDpz8FmPBW9utMrKl0C X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-31_06,2023-10-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 malwarescore=0 adultscore=0 impostorscore=0 bulkscore=0 clxscore=1011 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2310310159 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 31 Oct 2023 12:48:01 -0700 (PDT) [HPE only, 3rd version. Nobody noticed that I had typoed "x68" instead of "x86" in the subject line! Glad I caught it. But mostly, incorporated Uwe's and Dimitri's suggestions. Need to test with the change to make sure it still works, though.] Instead of using gbpages for all memory regions, use them only when map creation requests include the full GB page of space; descend to using smaller 2M pages when only portions of a GB page are requested. When gbpages are used exclusively to create identity maps, large ranges of addresses not actually requested can be included in the resulting table. On UV systems, this ends up including regions that will cause hardware to halt the system if accessed (these are marked "reserved" by BIOS). Even though code does not actually make references to these addresses, including them in an active map allows processor speculation into this region, which is enough to trigger the system halt. The kernel option "nogbpages" will disallow use of gbpages entirely and avoid this problem, but uses a lot of extra memory for page tables that are not really needed. Signed-off-by: Steve Wahl --- arch/x86/mm/ident_map.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/ident_map.c b/arch/x86/mm/ident_map.c index 968d7005f4a7..b63a1ffcfe9f 100644 --- a/arch/x86/mm/ident_map.c +++ b/arch/x86/mm/ident_map.c @@ -31,18 +31,26 @@ static int ident_pud_init(struct x86_mapping_info *info, pud_t *pud_page, if (next > end) next = end; - if (info->direct_gbpages) { + /* + * if gbpages allowed, this entry not yet present, and + * the full gbpage range is requested (both ends are + * correctly aligned), create a gbpage. + */ + if (info->direct_gbpages + && !pud_present(*pud) + && !(addr & ~PUD_MASK) + && !(next & ~PUD_MASK)) { pud_t pudval; - if (pud_present(*pud)) - continue; - - addr &= PUD_MASK; pudval = __pud((addr - info->offset) | info->page_flag); set_pud(pud, pudval); continue; } + /* if this is already a gbpage, this portion is already mapped */ + if (pud_large(*pud)) + continue; + if (pud_present(*pud)) { pmd = pmd_offset(pud, 0); ident_pmd_init(info, pmd, addr, next); -- 2.26.2