Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3777159rwa; Tue, 23 Aug 2022 09:57:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Ao/tcIpT0ZsEIqehcWHG7WHHb98rJTM9ZDcw2lloIVL1O/rG1O+/U5wrn6uS3FPGcZxsI X-Received: by 2002:a17:906:8cb0:b0:730:d6f3:279e with SMTP id qr48-20020a1709068cb000b00730d6f3279emr351967ejc.25.1661273878553; Tue, 23 Aug 2022 09:57:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661273878; cv=pass; d=google.com; s=arc-20160816; b=eQBi+1qa7LbOk84DkhzLnVaz3DvDgIkMvNmQ4Hh688MuZv6GmwxMcHVXxrkgRdd8fb DB7NhIicLQl7SrKsIfGZimmq6KSOb3pVQlZPxmZNWmHOW2OGUgkGNmzerSa6E1xlTA0A DUVGAi28W32YpmFiNdXbtwh2wEO1pE6B70vLZongAXKiYVSPFUx4nniX48m+OnfMmiKY sywxmDbWZ3XnjJdYOeXT/+4QfwRysBRoYJsYEnCp6YqZd//04JQViQBiPm9/6xQk7pGG IgizPE3Wjaf9AXmBJHT6LgVCNWjS4LemPt79JYBXm9V1gl7GMIPgaogBv+EFec0hnZe6 pI7Q== 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=lQ2nDgObULu6ZYbY4RWyJhlTL08jmeM6UDLU4VszwAg=; b=ndllT61GXtJz+0inKlYCsl8kKfB4c0n1muiv7VPo25w5XfEdrIZ6CI9xofMXcpk813 ipllLq6ui0NGqIqfeyO5SHc0P51wUdmS0bD2uyvqKtGPn8jH1jCY/bWrYRlK0S/ZQPtd 3yNCrrI4UFMUjieevkOaEFLDNG6gjXvfcpeNHUJJalgZ2iyee0GvCvsHgQY8YggtHbrR mOZMi1QzfOlHZeMadqgW+mJVzQlsMM+3I6MCubBGx2DiENStMKQ9TEIKptz0/MfPlres PrcOsBWy4ZoMJ14ME6WWVVDwk9WOwREm5OLic4+dwitwNxTHVuoft/KJQ1FtN9xQvFHa om/g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=LyvBZB7+; 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a17090632c600b0072f231e80desi137605ejk.420.2022.08.23.09.57.31; Tue, 23 Aug 2022 09:57:58 -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=@amd.com header.s=selector1 header.b=LyvBZB7+; 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245456AbiHWQrz (ORCPT + 99 others); Tue, 23 Aug 2022 12:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343992AbiHWQqc (ORCPT ); Tue, 23 Aug 2022 12:46:32 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2089.outbound.protection.outlook.com [40.107.92.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2931A6AE5 for ; Tue, 23 Aug 2022 07:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fw7YRDCKjBiDmJOIlg4XS5nyE8lKJqlPgORjVWjwpj0ch5Hsh4xSQRf8wy5G+vYeOM7S9RndfrN4iXtXzk/tbJxQ2aDlFR5m/s2NwpjJA9PagcckZ48gWcxI5I9zvG2/UeiLYJaE+VZL7CscxU2wZ7FwLk+Ph4lcgUvYLgSmJ5D2QbwZkUlDxW34ATccGoCdJ33CD7JzvSIHOIBKioqL0GIth0rL/uWYndK4SwBRTFg7GUW1YS1zf2wLs5+0BsNOy+aJSn6QwfhT/svqBAlQ+35QxALr1MRo6YaEfgmW8BDE5bliUp2IkL3B4PLItQqIUrWe06r+VUcpypv9gL8t/w== 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=lQ2nDgObULu6ZYbY4RWyJhlTL08jmeM6UDLU4VszwAg=; b=UbocOhmdcWMynpGRJjdHoIV+jOCn3k0OO+KCNBWKZfP95rI4r6T81DS6L893xG9BbSzfKho+NIA7a2g5zPemhACDn37usQxipkfCFVMpHeHrTRjt4h1kSVqo8bt++Fua+k/8o8nkPU3aigjn+mZqMKQUT/qGaR/PBuzhk1wgzGwBh2LBey93DjpjD/laD5JTE1+j5RLJ3DRz6eEit0ippG9IHFvLcCmkCqjIncpCv+DrgEE75Wd0uYyDg39eWBpFs5rE/bEoONTsd5IUkuZqJtBJ2q8Vuk0eJJ42N3cip61lWmHJusDz93xByMnP3GRB+Eprtqo3j9AtHhsDU3a8Sg== 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=lQ2nDgObULu6ZYbY4RWyJhlTL08jmeM6UDLU4VszwAg=; b=LyvBZB7+Z9om2bKVWLx3hTnRBvX3hHuMX2mJEtQlE39q6l/L/kt+PYPLD4zKDh719i+GxP/mvgn80XCRxI3zeBjdDQgeIllNirOFf1pEHA+R92FmjBB3YiVkPCXThuSXnuXkFrudVQA9IYVyX0oHemow/4KZ1Xfbh2KVPhUiqCo= 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 LV2PR12MB5917.namprd12.prod.outlook.com (2603:10b6:408:175::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Tue, 23 Aug 2022 14:28:05 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::1dac:1301:78a3:c0d0]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::1dac:1301:78a3:c0d0%4]) with mapi id 15.20.5546.023; Tue, 23 Aug 2022 14:28:05 +0000 Message-ID: Date: Tue, 23 Aug 2022 09:28:01 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v1 2/2] x86/sev: Add SNP-specific unaccepted memory support Content-Language: en-US To: Dionna Amalie Glaze Cc: LKML , the arch/x86 maintainers , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "Kirill A. Shutemov" , "H. Peter Anvin" , Michael Roth , Joerg Roedel , Andy Lutomirski , Peter Zijlstra References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <44495aa8acb666b447a08a1c3af80987aa3cea3a.1659103274.git.thomas.lendacky@amd.com> From: Tom Lendacky In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BL1PR13CA0275.namprd13.prod.outlook.com (2603:10b6:208:2bc::10) 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: 3ce4d2fe-6b06-49dd-1ead-08da8513b144 X-MS-TrafficTypeDiagnostic: LV2PR12MB5917:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Mu2r2n9oY/e85HQz6533WHl1G+eQOpJfw+QFK1+iJFwb93FDmm5XxgtfZ8GUwgyDLSWBpe9cG4qOKTvJ+gpmLZz81qqqt2kFDdVXWnUjLwr8o0t9cE7XGex8RKB9b9YNT6tNSD9j+no/N2WtE7WE63KRry0pqGj4EtAJduJqBOlQll8wyBtOaAemqeVVP0BTw985YjIs2SihISPpysPnVg5L3PjfzP/h7ly2FZ4zb3MsfCokLIMvuOPYFCjI7T9u3D+GmslgJIkIjLmFX/rUUmzXHeWcv9IzHK09IW2x0nbeEzqzs5fqvK8T+cPYvoyBiwwZLoMMhMXS+Jhvs5nIHh0Us9mdVb92JRvyCYufZGWy8TUpoXoU4wB4Tvs0HSEmE/m6RrthaBPYb3ti8hGIOzD0N/jO9RVdOVUJ0edSLx7b9FPu7MexGJj3jtYTS2n62iT1bGunTCnfAIdvSwblJ+n/Mc+/rTEOk2NfT1KgoE5IhsXEE1a8PHfMx1zw5sDioOkK/ftHNwc2xbnc2qy/AqKLazG751yJr08FROvsNcvIQKJ1KOYJx1omg94eA7akEMIcQ+P4voVfWXLUsN9ArH6dqddct0A2eq4okcv30CnuvQY8hVFE5dip56nuJTcplKYnG3Im6Obmiz8LyopBtp41GfoNKhN6/izi6UxpeX2bcFBLQ32AkobvGEzdTWjB6s2PzpyzKhXPKXYaP9vv/jVcz5RkoM+vyNYuX47THzmevyPMSI83vvJBvgV3oRKpDZ8sdTBKQpOSkqjtD70clhyFEbDh8Bmf4zae/CziGYU= 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:(13230016)(4636009)(346002)(396003)(136003)(39860400002)(376002)(366004)(26005)(53546011)(6512007)(6506007)(6666004)(38100700002)(41300700001)(86362001)(66556008)(66476007)(8676002)(8936002)(7416002)(5660300002)(31686004)(66946007)(4326008)(31696002)(36756003)(2906002)(6916009)(54906003)(478600001)(6486002)(186003)(83380400001)(316002)(2616005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bVpjR3NldGRqR0p6dVJwZk04R0dHRSt0aXhFNkFpQUo3WGxtclA4LzEzajRo?= =?utf-8?B?Yy9DM2lhWUpRd0lKNjFKMFFtcmVwWDFRNEd5WVUxOW4xM24yeDVBWGhzOTRV?= =?utf-8?B?bnZjMCs2UmNXUm9qOWdETVNlYnh6VEIyS09FMnZ0WHhMYkloVGVwTG5WZXJS?= =?utf-8?B?bkl0WGRMWW1GeFgvbzNIb2I5QXF6N0FFVERSRGVEanpmQzMrbThRY0xXcklJ?= =?utf-8?B?SytVVmxmYm9YTVFzUXhoRFM2SnYxR0EvNnI2TFV2TFpEZHdoQnlFeENPOUNO?= =?utf-8?B?YUpZWU9kWTA0RmZnM2VobnlES3gwaE0yYW1ITHo5cVdiMGpaZk1lRXlqS255?= =?utf-8?B?SGM1cXVQZjFMMWVwVEtTYk54R1VROUhPaE9qMTlKRU5NbCt5YnFNdTRtVm9D?= =?utf-8?B?Zl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exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2022 14:28:05.7043 (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: +DBEAV7nR6VcXh5Dx6yST9rczBuilH5saEMzo03J8vxLSQE1nRs76nzLKFhflnPcxlj+mOESWvTKcVCY3wtonQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5917 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_FILL_THIS_FORM_SHORT, T_SCC_BODY_TEXT_LINE 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 8/22/22 19:24, Dionna Amalie Glaze wrote: >> >> +void snp_accept_memory(phys_addr_t start, phys_addr_t end) >> +{ >> + unsigned long vaddr; >> + unsigned int npages; >> + >> + if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) >> + return; >> + >> + vaddr = (unsigned long)__va(start); >> + npages = (end - start) >> PAGE_SHIFT; >> + >> + set_pages_state(vaddr, npages, SNP_PAGE_STATE_PRIVATE); >> + >> + pvalidate_pages(vaddr, npages, true); >> +} > > My testing of this patch shows that a significant amount of time is > spent using the MSR protocol to change page state, in such a > significant fashion that it's slower than eagerly accepting all > memory. The difference gets worse as the RAM size goes up, so I think > there's some phase problem with the GHCB protocol not getting used > early enough? Thank you for testing. Let me see what I can find. I might have to rework Brijesh's original patches more to make use of the early boot GHCB in order to cut down on the number of MSR protocol requests. Thanks, Tom >