From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2880CC6B00 for ; Thu, 2 Apr 2026 06:25:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1271100.1559390 (Exim 4.92) (envelope-from ) id 1w8BUB-0001DN-9F; Thu, 02 Apr 2026 06:24:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1271100.1559390; Thu, 02 Apr 2026 06:24:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w8BUB-0001DF-6A; Thu, 02 Apr 2026 06:24:59 +0000 Received: by outflank-mailman (input) for mailman id 1271100; Thu, 02 Apr 2026 06:24:58 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w8BUA-0001D9-10 for xen-devel@lists.xenproject.org; Thu, 02 Apr 2026 06:24:58 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w8BU7-003rfY-On for xen-devel@lists.xenproject.org; Thu, 02 Apr 2026 08:24:57 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ce0bb9-2eae-0a2a0a5409dd-0a2a4506c406-0 for ; Thu, 02 Apr 2026 08:24:57 +0200 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69ce0bb9-0df0-0a2a45060019-d1558032c5c9-3 for ; Thu, 02 Apr 2026 08:24:57 +0200 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-486fd3a577eso3862715e9.1 for ; Wed, 01 Apr 2026 23:24:57 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887c8852a5sm138753715e9.9.2026.04.01.23.24.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Apr 2026 23:24:56 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1775111097; x=1775715897; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=KYjlo8eTh1e3f7SUAmu5caQMG1Fwh+iun7Ol8ixjQvw=; b=DNdW34uJAEAGG5x29sxLnCUUqO/QBMtB+/1x0p/qYcj26OZ7jlGehsKLUHNfJqIhzI ESlMgslyuFSYchKs8U4w9GXhby52kzkmOzEIKsKq/o0hrxj+Lrx3A7fr9k6t5boqvnMU WV+MiQJp+B/Rme15QfE40JbopjZtBd7Xam37iW41dVvkEs16U3QLiVngkhPmR1YxlJzd Qra14NH61zAnUF5PSK08JSWLMeVWhJR+Os1LT4UMswNUXp65lZiOEtqCjNAinRb/lyCK VmmkIaPzv5vufGPHUdtM5lGWxQosF34uEWlhmyfMS5wpaBVFp6GJpdTxII52A6pki2p9 112g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775111097; x=1775715897; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KYjlo8eTh1e3f7SUAmu5caQMG1Fwh+iun7Ol8ixjQvw=; b=chIC+JuqqWNhc8VLlUQ3t+JUKeDZL2TB37988yJFxPSf3H7xFqaqQLjW+vBsGwfM2i 9bcEy+gyhMtpqIu0FmvRSq4o8sSOwsxEDn4Gk9MvvSliMg/bgGTgYrn5IlN764XnRdoN Y86O3Gv9q/iftqO8SiNi/6SCD9soC8+Tn4xaCnhEVQnwq1w7kFFEZ8UkECYIcm72gQYS hxMmCueB+1TeUBri3FTL/6w+VJIuJ2EXz/JCQwK+6D0txuTfGdD5CERAjAgFJ4f8Y3mC 5/ek1Y9AUOD1U3ufSvZEfBvQS5HQkXFb9kHPQAZcs7LdKiOm+MUB+pd219xkE1j/wIxy XmnA== X-Forwarded-Encrypted: i=1; AJvYcCWvKsXmaE5iLsEn2pLXSODC8lgeWRBee7mr5QLIyKaqfp3j/geFcPQU2oJAh5HXiX38sq64r61lDHU=@lists.xenproject.org X-Gm-Message-State: AOJu0Yzeqy82L/Xo115mahJEYyCZWaKLWBKwOihDTAQHsnrIg5gbfbVM Qkx9ymQqpIlF3AqzmxCIXqsTKxzAurDxr3HMlz4oNXTBX18v5Zi98/nTYlEdjCh5ow== X-Gm-Gg: ATEYQzycvc/mrOMbcQ164UnmbBP5T8TCMR708MRYtsUdxOJEw3Sdw1B7uY0Nq6SeaXJ TBv2XQjyOupmmeg0khGLbi0f1AoE0GvLKsv3oobMSF/v4NQ8mJPUYU1YnSHqhhaYcgyteUWQC3L qb3HK4rZxFtBZPwthvQ3TxrLM7HZhme3n2GPgegKi7MzNTbtTq8smAhO/lfDIHiMuOByJ14x+zC riJ2aw6ZTs5MztbcPcImXqRwESYDZ7VYSOv4fncJhe7rSTDFiy37ZERUkL75gV4QKLSl4+0d5aq iqsb9EJUjyvUIoKH3OKhURCGTUcru1LHb2etsTaXICrutsKI6EG2vbTHXhRrMGvukIw67YolW4L ra5bDcY2lH1wJFWh3h8Zapukor2DI4IHqeWpMLJafse6QFQTmXRJGgtzmmE/aEcEfkU5nnUfgYm pKr8TA70+hy/K1P7c0n9ueh2zpAJZ62AW2KuQWtUNUeH0y23UBmPcbi/3O/eQ4Fc5dOJTF7N4H2 QCZPmN2moOwyiE= X-Received: by 2002:a05:600c:4594:b0:486:ffa3:55f with SMTP id 5b1f17b1804b1-488835d0f0cmr108092575e9.27.1775111096583; Wed, 01 Apr 2026 23:24:56 -0700 (PDT) Message-ID: Date: Thu, 2 Apr 2026 08:24:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] xen/riscv: add exception table support To: Oleksii Kurochko Cc: Romain Caritey , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org References: Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AO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QCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-purgate-ID: tlsNG-16d1c6/1775111097-5D92A3D8-69493B11/0/0 X-purgate-type: clean X-purgate-size: 2982 On 31.03.2026 21:04, Oleksii Kurochko wrote: > --- /dev/null > +++ b/xen/arch/riscv/extable.c > @@ -0,0 +1,85 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +#define EX_FIELD(ptr, field) ((unsigned long)&(ptr)->field + (ptr)->field) > + > +static inline unsigned long ex_insn(const struct exception_table_entry *ex) > +{ > + return EX_FIELD(ex, insn); > +} > + > +static inline unsigned long ex_fixup(const struct exception_table_entry *ex) > +{ > + return EX_FIELD(ex, fixup); > +} > + > +static void __init cf_check swap_ex(void *a, void *b) > +{ > + struct exception_table_entry *x = a, *y = b, tmp; > + long delta = b - a; > + > + tmp = *x; > + x->insn = y->insn + delta; > + y->insn = tmp.insn - delta; > + > + x->fixup = y->fixup + delta; > + y->fixup = tmp.fixup - delta; > +} > + > +static int cf_check cmp_ex(const void *a, const void *b) > +{ > + const unsigned long insn_a = ex_insn(a); > + const unsigned long insn_b = ex_insn(b); > + > + /* avoid overflow */ > + return (insn_a > insn_b) - (insn_a < insn_b); What is the (slightly malformed) comment about? I don't see anything close to possibly causing overflow here. > --- /dev/null > +++ b/xen/arch/riscv/include/asm/extable.h > @@ -0,0 +1,58 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > + > +#ifndef ASM__RISCV__ASM_EXTABLE_H > +#define ASM__RISCV__ASM_EXTABLE_H > + > +#ifdef __ASSEMBLER__ > + > +#define ASM_EXTABLE(insn, fixup) \ > + .pushsection .ex_table, "a"; \ > + .balign 4; \ > + .long ((insn) - .); \ > + .long ((fixup) - .); \ For readability's sake I'm generally advocating for having enough, but not more parentheses than necessary. What's the purpose of the outer pair here and ... > + .popsection; > + > +.macro asm_extable, insn, fixup > + ASM_EXTABLE(\insn, \fixup) > +.endm > + > +#else /* __ASSEMBLER__ */ > + > +#include > +#include > + > +struct cpu_user_regs; > + > +#define ASM_EXTABLE(insn, fixup) \ > + ".pushsection .ex_table, \"a\"\n" \ > + ".balign 4\n" \ > + ".long ((" #insn ") - .)\n" \ > + ".long ((" #fixup ") - .)\n" \ ... here? I'm also uncertain about the use of .long (generally in RISC-V code, and really also in some other architectures). Imo, considering suffixes used in the instruction set (e.g. load/store insns or OP-32 ones in RV64) .word may be the more expressive directive. Preferably with the adjustments: Acked-by: Jan Beulich Happy to carry out while committing, provided you agree. Jan