Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp970736rwb; Sat, 13 Aug 2022 13:03:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR67jSR41XSwHbIhkkPUSBEdcx7dpZtbdRLuj5GJQnQvRLQQ1wAWQr9QoE0G+X4qXF5WfXYy X-Received: by 2002:a05:6402:3689:b0:43e:43d6:6039 with SMTP id ej9-20020a056402368900b0043e43d66039mr8589469edb.341.1660420998977; Sat, 13 Aug 2022 13:03:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660420998; cv=none; d=google.com; s=arc-20160816; b=xCY69qGOoxfGn9nUtwAwlu38Zpze8NtJXYxA4C1volr1bdXe5z54aa/yB7FGKtIGvj YE/ABW77OggnkS7uY4XVSrZpdBZk8FSSPjZcj1DeQqfYTPae0RNdGqQaE/wpJe9Fu8Xr ytEZ5K7RZNP/om7TYuY6Zdkk78SJh0Auq1j/EWJqdr0IbEh/kYMBUSnHO4wxBY2tTBuZ 0Zw9Hw/aekBiFWnBQswUr/BhgliFpp+OAPvpZ/xFYAUzi9ydlWH1GyKelIWvxMbAPL5X 5Ms8XpRee+gukL2fW0nsSs/ovh7nl6WdHopmnea5rHch8UirCWeyh/iOzi6IAzZynhIF A1nw== 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=ZBaCHodZtQdoAxEcaFO06NCvHc0MdEgcdLsNN8F00i4=; b=G6qi59Z2+0jdrH8n4kNiFYOfUTZ+iPcKBE4Bkpr1dZ/nTeYS8ybZK7Mvpst+31eJHR 8yKMbiIGYpVlydd0odBIEsitNY3J9HhZfUH9D54mGHRnKfYa+oxSNeaewWaCfJgT8jBr iRtnbZNQin7lY2pgo7C6TeIUNt/TlJTRMJPnnyRmrpQRK6W/qQqFn8jtvgMQWu5uEg3b 2xHpmqj/UB6jzE7LIySEEBbBaj4itcwwQqDwLzZQT9D8SP0sWaBw4L/n8AqhNhDlCy4L 2WHp6037GXpLVX8htVYgygJnOahIRHjgTMAAZE4iUuKYyeiGcHpGn8fms+TWl/Ga5Xro 77dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=VszxltkJ; 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 qb31-20020a1709077e9f00b00730a8153033si4341135ejc.813.2022.08.13.13.02.21; Sat, 13 Aug 2022 13:03:18 -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=VszxltkJ; 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 S236467AbiHMTmh (ORCPT + 99 others); Sat, 13 Aug 2022 15:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230460AbiHMTmf (ORCPT ); Sat, 13 Aug 2022 15:42:35 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D91ADF3E for ; Sat, 13 Aug 2022 12:42:33 -0700 (PDT) Received: from zn.tnic (p2e55d27b.dip0.t-ipconnect.de [46.85.210.123]) (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 28A241EC0674; Sat, 13 Aug 2022 21:42:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1660419748; 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=ZBaCHodZtQdoAxEcaFO06NCvHc0MdEgcdLsNN8F00i4=; b=VszxltkJd00ofa9SoHDpxDgAX6nJWdGuqRy7SdOA+HigNK2oZCFEVg8DPzssk6KtFdx8SF I7eDowNI09Jd8jSWJyiTC8DBlDawyq5eSNKiafvwdFN2I0Kw8QvD+HEz32RdZt6b+KoSxQ SVzVa3APC6kb3lMe1HJzsx0UlLKr3hg= Date: Sat, 13 Aug 2022 21:40:14 +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 v2 1/2] 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> <21d5d55640ee1c5d66501b9398858b6a6bd6546f.1659978985.git.thomas.lendacky@amd.com> <6d9d433f-779d-7531-02b5-382796acceef@amd.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, T_SCC_BODY_TEXT_LINE 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 Fri, Aug 12, 2022 at 09:51:41AM -0500, Tom Lendacky wrote: > On 8/12/22 09:33, Borislav Petkov wrote: > > On Fri, Aug 12, 2022 at 09:11:25AM -0500, Tom Lendacky wrote: > > > There was a whole discussion on this > > > > Pointer to it? > > It starts here: https://lore.kernel.org/lkml/658c455c40e8950cb046dd885dd19dc1c52d060a.1659103274.git.thomas.lendacky@amd.com/ So how come none of the rationale for the on-stack decision vs a single buffer with a spinlock protection hasn't made it to this patch? We need to have the reason why this thing is changed documented somewhere. > > So smaller, on-stack PSC but lockless is still better than a bigger one > > but with synchronized accesses to it? That thing. That decision for on-stack buffer needs explaining why. > > > Well when we don't know which GHCB is in use, using that reserved area in > > > the GHCB doesn't help. > > > > What do you mean? > > > > The one which you read with > > > > data = this_cpu_read(runtime_data); > > Memory acceptance is called before the per-CPU GHCBs have been allocated > and so you would be actually be using early boot GHCB. And that is decided > based on the #VC handler that is invoked - but in this case we're not > coming through the #VC handler to accept memory. But then ghcb_percpu_ready needs to be a per-CPU variable too! Because it is set right after snp_register_per_cpu_ghcb() which works on the *per-CPU* GHCB. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette