Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp586949lqh; Fri, 31 May 2024 10:01:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtSGilVMNr5PQlG49qux9doVuAzGt+9aNt0fI54C/QQixqK5zu76voiWqTInTfdZPPqmkHdm7yz9CPD02LM9CuhSRVLX++swWubalSCA== X-Google-Smtp-Source: AGHT+IFP0DBkVQvTWYtwd+g+sdJ3uxPRwoZ0s7f6hv16ASoFp5CAebcB9TvT+TnRhDZeCgfnEJ7R X-Received: by 2002:a50:9b13:0:b0:57a:2ccb:b3f2 with SMTP id 4fb4d7f45d1cf-57a363e2bf9mr1488648a12.16.1717174894355; Fri, 31 May 2024 10:01:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717174894; cv=pass; d=google.com; s=arc-20160816; b=KcD0J7axlEYsGVntdQIeb+RaUK1FuVuA/LRX4nZqLF9ZraclxFvsdMU0SwNO6xgm7G bHk18c8d8Psl+z8NBGV7m8JFd6/BHrVRIef50h6NunEp9NWh1VFo3kHIdfCK3OyWpOVX T2at39hSRJFm8HucHfeSe7/H9xpjzs8uWSkP+jLAWGURoR+Spi+sAzt96VA/f1zh4xRY +UHcabZ4XwSVGYefjIdNISP/JU1e58SZMiOQcLhk0nLstFu38K1Kp+Maj+a3lEHAWUSB Zmv6k9WWOxj5Hk0Ty7U34FCwdKNltggVU975bTkQIaZeFbxuvZ+ctTSTXjekN8ROjEwc 6aOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Kk2OxyZMtbnZSm/LI3qv3dX7yiLbidrXsgXiEDTxDig=; fh=V85x6Xu3uokm4ByQnBC6U/X1FqAURyT2cOrNsKuNPzI=; b=QQsBX2jRa4qCtFj/T8QBVKN+lkO0jgWWmzX9hxcOplGdMOzmz1an9P258ePgFV8xVB 95Hc+qK6sjcEkocERnN1/E+ciDan1Zyp3jVqcuE9MzglWr41pW+rx2bTiMSHR9oRmOca qV7nhwWuA1yVRwDNtj5Lx4fEZmqhFk/eNShUQwjiq4gve50ygEZRLHB7YKbhT4MuzFdF obi1fD5PTusSUQkZG/Tdr3+SjPm/l2gxY4IsRLKqYuxSY6j7BQM1FQvQIgfWvWfnU65+ 1O7moctHu59Hss9iwc4yGEcN3Ki8tYw2LRKFjaPZZOdrfUQeNoG+mtEQy1ecpUwvDM6c xeSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DA0rfTWW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-197211-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197211-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31b8180asi1135114a12.133.2024.05.31.10.01.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 10:01:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197211-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=@gmail.com header.s=20230601 header.b=DA0rfTWW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-197211-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197211-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 E41661F2736B for ; Fri, 31 May 2024 17:01:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A4EA172793; Fri, 31 May 2024 17:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DA0rfTWW" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00D92770FC for ; Fri, 31 May 2024 17:01:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717174872; cv=none; b=HvMsTgp1cTKFk9EgdgLfTgzir+mC6+ZrRUazkYUx2a7LWGwv0BXxlH+gcQJvMUsabFVrghRQNTnn52rNG75pvqzPE6+y7N3BlAsc+GtbyicSY4hyzyb/qB3ZvZAw53IQCS/wNk36HfyKs7NAKFPwL/ifG2qwDRLLHLOfyNi/5+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717174872; c=relaxed/simple; bh=MCVV0IUaW6kQ8ECcAxm/dAlg6y+EfifG6LVOd37rQi8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=aloX3b4oZmS49sFuMNQuZkvjYSqrGBbf6QlNFCUcZbfKLpUWrI+C35RBf1n7rtVZvfsR4xhNzdLwn1gybLVFOjNgg4MR+hjOmjvFo1SJv80R6ZYL+Z1Ll+ZQKKWoU+cKZ07lDki0iL743aXtBt/SlnuJzaldgVsoX8v8VJxBymo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DA0rfTWW; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-52b03d66861so2525483e87.1 for ; Fri, 31 May 2024 10:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717174869; x=1717779669; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Kk2OxyZMtbnZSm/LI3qv3dX7yiLbidrXsgXiEDTxDig=; b=DA0rfTWWcvBvcBoNvMczGEq2EA1zSt0lhuwkTXpqsyrYwEOEoSTQiQ+qdxCAJpwj/0 2cPW8GojcRxWyxUQVX+a5y9ONBFlXCKcfRUJr0CIHURKfb4rb/LSlMYzya/sQI67QQpK Bp3mfK+fqI3bmi1McqJJ+1iJrp8exZfOkQC8Jq8SjOK5Cc8IOtSJjQBwhM1SqaHbgfX4 A7TxOH2LddqRxFok6hBIurO0L9eHRTZNtQ6RtOU8Iy3RUyDkmIEfylR3DHlndLRl6mfL BwCzvGXfObZWATE0Col1sZEGNVpBAoAw5mzGgM9gBp/5fG2o58oYPjYFMgMv/b1yg31s i0ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717174869; x=1717779669; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kk2OxyZMtbnZSm/LI3qv3dX7yiLbidrXsgXiEDTxDig=; b=EdUtFNpOwJHFxDFBqtDC8Hiovfsf2mbNiYm8XP31jhfqDPaoOZcsBsmQkz32GyoLQo 8zgEsaqPM+BlIj1kTuEunaw0sLs/TJtMmS7vqOrKx2X/eeY78bnM0QQp8pO5JmrB3+at kwjxRY+C8Bcc5Je/PkqKIn2FD1AVTrXyvdwdXKcVotHOkjonRFggDs2PYWYMcXD5YQf4 3MmnWajS6dIGtmGLEwTUqwsma3Ek19QXsr6zcmWwVB0hAfxJUEoNrOX/yNZ8ZnPJYpDQ pTgP0d15adGBgOI2KLnATn4EbiyoIk0U1YOIYoJuiz6DdiH0s9HnGsAJkpSsUalpluyM Svlw== X-Forwarded-Encrypted: i=1; AJvYcCUIQ05vy2DegHYNBnQ+32f7fMPmGtVLvlKnXYuJYOsXzaNUegYUA/XN9zceSVY40yaiA/PbEPCrgwZcXRq9h2YOPbNByY3XUxvdMy0P X-Gm-Message-State: AOJu0YzizrJjp2FYaT2iPCPBNY2IalwEBJ6iquLsnq8gaG235kFXuJdT oT+MeuFUCtlBuLx61eJIbdqv39a2DLr3+JRkEXVFK2WMFtNzhbyBdYN4WQgNTWCrw/b2R7b6oe1 5paGmYZUK/PkA0FqXMso8+DComVdSiS8= X-Received: by 2002:a05:6512:21c:b0:52b:8610:a7fd with SMTP id 2adb3069b0e04-52b8980f6a3mr1349589e87.67.1717174868719; Fri, 31 May 2024 10:01:08 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240531123512.21427-1-bp@kernel.org> <20240531123512.21427-11-bp@kernel.org> In-Reply-To: <20240531123512.21427-11-bp@kernel.org> From: Brian Gerst Date: Fri, 31 May 2024 13:00:55 -0400 Message-ID: Subject: Re: [PATCH 10/14] x86/alternative: Convert ALTERNATIVE_3() To: Borislav Petkov Cc: X86 ML , LKML , "Borislav Petkov (AMD)" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 31, 2024 at 8:41=E2=80=AFAM Borislav Petkov wro= te: > > From: "Borislav Petkov (AMD)" > > Fixup label numbering too as the new macros have new label numbers. > > Signed-off-by: Borislav Petkov (AMD) > --- > arch/x86/include/asm/alternative.h | 24 ++++-------------------- > arch/x86/kernel/fpu/xstate.h | 4 ++-- > 2 files changed, 6 insertions(+), 22 deletions(-) > > diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/al= ternative.h > index 73ee18705ef1..0df99855e003 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_flag= s2, \ > + newinstr3, ft_flags3) \ > + N_ALTERNATIVE(N_ALTERNATIVE_2(oldinstr, newinstr1, ft_flags1, new= instr2, 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 05df04f39628..4fe8501efc6c 100644 > --- a/arch/x86/kernel/fpu/xstate.h > +++ b/arch/x86/kernel/fpu/xstate.h > @@ -108,7 +108,7 @@ static inline u64 xfeatures_mask_independent(void) > * > * We use XSAVE as a fallback. > * > - * The 661 label is defined in the ALTERNATIVE* macros as the address of= the > + * The 771 label is defined in the ALTERNATIVE* macros as the address of= the > * original instruction which gets replaced. We need to use it here as t= he > * address of the instruction where we might get an exception at. > */ > @@ -120,7 +120,7 @@ static inline u64 xfeatures_mask_independent(void) > "\n" \ > "xor %[err], %[err]\n" \ > "3:\n" \ > - _ASM_EXTABLE_TYPE_REG(661b, 3b, EX_TYPE_EFAULT_REG, = %[err]) \ > + _ASM_EXTABLE_TYPE_REG(771b, 3b, EX_TYPE_EFAULT_REG, = %[err]) \ > : [err] "=3Dr" (err) = \ > : "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \ > : "memory") > -- > 2.43.0 > > Just add a label at the start of this macro, so it doesn't depend on the internal labels of ALTERNATIVE(). Something like: asm volatile("1:" ALTERNATIVE_3(XSAVE, \ ... _ASM_EXTABLE_TYPE_REG(1b, 3b, EX_TYPE_EFAULT_REG, %[err]) \ ... Brian Gerst