Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1062623rwd; Wed, 7 Jun 2023 10:24:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61dIYgcj8ugsnG2Tki5PLQzYmj7sIwxcHMcriwfM01XF5uzhe8wi4Ec89BKzWJwecVuSaf X-Received: by 2002:a17:902:9a06:b0:1b2:4be9:c25d with SMTP id v6-20020a1709029a0600b001b24be9c25dmr2626011plp.4.1686158675095; Wed, 07 Jun 2023 10:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686158675; cv=none; d=google.com; s=arc-20160816; b=SQcGqo4Det1BBGDczX0vVYU695GlGyvUS15U0U2lk2BG7hQxJzhye2sZFF5XfnbJnT C32D5cTq9BSz23lZnD30JYage/5ZJCdgM8gfLrkMx7Co9leb9iq5ZAbOKUgFNbBvthbS uFARseqXo6aSsOD5BwEiufTnaTOusUiTYLVxcOJacVikLPY601uBkVzseWBlX/B1ERIb LB/s2SsT0mfbdPQhxkfYiuI0x7nmdewu3Ka/lix7upLFFfxeJDh2dYI9GOYHK2aMWomS 8GLmvzEQFg135vy+/+jKlciWUglFuEJEW/ZlgNl9diqwslR5YLKW3lGid86wHrF1b6S4 Exhw== 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 :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature; bh=UKRz/uZ87RNOojiWxbkoJL1O6bZ0Um+/EcDEPJ0G8TM=; b=WWng92PbQVnmqJ6cnXzq488RQHQ0M6MJVZU4osxKEUjtVXsimvMcLuavWgFg3yh1x4 34KTSsyQwM7hHeM8KepitaWHTcMP9YZl95N5GYAYC5gU9zcIwsgSKvyQu1UTHD1kEQSf S6op+EW6dL/SwlihGT0b7zt+bhO0t3BBLsiQObPxj3yLhjvP6kZCSnWSSv5P6kH2RerF 3H7PG11Fu9IW357jneOqRVLYCifRfesrhq2ZTB6id1BTzlsTCEqT4uqVHBuvJyTwo+pQ Ph2vBD6bvF4BnV+uyvndMbT+mBKn7xW3ShRLaKDKca4ePxUrrqX2s/8SWOIDsM+m3fOx i7bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="H1Uf/yfp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a170903120900b001adf26a9390si9530675plh.191.2023.06.07.10.24.20; Wed, 07 Jun 2023 10:24:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="H1Uf/yfp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbjFGRLO (ORCPT + 99 others); Wed, 7 Jun 2023 13:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbjFGRLN (ORCPT ); Wed, 7 Jun 2023 13:11:13 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDA7A1BC2 for ; Wed, 7 Jun 2023 10:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686157872; x=1717693872; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nn861VFp35Q9ZBleEYgKaQLtJQsWGLX2Vj1qxZbrt3k=; b=H1Uf/yfpRjn861OyFBqw0GPObq/mW4DmAVt/1y3VoXA12KyNklR7i9V+ +WRCriW3UZ9ZHWBRRfUY38Xdz9cQys2Xi+AmuDWuB8uExpZ2fbNn8DmeY Xj8z4QYv2vLm35ZnJbDoYd5/zqmP0ABXcWEHqQ6Y275SaNTVO0j3wIDqx TZVOR0YuMk3MC0s4002Me9dcscYMBj2V0acaSUCLtyZHSkmeKEqNNUDH8 WHs4M1utJsKYC0g4VNxeBLIPvLGRQ7jC6YzKIxQcdUKmusn/eVKv3UfQ4 8XlAdFzv30zuyzSBVParwRK9uLS66mElZRQsiHze/zjAuSknWUJek+i6c Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="443418006" X-IronPort-AV: E=Sophos;i="6.00,224,1681196400"; d="scan'208";a="443418006" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2023 10:11:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="779541683" X-IronPort-AV: E=Sophos;i="6.00,224,1681196400"; d="scan'208";a="779541683" Received: from jkrzyszt-mobl2.ger.corp.intel.com ([10.213.10.174]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2023 10:11:06 -0700 From: Janusz Krzysztofik To: Borislav Petkov , Dave Hansen Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Andi Shyti , intel-gfx@lists.freedesktop.org, Johannes Weiner , Janusz Krzysztofik Subject: Re: [PATCH v2] x86/mm: Fix PAT bit missing from page protection modify mask Date: Wed, 07 Jun 2023 19:11:04 +0200 Message-ID: <38324471.J2Yia2DhmK@jkrzyszt-mobl2.ger.corp.intel.com> Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 In-Reply-To: References: <20230607152308.125787-2-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, 7 June 2023 17:31:24 CEST Dave Hansen wrote: > On 6/7/23 08:23, Janusz Krzysztofik wrote: > > > > Extend bitmask used by pgprot_modify() for selecting bits to be preserved > > with _PAGE_PAT bit. However, since that bit can be reused as _PAGE_PSE, > > and the _PAGE_CHG_MASK symbol, primarly used by pte_modify(), is likely > > intentionally defined with that bit not set, keep that symbol unchanged. > > I'm really having a hard time parsing what that last sentence is saying. > > Could you try again, please? OK, but then I need to get my doubts addressed by someone first, otherwise I'm not able to provide a better justification from my heart. The issue needs to be fixed by including _PAGE_PAT bit into a bitmask used by pgprot_modify() for selecting bits to be preserved. We can either do that internally to pgprot_modify() (my initial proposal, which my poorly worded paragraph was still trying to describe and justify), or by making _PAGE_PAT a part of _PAGE_CHG_MASK, as suggested by Borislav and reflected in my v2 changelog. But for the latter, I think we need to make sure that we don't break other users of _PAGE_CHG_MASK. Maybe Borislav can confirm that's the case. Since _PAGE_PAT is the same as _PAGE_PSE, _HPAGE_CHG_MASK -- a huge pmds' counterpart of _PAGE_CHG_MASK, introduced by commit c489f1257b8c ("thp: add pmd_modify"), defined as (_PAGE_CHG_MASK | _PAGE_PSE) -- will no longer differ from _PAGE_CHG_MASK as soon as we add _PAGE_PAT bit to the latter. If such modification of _PAGE_CHG_MASK was irrelevant to its users then one may ask why a new symbol was introduced instead of reusing the existing one with that otherwise irrelevant bit (_PAGE_PSE in that case) added. I've initially assumed that keeping _PAGE_CHG_MASK without _PAGE_PSE (vel _PAGE_PAT) included into it was intentional for some reason. Maybe Johannes Weiner, the author of that patch (adding him to Cc:), could shed more light on that. Thanks, Janusz