Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp2883465lfb; Thu, 23 Jun 2022 14:02:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vqQyGbtRZoW4YFE51pYU7CxSS+f/8JUrPujRPoUvfYF23VDTzwt6PVRfMDC0xwjSp6Pxd8 X-Received: by 2002:a63:84c1:0:b0:40d:3be2:3e96 with SMTP id k184-20020a6384c1000000b0040d3be23e96mr7111489pgd.340.1656018164655; Thu, 23 Jun 2022 14:02:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656018164; cv=none; d=google.com; s=arc-20160816; b=BbPsBfrDoV7duFXt7R1IoIQ1f3SjmG+7qKB9Zwt72bc0nUuN1MEUqN/CaN6oOUclnQ 6hqtS/3+7KawBntj2Cf6No7YOWmYB/mTAQhATb8cr2HpPxYlRpO5FS+eESC8Cx0bPI7K GCdREI2Jn/Jd9Wbvig+4wCxnvn/gnBxcZT7uQge1M6LEIWyGogs3iblul+zcjmWUBYzM 4w+JrAmORFkmopw6BVIMXfv44Nib+FvDxCXnJB6kS0nlqrG7b1MabhK3dVfWKCF3q4iV fUGQaTn+6JxZyqrhsmir7N0nhQ7sR9ZJwBSG70gB+ZrZXtvCH/D4TE66tb3jk6q1QoTq nMBg== 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=YFZn+6KIIWp9gABMuWoR/dKCyEO4Zr5Rzf3hYjExeKM=; b=CXl1eqeYbBp3uTf04XXuGYcVT3xcox+fxPyss6A/AR1KYj8OngWaBzUev4r+Btnxw6 i8613wMJszBFhPqghZYVcYBKe1fLH8Pjz2jenitW6dK79kbuqa3j0ugKUJP9qtXK1Pm7 GsATbTWFnoBJ2ew+qWMI2RzqUB0xmSqcl6CQMz28rt1I4PaNypknHqeYe3xclmhoyJeG 1yT2qrR5avNPm9QCAm3RAcjGK9Hfld09P0L5P74jkT+seUg6myVTLwD8acH+SawHPCsW 9UEVlTIzNLTw37gZfTDIKBL9VDf9l34rLgVreezAlAqY1tghIsFJgdXjQ4lMKtrezaxw Gbmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SLSQuGNH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a85-20020a621a58000000b0051babb88d79si222562pfa.277.2022.06.23.14.02.24; Thu, 23 Jun 2022 14:02:44 -0700 (PDT) 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=@google.com header.s=20210112 header.b=SLSQuGNH; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbiFWVAw (ORCPT + 99 others); Thu, 23 Jun 2022 17:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiFWVAv (ORCPT ); Thu, 23 Jun 2022 17:00:51 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080E054BFA for ; Thu, 23 Jun 2022 14:00:48 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1048b8a38bbso1032825fac.12 for ; Thu, 23 Jun 2022 14:00:48 -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=YFZn+6KIIWp9gABMuWoR/dKCyEO4Zr5Rzf3hYjExeKM=; b=SLSQuGNHJV37cOtMEFG3uwEzqjiH7rjf8lBN6dlJxGi5K+qWAXGF9NaHB34fDTGnnG 5BO6KBC5M9pv9FZxmNICTOXTmCjuDmEFXatrzbKgwFgT5Xwxwx7ok4mIUzi9Zaw9ZH9j hPKLQ5ipJETzDMCc1BbrD2MIcLQZi9LLB3BXeXoa6G+i5m3Lx1QgXn15IUHKZkjT/GnV HRCmcy3hXV0Lzzz0YERx53i6O5/3isS7ABZxFZgI7IoNX1ywx7gub33tTSzKErrXnsAa P84cUd7O2iPNeHWqT+MEBYdPFRU5j5M8eVJefEmJlF34ljWH6wgP3O2BHg+Wg97ictpa mBvA== 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=YFZn+6KIIWp9gABMuWoR/dKCyEO4Zr5Rzf3hYjExeKM=; b=OriFdIyTt5HPhU0Z853cUu0vAadfHyGDs7+9HMv4pvVjFTov7pxr2RCXYYI9x1H8JN Els3r91sKSvelhoc9b1a9QtX3wrZxf2ZLpQraWGLC2I9mRKghB1o9oLI+yLxJ1VwzoDI Ktr8KR75dzJeSuoGK4MkkAIKyaVwpZoDUWSi7sfJL6dc5xvegOKSJYfPMl5sfb5kV5zq h89CToTEtXYIS0BR1bajWRw6w1KFP6os4p+CbA0xPkpfsUgHXVpJm59A7qAjJHU72Vjg pmsKCX6xPRYOVDK+J4XNzX35AllB+LuAW5Qnbg4VsgTsp3dIZCYB0gWmTGlAKlD5XloN y15Q== X-Gm-Message-State: AJIora/09iBFU8Ala16FY8giLfW8yu/QY0RX6glUI6zixQ+nGKs7ndgI Fc1rhAXlR7/jmjWok/KKitPrGQy9qOXODUSYcT/o/w== X-Received: by 2002:a05:6870:b616:b0:e2:f8bb:5eb with SMTP id cm22-20020a056870b61600b000e2f8bb05ebmr3694057oab.218.1656018047090; Thu, 23 Jun 2022 14:00:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marc Orr Date: Thu, 23 Jun 2022 14:00:36 -0700 Message-ID: Subject: Re: [PATCH Part2 v6 04/49] x86/sev: set SYSCFG.MFMD To: Ashish Kalra Cc: x86 , LKML , kvm list , linux-coco@lists.linux.dev, linux-mm@kvack.org, Linux Crypto Mailing List , Thomas Gleixner , Ingo Molnar , Joerg Roedel , "Lendacky, Thomas" , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , "Roth, Michael" , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , Tony Luck , Sathyanarayanan Kuppuswamy , Alper Gun , "Dr . David Alan Gilbert" , jarkko@kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Mon, Jun 20, 2022 at 4:02 PM Ashish Kalra wrote: > > From: Brijesh Singh > > SEV-SNP FW >= 1.51 requires that SYSCFG.MFMD must be set. > > Subsequent CCP patches while require 1.51 as the minimum SEV-SNP > firmware version. > > Signed-off-by: Brijesh Singh > --- > arch/x86/include/asm/msr-index.h | 3 +++ > arch/x86/kernel/sev.c | 24 ++++++++++++++++++++++++ > 2 files changed, 27 insertions(+) > > diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h > index 57a8280e283a..1e36f16daa56 100644 > --- a/arch/x86/include/asm/msr-index.h > +++ b/arch/x86/include/asm/msr-index.h > @@ -587,6 +587,9 @@ > #define MSR_AMD64_SYSCFG_SNP_EN BIT_ULL(MSR_AMD64_SYSCFG_SNP_EN_BIT) > #define MSR_AMD64_SYSCFG_SNP_VMPL_EN_BIT 25 > #define MSR_AMD64_SYSCFG_SNP_VMPL_EN BIT_ULL(MSR_AMD64_SYSCFG_SNP_VMPL_EN_BIT) > +#define MSR_AMD64_SYSCFG_MFDM_BIT 19 > +#define MSR_AMD64_SYSCFG_MFDM BIT_ULL(MSR_AMD64_SYSCFG_MFDM_BIT) nit: Similar to the previous patch, the alignment here doesn't look right. The bad alignment can be viewed on the github version of this patch: https://github.com/AMDESE/linux/commit/6d4469b86f90e67119ff110230857788a0d9dbd0 > + > #define MSR_K8_INT_PENDING_MSG 0xc0010055 > /* C1E active bits in int pending message */ > #define K8_INTP_C1E_ACTIVE_MASK 0x18000000 > diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c > index 3a233b5d47c5..25c7feb367f6 100644 > --- a/arch/x86/kernel/sev.c > +++ b/arch/x86/kernel/sev.c > @@ -2257,6 +2257,27 @@ static __init void snp_enable(void *arg) > __snp_enable(smp_processor_id()); > } > > +static int __mfdm_enable(unsigned int cpu) > +{ > + u64 val; > + > + if (!cpu_feature_enabled(X86_FEATURE_SEV_SNP)) > + return 0; > + > + rdmsrl(MSR_AMD64_SYSCFG, val); > + > + val |= MSR_AMD64_SYSCFG_MFDM; Can we do this inside `__snp_enable()`, above? Then, we'll execute if a hotplug event happens as well. static int __snp_enable(unsigned int cpu) { u64 val; if (!cpu_feature_enabled(X86_FEATURE_SEV_SNP)) return 0; rdmsrl(MSR_AMD64_SYSCFG, val); val |= MSR_AMD64_SYSCFG_SNP_EN; val |= MSR_AMD64_SYSCFG_SNP_VMPL_EN; val |= MSR_AMD64_SYSCFG_MFDM; wrmsrl(MSR_AMD64_SYSCFG, val); return 0; } > + > + wrmsrl(MSR_AMD64_SYSCFG, val); > + > + return 0; > +} > + > +static __init void mfdm_enable(void *arg) > +{ > + __mfdm_enable(smp_processor_id()); > +} > + > static bool get_rmptable_info(u64 *start, u64 *len) > { > u64 calc_rmp_sz, rmp_sz, rmp_base, rmp_end, nr_pages; > @@ -2325,6 +2346,9 @@ static __init int __snp_rmptable_init(void) > /* Flush the caches to ensure that data is written before SNP is enabled. */ > wbinvd_on_all_cpus(); > > + /* MFDM must be enabled on all the CPUs prior to enabling SNP. */ > + on_each_cpu(mfdm_enable, NULL, 1); > + > /* Enable SNP on all CPUs. */ > on_each_cpu(snp_enable, NULL, 1); > > -- > 2.25.1 >