Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp692883pxb; Thu, 31 Mar 2022 15:12:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN8MQV1dkSthdjv5hEUsKmm/p5lciWhpEJWDDcKS5hOb03bwD9MoFf2GeW8r/fF7nsszGX X-Received: by 2002:a62:e404:0:b0:4fd:b97b:8bc9 with SMTP id r4-20020a62e404000000b004fdb97b8bc9mr4281196pfh.48.1648764727708; Thu, 31 Mar 2022 15:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648764727; cv=none; d=google.com; s=arc-20160816; b=e3CxRDgj5spdtTkOuPBF4zvCy7SJt4H7EhxHShRQ01okx5ncHGOuz3GvVbod1dTeCA yD41CkwH07XtdsQiMb+HgWVHXaTXQHhApqaSdFRul/n9lRrs5dqgELpm1FZmBk0EnAcU YBSfVfAHdhXxGsl1ykTAqSqQRSdJYQjW49UslCLBtBXjHLI3C8S+49Ycs5ttMQfkVMKx GmBLS/LBBkirfxXKXG5DAb8OoR5xq07YkV73/yvIqQRX574K73i245WBulnS4zMKerHB kkkOsTDBI5O/IpOqk+etA/AqRJ/bShsX2BkIz8XN1vJq8E03p1/8FgXKTbe1AXUoLrdz lT2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=IeZ4/Sb63ngG7P3EFI0+0wB8F765VYIZarNhfw3KqsY=; b=JVSny/URIgoXhTIhDCW2D3EYaYMAlhOvuYeXUbYUzGWh9wm14JF+ajLeBEkdtonnjJ +PUFPGxGdDHeaYjiMCObz1R42YItwcnRmLY2/V7/VM47zNCuC7Ze2cVYoRu3RZmgSm13 ImJODILcF7DOrVN3Agmh4lDjlcRa9JJ3i+udyR6GUPB3SMuVA6o7CH4YhkP//RIW23nd i8iXz2mbVciyZ1cSfX/bIIcbkc8B5YxGTBfjmPlu32pZ/MZAld/Zocx4vOYROwMKprRM g9Qv/VWy7sU+a0SifXlZzoOkFp/s7Tgn/xNny8XKynSllkOS5UZywm5zLYlgRnUuhZnj fv2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PvOvTKTZ; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o4-20020a63a804000000b003816043f026si718163pgf.539.2022.03.31.15.11.54; Thu, 31 Mar 2022 15:12:07 -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=@linutronix.de header.s=2020 header.b=PvOvTKTZ; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233510AbiCaJCw (ORCPT + 99 others); Thu, 31 Mar 2022 05:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233439AbiCaJCo (ORCPT ); Thu, 31 Mar 2022 05:02:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749EF541A5; Thu, 31 Mar 2022 02:00:57 -0700 (PDT) Date: Thu, 31 Mar 2022 09:00:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648717256; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IeZ4/Sb63ngG7P3EFI0+0wB8F765VYIZarNhfw3KqsY=; b=PvOvTKTZi0or8c7lus+WiFPsPw6CWqAKKNSr8W6RU2S/FKYVUQY15aEZhnvWVBRxvhxQpV 8LPBxsKqm0DpjhUDZT5NFkA6uM9kk0wdGf9UQfewRasWHFqBdFmOK48giGyFsgAFM+3ihD y0Kb5MMOqFUQpMx1sgvm4+AABg6ASZszCOKZeL8fvMQnuN042s/NV9mTqAxmBlM6wcOvxX VgSTy5sXy+Mm4QMZkGuuMFALUttsYf0vaXUC1TDvcaI7jO94Deb/8YtK3ywKPNa9slukAc J+LtzyePP+h5M1mbUjNGvYvEBT0unIR+UmFaLTqIuY60UhkHgShfs6gEET0yEw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648717256; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IeZ4/Sb63ngG7P3EFI0+0wB8F765VYIZarNhfw3KqsY=; b=NW+tbKQn5XtVCczasX19SYEe0KIxhJEiHzHcFPobf3ZThv5A4oKCIhnTJam3WSTRg59VwJ hdQb1HyObdnvE5Bw== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/fpu/xstate: Handle supervisor states in XSTATE permissions Cc: Thomas Gleixner , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220324134623.681768598@linutronix.de> References: <20220324134623.681768598@linutronix.de> MIME-Version: 1.0 Message-ID: <164871725392.389.9637668418038210580.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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_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 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 781c64bfcb735960717d1cb45428047ff6a5030c Gitweb: https://git.kernel.org/tip/781c64bfcb735960717d1cb45428047ff6a5030c Author: Thomas Gleixner AuthorDate: Thu, 24 Mar 2022 14:47:14 +01:00 Committer: Borislav Petkov CommitterDate: Wed, 30 Mar 2022 11:35:22 +02:00 x86/fpu/xstate: Handle supervisor states in XSTATE permissions The size calculation in __xstate_request_perm() fails to take supervisor states into account because the permission bitmap is only relevant for user states. Up to 5.17 this does not matter because there are no supervisor states supported, but the (re-)enabling of ENQCMD makes them available. Fixes: 7c1ef59145f1 ("x86/cpufeatures: Re-enable ENQCMD") Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20220324134623.681768598@linutronix.de --- arch/x86/kernel/fpu/xstate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index c55f72e..5ac934b 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -1571,6 +1571,9 @@ static int __xstate_request_perm(u64 permitted, u64 requested, bool guest) /* Calculate the resulting kernel state size */ mask = permitted | requested; + /* Take supervisor states into account on the host */ + if (!guest) + mask |= xfeatures_mask_supervisor(); ksize = xstate_calculate_size(mask, compacted); /* Calculate the resulting user state size */