Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp484520lqp; Tue, 11 Jun 2024 09:55:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLQlwqg3eLy4v4Tm5DgF8/MbC/GyQOLIerYOTmVyXCR1Ya6v7AftoaEfMnVlPlro+0ziYiVlUfJW5Zo8UbO734r1ijCKZoWkpzHwbR1Q== X-Google-Smtp-Source: AGHT+IEg+OrmjCfJZjGiGUYstffUO1QfjcRAIQ6yjM/eWOb+66yuvyd8nerODLPqXunulVidOwXD X-Received: by 2002:a50:ab58:0:b0:57c:61a3:546 with SMTP id 4fb4d7f45d1cf-57c61a3066cmr7221415a12.21.1718124916532; Tue, 11 Jun 2024 09:55:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718124916; cv=pass; d=google.com; s=arc-20160816; b=kALt9RFO9kf/KY8QihyVWRvvzWxvuXPzA5iWfSUChMw8HGCv8BcjnZSO8VC/TvgG11 jaC2p999yse315LJZBFA7fZWXH+Uw/qTG9Dg+1siAvwlApldZgySdEcRqRI17lM6hHoF hA0Rx4QmtJ8miYk7sUYjkVWau5AXwPhbaZLNp5FjW4KE4Yuage9ASDEGRIpckvURObJh m8FX4rpXQPJSDZS2a/VJn70wIksAhIuzO8wGI/9MnCzZuEdrZJyYYVXMOLbn8vHEJx/v scC5O0rD0F/YG2c7rI0qse+XHi5vHUQBOqkqNzyDF0Iy2Wg8NlMyIlc/nC4b/8/JJHI6 1H/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=DnfXJou5oXaes8NRV8HoH6G7ySQTHvCWo43c4GirjqE=; fh=QTzL0XpWv5tiFAeTRD/6A61kjU0JIaeKc+DG+Jn+lH4=; b=DIa5L5uXMmBtfVjCM9mxXAnD/RtqoRYf0lvVmKanUzjPYs9eocVvXf1sDXJr/ng5WP Ahuk+bNCtSzgapHPllYtjO+Tpkyba2u90CLT22FugNOrRsFPYjtTHysh4xx4f6PFHmRp 1KRi1cmanjYE0J2YK6vEpwQhcdBRQRsL8XiV/WybDzUF1HDgFVCyOqs6aETMCPlgeMlU IFZ+MAww9QSO3No6J+lZd7fR1gCAVw41QH0AUf3pflkOgddbUK2ReiSSgmR20Yaa+CI4 KqVnksmK677umKgq+O3kKVRaOLxpwUIwDSeb3G5u+zLM4+7Yx3XoFqPqR0BphZPMZwzV xMgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Rgm+YsOZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-210286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c742aac89si3234235a12.408.2024.06.11.09.55.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 09:55:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Rgm+YsOZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-210286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 18B131F26235 for ; Tue, 11 Jun 2024 16:55:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5BB674425; Tue, 11 Jun 2024 16:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Rgm+YsOZ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="6SQzF/5F" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA5BB48CCD; Tue, 11 Jun 2024 16:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718124839; cv=none; b=BQBe5CuXAsjyDThJQrb6UrdB2iwb+oUHpx8MFwmCk1qPfKfdoi9RmOHhS/6/mxPX5RvKjQbk9C4Ook4OIkIo2GaF8dOuMwzfsUka43mlUhPmJ63aWeWjzWDc4biKZ3tA4nsXdyf1XrIIBnsVYv2Oq3TSuOZuh8LdtIUG2Pb13F8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718124839; c=relaxed/simple; bh=xeT+UcB3jgw0iQ7ODeXiC8Tq+NUmtrGQYOKVNRSo+mU=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=rsu+Nz0LU88xjVocpVIizDmOo7Z5Lc7AJAELNmucGNd/lXj6/NqCoddQaNwQFZZM1m+dAiH2vf7XEjJcbCYl+Y/5CJzn1GOna4yxFbPcNCX1f2YCxSucawRs0lamMz0JfJfh2769hFK4VBt+LOQcmFZVtjcFHbDNZtiUfOJxe4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Rgm+YsOZ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=6SQzF/5F; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Tue, 11 Jun 2024 16:53:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718124828; 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=DnfXJou5oXaes8NRV8HoH6G7ySQTHvCWo43c4GirjqE=; b=Rgm+YsOZOYp+b7JEGt65dIyrmjLMoZ6x50wCBXpfQvVoF/PeT6gy/nrwl5dZYL/WLuZehy fMNxrBBLBqKIVWr33rpbl8VJES1d0gaArO0rA/LCkH0WSkdDEo5DFvXBAT4iK2ZfIkw0fh hP2kl80UhrDKm7fygrYvQOxoNCqPch+bSCd6tt+WxZVTTvj6Ntu2dh4AO6oSNDZOOccFcr UJDEm4zl3uv2ZGY9T/XK/Kl9Pdyhj5kaRiA5+B8hZZdx2l7wPLGgaU1R1HwIjIMFcmCqK5 zfr0w2Bv3kRuDInpi1iEudx6Ie9hkACtS3TTpTukQtVUoRYoXknSbRDJQKVfHQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718124828; 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=DnfXJou5oXaes8NRV8HoH6G7ySQTHvCWo43c4GirjqE=; b=6SQzF/5FFhcxFShgsD6TIZwFKZD30V6CPJSjQi8k6v07Z1NRZ1wT5bwYZ04C2Zgr7jiRCT 6UgN+7It5200a1Dg== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/alternatives] x86/alternative: Convert ALTERNATIVE_3() Cc: "Borislav Petkov (AMD)" , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240607111701.8366-11-bp@kernel.org> References: <20240607111701.8366-11-bp@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171812482793.10875.5973086213214340869.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/alternatives branch of tip: Commit-ID: 93694129c6e84d3013f5b2787e2ff88dd706c4f0 Gitweb: https://git.kernel.org/tip/93694129c6e84d3013f5b2787e2ff88dd706c4f0 Author: Borislav Petkov (AMD) AuthorDate: Fri, 07 Jun 2024 13:16:57 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 11 Jun 2024 18:22:41 +02:00 x86/alternative: Convert ALTERNATIVE_3() Zap the hack of using an ALTERNATIVE_3() internal label, as suggested by bgerst: https://lore.kernel.org/r/CAMzpN2i4oJ-Dv0qO46Fd-DxNv5z9=x%2BvO%2B8g=47NiiAf8QEJYA@mail.gmail.com in favor of a label local to this macro only, as it should be done. Signed-off-by: Borislav Petkov (AMD) Acked-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20240607111701.8366-11-bp@kernel.org --- arch/x86/include/asm/alternative.h | 24 ++++-------------------- arch/x86/kernel/fpu/xstate.h | 14 +++++--------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 007baab..fba12ad 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -277,26 +277,10 @@ static inline int alternatives_text_reserved(void *start, void *end) N_ALTERNATIVE_2(oldinstr, newinstr_no, X86_FEATURE_ALWAYS, \ newinstr_yes, ft_flags) -#define ALTERNATIVE_3(oldinsn, newinsn1, ft_flags1, newinsn2, ft_flags2, \ - newinsn3, ft_flags3) \ - OLDINSTR_3(oldinsn, 1, 2, 3) \ - ".pushsection .altinstructions,\"a\"\n" \ - ALTINSTR_ENTRY(ft_flags1, 1) \ - ALTINSTR_ENTRY(ft_flags2, 2) \ - ALTINSTR_ENTRY(ft_flags3, 3) \ - ".popsection\n" \ - ".pushsection .altinstr_replacement, \"ax\"\n" \ - ALTINSTR_REPLACEMENT(newinsn1, 1) \ - ALTINSTR_REPLACEMENT(newinsn2, 2) \ - ALTINSTR_REPLACEMENT(newinsn3, 3) \ - ".popsection\n" - - -#define N_ALTERNATIVE_3(oldinst, newinst1, flag1, newinst2, flag2, \ - newinst3, flag3) \ - N_ALTERNATIVE(N_ALTERNATIVE_2(oldinst, newinst1, flag1, newinst2, flag2), \ - newinst3, flag3) - +#define ALTERNATIVE_3(oldinstr, newinstr1, ft_flags1, newinstr2, ft_flags2, \ + newinstr3, ft_flags3) \ + N_ALTERNATIVE(N_ALTERNATIVE_2(oldinstr, newinstr1, ft_flags1, newinstr2, ft_flags2), \ + newinstr3, ft_flags3) /* * Alternative instructions for different CPU types or capabilities. * diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h index 05df04f..2ee0b9c 100644 --- a/arch/x86/kernel/fpu/xstate.h +++ b/arch/x86/kernel/fpu/xstate.h @@ -106,21 +106,17 @@ static inline u64 xfeatures_mask_independent(void) * Otherwise, if XSAVEOPT is enabled, XSAVEOPT replaces XSAVE because XSAVEOPT * supports modified optimization which is not supported by XSAVE. * - * We use XSAVE as a fallback. - * - * The 661 label is defined in the ALTERNATIVE* macros as the address of the - * original instruction which gets replaced. We need to use it here as the - * address of the instruction where we might get an exception at. + * Use XSAVE as a fallback. */ #define XSTATE_XSAVE(st, lmask, hmask, err) \ - asm volatile(ALTERNATIVE_3(XSAVE, \ + asm volatile("1: " ALTERNATIVE_3(XSAVE, \ XSAVEOPT, X86_FEATURE_XSAVEOPT, \ XSAVEC, X86_FEATURE_XSAVEC, \ XSAVES, X86_FEATURE_XSAVES) \ "\n" \ "xor %[err], %[err]\n" \ "3:\n" \ - _ASM_EXTABLE_TYPE_REG(661b, 3b, EX_TYPE_EFAULT_REG, %[err]) \ + _ASM_EXTABLE_TYPE_REG(1b, 3b, EX_TYPE_EFAULT_REG, %[err]) \ : [err] "=r" (err) \ : "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \ : "memory") @@ -130,11 +126,11 @@ static inline u64 xfeatures_mask_independent(void) * XSAVE area format. */ #define XSTATE_XRESTORE(st, lmask, hmask) \ - asm volatile(ALTERNATIVE(XRSTOR, \ + asm volatile("1: " ALTERNATIVE(XRSTOR, \ XRSTORS, X86_FEATURE_XSAVES) \ "\n" \ "3:\n" \ - _ASM_EXTABLE_TYPE(661b, 3b, EX_TYPE_FPU_RESTORE) \ + _ASM_EXTABLE_TYPE(1b, 3b, EX_TYPE_FPU_RESTORE) \ : \ : "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \ : "memory")