Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3530866imw; Mon, 18 Jul 2022 09:42:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1usG+lmuLwlWDsEmQuv+tYlep+xZ4IgJ2O7/CWCXIxPIGoQjOHf1hilqHcFMU9FBAH5HLd0 X-Received: by 2002:a17:906:cc52:b0:72b:114e:c56c with SMTP id mm18-20020a170906cc5200b0072b114ec56cmr26832276ejb.144.1658162526901; Mon, 18 Jul 2022 09:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658162526; cv=none; d=google.com; s=arc-20160816; b=JIR1+chJ0IYkzU4GGboCwpcFixY6P7X+VX7gtzPP5hl5CVGZXTSs2pwvwqwALon8g+ xQPbm7mM6g0Fah01iTEuad/Q94TAid0mWmKcUPj8TdOwKdmtKjyS2bBF+i3FH1mT0AIq 7k9KESl9W2G9ra/RLdwz8pqAhXRtFUc4btB06c8NTOAvOTfs0cehuYCM+v0vtuUn1KtD 4tbhZOcjOoP4cnmF5ntlo/sG05PetbncVb92iISvifYSPQJdabCSZmZBkeEMDQXg44j0 zjpGw2/OfEjYyHGofGIhqgZRDkibDOW7rqG9XT6CuAOoHRXRqdKJqdde6sGWnGUOdepk ci6Q== 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=q498TUyBgFKahP8/Mq2OBXRnjBoiDJLsVpL5QujD8eg=; b=kOkO42v546/JPF8ZNsJ4Q0LmFx6Un9bv+goAh1WXjuGEacGOx897SuTnO2nmfpI/ce ET67i5pNbj4eInaz4o367diBs1jOiuq1XAf9w+TGucmB3IfkJ/ckiPbVJ1Zko50vExIS VDsvKXP+tyRS45bFKtyN9kRl7+jwVoCqShu/iJCjNH4cyquBmceKvN04wdNPYhoaj4Yv yvf2f5Nu6t/FbhQcW1OnpyFDAFnLJKSBF3i2fEZQkPDPYQoW1GNU6fi05ElMk0Mo5Kfm tW6ihkyWHuZMyh0+AYNM8p4wXqUr4ouxp55Px6jbxbqKw3G4fqUD+tF2BlmNGHVHqhj8 PD1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qicc0hee; 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 t12-20020a056402524c00b0043a9a95d32fsi18730922edd.433.2022.07.18.09.41.42; Mon, 18 Jul 2022 09:42:06 -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=casper.20170209 header.b=qicc0hee; 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 S235317AbiGRQjP (ORCPT + 99 others); Mon, 18 Jul 2022 12:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235768AbiGRQi5 (ORCPT ); Mon, 18 Jul 2022 12:38:57 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36BE4656F; Mon, 18 Jul 2022 09:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=q498TUyBgFKahP8/Mq2OBXRnjBoiDJLsVpL5QujD8eg=; b=qicc0heer4g3rBVZzes21636YX z5abYKnvAGcm6lO029U6O0Kk4hFYne39T6B1xyn3/U92xzDWz9Ex5MPFRTUmxHEnhOqOD4FxatXt9 C2DXdlsc12Luig8IxG2U5QN1W3er6+ldLP+AQk2J0EV5tG4nCjZ70XdHJXC3AAbNrzCAPS0HxA+44 YcQk/ji8kH1A+uvhrcNFvPvU2AeJPMCWvJAfcZ4bwwTUPPHkXC4m/V9qWFwR1b4DvC1P5nYWxZqeg kwKBRMpbEzkNwYyzAGkE6dYnK/MaELLQcV1Bh/UxL8TsVVWw2MNBoj3UmalN2/Cbr2f6WfUHyYOs7 DnJfNLSQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDTlT-00Cq9G-Lk; Mon, 18 Jul 2022 16:38:35 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 32FBB9802A7; Mon, 18 Jul 2022 18:38:35 +0200 (CEST) Date: Mon, 18 Jul 2022 18:38:35 +0200 From: Peter Zijlstra To: Borislav Petkov Cc: Thadeu Lima de Souza Cascardo , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, x86@kernel.org, ardb@kernel.org, tglx@linutronix.de, gregkh@linuxfoundation.org, torvalds@linux-foundation.org, Guenter Roeck , Josh Poimboeuf , stable@vger.kernel.org, Andrew Cooper Subject: Re: [PATCH] efi/x86: use naked RET on mixed mode call wrapper Message-ID: References: <20220715194550.793957-1-cascardo@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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, Jul 18, 2022 at 06:28:27PM +0200, Borislav Petkov wrote: > On Mon, Jul 18, 2022 at 01:41:37PM +0200, Peter Zijlstra wrote: > > diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h > > index 10a3bfc1eb23..f934dcdb7c0d 100644 > > --- a/arch/x86/include/asm/nospec-branch.h > > +++ b/arch/x86/include/asm/nospec-branch.h > > @@ -297,6 +297,8 @@ do { \ > > alternative_msr_write(MSR_IA32_SPEC_CTRL, \ > > spec_ctrl_current() | SPEC_CTRL_IBRS, \ > > X86_FEATURE_USE_IBRS_FW); \ > > + altnerative_msr_write(MSR_IA32_PRED_CMD, PRED_CMD_IBPB, \ > > + X86_FEATURE_USE_IBPB_FW); \ > > } while (0) > > So I'm being told we need to untrain on return from EFI to protect the > kernel from it. Ontop of yours. I don't think there's any credible way we can protect against EFI taking over the system if it wants to. It runs at CPL0 and has access to the direct map. If EFI wants it can take over the system without trying.