Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2081886pxb; Mon, 23 Aug 2021 11:37:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxE5U9SpxmdsqQupRmHwpiQ5DhlW1gVmuYiYKbyd9x8PEJVMv9Gia9LAHXTUjv13ZuxB+C X-Received: by 2002:a5e:dd42:: with SMTP id u2mr16466558iop.157.1629743869134; Mon, 23 Aug 2021 11:37:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1629743869; cv=pass; d=google.com; s=arc-20160816; b=i7pDM1tNxDVx6E0uOqHCi0emkNRnVKnPpXSXm848RYgs4rkNQrJSVAkJ1b2633Adi6 lugEMy/KT2XpuKZAmOQYlz9FYGhZ/eJbbuVIWBQlZ4AtyVIm2y29I2WRczEs3Sea6itV RFFgsA+lWDdZnVWKfiz6M7I2q/juRQ/rmbNkEVK4k3VA0VvtxiS7P9Xi0mhVBWEydA7P aPFoeeqMu6hYwGbvZIfi7ZR0GD1n+UTe0C5/QOpVAYJJFxfQ55vid9Yp5ZDADLV7UkF1 OsOOr2lvpg0kEkJRI80IJGS/8F8YywYvM7jfgKKLAcJSzjmVmqCMt/67b2sSZ8Lvp1xU Tg4A== 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 :content-language:in-reply-to:user-agent:date:message-id:from :references:to:subject:cc:dkim-signature; bh=sRiV8vEkSGXwRbuEj+SNMRB1u2uguCBnuAL0Vs33Clc=; b=vbAMBLF6tfKs2z9BG3auXDCpnCyMtgc3hfVVF+jh6wPNjawXBOb+B/1/T40hW8Yf0Y df9uoInGzdjmhGJS6EF5ZvEXtOuc0BY2RK/WVm1egUM4Ilp/7kz7Mh2qR/EPyKdItf9i jhKctpldsu+AT4cuXa75LxHN4cfgTD98ULnd7yMFOvpfHuUfdN9Ty/JLH/QdEVfuU4O2 a5XQ+0wUsZ+oOdjjspJwGiUvvMXeo5kzsomAcGpUQux4j5W3l6iM1REib2FbgA55vcdk +GCrOxqrOjbKjnX4+OjRWsckk/+2uDxx5VMFAbkOgrZt/RBkXNOOcHtC5rCjxjWBVabz GvHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=D1sGChAY; 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 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si14150789iok.10.2021.08.23.11.37.37; Mon, 23 Aug 2021 11:37:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=D1sGChAY; 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 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231217AbhHWSfh (ORCPT + 99 others); Mon, 23 Aug 2021 14:35:37 -0400 Received: from mail-bn8nam12on2053.outbound.protection.outlook.com ([40.107.237.53]:65376 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229883AbhHWSfh (ORCPT ); Mon, 23 Aug 2021 14:35:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PTYg4jXHRKkuzWFFzE/GnCXhYqHDdN8ORZhMTp2ZJ0bWUdTUVNkX+szsUgtj7nPlTqw4C5FNvkm5FyTrxWniFKoweJUqaqAo2yl7wha0RoJ7leiLSRtDSJRsmDPAdvaJCcK8itDjPBPZdvGwzsB8OFGiduKbAe7VBMDa2Dp+ye8t+wCedF3J4etdIBHnAlfMMfBIpvT4u/mDtgw9E38L4Eo16UYP9C96VyQguTex0JoSU+o9CAGq01V3L8FrYuSa2Q+wsU42WRwZLY1leR6bNmeNd+zonhQiJofDdXIA41cKZrQCS3nlIZmOisexTmXjKv0OQ4O7Nm7l8VL60qOv7A== 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-SenderADCheck; bh=sRiV8vEkSGXwRbuEj+SNMRB1u2uguCBnuAL0Vs33Clc=; b=d2Y0aTdRueGwa2DPRthwXDB8L7mRWAaCnblmz/7jEMHwDhvgXb6LaxM7rVsQixsXCCMEtRKHBT12P0CRr0gsL3BrMdVvIxJa7sT6zx/zKxMoDFe3J2gNyM68RhqWfYTyOMe+uP8D9d34q6ltEzYlsRDwh/0JM0wVP+KPlkSk1CbUETgc/GwBr+4YQv39o2VtWjtrcGrkyJ79tZNd5cIHYARwHBymlc6O5qRBqe0oV6ZmegX16gScrod/bWFWllAqHhs92EpWaf6oS5aVfyZVkQyisraNpA9/dIcQsrhjmYw6LW8AtPhzvlNH443C9313/oiZuc0ozV9PI/lNWIkxJA== 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=sRiV8vEkSGXwRbuEj+SNMRB1u2uguCBnuAL0Vs33Clc=; b=D1sGChAY7sH/RgKQLZzpftlE2QeIzXzjKTe8Sfnie7ns3H80J5JIihrOXUzHentahiz8kkdFvESi+3QgsBv9EHc2v+QtH++/dJprzkUVhSDysBchkRWUH+M7xOXX+n91LLkMUmb6/WS3Zo8Ud15P3alaEBEn0eEweoCzrN3/8iM= Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none;linux.intel.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SA0PR12MB4431.namprd12.prod.outlook.com (2603:10b6:806:95::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19; Mon, 23 Aug 2021 18:34:52 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3%6]) with mapi id 15.20.4436.024; Mon, 23 Aug 2021 18:34:52 +0000 Cc: brijesh.singh@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH Part1 v5 07/38] x86/sev: Add support for hypervisor feature VMGEXIT To: Borislav Petkov References: <20210820151933.22401-1-brijesh.singh@amd.com> <20210820151933.22401-8-brijesh.singh@amd.com> <844774cc-4a6f-daa3-89cc-4d2dc6ca22a5@amd.com> From: Brijesh Singh Message-ID: <634e4d5f-1b44-e715-0232-351d0ab57405@amd.com> Date: Mon, 23 Aug 2021 13:34:49 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <844774cc-4a6f-daa3-89cc-4d2dc6ca22a5@amd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SN6PR16CA0043.namprd16.prod.outlook.com (2603:10b6:805:ca::20) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [10.236.31.95] (165.204.77.1) by SN6PR16CA0043.namprd16.prod.outlook.com (2603:10b6:805:ca::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.19 via Frontend Transport; Mon, 23 Aug 2021 18:34:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e8a1f72d-d3ba-4e76-a352-08d96664b1e3 X-MS-TrafficTypeDiagnostic: SA0PR12MB4431: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uIBQLhjFh/H/8ZbWkcDOaf2a4CcKlPAMT2uHjRv1AVoNC+MHERJOBTwUm2zPhmeggIeiCQrx/q0Cc3/ompU+W8cswZV/fXlSkJ2iZIddZn7twlrLPotsxzgdZCiY1H7yc9i3ce/Fupy5QQSpr3w4GSa6W1SFrkg/mQ7aZj+s48D1G1Z3jDLLfC1b5QYPbUgbe7XU+RcQze3DErbvu0ieAWbRjJwZM24wo3dCtWXELjKyyCgsbzlvxQ9TJyY+yiNHyKdrCF5OFEEWJiFXpo+Fs1zdXaVO1J313853+2PDbpZsnK5XjTFsoQzdKCTtR8hrDyccwEl02co4R9XU8oMZsjYm1vOU1xAis1B/e4fvQrXiHS/VUH3oJKUAOwyJO9rT/n5vCmqKtp0HYjkYJ7GpErkqBiZKx4sjDWuslL5EEr5ghgsL8Dy+pBegNuw0tiGkOP2jU0OM7x6DYn5ILGDSIQ0kSt8YxXEpUD0uQcUt30zyIqInVUFzT8z58psa3HgIEwfC4yRPrceh9lHDjUUn8Ed7N2+McXiQUF/a/USUWSEJK+nXaNXG4bbPf4ExLZOl4n3g2FrEWnHolwWbahVd9pzX+R066nFOBSTsR/omnj6Vo68ybDcI9CUop4z7rj9BAP11UMIU1de4USzVOJUBJRXM9bB1HldJIYx/xiWI1+nydg09b3j3+LnkVbHbYtjqlyiGPo6DFWHTW08zYv//aOPC2OW8TqjN1YXQhbmJiFFNqpqhMkp955uelxiOMk6fcgX5phCcPPo+YrNyG9Idlw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(376002)(136003)(396003)(346002)(366004)(7416002)(7406005)(6916009)(26005)(31696002)(478600001)(52116002)(4326008)(86362001)(5660300002)(31686004)(54906003)(38100700002)(36756003)(8676002)(6486002)(956004)(2616005)(44832011)(8936002)(53546011)(16576012)(316002)(186003)(38350700002)(66946007)(66556008)(66476007)(2906002)(83380400001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?V1BlYnJxWjZQbCtEMURTNTRBQngzVEhLYWxIQzBTamRnWFJQSnFPeDIwNDVV?= =?utf-8?B?Vy8vVkdLY0VlR09BV2VIdVlPZzlkT2t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ource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2021 18:34:51.9093 (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: pHD0+oQbPg7qJEgvus2Ts7hhrAd45Ez4Q3IoD4RzldFDw7ODtypQkX7wVu8nNcMpJmyf4PIt8OpPNzqbq+IPMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4431 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/23/21 1:25 PM, Brijesh Singh wrote: > > > On 8/23/21 4:47 AM, Borislav Petkov wrote: >> On Fri, Aug 20, 2021 at 10:19:02AM -0500, Brijesh Singh wrote: >>> Version 2 of GHCB specification introduced advertisement of a features >>> that are supported by the hypervisor. Add support to query the HV >>> features on boot. >>> >>> Version 2 of GHCB specification adds several new NAEs, most of them are >>> optional except the hypervisor feature. Now that hypervisor feature NAE >>> is implemented, so bump the GHCB maximum support protocol version. >>> >>> Signed-off-by: Brijesh Singh >>> --- >>>   arch/x86/include/asm/mem_encrypt.h |  2 ++ >>>   arch/x86/include/asm/sev-common.h  |  3 +++ >>>   arch/x86/include/asm/sev.h         |  2 +- >>>   arch/x86/include/uapi/asm/svm.h    |  2 ++ >>>   arch/x86/kernel/sev-shared.c       | 23 +++++++++++++++++++++++ >>>   5 files changed, 31 insertions(+), 1 deletion(-) >> >> I think you can simplify more. >> >> The HV features are read twice - once in the decompressor stub and again >> in kernel proper - but I guess that's not such a big deal. >> >> Also, sev_hv_features can be static. >> >> Diff ontop: >> > > The sev_hv_features is also referred during the AP creation. By caching > the value in sev-shared.c and exporting it to others, we wanted to > minimize VMGEXITs during the AP creation. > > If we go with your patch below, then we will need to cache the > sev_hv_features in sev.c, so that it can be later used by the AP > creation code (see patch#22). > Let me take it back, I didn't realize that sev.c includes the sev-shared.c. So your patch will work fine. sorry about the noise.