Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp935410pxb; Thu, 23 Sep 2021 13:55:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy34p0bbIdPLCe3+W20JyaBWOeVA+DrB/cQJlEePHHhuC4NVnv8yqa3a0eIAy5dM2WoDRiL X-Received: by 2002:a05:6638:24cd:: with SMTP id y13mr5916128jat.140.1632430540368; Thu, 23 Sep 2021 13:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632430540; cv=none; d=google.com; s=arc-20160816; b=P5b2TEFqa5a7e/xTxdWdFpcQ2/qxEoA1+w9YelOCajgebXGHnuQsvH0G5DNyXFoRn3 9CEJV/fFDy4D1ZmqwY8D9u1tsVeiEZVCwGe6g/Coy0A8TdOk+jr+TC0R3TtrpEzUZtzF nRtUZtm/D2i3sis805Ou+p6wK+sOsHfBqPhuGhZvbJ9xaVuCEGRoyvkDgTcGHslKdPxt WuWJpkLM65/oQYdWGm0giT4+eS9yahgaZbUfh9Yl79o+Y1EmUKNjV51Mc4TZCT7+BynL Hrcz3kM/P7khkQSrViqOSu1a6f53KuXIjxvnMv7kGzk/gsJ+GXAh7/SxmfB1QhdjWxoT 5jbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tuAuDbYoqWTX1qLGSlEdN/vEAB2ogbMYztyFItd+EBc=; b=WojdArSQcX6MmFR5AnT3vg7P3jh9c7jHHgQVbGoq7EDcEN2Uq66+WxYSXP05HvX3KR F8dV688PfL1iYI/dcbVJeb86drwso4p/KJtmejfMoc5e1OIeYX7G3CcJBFE8kWwpEKCj eKmT0yiTrLtly+uFPDgrKQC2dwGn0XqfUSEmFCFpTsBinXYPUXOrQPc1Nt2kiUeG3TD0 wfmXT7KMGUn2sP9FktQXwVl7Ks/9Sl3rwIKGfJ7dxs7Rst/r7rGyIvijVRmuc183BSyC Rb8qyV54bAOfi73aZCQbyRHP/btEW4i6uJmDJYMBV+rB78Ad1jabmPhJef1IJStSnVsC X1Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=kffc8Bs2; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si8419674ioc.9.2021.09.23.13.55.20; Thu, 23 Sep 2021 13:55:40 -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=@google.com header.s=20210112 header.b=kffc8Bs2; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243056AbhIWU4s (ORCPT + 99 others); Thu, 23 Sep 2021 16:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhIWU4o (ORCPT ); Thu, 23 Sep 2021 16:56:44 -0400 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C153BC061574 for ; Thu, 23 Sep 2021 13:55:12 -0700 (PDT) Received: by mail-oo1-xc2c.google.com with SMTP id y3-20020a4ab403000000b00290e2a52c71so2591785oon.2 for ; Thu, 23 Sep 2021 13:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tuAuDbYoqWTX1qLGSlEdN/vEAB2ogbMYztyFItd+EBc=; b=kffc8Bs2M9fmas9cVTmc2dxOYcmX43mfJnInRmBRfKL4ci0Ra/Ed4N8E9aIVQqSA24 y6quxScpBT1ZO+7locgf2IBsBtTWSV1MKNtI2oVT4do2OZeKdRz10YZCGL/52KyupAbV 8aWkm3j9u3p+CMwFtEy2BYAl++cwlQPKQPEbredKllWpQDcZG0YCswdFmrI0IV65882C QrAs7PCAcggjX4Ld0w7WKDz9iYcyrX72CHPj2bDCzmi5ujt9pcaMq+9eQgQMIWSurH2G Eys/T351rHFPil0fxp9pW01KjxiNyz8ucX3AGU0NrklTz5k2qrrM1pH/hsaX+WoH5gj0 HvuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tuAuDbYoqWTX1qLGSlEdN/vEAB2ogbMYztyFItd+EBc=; b=BO2gCBms+EmYkM+KRN8rPT5PJr7SO4OGAZ/GUBYa4z3ytR5m8XkPXuBMPKmnGjdIDz YwXgSzf7m0qSRWiVv0Uytz1+J7VoMUzNx/9lXNrH+nUkYWCPw1eQV3f5TRkamvWPQTXb 9LyTQixDZqwLGAcch0xF7EiuIrSJyO56qowrHcy0g9v0ctvhvoGm4yNBN3n7XcNiEUV4 b3h3hCuLPQJykajTpK5lFrv0H6FxrhhrxYyRGGdMIdhzdLGqkkZWpQCD/pcbQlDlMN5S ElV/BWT8JGhobiC557qvj2Y4idXMZAGMvT+eJHCI6Cm3g2o9mbJ+gb7gqZ6Hjy0RyabL 0qjQ== X-Gm-Message-State: AOAM533lZbAJWXrFkRyATbBjXlvdy2TRE3jzyJNsGPBTO01FrMwLGNWM GJioiinbJxm/w4GNRZUASbyvnSRHCGpHrhgyObhYcA== X-Received: by 2002:a4a:7452:: with SMTP id t18mr5499065ooe.20.1632430511717; Thu, 23 Sep 2021 13:55:11 -0700 (PDT) MIME-Version: 1.0 References: <20210820155918.7518-1-brijesh.singh@amd.com> <20210820155918.7518-22-brijesh.singh@amd.com> <9f89fce8-421a-2219-91d0-73147aca4689@amd.com> In-Reply-To: <9f89fce8-421a-2219-91d0-73147aca4689@amd.com> From: Marc Orr Date: Thu, 23 Sep 2021 13:55:00 -0700 Message-ID: Subject: Re: [PATCH Part2 v5 21/45] KVM: SVM: Make AVIC backing, VMSA and VMCB memory allocation SNP safe To: Brijesh Singh 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Sep 23, 2021 at 1:44 PM Brijesh Singh wrote: > > > 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 You are right. Patch #3 does exactly what I was asking for in `snp_rmptable_init()`. Thanks!