Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3714861rwl; Tue, 27 Dec 2022 13:56:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXsw7FoTQqTsI7Z60bxwetCy/lLocSCAMbw/VTCN1AaawC9k3sYRypCVDHQPXcg1okgmrkng X-Received: by 2002:a17:907:6e16:b0:7e0:eed0:8beb with SMTP id sd22-20020a1709076e1600b007e0eed08bebmr26138793ejc.41.1672178168485; Tue, 27 Dec 2022 13:56:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672178168; cv=pass; d=google.com; s=arc-20160816; b=HbzKpPxFXj570ga88DGEdgvxPUIPr75oF65sI1tQBqlMRO4XZhyPxWQhcR9PPpURyF SEH3GsQ7MzeezSIM8ocFMozk3gaz+TdDwiM33Uti0M4Z8sN1A+8BuXtUA6vZaNVO3BCJ 0lIjLfJLPy6dtADbodHHQ/FFCD0cBVnxefSTAwroyjdOa8+B9ZBbaKbGHFEAtWTYXuNs IfAxSVL4jSVZOa+MoycJ8ZvEFLh5g2Jsn3JhNr9RTxmjVJ/0OMtet6kgdGPrFet2ll1C Su/8lNb8c5P1yr90USvAiWsH9ZACtMAbYFkcZ/4RbrpYCX8IS0u1rKlqZXQfHcRYSMTa XxWg== 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=WkemZj2jZDdu8KAJ1zNdQlK4krUuT7b5oSMTAoqs+CU=; b=eKkmDMtUM3bUOSIxRdR3wIms37Oe+G6WzSp4LuxTAAvAs3CR6hFa+P9p3eFPTYcsAu SiwfYxoE4cy7jvo0xjz9Zymm8CEppZNJUwAlxkBfFywLgjJZNT152zUctIga3x2VxZcz 5n/vt78u7e7MpH5g+CQA1QLTR5CjIQzUZsEXtiVvlN3sDI5VE6+J2PNZ8B03zIeOQeDw Leg8Rh7gWZaHQ7XLB2JpZ+S76T74xAE94+R9iZmKBylbBu5vT8ADBd13bclEKnkKaqfj cKAcFkMQ2EoXfNfosUKaWSI4mtsayds/3CWKWXxAHJw16DFtivVKoveO64i1UXdx7LcE 8jvQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=pwfYqiVF; 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-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 xh5-20020a170906da8500b007707c67f523si10737122ejb.335.2022.12.27.13.55.37; Tue, 27 Dec 2022 13:56:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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=pwfYqiVF; 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-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 S229863AbiL0Vtx (ORCPT + 99 others); Tue, 27 Dec 2022 16:49:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbiL0Vtw (ORCPT ); Tue, 27 Dec 2022 16:49:52 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2063.outbound.protection.outlook.com [40.107.94.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D12A4B23; Tue, 27 Dec 2022 13:49:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e8n9oYf6WwJdTuF/kxscRi1brvlgjzQgRK1gV0+osbsDPPPcUZXoQyXtRhaY84rqhYIZjVk2LeTZMbkG0w30n080xTtOZD0w5OWslN1NMY+SOHd5BViGAtZkmpvce0UNVg5W5zapz610Sjd/uh63IiAzx2fn2ptsvdFJiF1rD9djcufIEgA3cBwHx3jm3qC3KqTuOjnSjxmP7zUeqWVkrJZ9z2ARLEF/B2f1XvfMFXqwstBwk+qrwYdN1n8O6L8M9eCT851yUZW9rVBaYnu7fq7YrZ2dmeCVSBt59ZQgG0ifu6LkJupgD9Y7fgQMONcEU67GeJ8aEHxyTnHhWhdEHA== 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=WkemZj2jZDdu8KAJ1zNdQlK4krUuT7b5oSMTAoqs+CU=; b=CNIrLMZqGURSHLkN50TRAJqONBopOkL33USKcUyyJea8KGpQgRffOpmaXe7+WGqq3TCUPxXUvkqgRyVlbUQ4J5VF8x24Y5qcLodqsiiZwDQUhgKfxyD9CvSKhIhpISG+Dn7/ZUZJ3qHFlDLmtuErB1BxKUbJL9vqyU3OrjA4kSVq9VXMaxk4KLvnBQNl6FoIKnsy634VR7LbMKo2MLlg9RTxGVCmGlyqTow1M9VeBWfpdezKLFbejr8kciGTBboe6d0uR+3fz3SGjESc2lkiY68rFxLhZZ2dbIMH2y0GRM5qu4eAL4E6ekYQOwLM2ZHvfVs8pu2jHlRqjt9Ku1Q7Ww== 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=WkemZj2jZDdu8KAJ1zNdQlK4krUuT7b5oSMTAoqs+CU=; b=pwfYqiVF/jcMOlMo4qQcA8D/I9yNQvmVwfz/aceerf+KcWl0moclcBdeofQ7DT0piXwSM/TX3f/9lpuGjTbR0fwCp+4zcaxkr/ualEG/vOGZdCGbf70uNQQRXxtev7c1lPQSwx5YgF/R3cLFRzuWNXt45sQI9TcIHutZt3xj0z0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) by PH7PR12MB5878.namprd12.prod.outlook.com (2603:10b6:510:1d6::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.15; Tue, 27 Dec 2022 21:49:47 +0000 Received: from SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::5317:fa3f:5cbe:45e9]) by SN6PR12MB2767.namprd12.prod.outlook.com ([fe80::5317:fa3f:5cbe:45e9%3]) with mapi id 15.20.5944.016; Tue, 27 Dec 2022 21:49:45 +0000 Message-ID: Date: Tue, 27 Dec 2022 15:49:39 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH Part2 v6 07/49] x86/sev: Invalid pages from direct map when adding it to RMP table Content-Language: en-US To: Borislav Petkov , Michael Roth Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, jroedel@suse.de, thomas.lendacky@amd.com, hpa@zytor.com, ardb@kernel.org, pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, jmattson@google.com, luto@kernel.org, dave.hansen@linux.intel.com, slp@redhat.com, pgonda@google.com, peterz@infradead.org, srinivas.pandruvada@linux.intel.com, rientjes@google.com, dovmurik@linux.ibm.com, tobin@ibm.com, vbabka@suse.cz, kirill@shutemov.name, ak@linux.intel.com, tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com, alpergun@google.com, dgilbert@redhat.com, jarkko@kernel.org References: <243778c282cd55a554af9c11d2ecd3ff9ea6820f.1655761627.git.ashish.kalra@amd.com> <20221219150026.bltiyk72pmdc2ic3@amd.com> From: "Kalra, Ashish" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: CH2PR02CA0008.namprd02.prod.outlook.com (2603:10b6:610:4e::18) To SN6PR12MB2767.namprd12.prod.outlook.com (2603:10b6:805:75::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR12MB2767:EE_|PH7PR12MB5878:EE_ X-MS-Office365-Filtering-Correlation-Id: aaa87af2-6b8d-4f55-4515-08dae854446d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q4s/yevOIvgkSfN/bq7VUtm1+xdq7KiTUB18668PYlAb8JcxMyEUXJe5z1Ba/THyh3+eu0MdLq9nwZXkQfToaYhyfmAWY60Mu+UR6rjOs6Sy8t2wraIfp+BSXchecxlGY0oyaNpXxtMTCHSrOMhTwFMNyujDzGXz81qI7tYNxHkNN7QYztHmQ7RcoqGe0KS4dHFFbmJDg2Ye3ZM37EI8rnpYnQrHL6dKpG2XEyDEJV7o0f5pIdJ/waDnTCRDjT6b8d93bChdWDFYFcQ+Y94zTZK5z4RKi3yqGDJSopVm9wy8L/1fnBHjuFEun46PWs6B3ytXwjUII3X5I+f//vxu53PRcKKusAoW4zi2OH9yZiH0L6dfYZwDkeNgtzMxncq9FdS6XPrCJfbIfeTv70E12Iue5TJGIdD2HTHqM3lxUS5FY+dNg4nRY5MS89vNZhgrO/X8ZhZReGd4wf1rrp3Cf7Jd0CmfzsdvD3Kl4jEPtTO348F7aq9b4XTT9pmPWJYHKY8Jy8G4GEe4pXRNeYMYjGdNuMkmqTh4pZgkIVyS/bqlLrkcoHFXLLjJjUjhDLsYBrBiIARHWSADYcFMalAzYu1EHVXgG9OJj3aA9nN3Sxyowz8nEpWKnUvDXO+FB2keQ5o0WiCIdwWnqd+wDKom3rZUGSWdQ/DMKDFp8qAtfoF/gO29HFNrdE8/vTrcX8fJtBPw0Twg+IuD/NpGz6kiM31s6YU4vmxYVO4KOiY4wk8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2767.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(136003)(366004)(376002)(346002)(396003)(451199015)(4326008)(8676002)(66556008)(66476007)(66946007)(478600001)(6636002)(6506007)(53546011)(36756003)(2616005)(316002)(6486002)(38100700002)(110136005)(7416002)(7406005)(26005)(6512007)(186003)(5660300002)(4744005)(31686004)(31696002)(86362001)(8936002)(6666004)(2906002)(41300700001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eDR5dTF1alBmRGVqK28zTnZjVWtUWmdoMGJucEFOUWQ2aWYya0t1MHAzTVJn?= =?utf-8?B?Nlg3VlB5ZTVkdzdJWUQzMjcxcUZKSnJLSkpzc3RVS3RQVEFCUURKRGMycmFt?= =?utf-8?B?M1FmQm1zWGdxSENxa09hNjdTR1RTdkplaGY5dmhvbVpDMlI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2YU1VTVM5R0tPelBaRVNwSzhHZGtiU1V4NEZ0Y3QzT0pZckZC?= =?utf-8?B?UHhtVUVBMlFPVDZmem5hR0p3M0R4MzQ4dTVWODEra1V2ZVUwakVyL3pRV1lC?= =?utf-8?B?REtWS1cydXk5Si9YTkN2V0N1RUtpcVpyZXNGaHZ4Z0xpRVAvV3pqOGFVTHRO?= =?utf-8?Q?9oTE3SMbuasgJqRAb1GXwtbUX?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: aaa87af2-6b8d-4f55-4515-08dae854446d X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2767.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2022 21:49:45.1755 (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: gGdiphVww4IuC7yXm4+Pdk1p7JdNoYlXXfUvLNMtgafGe22PI2F0ihDN1Z3dF7NI0pimDF9+ZA5ws5UP/qxWBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5878 X-Spam-Status: No, score=-3.2 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 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-crypto@vger.kernel.org Hello Boris, On 12/19/2022 2:08 PM, Borislav Petkov wrote: > On Mon, Dec 19, 2022 at 09:00:26AM -0600, Michael Roth wrote: >> We implemented this approach for v7, but it causes a fairly significant >> performance regression, particularly for the case for npages > 1 which >> this change was meant to optimize. >> >> I still need to dig in a big but I'm guessing it's related to flushing >> behavior. > > Well, AFAICT, change_page_attr_set_clr() flushes once at the end. > > Don't you need to flush when you modify the direct map? > Milan onward, there is H/W support for coherency between mappings of the same physical page with different encryption keys, so AFAIK, there should be no need to flush during page state transitions, where we invoke these direct map interface functions for re-mapping/invalidating pages. I don't know if there is any other reason to flush after modifying the direct map ? Thanks, Ashish