From nobody Mon Sep 16 18:57:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1707139975; cv=none; d=zohomail.com; s=zohoarc; b=nf6kCYxb4dnAzusQ+lgIVmmys4jiIWwfz4R2aWVgfFgMY98F7TcLHXysNj6C2U81HvibjYyiHGNLctTn/mC6LlWDxOl9r4VlseVre+OH5ysTxqgLJ+wwWNkn2ghl0aPWi9f6N0Bf/5su3hKG6899CHPD/gUnegm1BXysSXlUNok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707139975; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l1ReB3jZD1WlYuF9U7WzsUOq1WPtCay0Ptk0kyAo6EU=; b=VIpOhXcgyGVVxSjcN/nPXfdmteP7lN21SMljpNONVvKOLGzgoZzFnABLm1A8Uxh7/he5hwG8jB43Q6jp7BUxad9uv0F9rDHelS+DXApSYW8ypv6PxwY860XYtrdzcw6Jyr0L/dAlr9J8Xutbi0Wwo/bflbLKwywQA9U29YyIWNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1707139975702790.9023861260662; Mon, 5 Feb 2024 05:32:55 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.676063.1051863 (Exim 4.92) (envelope-from ) id 1rWz5V-0006zk-EM; Mon, 05 Feb 2024 13:32:41 +0000 Received: by outflank-mailman (output) from mailman id 676063.1051863; Mon, 05 Feb 2024 13:32:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rWz5V-0006zd-B0; Mon, 05 Feb 2024 13:32:41 +0000 Received: by outflank-mailman (input) for mailman id 676063; Mon, 05 Feb 2024 13:32:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rWz5T-0006zC-KT for xen-devel@lists.xenproject.org; Mon, 05 Feb 2024 13:32:39 +0000 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [2a00:1450:4864:20::32f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 06b4388b-c42b-11ee-98f5-efadbce2ee36; Mon, 05 Feb 2024 14:32:37 +0100 (CET) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-40fcb4ef7bcso24017385e9.0 for ; Mon, 05 Feb 2024 05:32:37 -0800 (PST) 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 n10-20020a5d67ca000000b0033b3cf1ff09sm2278382wrw.29.2024.02.05.05.32.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Feb 2024 05:32:36 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: 06b4388b-c42b-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707139956; x=1707744756; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=l1ReB3jZD1WlYuF9U7WzsUOq1WPtCay0Ptk0kyAo6EU=; b=OsdNTd6VMeUh4ga+XuwOrHQkxh7A6GWbkpi5eCDqNmXBkK834Jk91+PHum1oZG0uRY IbeMiLbL5Qcsp0gAJN2LvqZX9zOZb3D7Ex9VTfhtK91vPnvcB3e6bGEzOIo92tFh40HQ zY456ruFJqnqln0ALSAajjDy4OgmqWiB/QcBCFTZwxkrVwjiMN1CYanWby17eoWp6+rm WOt82awziojisi29NohcHVLvrug6WuVEYYY7qIsgqLDOQbNtCZ6pMMMbvgY7gVeAwfyr lMXhzKY6lwYYKLYIxOhtJ+aX4853V52XNuHTx2S4oP827WCjoKNAkVdg6BFD2lzTGult WSfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707139956; x=1707744756; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=l1ReB3jZD1WlYuF9U7WzsUOq1WPtCay0Ptk0kyAo6EU=; b=kObTvxeaDCx9jVG2wR7dMXqgkc/SOPy93t5UEIkcCw4JVKLaHkvgIr3phM5ZkHdPoz CvMnEeLe7n8E4vc36YSQjFgGhgyJtGhP1z1mexpKMjlDefspBLD8NyoJZ53vxZnVRvez 79QGkTmUuLi3mqt51Xi+BCl5e+YKubCOU3/wzIYrhTVRmtzpwncU2NGGDt2rEVilr9gR BpzYiVqWvTTIJ7dWUl/Y0mz9Nrc7xzfVdwY5wIxIlBEpiVLn8nTB4M7xPC/3/D33+ETj ZrhvecvoNs/Z19hHBa4NtvCl0EfvrXEYHEdNQ9wsedRXJ/qR8PihAlKP10ML25KWn8YI tIRA== X-Gm-Message-State: AOJu0YxJqQwAQN+KpEOjBjZ6RBXbvelnNZ/lZ8+XkVL0PJCd2jM5fK1+ pP55waFQkGLwK7rs6WO8bAMLBQGp2INcyA+u+dtjPlP0EdZ8xaWUfITLREbr9W2qhXEPg/H5jU4 = X-Google-Smtp-Source: AGHT+IF5ujFRkwOP55BlIw1cbRp7a5E9Ub1z36GcCR65nDdw4WLhkgsaaFcxuA6JhcSbFMJ2OgtpNg== X-Received: by 2002:adf:fc07:0:b0:33b:381f:a89d with SMTP id i7-20020adffc07000000b0033b381fa89dmr2590949wrr.67.1707139956605; Mon, 05 Feb 2024 05:32:36 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUzG0P9zKzwFHwq5DPm4P9WDTXo3Zio+7hklMnfnsR5ZTOxFq+l7Aqqzb3rFGSatuJAUaPnHDX7I0n1fg8v7aPhvjDIsY42b2FhjXJRSW9pGCldwZTGy8+jl8BqgNMT7rDsN0WOdDG48EnSZ75tczgGbRCqN7de3njxXpq9UMLcU+Wzsi5Uzldk91rLha61HW8jwbDJWtGQN7avnT+dRarUUie1fDPZhpHozEAHlpjVA4shmyUOXSRZ5INT2kXwEdxTEUA/togY1DNLDDEMeFkiy2B1COzJJtqHOBYWylo= Message-ID: Date: Mon, 5 Feb 2024 14:32:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 8/8] consolidate do_bug_frame() / bug_fn_t Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk References: Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6z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/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1707139977995100001 Content-Type: text/plain; charset="utf-8" The type not being used in do_bug_frame() is suspicious. Apparently that's solely because the type uses a pointer-to-const parameter, when so far run_in_exception_handler() wanted functions taking pointer- to-non-const. Expand use of const, in turn requiring common code's do_bug_frame() as well as [gs]et_irq_regs() to also gain const. This then brings the former function also closer to the common one, with Arm's use of vaddr_t remaining as a difference. While there also replace the bogus use of hard tabs in [gs]et_irq_regs() (I clearly didn't mean to put it in like this). Signed-off-by: Jan Beulich Acked-by: Julien Grall Reviewed-by: Andrew Cooper --- This is an alternative proposal to https://lists.xen.org/archives/html/xen-devel/2023-12/msg01385.html. --- v3: Retain / extend use of const. Make part of series. v2: [skipped] --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -220,7 +220,7 @@ void do_IRQ(struct cpu_user_regs *regs, { struct irq_desc *desc =3D irq_to_desc(irq); struct irqaction *action; - struct cpu_user_regs *old_regs =3D set_irq_regs(regs); + const struct cpu_user_regs *old_regs =3D set_irq_regs(regs); =20 perfc_incr(irqs); =20 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -409,8 +409,7 @@ static always_inline void rep_nop(void) void show_code(const struct cpu_user_regs *regs); void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *reg= s); void show_registers(const struct cpu_user_regs *regs); -#define dump_execution_state() \ - run_in_exception_handler(show_execution_state_nonconst) +#define dump_execution_state() run_in_exception_handler(show_execution_sta= te) void show_page_walk(unsigned long addr); void noreturn fatal_trap(const struct cpu_user_regs *regs, bool show_remot= e); =20 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1896,7 +1896,7 @@ void do_IRQ(struct cpu_user_regs *regs) struct irq_desc *desc; unsigned int vector =3D (uint8_t)regs->entry_vector; int irq =3D this_cpu(vector_irq)[vector]; - struct cpu_user_regs *old_regs =3D set_irq_regs(regs); + const struct cpu_user_regs *old_regs =3D set_irq_regs(regs); =20 perfc_incr(irqs); this_cpu(irq_count)++; --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -643,7 +643,7 @@ void show_stack_overflow(unsigned int cp printk("\n"); } =20 -void show_execution_state(const struct cpu_user_regs *regs) +void cf_check show_execution_state(const struct cpu_user_regs *regs) { /* Prevent interleaving of output. */ unsigned long flags =3D console_lock_recursive_irqsave(); @@ -655,11 +655,6 @@ void show_execution_state(const struct c console_unlock_recursive_irqrestore(flags); } =20 -void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs) -{ - show_execution_state(regs); -} - void vcpu_show_execution_state(struct vcpu *v) { unsigned long flags =3D 0; --- a/xen/common/bug.c +++ b/xen/common/bug.c @@ -10,7 +10,7 @@ * Returns a negative value in case of an error otherwise * BUGFRAME_{run_fn, warn, bug, assert} */ -int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc) +int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc) { const struct bug_frame *bug =3D NULL; const struct virtual_region *region; @@ -44,14 +44,10 @@ int do_bug_frame(struct cpu_user_regs *r =20 if ( id =3D=3D BUGFRAME_run_fn ) { - void (*fn)(struct cpu_user_regs *) =3D bug_ptr(bug); + bug_fn_t *fn =3D bug_ptr(bug); =20 fn(regs); =20 - /* Re-enforce consistent types, because of the casts involved. */ - if ( false ) - run_in_exception_handler(fn); - return id; } =20 --- a/xen/common/irq.c +++ b/xen/common/irq.c @@ -1,7 +1,7 @@ #include #include =20 -DEFINE_PER_CPU(struct cpu_user_regs *, irq_regs); +DEFINE_PER_CPU(const struct cpu_user_regs *, irq_regs); =20 int init_one_irq_desc(struct irq_desc *desc) { --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -135,7 +135,7 @@ static void cf_check show_handlers(unsig =20 static cpumask_t dump_execstate_mask; =20 -void cf_check dump_execstate(struct cpu_user_regs *regs) +void cf_check dump_execstate(const struct cpu_user_regs *regs) { unsigned int cpu =3D smp_processor_id(); =20 --- a/xen/drivers/char/ehci-dbgp.c +++ b/xen/drivers/char/ehci-dbgp.c @@ -1246,14 +1246,14 @@ static int cf_check ehci_dbgp_getc(struc /* Safe: ehci_dbgp_poll() runs as timer handler, so not reentrant. */ static struct serial_port *poll_port; =20 -static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs) +static void cf_check _ehci_dbgp_poll(const struct cpu_user_regs *regs) { struct serial_port *port =3D poll_port; struct ehci_dbgp *dbgp =3D port->uart; unsigned long flags; unsigned int timeout =3D MICROSECS(DBGP_CHECK_INTERVAL); bool empty =3D false; - struct cpu_user_regs *old_regs; + const struct cpu_user_regs *old_regs; =20 if ( !dbgp->ehci_debug ) return; --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -206,11 +206,11 @@ static void cf_check ns16550_interrupt(i /* Safe: ns16550_poll() runs as softirq so not reentrant on a given CPU. */ static DEFINE_PER_CPU(struct serial_port *, poll_port); =20 -static void cf_check __ns16550_poll(struct cpu_user_regs *regs) +static void cf_check __ns16550_poll(const struct cpu_user_regs *regs) { struct serial_port *port =3D this_cpu(poll_port); struct ns16550 *uart =3D port->uart; - struct cpu_user_regs *old_regs; + const struct cpu_user_regs *old_regs; =20 if ( uart->intr_works ) return; /* Interrupts work - no more polling */ --- a/xen/drivers/char/xhci-dbc.c +++ b/xen/drivers/char/xhci-dbc.c @@ -1164,7 +1164,7 @@ static void cf_check dbc_uart_poll(void struct dbc_uart *uart =3D port->uart; struct dbc *dbc =3D &uart->dbc; unsigned long flags =3D 0; - struct cpu_user_regs *old_regs; + const struct cpu_user_regs *old_regs; =20 if ( spin_trylock_irqsave(&port->tx_lock, flags) ) { --- a/xen/include/xen/bug.h +++ b/xen/include/xen/bug.h @@ -101,8 +101,7 @@ typedef void bug_fn_t(const struct cpu_u =20 #ifndef run_in_exception_handler =20 -static void always_inline run_in_exception_handler( - void (*fn)(struct cpu_user_regs *regs)) +static void always_inline run_in_exception_handler(bug_fn_t *fn) { BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL); } @@ -133,7 +132,7 @@ static void always_inline run_in_excepti * Returns a negative value in case of an error otherwise * BUGFRAME_{run_fn, warn, bug, assert} */ -int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc); +int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc); =20 #endif /* CONFIG_GENERIC_BUG_FRAME */ =20 --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -134,21 +134,22 @@ void cf_check irq_actor_none(struct irq_ * Per-cpu interrupted context register state - the inner-most interrupt f= rame * on the stack. */ -DECLARE_PER_CPU(struct cpu_user_regs *, irq_regs); +DECLARE_PER_CPU(const struct cpu_user_regs *, irq_regs); =20 -static inline struct cpu_user_regs *get_irq_regs(void) +static inline const struct cpu_user_regs *get_irq_regs(void) { - return this_cpu(irq_regs); + return this_cpu(irq_regs); } =20 -static inline struct cpu_user_regs *set_irq_regs(struct cpu_user_regs *new= _regs) +static inline const struct cpu_user_regs *set_irq_regs( + const struct cpu_user_regs *new_regs) { - struct cpu_user_regs *old_regs, **pp_regs =3D &this_cpu(irq_regs); + const struct cpu_user_regs *old_regs, **pp_regs =3D &this_cpu(irq_regs= ); =20 - old_regs =3D *pp_regs; - *pp_regs =3D new_regs; + old_regs =3D *pp_regs; + *pp_regs =3D new_regs; =20 - return old_regs; + return old_regs; } =20 struct domain; --- a/xen/include/xen/kernel.h +++ b/xen/include/xen/kernel.h @@ -110,8 +110,7 @@ extern const unsigned int xen_config_dat struct cpu_user_regs; struct vcpu; =20 -void show_execution_state(const struct cpu_user_regs *regs); -void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs); +void cf_check show_execution_state(const struct cpu_user_regs *regs); void vcpu_show_execution_state(struct vcpu *v); =20 #endif /* _LINUX_KERNEL_H */ --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -173,7 +173,7 @@ extern char *print_tainted(char *str); extern void add_taint(unsigned int taint); =20 struct cpu_user_regs; -void cf_check dump_execstate(struct cpu_user_regs *regs); +void cf_check dump_execstate(const struct cpu_user_regs *regs); =20 void init_constructors(void);