From patchwork Mon Jan 22 13:48:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13525498 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 8CD6CC47DDB for ; Mon, 22 Jan 2024 13:48:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.669903.1042403 (Exim 4.92) (envelope-from ) id 1rRuf0-0007MF-Hj; Mon, 22 Jan 2024 13:48:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 669903.1042403; Mon, 22 Jan 2024 13:48:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rRuf0-0007M8-Ec; Mon, 22 Jan 2024 13:48:22 +0000 Received: by outflank-mailman (input) for mailman id 669903; Mon, 22 Jan 2024 13:48:22 +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 1rRuf0-0007Lx-1r for xen-devel@lists.xenproject.org; Mon, 22 Jan 2024 13:48:22 +0000 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [2a00:1450:4864:20::231]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e6f1ea63-b92c-11ee-9b0f-b553b5be7939; Mon, 22 Jan 2024 14:48:20 +0100 (CET) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2cd0d05838fso36520391fa.1 for ; Mon, 22 Jan 2024 05:48:20 -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 cw13-20020a05663849cd00b0046e627dbc4csm3035114jab.121.2024.01.22.05.48.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jan 2024 05:48:19 -0800 (PST) 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: e6f1ea63-b92c-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1705931299; x=1706536099; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=F6sfSK5/SEtKGPEcmvIsDK1a/u9AKBGy1bR54EVhbWU=; b=OkSR/V9YdLw27FJ3+jZ+yGWSCEr+yYIVAjEQLVa02rFBDSG8I+LEM+FUIHsP1yBFAX bnGDrnR7HCk3lkkAM19hCjOKP880fNZvXCToqSbyIRn+YCBT7hxy/CAv1TkgfnbD0HKT oTprAv7y50N2S4i2N1+6DViK6UxIcANVkTwpNmQubBWiOFX35IIgGK743DBk1wCRkfUW /GfKFKkSIJ6jIrLqBJ3NC3al/nAUrpYtVtQ72KgrHRJrY2mopshHks+E87GOjxXnmRjq cBhhGDpLTzLvlCiHKKrLAJc2/byUA/03guijnWZ6C3miPy3i3JH+23ct4tIlvv5pPUpv UPeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705931299; x=1706536099; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F6sfSK5/SEtKGPEcmvIsDK1a/u9AKBGy1bR54EVhbWU=; b=N4N4C4LE1G8aEV7NG98ygFEY9U9vBBwJWQ1YyM3iMXsKr1oqMFjDpAIpVbYxtiwxHz shltwzrdbPwuYpH0h1myohdbMC8j4Y5mQdPc8myyat96oc2dmqj61Mnb6nsGxWJcp9iX hmTFgUypZqOUiXB3ult3ypVWDsf0jWuV9R9LScjv1AEKx81JgwtNFyC8ooLBQHKIGMSd p1jrNthtatmD9lfhLx2E7y6UFYt2DrlXdeLoasRKOPLaut4joa0V52CXg8OGkE9g+SEw 6cj9dnect4L6nFNjGs8F3n+2JEeHKQnWrbLuzKd+oMBstohHX+jq8VSs9BNIs/MmnkUm qNSA== X-Gm-Message-State: AOJu0YxIF8RSWwhtfyH2rjtmF+DT8fVhw54b+W8hiLF+pkq03ej+vRzt 5pJ624W/JljB9XX7pYPMZqqpqlzXLNJIcANP2ty/le6jAkdswYtxNhuxPfa0Jc7AQBHlKpjf3BY = X-Google-Smtp-Source: AGHT+IEy0es+DcUtS81PJaJXL6AOMKdRsEhFyA0WPkwSR99PlWMJIilCPgx048+qJuGD0Z+dZczjLA== X-Received: by 2002:a2e:b0f4:0:b0:2cc:603f:5cd7 with SMTP id h20-20020a2eb0f4000000b002cc603f5cd7mr1722201ljl.6.1705931299498; Mon, 22 Jan 2024 05:48:19 -0800 (PST) Message-ID: <03da16df-2d31-495e-9757-17e329b89d8d@suse.com> Date: Mon, 22 Jan 2024 14:48:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 1/8] IRQ: generalize [gs]et_irq_regs() 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 References: <33db57a2-b569-4fa8-b0b0-36ea92528d7b@suse.com> Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwG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lNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <33db57a2-b569-4fa8-b0b0-36ea92528d7b@suse.com> Move functions (and their data) to common code, and invoke the functions on Arm as well. This is in preparation of dropping the register parameters from handler functions. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Reviewed-by: Julien Grall --- To limit visibility of the per-CPU data item, we may want to consider making the functions out-of-line ones (in common/irq.c). --- v2: Add a blank line. --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -221,6 +221,7 @@ void do_IRQ(struct cpu_user_regs *regs, { struct irq_desc *desc = irq_to_desc(irq); struct irqaction *action; + struct cpu_user_regs *old_regs = set_irq_regs(regs); perfc_incr(irqs); @@ -288,6 +289,7 @@ out: out_no_end: spin_unlock(&desc->lock); irq_exit(); + set_irq_regs(old_regs); } void release_irq(unsigned int irq, const void *dev_id) --- a/xen/arch/x86/include/asm/irq.h +++ b/xen/arch/x86/include/asm/irq.h @@ -70,27 +70,6 @@ extern bool opt_noirqbalance; extern int opt_irq_vector_map; -/* - * Per-cpu current frame pointer - the location of the last exception frame on - * the stack - */ -DECLARE_PER_CPU(struct cpu_user_regs *, __irq_regs); - -static inline struct cpu_user_regs *get_irq_regs(void) -{ - return this_cpu(__irq_regs); -} - -static inline struct cpu_user_regs *set_irq_regs(struct cpu_user_regs *new_regs) -{ - struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(__irq_regs); - - old_regs = *pp_regs; - *pp_regs = new_regs; - return old_regs; -} - - #define platform_legacy_irq(irq) ((irq) < 16) void cf_check event_check_interrupt(struct cpu_user_regs *regs); --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -53,8 +53,6 @@ static DEFINE_SPINLOCK(vector_lock); DEFINE_PER_CPU(vector_irq_t, vector_irq); -DEFINE_PER_CPU(struct cpu_user_regs *, __irq_regs); - static LIST_HEAD(irq_ratelimit_list); static DEFINE_SPINLOCK(irq_ratelimit_lock); static struct timer irq_ratelimit_timer; --- a/xen/common/irq.c +++ b/xen/common/irq.c @@ -1,6 +1,8 @@ #include #include +DEFINE_PER_CPU(struct cpu_user_regs *, irq_regs); + int init_one_irq_desc(struct irq_desc *desc) { int err; --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -131,6 +131,27 @@ void cf_check irq_actor_none(struct irq_ #define irq_disable_none irq_actor_none #define irq_enable_none irq_actor_none +/* + * Per-cpu interrupted context register state - the inner-most interrupt frame + * on the stack. + */ +DECLARE_PER_CPU(struct cpu_user_regs *, irq_regs); + +static inline struct cpu_user_regs *get_irq_regs(void) +{ + return this_cpu(irq_regs); +} + +static inline struct cpu_user_regs *set_irq_regs(struct cpu_user_regs *new_regs) +{ + struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(irq_regs); + + old_regs = *pp_regs; + *pp_regs = new_regs; + + return old_regs; +} + struct domain; struct vcpu;