Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1020066rwb; Thu, 19 Jan 2023 05:47:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXsROBqt65ZKRQiyUR2as9SaYvsSUUK5VAoYzg2cSC9vdR0Qw2jcclIuv2536gxgIVncr+V2 X-Received: by 2002:aa7:c84d:0:b0:499:d374:e18b with SMTP id g13-20020aa7c84d000000b00499d374e18bmr10523752edt.35.1674136063620; Thu, 19 Jan 2023 05:47:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674136063; cv=none; d=google.com; s=arc-20160816; b=EoZceK/pjmU5+lmNbwyGRZ53IYFxWaB/EuH7/QqaoaDWxzvBtPhEe4d5Ui9N+0qErN voXVG+orM3NC/MLPSNnjbJQlKy16WRFHx0DxN1MowEU/nLNke/6iVn5V1Ud4INJwItMA QOaT08IgUaTpsweGbjvYkZFFZq3FYoDbha/qqe739e4IoBYW6EMlioXHzRQ5kz3O9SaH +MnPXe0H/DZr29T+D3XWdFqt2wrNp0XQw6P2wuM8T21aD+Syc7R3b0lBIUicasmL1xWa 6FIAkQ6mOHTN35JKy2wdvZ0DiYls5OS50KfM0Fo+ugHmRDEVYoVDWU2IIztq6cWTBW+L +iYQ== 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=KQnyLQfK7qJC86oYK37cAQ7hek4siDxOAmRxTyQrFa0=; b=rTEwqnqLr28I6P33ilesUakDxuye/FRYqN9QK3H9ommn695vl/utR2DLtBsQv3tjhg dWwL4j2VhNv/ETMxNf7xvGihst6wub4+09sXQZbQw1fjvkBoZBmzDZvvJxYfFMuHm6zA 2EQwmeNY29ZzC+EJL6q6W0+IJvcQhwQMshtN50rs1vA5u6sHi/kspRoocMvBXMp6e3CX 0ohHB2wkqHSzV0cG0vDBv6SSJuiSho+PBx5YYQ9ozjZS3KFjOqUNk8ikOQgDAHtVztes v+AyHd22V5o9ZHPh1GNTgk+69TRtvb7p8DzSX8vttRYzEOnNJ0ljw/zmu9cmBcJZw5+r PJzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=PZtimvQk; 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 js18-20020a17090797d200b0086dd3de7985si20000756ejc.864.2023.01.19.05.47.32; Thu, 19 Jan 2023 05:47:43 -0800 (PST) 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=PZtimvQk; 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 S231307AbjASNTW (ORCPT + 45 others); Thu, 19 Jan 2023 08:19:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbjASNS4 (ORCPT ); Thu, 19 Jan 2023 08:18:56 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546521BCE for ; Thu, 19 Jan 2023 05:18:54 -0800 (PST) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (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 E2B871EC0691; Thu, 19 Jan 2023 14:18:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1674134333; 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=KQnyLQfK7qJC86oYK37cAQ7hek4siDxOAmRxTyQrFa0=; b=PZtimvQkqlW/cJilj6IlzV376vPd6z0Ph1rqtUb3ByHCk/BeQkmicHqrBF+DY+kYjExKTd WSM2lsHs//3WaJrIcjFy2fnI+Sc3ZkLWm9cCgQBuq1ytKkWulN3q2Fnry/oCuZunWxvxgd HNIOXbeTbVZCwhjTV29fcAxtjneo6X0= Date: Thu, 19 Jan 2023 14:18:47 +0100 From: Borislav Petkov To: Peter Zijlstra , =?utf-8?B?SsO2cmcgUsO2ZGVs?= Cc: x86@kernel.org, Joan Bruguera , linux-kernel@vger.kernel.org, Juergen Gross , "Rafael J. Wysocki" , xen-devel , Jan Beulich , Roger Pau Monne , Kees Cook , mark.rutland@arm.com, Andrew Cooper , "H. Peter Anvin" Subject: Re: [PATCH v2 2/7] x86/boot: Delay sev_verify_cbit() a bit Message-ID: References: <20230116142533.905102512@infradead.org> <20230116143645.649204101@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230116143645.649204101@infradead.org> 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 Mon, Jan 16, 2023 at 03:25:35PM +0100, Peter Zijlstra wrote: > Per the comment it is important to call sev_verify_cbit() before the > first RET instruction, this means we can delay calling this until more Make that "... this means that this can be delayed until... " And I believe this is not about the first RET insn but about the *next* RET which will pop poisoned crap from the unencrypted stack and do shits with it. Also, there's this over sev_verify_cbit(): * sev_verify_cbit() is called before switching to a new long-mode page-table * at boot. so you can't move it under the movq %rax, %cr3 Looking at this more, there's a sme_enable() call on the BSP which is already in C. So, can we do that C-bit verification once on the BSP, *in C* which would be a lot easier, and be done with it? Once it is verified there, the bit is the same on all APs so all good. Right? joro? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette