Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5131151iob; Mon, 9 May 2022 09:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBcw0AQX/AVCe/KSJN5/hsl4EAgJ825VxHcuH6Wbq2bM5DO4PiEaXI3ZylTbB63CnOvg1j X-Received: by 2002:a05:6808:208e:b0:326:bb9c:5b2d with SMTP id s14-20020a056808208e00b00326bb9c5b2dmr3673944oiw.152.1652112811225; Mon, 09 May 2022 09:13:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652112811; cv=pass; d=google.com; s=arc-20160816; b=iZTEAljg5G5+vCjHKZ2teTzOr19bvWBGMsdfsjKNn5GG0SAnAgMdylv3ORZPvvP+e1 qBWnXsdJpWNhC1woF7M6Nw0DjtVkDJ28q/gNtEgdzdvV2GAAksigvmTfpoMzkiuM+Av7 32TNWgdbdjiPq4VMkL08k7R6dQwHD2rrMt/Nt4vcOEVbTZg8PTxspKKw0ugN/HFleFjg ThanMahxLFiDemwvjrGkP0s1TMQRJuoCqNqgdNnNG7zqjxu/nKtZ2pVW3UQdYpFb5iHN a95n0nu0mF5l/ZZktPf5bTfBjLcJpgVm8lXvOOaLySMGQYI21/nK3tcH46TyynMMt/Fo cTZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=90XeeYXo757SwrG1O5NrR65fTu54UuDZ7JSJiul292s=; b=Vl+uKbiRsiKNYU6Rhf1ud6R++KA4RpY0CbmIGPfMsfmlPN3nvo8JkVXplbSWOH8jEK eAqxh18Pw41B+iWxnFJ9gjMrBByCicr2DzdENLbsoW9KV4JyQsgvXeGzhNlYBoqHXfbF bkeUUL+ateXrrt3U9wi56QoBQwkMd/YsTCupYtJEwYqOrnEuJgWmMf+pr7gZbz6COw/k 31AJF/3N7JahmMfd7Rnj56PgmNROtGV14aTHCSU50epm6U/u92P3FWrZ95cOHFERRAAw AuYKtzE0EzOUzkxFhxhztIRNxS3eXo/WTzs69im7CNdXsWHv/H3hVkKuLV982HJ0W+V0 5SFQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=n1CRpixF; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s39-20020a05683043a700b0060698508847si2261641otv.8.2022.05.09.09.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 09:13:31 -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=@amd.com header.s=selector1 header.b=n1CRpixF; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 078DB2618C8; Mon, 9 May 2022 09:06:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238901AbiEIQK0 (ORCPT + 99 others); Mon, 9 May 2022 12:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238850AbiEIQKY (ORCPT ); Mon, 9 May 2022 12:10:24 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2046.outbound.protection.outlook.com [40.107.93.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0BB82609C5 for ; Mon, 9 May 2022 09:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oBSvAr8Z//eXZrVz2HWSCkQzzH970C7lhz6a5txfUzoQdvoHhxt4fxL0kROeE/Z4RYAi32Ow+b9ukb7KaUCXtqe8Xat0s6ugHf34S4T1leRRX1z/6i7tpup1zSPvhF4A19gnyTB3LNh5QJHmnkjPCuGeToG9id66agqoAnU9vK7aw32mZ0VmzW13GVHz3IMZojdQXQWfi3OBDoX1ENpVm5OIBykvBEhjPVUFbymlwuxWD4366Ybx45lUBhFXOvbdM14giSpY+LG1lIYXJk132JgFRc0SdDPhUIsrwKFNjdHBjLtduXr53w4NBVWNGWfivQbq8KrG675B/Qa/lpneqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=90XeeYXo757SwrG1O5NrR65fTu54UuDZ7JSJiul292s=; b=a7hSilAxLuEqEUiDXbnAUHxyppAS119IOwn2X3jyzFpYSTNYvzYlKqAg9uV6JHHOCQH62u1UNQzBitrp5dQ7XClgCQkd+fqD+TQwzBoNASD5Brk2q/jT9fCOFTiXLCl69hXgsP9C6uQe0v+Un/bGC+3YDG0F/WaoTIypNfMZL9vmNdjt8QahKWarqNefsV0k4DWYEq+zbRtk9g5WM3Sebh1AadS2zq5EBue7gx2PtOrh5o05fkbrPGO3K0+Znyqc0xf1OPrll+cS3WeaJdQtTamkL7O4IT2EUm6VaiAR7YT33ZgiLokWWtObiLyNRcZFuaAtTO1RuMjsNWY7QURXTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=90XeeYXo757SwrG1O5NrR65fTu54UuDZ7JSJiul292s=; b=n1CRpixFE5UrOfY9NyCvofYnMBcg+3kqiVk+fTVhSJEusG9MG1dDAQtdBqmYhWEGBr/EOlx9mnnCpwxwZ5RzI/UFG8JrnEy0sXMqK6OsR0qJc2ErizMgWCZfQoCYlBuGMvnJ/jyH0S/x4pzKT4GBCNxPDbHSFIMRMrPgGHrXrK4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by BN8PR12MB3475.namprd12.prod.outlook.com (2603:10b6:408:48::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23; Mon, 9 May 2022 16:06:24 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::db8:5b23:acf0:6f9a]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::db8:5b23:acf0:6f9a%4]) with mapi id 15.20.5227.023; Mon, 9 May 2022 16:06:24 +0000 Message-ID: <56f89895-601e-44c9-bda4-5fae6782e27e@amd.com> Date: Mon, 9 May 2022 11:06:22 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] x86/mm/cpa: set PAGE_KERNEL in __set_pages_p() Content-Language: en-US To: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Rick Edgecombe Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , "Kirill A. Shutemov" , Brijesh Singh , Tianyu Lan , "Aneesh Kumar K.V" , linux-kernel@vger.kernel.org References: <20220506051940.156952-1-42.hyeyoo@gmail.com> From: Tom Lendacky In-Reply-To: <20220506051940.156952-1-42.hyeyoo@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SA0PR11CA0076.namprd11.prod.outlook.com (2603:10b6:806:d2::21) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 209eb63b-5105-4eb6-c16f-08da31d5ddd7 X-MS-TrafficTypeDiagnostic: BN8PR12MB3475:EE_ X-LD-Processed: 3dd8961f-e488-4e60-8e11-a82d994e183d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nML/+QqkGWAnZpFb52AHNK5TxTBGUQ13XypMxJX86BOWpBAG06LE0P9wnEBNt0lnL/6cL1T2+tZl5SP5KgmyELxfh4fI8Q6sS6HZ1XKPO6mGFZd7fQZFEcJr8eYfa7OCfGFIlVQqN3InwuVQJZG9apswKbGTjLQup/thJ6KOTiAZui940a/jyvFlP7Sq1SfX4v0MF9bgLkv4qWFgjD683igwqAQam7N6U2EYp4yuLYurcgr26U60lleXZ1avE7Nxpbto/sEpWAg8pStXj9wsSeFwkV9htShLCJtuH0a/L2IokgYalI7Jo5MsrmE4k9Pc0FPGCvTWdrFkLmJTUiKaW0kk0fuJKb6WZiS+7o9gXnkYYU7bnHCsc+zHMENbkYr45lCbV+uLqa3tiEhoilq/QkYz0HunGDal95+pzievOKoOcDpRQ5rEhx4/viCve89x9u9GZg4rCLl16fOkd2rNc7CiTyyno7UcRNLQGnqGsxGd0f2JfzUYsImDq/lmxd8xCtXjQbBTDkgUlHkixDUSLuu2OXFUz0yQN3l0oHP71BzPZsYeqq3aEtPuGvWoMaQwIDgR2oMHqZBQd2Oqj2Lklm5A5jl6xH7GgTwTu6RliQMeIJW3WNGfpOrkudr0Upmiv0jQxtLl2HU2Qv9yBFQTwOWxm5hDOdZwkLWP/A6QUzAuokmlzmiaI9bwcwtHph6gweyUf7ICBFuIpSS09VDmMbY6j6TJjnjWyiP9RfQ/cEI800q9akIJO9YpKuRHGc2G X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5229.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(31686004)(83380400001)(186003)(2616005)(2906002)(26005)(6512007)(36756003)(110136005)(86362001)(508600001)(5660300002)(6486002)(7416002)(38100700002)(8936002)(31696002)(66476007)(66556008)(66946007)(54906003)(8676002)(4326008)(6506007)(53546011)(316002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZHp4TTdrK3ovVnBXTTNta1puaVNSTFZYSC9TcGVTN3lobnliNDV1Rk9QQTFt?= =?utf-8?B?UXlwY3BQcDN0eGxiK2locVZHREthbkJWVGNtZUtyaUVNOEJMMXFQQkRDbzN5?= =?utf-8?B?ZkcvYlFncUwrcElaQUd1N092OHhqV0trVko4ZVMwYjJrdEVSR0VDdlNROVJ3?= =?utf-8?B?VzRhUGduVnc1ZXpqZEY0RGhETGNYajhZTlp0SjZscUpBYnZ5U2pJUEVWRk1Y?= =?utf-8?B?ckNxdStzL2xhMjJHc0pxM0NBWG1FVDMrTG15M2dhdEI4MXFXaERXQXJrY0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dFJ6b01mb3dla0JpcHdI?= =?utf-8?B?NFRTZkNxWEtMZkVzUTRVaWNhU3NJdHJPbkt2NEk4WDl3d3RCS2VmN2hZNC9G?= =?utf-8?B?R3dWY2VXWkFCSzdoY21uUHNNZURuMnlRaWlsVFc4L3BwbUdJano2b1ZHMEhm?= =?utf-8?B?eDc1ZnVpS082ZjJRb3Z6OVZDQlZ0eGFqYjJPWk9TL1hRTytpNmFnc3NxaWFu?= =?utf-8?B?ZFNCbXJaQzFkTkhScVhCaXgrcXpmZ2IveW9xYmp0cTFkOXBaOUdCZz09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 209eb63b-5105-4eb6-c16f-08da31d5ddd7 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 16:06:24.7608 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3i4tgmUwwu9sUkaiQiQOhBi1KtQ/9cxldUq9CLOrUfnagKj4CRYhM/BPk1sEbVOZt0PmjmA4f9bKSZWQziqiAg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3475 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/6/22 00:19, Hyeonggon Yoo wrote: > __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, With SME/SEV, this will also (unintentionally) set the encryption bit, so I don't think this is correct. Thanks, Tom > .mask_clr = __pgprot(0), > .flags = 0}; >