Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4839730rwd; Tue, 30 May 2023 10:35:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6XHO0ei4/P5LayG3zk+RAX8dG9S7SnN8yujoLoCGFHRx3JyjfKM75+RCbxPhbEW5UI8rj5 X-Received: by 2002:a17:902:c411:b0:1a6:7b71:e64b with SMTP id k17-20020a170902c41100b001a67b71e64bmr13356804plk.15.1685468154525; Tue, 30 May 2023 10:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685468154; cv=none; d=google.com; s=arc-20160816; b=fIKbzmowI6tCL+nofwPMlk2XWBgsNbCl0yJLtRWTHfmSpAgAXm7Vh46noo7Jothnxc R98QT5cN0dq6HS9bFRgCnwsTHJ2vkuYPSmOyW+EBpJHjoipXyNBrAzbIW1+jsiDse2Ce +y/P5tAgcilYNb71K1sMSnjxRTWTe+7YFF/uxQNfXBdQg/8PPyv1cLfn2YUubicLVpOA EBPLPozu54uIXS5NZDYwwlATPHXrrL5b+mWUCiTJ64RHuMU/cmLrtd9of9fUThposOex VNy3Y1re5vJJMyhTDky8suBUstIIGzA6gf6MCQgESjwkaUFFhlsD3/DXErv+8X0nB9U6 feHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=5dIo9ozu/tftAp1UmpoAUrczqs99lWKXi5qA1UpHNYE=; b=EWxjYqth+QKXPJUHsd2SgrYzEQJBlklA5VKjiVtloLCPrGDIBRt2hNjrvP30BVOb8i SjdUOWRBzBNpLeoob2/EMk0D9vY8+gUSL4LH7EAcfBkpLRlRm666cEVnlHhs8uHHEYOA DFf5WBJ83r+YqbCRJS8EwwVgXFzKSHfEl+Mb41CEBpwVJBtxsh+NAo84Z7EFApg3GqYu he+lI4HcIVbPKG64YnTfmJtr78PfkvlbEThRVCRLrF1sM3Gi4oPeMuQDmrkcReL3jnKe mrcyUDjmEfifhOhx5uYac2NIjSVjGlu8ufBDBxvx7GVq5CGv7gpP8Rt8Nd/qoPPAVPjs B34w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=fcMt7E9o; 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=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 t9-20020a1709028c8900b001ae5fb1436asi11032780plo.184.2023.05.30.10.35.40; Tue, 30 May 2023 10:35: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=@google.com header.s=20221208 header.b=fcMt7E9o; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231422AbjE3RcZ (ORCPT + 99 others); Tue, 30 May 2023 13:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230521AbjE3RcY (ORCPT ); Tue, 30 May 2023 13:32:24 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 720B9F3 for ; Tue, 30 May 2023 10:31:52 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-53f2128ab1bso2602593a12.1 for ; Tue, 30 May 2023 10:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685467912; x=1688059912; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=5dIo9ozu/tftAp1UmpoAUrczqs99lWKXi5qA1UpHNYE=; b=fcMt7E9oftWvnXylT0q0LSi2ovxYU6GROaZO/YpP+hWVROA5CGkN858ssUM/OEUsq+ cy2yKP5XxthrBWOhhRWmnMfaInbcFln+rmGuOYxtdLasZqdrf9i2ZKdgt/TEdCrBBjG7 ZT9ootqRsxe/NChBz/85WsRSsuU1KSVsGHKC2qIH/mmVq1mmccPpcHFqUeIQGRkih0S3 aGvDJJEkz3g8ZQ99QNMUDAP/dYZioxFkRygbUSwiPYm9+GJu5Jyv2dh2A01JO3qxQH41 6ykaek6RLxvtQMhW8/hOelD76pSAAtY75YP51exJDFZC+VMuMAXLJkFisg7dDXEPnO0i fv+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685467912; x=1688059912; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5dIo9ozu/tftAp1UmpoAUrczqs99lWKXi5qA1UpHNYE=; b=LZIvJkdKg961yf/kg7P4xggAeXeOwwqdQX53giZ6UpaZrID2Hndn90DukJbliq/GSO rTlt+g6BVJMTYi7NZ0ITeqm0hkYPPPDcmPC5bKNhwmmR+uThUt2sC76hMzTXdEcNPFsJ 0ZfY/LtYlgurGhDQnZYZPrZSMG3JZcLoafLYJqZSzTnIcx5YWTM3XWpP7Vk9erzrxMJN UW4n9gov8Z18CK3J27kp5348TMeh8rFw68ZrDAil5TuX2hIOQCqxn42lPjy7wW3Ih7OB k0ElqyiACASSaO2P6GmRJ5tgw2rUvBWXThubyusqLRubHYhQdr9oiYA46xaNtKW3YYUT DSoQ== X-Gm-Message-State: AC+VfDygx0cKW6yVQlofaYF/rWdMWmmYxJc6WiOpE/Ba2sxY18o48w33 o9uzAJ6UR+MNnC6cldQnKvY5JjZtJBI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:510:0:b0:52c:9996:c1f8 with SMTP id 16-20020a630510000000b0052c9996c1f8mr555070pgf.10.1685467911952; Tue, 30 May 2023 10:31:51 -0700 (PDT) Date: Tue, 30 May 2023 10:31:50 -0700 In-Reply-To: <20230530170210.ujkv737uyjfvdoay@box.shutemov.name> Mime-Version: 1.0 References: <20230529023939.mc2akptpxcg3eh2f@box.shutemov.name> <87bki3kkfi.ffs@tglx> <20230529203129.sthnhzgds7ynddxd@box.shutemov.name> <20230530005428.jyrc2ezx5raohlrt@box.shutemov.name> <87mt1mjhk3.ffs@tglx> <87jzwqjeey.ffs@tglx> <87cz2ija1e.ffs@tglx> <20230530122951.2wu5rwcu26ofov6f@box.shutemov.name> <87wn0pizbl.ffs@tglx> <20230530170210.ujkv737uyjfvdoay@box.shutemov.name> Message-ID: Subject: Re: [patch] x86/smpboot: Disable parallel bootup if cc_vendor != NONE From: Sean Christopherson To: "Kirill A. Shutemov" Cc: Thomas Gleixner , Tom Lendacky , LKML , x86@kernel.org, David Woodhouse , Andrew Cooper , Brian Gerst , Arjan van de Veen , Paolo Bonzini , Paul McKenney , 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)" , Dave Hansen Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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-kernel@vger.kernel.org On Tue, May 30, 2023, Kirill A. Shutemov wrote: > On Tue, May 30, 2023 at 06:00:46PM +0200, Thomas Gleixner wrote: > > On Tue, May 30 2023 at 15:29, Kirill A. Shutemov wrote: > > > On Tue, May 30, 2023 at 02:09:17PM +0200, Thomas Gleixner wrote: > > >> The decision to allow parallel bringup of secondary CPUs checks > > >> CC_ATTR_GUEST_STATE_ENCRYPT to detect encrypted guests. Those cannot use > > >> parallel bootup because accessing the local APIC is intercepted and raises > > >> a #VC or #VE, which cannot be handled at that point. > > >> > > >> The check works correctly, but only for AMD encrypted guests. TDX does not > > >> set that flag. > > >> > > >> Check for cc_vendor != CC_VENDOR_NONE instead. That might be overbroad, but > > >> definitely works for both AMD and Intel. > > > > > > It boots fine with TDX, but I think it is wrong. cc_get_vendor() will > > > report CC_VENDOR_AMD even on bare metal if SME is enabled. I don't think > > > we want it. > > > > Right. Did not think about that. > > > > But the same way is CC_ATTR_GUEST_MEM_ENCRYPT overbroad for AMD. Only > > SEV-ES traps RDMSR if I'm understandig that maze correctly. > > I don't know difference between SEV flavours that well. > > I see there's that on SEV-SNP access to x2APIC MSR range (MSR 0x800-0x8FF) > is intercepted regardless if MSR_AMD64_SNP_ALT_INJ feature is present. But > I'm not sure what the state on SEV or SEV-ES. With SEV-ES, if the hypervisor intercepts an MSR access, the VM-Exit is instead morphed to a #VC (except for EFER). The guest needs to do an explicit VMGEXIT (i.e. a hypercall) to explicitly request MSR emulation (this *can* be done in the #VC handler, but the guest can also do VMGEXIT directly, e.g. in lieu of a RDMSR). With regular SEV, VM-Exits aren't reflected into the guest. Register state isn't encrypted so the hypervisor can emulate MSR accesses (and other instructions) without needing an explicit hypercall from the guest.