Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp928118pxb; Thu, 23 Sep 2021 13:44:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzapheXURg3AVmsq91PcG0/PJX5qrM5XoHyM/2tsJe4DDZHb7zhoto9/u6/SU2qNfs9G0+3 X-Received: by 2002:a05:6e02:20cb:: with SMTP id 11mr5197447ilq.237.1632429897392; Thu, 23 Sep 2021 13:44:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632429897; cv=pass; d=google.com; s=arc-20160816; b=SFg+Je0Tc+eolP4N912itTn3DNHLDppLg37fitLltnU1WdEjrg8X+RDcvFJHZw7kUH uQbZxAB/zcJ/IYaOcDgP1Q5iqBaCVXYEmk7K+CXhyRgIsT/144oqZhmQci88X8fXKNbQ ypndPE8lvBqbCLbEBrB3x+EaSGEfeBru2ri5HOrG7iWRWe1BTL9T4qOGThmyfrqx7JiN yrvjJaVflwUXhdSqVf9ahMdk/gEHNRqNxtKMPmg9f3jq0KOGNrkUjDEFa6P1Vv3zDIi+ iw/+aM5uyPTLa4KZwDUfzCsa9sDp9krb6KlxU1oAaU823SU1r4OuE7TiPRNhx6FoXpzI cStw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-language :content-transfer-encoding:in-reply-to:user-agent:date:message-id :from:references:cc:to:subject:dkim-signature; bh=xqgKJ2XSJxqhMiPcgCpS7n/zTcUc3NJvDQCQTNuoKG0=; b=O6rcK/hk4JUb0PNK4zW+H2rtqmzrepOvE6yRnu4wkIoVOzlJjMXWPqFVV8K8lWaDh5 QnIGpMVB3GA4+ophS8hu2lq4u25ICDBfYiVNrGAwVCbfLnP8aAF3zQnCUHWid0x59/4M x6a7TVcntqVDGW7nS/R9Sblal6UZkMOen3vGMYbBMwIAWsZvpptNbY4qoxTRTzDpBYC1 +WHuPsD4f0Lc0TyEMyDtNDiseKzpQ2nEjChDzVT0TVaxt9rJBB072W3sn5MSj6GI2EnO mNaWTyF+MY3MOlAkMg5wja2du7FoO7nYGs0puI+tt2WvHbj9XHitymYvBBj640JKEU+p +S2Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=JHyWk9p8; 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 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x1si7045405ilm.82.2021.09.23.13.44.35; Thu, 23 Sep 2021 13:44:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=JHyWk9p8; 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 23.128.96.18 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 S229609AbhIWUqG (ORCPT + 99 others); Thu, 23 Sep 2021 16:46:06 -0400 Received: from mail-mw2nam10on2083.outbound.protection.outlook.com ([40.107.94.83]:2816 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229753AbhIWUqF (ORCPT ); Thu, 23 Sep 2021 16:46:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CEm9D7tDcB5GUgYJd1fYjJwg7FtDE9GMlewMASv/BnaN83jCzTsRnFPMOT/JovPgXAMv0dED5XsqON55OljAgj1jIB3DYCR1pSNBEy4nuPvU1mli/n+iQu3w1tnPl5/5CmoEeypIPl2XowH3qrrMomFTUEFC4IrLGDnoeGfMLOMBD33/LV9/swxrNqvq3kgGhvL0Q54eWOorQU2cf9LhNYgjvo3b3QlWj1fp3KWl+dcLAh6lelXsgt73nyOYmAUifeiivY+y9glLAuWp5tWYxYiWaPeaZCMcNNvEOXFzFaw4MyL7ml3AzDmvxKwEfjSU4vGFUe7wmcP57j+1tYZd4w== 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; bh=xqgKJ2XSJxqhMiPcgCpS7n/zTcUc3NJvDQCQTNuoKG0=; b=Jcp383MKi6eSO96M9AMsLt7onl+jnPhrrhOjzmUZgX4GgVh0LWtmw5FJjP3yv3cQGRFNRUq2ud0Z9ppCNfLqVNqL/Zi4tQfoZWGr1b2AqYrORthzkil2/LUtpg3jPTQdfMZKyNgJRLXuadtSlCtuVxFh3HmCYc9RARAMe4XlIqKbFm185jMg7y4XEvE4EWlk5E+yCr+aFK7OrNbXMLNbC4rKceWJVXnjWJ2XAdRI+uiI1u+6GUMD+ruse3LeMdfNPZmX5QbX61T3XdjzARm4o8BRi/7ikF/itX3J5lYLOsYsc4fGGslk+m6DphOYRCQdWFdpU2mLJn/vg+NwX44k+g== 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=xqgKJ2XSJxqhMiPcgCpS7n/zTcUc3NJvDQCQTNuoKG0=; b=JHyWk9p8Lr+9Xbk7XSYDUXmuMtMF4hR1gASLlNs/hD/Lto2/b8QJPLSslcwse4bLmzDcpgYiht7dujmZ6vOAYWK7EPRFNeMUuWs6aux5jkYS3LxpJWR4Cr7dmTEZKiQ40VXnpFngiR34rQ6PwKTdr7evfitDXKfd035DIxIINZE= 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 SA0PR12MB4509.namprd12.prod.outlook.com (2603:10b6:806:9e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 20:44:31 +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.4523.022; Thu, 23 Sep 2021 20:44:31 +0000 Subject: Re: [PATCH Part2 v5 21/45] KVM: SVM: Make AVIC backing, VMSA and VMCB memory allocation SNP safe To: Marc Orr Cc: "Dr. David Alan Gilbert" , x86 , LKML , kvm list , linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.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 , Borislav Petkov , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com References: <20210820155918.7518-1-brijesh.singh@amd.com> <20210820155918.7518-22-brijesh.singh@amd.com> From: Brijesh Singh Message-ID: <9f89fce8-421a-2219-91d0-73147aca4689@amd.com> Date: Thu, 23 Sep 2021 15:44:28 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-ClientProxiedBy: SN4PR0501CA0001.namprd05.prod.outlook.com (2603:10b6:803:40::14) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) MIME-Version: 1.0 Received: from Brijeshs-MacBook-Pro.local (70.112.153.56) by SN4PR0501CA0001.namprd05.prod.outlook.com (2603:10b6:803:40::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.7 via Frontend Transport; Thu, 23 Sep 2021 20:44:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b88850f9-9331-43ce-3789-08d97ed2f170 X-MS-TrafficTypeDiagnostic: SA0PR12MB4509: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tO9ldR/w3q8X8N2TC7AfldD35c8W4RsySyqg6kJ/OE4N1EIr53+tdQICTwMgTaSBkcczpLD8vHk8A5bEaWFHSU5eN7AZ0lDqKIooX2tJF75FIdxADdf9199kXVo8Luq33zo0L6Hu3zGurRTMLLv/w/te7aNn7u/xtnX2xq8hG27Q3j61PGeJ1NH55Axwfe6JxiLrcJ6ePL1Fhz8gHnnpnfU6viLLOjJ4AezrY8NCBev2RZcwCCTJJZpVzF/pnIaN6/Wwsva4peaRwHpiWipUXao5JnY1nM6k6jDFs73eTK/zrsI2QM4YznhZy/YVT8M0qYAhdtNuPA8DZdd6IT7U9jBzw+IkKraD7whnSSu/+20ADqjkHNWBm1usohzNXGGNSVtfjBfeV+M6c/36eRHTgvnfsOej2rdpm8CL6PdH+LGwYUlSQxojXgQXKh+DtHceJH9dsdHnerFlFUzw62945uCmpuZRmVyvCQPuYpMtpk+9sJ1HMTCIDyAVP1Ne6ormZGSixOReFQiKbmCeaBnRMfLXrp6jLiiJwQ4MjFh4P/zh4blgO4Piy9pIrtMebEN7DgBbTf2cA1QOM8xlz0oRwwOiF8phKu1GLOqM6pJks7XQPrVLM8tBRLNMO6/jV6dfxKNw5qfllUauxqu4WnVUq5/KTLN6zEH5cTK7gYCiy7Tw1eFPTL9KTVnYl/GfPchL6AjrxCs5HIAb70GcyodFDislPC7KBNBGKlgOB+ugTB9vDwFTC3UKrvQNgzIv8kzBZbcFv95DO+wRSRFN8D2ryZbnM7fxp89akMy4VcRgVMOPoQogGSi2djHA1dtY2A3gMibjDmxBSd1BYBL5NnsHlYR+khVx9Sf/mnTQpDj5AR0= 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)(366004)(2906002)(966005)(5660300002)(66556008)(6916009)(6512007)(508600001)(66476007)(7406005)(66946007)(38350700002)(38100700002)(83380400001)(316002)(7416002)(54906003)(8676002)(26005)(44832011)(52116002)(31686004)(36756003)(31696002)(4744005)(4326008)(8936002)(86362001)(956004)(53546011)(6486002)(6506007)(186003)(2616005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bkZjb0VHUis1NUhzM3B6Ri9DcmYrV2J5QzRXOVkzdk1IWm4veXg4UWVMeHB5?= =?utf-8?B?Wi9zSGllbGExY05DT3lBWjNDSGpjMWNrOEFHWXd5S2xjQmM3dXYyYUlvNXpK?= =?utf-8?B?L2pqbXFUdkhmV3JTc25DUnFvNFRVME0yc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0NBK1BZNVU3M0d3QzB0eWNtQWZza3pIeWVE?= =?utf-8?B?WUFYajZCZThFbkxaeU1uTjhXMmVkL2NYa2Y4M3RGdFdYOWhEZE93VCszMVd2?= =?utf-8?B?V2VvKzZ3WUorM053UlluaDdKMGl2UklIU29IWTFvNUhvRXRHb3RxOGhtSUN4?= =?utf-8?B?dEVIT0JvSkpUTlhwY2RVdDRYODhEalp3ZWJkaEpDZW5TdjFoOEw1WkI3bGlX?= =?utf-8?B?WGdYVTZ5ZVhpYUlHcDVRc2ZaanEwTUNpVnBzdmhrYzNPOHZjSkcrcWhGeDJV?= =?utf-8?B?M2I3czNremh6cTIzaVJWd1ZHQzM2WGRsNmhBd3dBdW9CazR3S243dVpXbFEw?= =?utf-8?B?N3JGdXF1dVRPZFlZc1JJSStteTNNZ3huWlhYWXRwb2M4YnE3NVJqOTIwNDRY?= =?utf-8?B?SUZhaDFiSWFsbWhyeGw4MXdtUjE1V2xDSjlPM0VJME95NTFRdDJjMzVGRjJK?= =?utf-8?B?RUpOQjhtQ05wNjRWVmdxZCt0VEpPMTJZYzduV1VvdUFQZUZyT2RWSkRocGFN?= =?utf-8?B?eUVGdXhzRHJPWDlYVWdLZlFjY29ZcnJRN2dEeWFYRUJWWjVaZldMMXkvenVQ?= =?utf-8?B?aXB5Z2M3b2I5ZGYzSExSMWZFNDFmMFEyN2I0bDRFRUx5bmE2ZzlFNTh6czc3?= =?utf-8?B?ZWpNanlVajVDNTlsUGxVQXh6V2tpZm9ZekNYU0ZEY3A0a0hFRWx4VHZiVGVP?= =?utf-8?Q?I+YmHeZw8FQ97sdg9EbNSw2FT9Vs68Zx0EyCj6+?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b88850f9-9331-43ce-3789-08d97ed2f170 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 20:44:31.2218 (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: fi+D/f7ObtP0zzzefi/6/+fmqp/wVNN18a1FHT/+l3qtDYztwET+5SG4VQqcC/jkmw7n1U3QUMlaxQEJbNXMGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4509 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 9/23/21 2:17 PM, Marc Orr wrote: >>>> + >>>> +struct page *snp_safe_alloc_page(struct kvm_vcpu *vcpu) >>>> +{ >>>> + unsigned long pfn; >>>> + struct page *p; >>>> + >>>> + if (!cpu_feature_enabled(X86_FEATURE_SEV_SNP)) >>>> + return alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO); > Continuing my other comment, above: if we introduce a > `snp_globally_enabled` var, we could use that here, rather than > `cpu_feature_enabled(X86_FEATURE_SEV_SNP)`. Maybe I am missing something, what is wrong with cpu_feature_enabled(...) check ? It's same as creating a global variable. The feature enabled bit is not set if the said is not enabled.  See the patch #3 [1] in this series. [1] https://lore.kernel.org/linux-mm/YUN+L0dlFMbC3bd4@zn.tnic/T/#m2ac1242b33abfcd0d9fb22a89f4c103eacf67ea7 thanks