Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1955646rwd; Mon, 15 May 2023 05:33:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5h5QY8UVnDOjaaCMMh2lli0V6SQjunNdh8f6COR4grdCoGiK3T8QtvbQ/WTgPQ8Rfdd7Cv X-Received: by 2002:a17:902:d2c4:b0:1ad:cef8:f913 with SMTP id n4-20020a170902d2c400b001adcef8f913mr16813823plc.44.1684154015520; Mon, 15 May 2023 05:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684154015; cv=none; d=google.com; s=arc-20160816; b=iZvzas2Z1RDz7bVIqxtJnBKPwAcU/tmlTqp4/AU1NDAqUXAir+Cy+10m/oIT+srf7u pS5MOGUovGTq5Y3mnep/yskybHctD6DWjlI26u0QI2Kwn2ay2abDmuV4uSs9P4CQa+/B VaHjxRMqU6Zpt+3HjcYUK1+C7H8cOw1NzwB+E64v0PpFk0x08URGFvZ2WQH+vioTL9wD emTYBMK1i5+sfmWTM6aIcxG3JTpTb3vr0aFHOZG6DusZsuvpFFxzrMSJAtPxrVsTSFVY f8wBToXyoGAAV94IrA3+b/SKpHNM3xeNsUmqEomrdrkizNVCiIBOriLwHlTNy6+6kjjw I2dw== 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=5mEVtTPGjX5VUAK36tVkFbSuQO22AuGeDmAzn9epzuw=; b=S/xwMaHkZXKWpNq5vyrEk/U6VvRCFOSXjYuJB4/8YqbUlvMn8yDFVlj/qFoZr5+a05 r2kRECvCj6ZsUi8dcTc2C2kB3ijK4myDsth/OtLH7IKBboTLUQX6iJ0s1C2T6PJ8K0bY r/GvMkdOUjpWW+90S3LC4WFeKQLa6WzsWQldz3FNoaJULGkBG5duXCFYX1Inibh0llKL 5bw4PLXLrrU4huwn/FWOwACIPAJapNeq2hoicpQOWRmwSawhs2APBfYyu4THM0BTlhAb P5IcXaHqaKvk35RgWAp/YCJxhkC76axBiwJsJ2GHFNpo26gJtJMaUcTUgBaGSCvL5P9l bz/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=AmiVyh00; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a24-20020a170902b59800b001ac3f74f488si15239506pls.79.2023.05.15.05.33.22; Mon, 15 May 2023 05:33:35 -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=@infradead.org header.s=desiato.20200630 header.b=AmiVyh00; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241781AbjEOMDw (ORCPT + 99 others); Mon, 15 May 2023 08:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241676AbjEOMD2 (ORCPT ); Mon, 15 May 2023 08:03:28 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B95F19BA; Mon, 15 May 2023 05:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5mEVtTPGjX5VUAK36tVkFbSuQO22AuGeDmAzn9epzuw=; b=AmiVyh00bk/IBxeKT1sJOhNhPw sKnnSOF2uFizS5FDPwFE+Ot6Zv0LcoZ6HJF47h5sBYfsBjpiqyZyI5uuDK5u2MZ4g4WobyDMhkodb fUSujxE1pqhBhDi+eUM0ht45DR2Y3i+nr1YT42g2zawDfvMwb295A0aq8ARQ+5Z4gi/pV9YXxQYVt 3wUGZYGDjBC3RzitLceq6j/qPs1owVcSfLpElN1Y8S30KXDX5uH0Odcz4RLnxHbc6f5jNYL4oL/bz nTpSFPHQoB6BKp5r4Q6WAS69amz0yrUYHbuk51pYpxo8D3N1weBBW6mFoBFyYlJ+O4Y0A9ycf248d MFethNqQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pyWsq-00BTBM-2z; Mon, 15 May 2023 12:00:57 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D89B330003A; Mon, 15 May 2023 14:00:51 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A377520AA5AEB; Mon, 15 May 2023 14:00:51 +0200 (CEST) Date: Mon, 15 May 2023 14:00:51 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , x86@kernel.org, David Woodhouse , Andrew Cooper , Brian Gerst , Arjan van de Veen , Paolo Bonzini , Paul McKenney , Tom Lendacky , Sean Christopherson , Oleksandr Natalenko , Paul Menzel , "Guilherme G. Piccoli" , Piotr Gorski , Usama Arif , Juergen Gross , Boris Ostrovsky , xen-devel@lists.xenproject.org, Russell King , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Guo Ren , linux-csky@vger.kernel.org, Thomas Bogendoerfer , linux-mips@vger.kernel.org, "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , linux-riscv@lists.infradead.org, Mark Rutland , Sabin Rapan , "Michael Kelley (LINUX)" , Ross Philipson Subject: Re: [patch V4 37/37] x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it Message-ID: <20230515120051.GH83892@hirez.programming.kicks-ass.net> References: <20230512203426.452963764@linutronix.de> <20230512205257.467571745@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230512205257.467571745@linutronix.de> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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, May 12, 2023 at 11:07:56PM +0200, Thomas Gleixner wrote: > From: Thomas Gleixner > > Implement the validation function which tells the core code whether > parallel bringup is possible. > > The only condition for now is that the kernel does not run in an encrypted > guest as these will trap the RDMSR via #VC, which cannot be handled at that > point in early startup. > > There was an earlier variant for AMD-SEV which used the GHBC protocol for > retrieving the APIC ID via CPUID, but there is no guarantee that the > initial APIC ID in CPUID is the same as the real APIC ID. There is no > enforcement from the secure firmware and the hypervisor can assign APIC IDs > as it sees fit as long as the ACPI/MADT table is consistent with that > assignment. > > Unfortunately there is no RDMSR GHCB protocol at the moment, so enabling > AMD-SEV guests for parallel startup needs some more thought. One option, other than adding said protocol, would be to: - use the APICID from CPUID -- with the expectation that it can be wrong. - (ab)use one of the high bits in cpuid_to_apicid[] as a test-and-set trylock. This avoids two CPUs from using the same per-cpu base, if CPUID is being malicious. Panic on fail. - validate against MSR the moment we can and panic if not matching The trylock ensures the stacks/percpu state is not used by multiple CPUs, and should guarantee a coherent state to get far enough along to be able to do the #VE inducing RDMSR.