Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4681200iob; Sun, 8 May 2022 21:48:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpM8UTBvDYB6qxM/urXEDbgUl/IbhbBe0JRrkQh28GPUfc2Oq/lbm3vb5HHue1whfZ/3qY X-Received: by 2002:a17:903:2043:b0:15b:f6ff:79ed with SMTP id q3-20020a170903204300b0015bf6ff79edmr14536071pla.15.1652071699045; Sun, 08 May 2022 21:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652071699; cv=none; d=google.com; s=arc-20160816; b=HpGYka/Z9qt4TqvBM2i3JJ3spzxRT3/45CdtROXyT1eW/kgyXgZ+7lqwyOp2iarD9Q KiupyYvECIE1pCpYV9vyrUIYxnayb3mAgZ5BuzYi64/6fX17lALJKvAF/g80f+E7hquB ZabRcH84wlOziiqEtAucM3mHUt3QYYC/N7ysyxMBfTTCQNHobGdX2rdTBz+gZmC/2EdT qDfazufBOgmg4+PTcrr2W09vpyhTL8Vb9654C615c10m6evwjGhiM7MFkqjGOyFjH7s0 njJv5CHUPAM9yWhZNBbvn8hSyWoqw85SM3UARBS2bZ2n/BHBa8egJqnElHMR4Mw0auqk NvGg== 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:cc:to:from:dkim-signature; bh=Ny5V9hV8WNPqWG0K0hKRF+ytRyOWelWP3foEMg6Arxw=; b=AM7dy3R+qMZfOFGuN7KoOsnq/xNHW2O/s5aQk+smKPQ5N7BevNidpE7rgMhP+d7dUG 7ZedrRoKaBg00AFlmBau/j5EpBvRI4KJDhJ4SzlMnjlGWaIoMdRj0JGuDZ930D9v+OYk ub6g3tj3Kud8ViE9ehYV0SQ467FtCLWAZLHKnnxjhF9qe7PptacdYvuR1jeD+wOopmCu s+MuWElhXOprYR3j2zPEmtgSZgH1jSy1yRAgSF2A8qS5TS77AqA/i0ZPtSjwZZD5aX+G 4tj6isLJ53LWyufKnfqMhLCA8MGaBpLqu26J5qcU5OsxsHZoyy27OAHXo59Rh8VS+aKZ A80Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AQwkLRlg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i7-20020a654847000000b003c142fc5ca4si12789125pgs.336.2022.05.08.21.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:48:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AQwkLRlg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11E9412EA3D; Sun, 8 May 2022 21:46:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240616AbiEFFZz (ORCPT + 99 others); Fri, 6 May 2022 01:25:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239514AbiEFFZw (ORCPT ); Fri, 6 May 2022 01:25:52 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A9575DA5C for ; Thu, 5 May 2022 22:22:10 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id n18so6393459plg.5 for ; Thu, 05 May 2022 22:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ny5V9hV8WNPqWG0K0hKRF+ytRyOWelWP3foEMg6Arxw=; b=AQwkLRlg6wVbe9vtL5WcHTIR9yNaleyWfC9TGRE7bBtMfEaAnlTtEdzkRiTUczg8OM p9lBmS5hVcnLA2nJDYEKn2m8ooeSRN5gUbKaTD/sE0cOfRfTH6xFi8hpQMB9wOdzpzH4 c5FS4cSYRyR+h9SiLHJy0kKSXhnNqwkggYif1VaTCqpuIdJogBzx0ikEaAUG+uo5DlpK eLsXXC+y1KrnOXh4ufFMHUzEGtgzdc1vgP/qvE4qtDzisFGz8TN51QvYxPAJfuoGOnPT ikAcs53iIMTGDVA7KS/h5NTiOt/b64Bn/ry9txEojDJfgscAKUXj/IS/E2ODyWOhppX5 LNlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ny5V9hV8WNPqWG0K0hKRF+ytRyOWelWP3foEMg6Arxw=; b=TRpZk5/cJGy8S+ubPDO43TThP+n4yYmU0GT+hjGMBP8Qw5vxYD13+XdlhcER+u9UYl gVkY43Pc1UnQrErXIITR21NeGtTl/VeQeAXuwf7JoesKQIWP2W84O/KYVoO72vQQmJKq 2dpdJ4zzWeaH1ej1w1IUQEuzkO15snLvCqUKwq0/S1EbEWiRU+iSSoIBbayPt9P3/zYU l1lxeJZwrVKWn21hTCfbZA6edi9GM4QVonP6TMbEC6n21HVJPlBj0ZJmLwRJq1N4adxG 5O1/UbQV4Q6+isT/KxC+XcYx3QSAY1MUvTArwsRCiZNiz1GUuEyXu0ZeJIqzsSxBxxMM BrwA== X-Gm-Message-State: AOAM533zGi9BvFmMIN3auYD5flTNJ7wln1oe6JClgQfxmguBjQaub4Mm fB3YnuaBUIIcH3oPOPtVJ+Y= X-Received: by 2002:a17:902:ba91:b0:15a:42f3:73ef with SMTP id k17-20020a170902ba9100b0015a42f373efmr1765340pls.162.1651814529928; Thu, 05 May 2022 22:22:09 -0700 (PDT) Received: from hyeyoo.. ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id oc15-20020a17090b1c0f00b001d93118827asm2531958pjb.57.2022.05.05.22.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 22:22:09 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Rick Edgecombe Cc: 42.hyeyoo@gmail.com, Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , "Kirill A. Shutemov" , Brijesh Singh , Tom Lendacky , Tianyu Lan , "Aneesh Kumar K.V" , linux-kernel@vger.kernel.org Subject: [PATCH] x86/mm/cpa: set PAGE_KERNEL in __set_pages_p() Date: Fri, 6 May 2022 14:19:39 +0900 Message-Id: <20220506051940.156952-1-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 __set_pages_np() not only clears _PAGE_PRESENT and _PAGE_RW, but also clears _PAGE_GLOBAL to avoid confusing _PAGE_GLOBAL as _PAGE_PROTNONE when the PTE is not present. Common usage for __set_pages_p() is to call it after __set_pages_np(). Therefore calling __set_pages_p() after __set_pages_np() clears _PAGE_GLOBAL, making it unable to globally shared in TLB. As they are called by set_direct_map_{invalid,default}_noflush(), pages in direct map cannot be globally shared in TLB after being used by vmalloc, secretmem, and hibernation. So set PAGE_KERNEL isntead of __pgprot(_PAGE_PRESENT | _PAGE_RW) in __set_pages_p(). Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- arch/x86/mm/pat/set_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index abf5ed76e4b7..fcb6147c4cd4 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -2177,7 +2177,7 @@ static int __set_pages_p(struct page *page, int numpages) struct cpa_data cpa = { .vaddr = &tempaddr, .pgd = NULL, .numpages = numpages, - .mask_set = __pgprot(_PAGE_PRESENT | _PAGE_RW), + .mask_set = PAGE_KERNEL, .mask_clr = __pgprot(0), .flags = 0}; -- 2.32.0