Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4171065rwb; Tue, 20 Sep 2022 09:45:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5zx9jBr7+qm7t/ug38I53OqpkSmsqDFKsNGwRBZZqOb0osryls4p4FzLpBZ0lirel7NhYS X-Received: by 2002:aa7:d617:0:b0:44e:d2de:3fe1 with SMTP id c23-20020aa7d617000000b0044ed2de3fe1mr21346075edr.104.1663692354668; Tue, 20 Sep 2022 09:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663692354; cv=none; d=google.com; s=arc-20160816; b=Ng5BBnMNbNa7fBRSgVECqIg1HgmNhF7U6OjB2BU5tbn1F39ncMvWudKr9E7nSt+cur MMsyFNlO/eg5ADQqTTPb+gQHkQ6IOXhlJJP9xImIc99hCMa22Dew+/rry5BUyLOKYFEB k5GmVung5BwQAp95KBbrUCt8CqIkrZXDiMyCuaJ6CRlZuLuOCXxuIq5lsnlAXtJlPtvo V24Il7XkOpZPxE2lu5fCLwj9nMr1HcQogNiTvH2jRVWv7njfR22yB6670l3XZX/7KAJi YzMu1Eztha8mUHZpW99/xk+WvKDLb3JGKE8kCwkFveKP/mkuuQvhveuBk6d2zK46FyOk eWvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=l+pagcxPPfGt4bnG69SZ4WMdjJW1JGKDuu84r7EsXIQ=; b=JdcHG2avOmajKxaex1N0c+cLA7FxTUJwh2OIiw1TDRfY2mtxz1gXhi4hytAplSVCaQ iCHuAOjjFqdb31+YipYynslfQZOdjnY8t3x6Z4o5okNKCKCRm3XO/05ocm/16+AMhDyy g28iS7soCcEleanOn4yOIipVIg1j6MnWwb1X3Du9R74Ag+2sd38R/3y4zbTIlJraliaB DEaDek+5NU8YTdaYJTobt18OhWkkM/h9YYe7MWDILa4/nxw3scCpqmAbdjnbsWNpbjj4 NWyV/+aMn0QVfZKjh051YeY0KWW7QwINSk2IJcuLW2txvEdEoY5kD/dDfkFpufFB4zOc sPMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=o+bW83pB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h17-20020a05640250d100b00443e3fe60a0si170483edb.622.2022.09.20.09.45.27; Tue, 20 Sep 2022 09:45:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@alien8.de header.s=dkim header.b=o+bW83pB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbiITQPU (ORCPT + 99 others); Tue, 20 Sep 2022 12:15:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbiITQPS (ORCPT ); Tue, 20 Sep 2022 12:15:18 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8AC44F3BC for ; Tue, 20 Sep 2022 09:15:16 -0700 (PDT) Received: from zn.tnic (p200300ea9733e791329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e791:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 3A9C21EC0432; Tue, 20 Sep 2022 18:15:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1663690511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=l+pagcxPPfGt4bnG69SZ4WMdjJW1JGKDuu84r7EsXIQ=; b=o+bW83pBAIN6An904Fi9FAx5BaagIFfgcPt1z9igDWxRSai1vqjiPavfsSUfgnXIZubtXK I4XOvwQofvCW9UhlzLfN5molsr0r+qKm7yB3UawFS8ggMy3UAOW4CEGI/0g8tAOe5PsCoM +QYN/B0zyKK4rCcs+gRxhM5z5RNmAdU= Date: Tue, 20 Sep 2022 18:15:07 +0200 From: Borislav Petkov To: Tom Lendacky Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Dave Hansen , "Kirill A. Shutemov" , "H. Peter Anvin" , Michael Roth , Joerg Roedel , Andy Lutomirski , Peter Zijlstra Subject: Re: [PATCH v4 1/4] x86/sev: Put PSC struct on the stack in prep for unaccepted memory support Message-ID: References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,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-kernel@vger.kernel.org On Thu, Aug 25, 2022 at 09:23:14AM -0500, Tom Lendacky wrote: > In advance of providing support for unaccepted memory, switch from using > kmalloc() for allocating the Page State Change (PSC) structure to using a > local variable that lives on the stack. This is needed to avoid a possible > recursive call into set_pages_state() if the kmalloc() call requires > (more) memory to be accepted, which would result in a hang. > > The current size of the PSC struct is 2,032 bytes. To make the struct more > stack friendly, reduce the number of PSC entries from 253 down to 64, > resulting in a size of 520 bytes. This is a nice compromise on struct size > and total PSC requests while still allowing parallel PSC operations across > vCPUs. > > If the reduction in PSC entries results in any kind of performance issue > (that is not seen at the moment), use of a larger static PSC struct, with > fallback to the smaller stack version, can be investigated. "For more background info on this decision see the subthread in the Link tag below." > Signed-off-by: Tom Lendacky Link: https://lore.kernel.org/lkml/658c455c40e8950cb046dd885dd19dc1c52d060a.1659103274.git.thomas.lendacky@amd.com > --- > arch/x86/include/asm/sev-common.h | 9 +++++++-- > arch/x86/kernel/sev.c | 10 ++-------- > 2 files changed, 9 insertions(+), 10 deletions(-) > > diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h > index b8357d6ecd47..6c3d61c5f6a3 100644 > --- a/arch/x86/include/asm/sev-common.h > +++ b/arch/x86/include/asm/sev-common.h > @@ -106,8 +106,13 @@ enum psc_op { > #define GHCB_HV_FT_SNP BIT_ULL(0) > #define GHCB_HV_FT_SNP_AP_CREATION BIT_ULL(1) > > -/* SNP Page State Change NAE event */ > -#define VMGEXIT_PSC_MAX_ENTRY 253 > +/* > + * SNP Page State Change NAE event > + * The VMGEXIT_PSC_MAX_ENTRY determines the size of the PSC structure, > + * which is a local variable (stack usage) in set_pages_state(). Do not ... which is a local stack variable... > + * increase this value without evaluating the impact to stack usage. > + */ ... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette