[{"id":3683356,"web_url":"http://patchwork.ozlabs.org/comment/3683356/","msgid":"<20260428093905.GA1026330@noisy.programming.kicks-ass.net>","list_archive_url":null,"date":"2026-04-28T09:39:05","subject":"Re: [PATCH v2 2/9] x86/extable: switch to using FIELD_GET_SIGNED()","submitter":{"id":493,"url":"http://patchwork.ozlabs.org/api/people/493/","name":"Peter Zijlstra","email":"peterz@infradead.org"},"content":"On Mon, Apr 27, 2026 at 05:41:19PM -0400, Yury Norov wrote:\n> The EX_DATA register is laid out such that EX_DATA_IMM occupied MSB.\n> It's done to make sure that FIELD_GET() will sign-extend the IMM\n> field during extraction.\n> \n> To enforce that, all EX_DATA masks are made signed integers. This\n> works, but relies on the particular implementation of FIELD_GET(),\n> i.e. masking then shifting, not vice versa; and the particular\n> placement of the fields in the register.\n> \n> Switch to using the dedicated FIELD_GET_SIGNED(), and relax those\n> limitations.\n> \n> Signed-off-by: Yury Norov <ynorov@nvidia.com>\n\nAcked-by: Peter Zijlstra (Intel) <peterz@infradead.org>\n\n> ---\n>  arch/x86/include/asm/extable_fixup_types.h | 13 ++++---------\n>  arch/x86/mm/extable.c                      |  2 +-\n>  2 files changed, 5 insertions(+), 10 deletions(-)\n> \n> diff --git a/arch/x86/include/asm/extable_fixup_types.h b/arch/x86/include/asm/extable_fixup_types.h\n> index 906b0d5541e8..fd0cfb472103 100644\n> --- a/arch/x86/include/asm/extable_fixup_types.h\n> +++ b/arch/x86/include/asm/extable_fixup_types.h\n> @@ -2,15 +2,10 @@\n>  #ifndef _ASM_X86_EXTABLE_FIXUP_TYPES_H\n>  #define _ASM_X86_EXTABLE_FIXUP_TYPES_H\n>  \n> -/*\n> - * Our IMM is signed, as such it must live at the top end of the word. Also,\n> - * since C99 hex constants are of ambiguous type, force cast the mask to 'int'\n> - * so that FIELD_GET() will DTRT and sign extend the value when it extracts it.\n> - */\n> -#define EX_DATA_TYPE_MASK\t\t((int)0x000000FF)\n> -#define EX_DATA_REG_MASK\t\t((int)0x00000F00)\n> -#define EX_DATA_FLAG_MASK\t\t((int)0x0000F000)\n> -#define EX_DATA_IMM_MASK\t\t((int)0xFFFF0000)\n> +#define EX_DATA_TYPE_MASK\t\t(0x000000FF)\n> +#define EX_DATA_REG_MASK\t\t(0x00000F00)\n> +#define EX_DATA_FLAG_MASK\t\t(0x0000F000)\n> +#define EX_DATA_IMM_MASK\t\t(0xFFFF0000)\n>  \n>  #define EX_DATA_REG_SHIFT\t\t8\n>  #define EX_DATA_FLAG_SHIFT\t\t12\n> diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c\n> index 6b9ff1c6cafa..ceb8d03191ab 100644\n> --- a/arch/x86/mm/extable.c\n> +++ b/arch/x86/mm/extable.c\n> @@ -322,7 +322,7 @@ int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code,\n>  \n>  \ttype = FIELD_GET(EX_DATA_TYPE_MASK, e->data);\n>  \treg  = FIELD_GET(EX_DATA_REG_MASK,  e->data);\n> -\timm  = FIELD_GET(EX_DATA_IMM_MASK,  e->data);\n> +\timm  = FIELD_GET_SIGNED(EX_DATA_IMM_MASK, e->data);\n>  \n>  \tswitch (type) {\n>  \tcase EX_TYPE_DEFAULT:\n> -- \n> 2.51.0\n>","headers":{"Return-Path":"\n <linux-rtc+bounces-6445-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-rtc@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256\n header.s=desiato.20200630 header.b=fQZ+sdHr;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-rtc+bounces-6445-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org\n header.b=\"fQZ+sdHr\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=90.155.92.199","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=infradead.org","smtp.subspace.kernel.org;\n spf=none smtp.mailfrom=infradead.org"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4bxn50cSz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 20:18:53 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id ECCB3316E354\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 09:39:36 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id C963A3D523C;\n\tTue, 28 Apr 2026 09:39:31 +0000 (UTC)","from desiato.infradead.org (desiato.infradead.org [90.155.92.199])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id F29E12EF653;\n\tTue, 28 Apr 2026 09:39:26 +0000 (UTC)","from\n 2001-1c00-8d85-4b00-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl\n ([2001:1c00:8d85:4b00:266e:96ff:fe07:7dcc]\n helo=noisy.programming.kicks-ass.net)\n\tby desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wHeuJ-00000002bvc-0jGo;\n\tTue, 28 Apr 2026 09:39:07 +0000","by noisy.programming.kicks-ass.net (Postfix, from userid 1000)\n\tid A1C1C30330B; Tue, 28 Apr 2026 11:39:05 +0200 (CEST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777369171; cv=none;\n b=tk2jMhMJMFLzMi83k6fp/ispo4oxQm1JGrHVtTfd86W9gpCeR2DIwPb9DtVN1c0P4SpJO154l3tQqkfo8hoHD7z3vcSPUJlG3WeuITJu8ukgN15QchClWYEFwY33J7rJkL2okSmkSMN+LejqnyQ5XNu0IS97nY8gwzMke7e6rck=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777369171; c=relaxed/simple;\n\tbh=p7IdvtVE/evm+N22/Y2mzoWyYve0mGB/apLJBPbltXs=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=hcg319DMARvWXMsSU6quW2AYj7pmOZZ47JDfWy8+1ZFMInM7qaLU/YCXXPtKmyEiL/izP6k26XzNq9vQLBVzL9DHvqJaoFJBm3H24Yh1buAmQQb9ge9zqV1sXxRlhiXKDq9IqnI5d5X3mnzT7e8s2ht1PCusW6VX8sYXYWldCBU=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=infradead.org;\n spf=none smtp.mailfrom=infradead.org;\n dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org\n header.b=fQZ+sdHr; arc=none smtp.client-ip=90.155.92.199","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version:\n\tReferences:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:\n\tContent-Transfer-Encoding:Content-ID:Content-Description;\n\tbh=PSRhFVtT2RWFdp856Xk+KYQvTFkIYWnEyy7wWGqEW4M=; b=fQZ+sdHr/DxtXPOoTa0/PXsoq7\n\takesGkU6rpfZ8ktRkjQ7tb4j3wfiY2oC0JpAxpcj5J6QSH+4/QdbiyWoNvPOhdc3ymvaX15Tlsf6U\n\t+jDrDT9XWlUxaHuLTcM6FRz60Ez8QHwalzwaPVTo1RDVxgD8UnM9wteHViwqyt1dw0Y0Z82bUVQ5G\n\tLHZC0upELm//PQd4zJFQwM7yY1xBvPQOp7Z6Qxt3H5FLYzMbwmnUx+DgPPNFKttx2uYW4nflxpdsh\n\tftGz7lpw550Tda7nMjz+4g78gSeB0NfhUtv97VPsSjZsAhQvGEgVhgTCmMoVY8FxA/dRDpdIVYyGQ\n\t1O7O0eKQ==;","Date":"Tue, 28 Apr 2026 11:39:05 +0200","From":"Peter Zijlstra <peterz@infradead.org>","To":"Yury Norov <ynorov@nvidia.com>","Cc":"Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,\n Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>,\n \"H. Peter Anvin\" <hpa@zytor.com>, Andy Lutomirski <luto@kernel.org>,\n Jonathan Cameron <jic23@kernel.org>, David Lechner <dlechner@baylibre.com>,\n Johannes Berg <johannes@sipsolutions.net>,\n David Laight <david.laight.linux@gmail.com>,\n Nuno =?iso-8859-1?q?S=E1?= <nuno.sa@analog.com>,\n Andy Shevchenko <andy@kernel.org>, Ping-Ke Shih <pkshih@realtek.com>,\n Richard Cochran <richardcochran@gmail.com>,\n Andrew Lunn <andrew+netdev@lunn.ch>, \"David S. Miller\" <davem@davemloft.net>,\n Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>,\n Paolo Abeni <pabeni@redhat.com>,\n Alexandre Belloni <alexandre.belloni@bootlin.com>,\n Yury Norov <yury.norov@gmail.com>,\n Rasmus Villemoes <linux@rasmusvillemoes.dk>,\n Hans de Goede <hansg@kernel.org>, Linus Walleij <linusw@kernel.org>,\n Sakari Ailus <sakari.ailus@linux.intel.com>,\n Salah Triki <salah.triki@gmail.com>, Achim Gratz <Achim.Gratz@stromeko.de>,\n Ben Collins <bcollins@watter.com>, x86@kernel.org,\n linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,\n linux-wireless@vger.kernel.org, netdev@vger.kernel.org,\n linux-rtc@vger.kernel.org","Subject":"Re: [PATCH v2 2/9] x86/extable: switch to using FIELD_GET_SIGNED()","Message-ID":"<20260428093905.GA1026330@noisy.programming.kicks-ass.net>","References":"<20260427214127.406067-1-ynorov@nvidia.com>\n <20260427214127.406067-3-ynorov@nvidia.com>","Precedence":"bulk","X-Mailing-List":"linux-rtc@vger.kernel.org","List-Id":"<linux-rtc.vger.kernel.org>","List-Subscribe":"<mailto:linux-rtc+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-rtc+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260427214127.406067-3-ynorov@nvidia.com>"}}]