public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: Andrew Donnellan <ajd@linux.ibm.com>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>
Cc: Nicholas Miehlbradt <nicholas@linux.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Andy Lutomirski <luto@kernel.org>,
	David Hildenbrand <david@kernel.org>
Subject: Re: [PATCH v2 2/3] KVM: s390: Enable and disable interrupts in entry code
Date: Wed, 26 Nov 2025 13:31:30 +0100	[thread overview]
Message-ID: <6a717d9b-3771-41f2-9964-442fb6f68fb2@linux.ibm.com> (raw)
In-Reply-To: <20251126-s390-kvm-xfer-to-guest-work-v2-2-1b8767879235@linux.ibm.com>

On 11/26/25 06:33, Andrew Donnellan wrote:
> From: Heiko Carstens <hca@linux.ibm.com>
> 
> Move enabling and disabling of interrupts around the SIE instruction to
> entry code. Enabling interrupts only after the __TI_sie flag has been set
> guarantees that the SIE instruction is not executed if an interrupt happens
> between enabling interrupts and the execution of the SIE instruction.
> Interrupt handlers and machine check handler forward the PSW to the
> sie_exit label in such cases.
> 
> This is a prerequisite for VIRT_XFER_TO_GUEST_WORK to prevent that guest
> context is entered when e.g. a scheduler IPI, indicating that a reschedule
> is required, happens right before the SIE instruction, which could lead to
> long delays.
> 
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> Tested-by: Andrew Donnellan <ajd@linux.ibm.com>
> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>


Reviewed-by: Janosch Frank <frankja@linux.ibm.com>

> ---
>   arch/s390/include/asm/stacktrace.h | 1 +
>   arch/s390/kernel/asm-offsets.c     | 1 +
>   arch/s390/kernel/entry.S           | 2 ++
>   arch/s390/kvm/kvm-s390.c           | 5 -----
>   4 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/s390/include/asm/stacktrace.h b/arch/s390/include/asm/stacktrace.h
> index 810a6b9d96280f73311de873ad180c59a0cfbd5f..c9ae680a28af910c4703eee179be4db6c1ec9ad1 100644
> --- a/arch/s390/include/asm/stacktrace.h
> +++ b/arch/s390/include/asm/stacktrace.h
> @@ -66,6 +66,7 @@ struct stack_frame {
>   			unsigned long sie_flags;
>   			unsigned long sie_control_block_phys;
>   			unsigned long sie_guest_asce;
> +			unsigned long sie_irq;
>   		};
>   	};
>   	unsigned long gprs[10];
> diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
> index a8915663e917faed4551276b64013ee073662cc9..730449f464aff25761264b00d63d92e907f17f78 100644
> --- a/arch/s390/kernel/asm-offsets.c
> +++ b/arch/s390/kernel/asm-offsets.c
> @@ -64,6 +64,7 @@ int main(void)
>   	OFFSET(__SF_SIE_FLAGS, stack_frame, sie_flags);
>   	OFFSET(__SF_SIE_CONTROL_PHYS, stack_frame, sie_control_block_phys);
>   	OFFSET(__SF_SIE_GUEST_ASCE, stack_frame, sie_guest_asce);
> +	OFFSET(__SF_SIE_IRQ, stack_frame, sie_irq);
>   	DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame));
>   	BLANK();
>   	OFFSET(__SFUSER_BACKCHAIN, stack_frame_user, back_chain);
> diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
> index 75b0fbb236d05f420b20cac6bac925e8ac36fa68..e906f4ab6cf35e53061a27192911629c10c347ed 100644
> --- a/arch/s390/kernel/entry.S
> +++ b/arch/s390/kernel/entry.S
> @@ -189,6 +189,7 @@ SYM_FUNC_START(__sie64a)
>   	mvc	__SF_SIE_FLAGS(8,%r15),__TI_flags(%r14) # copy thread flags
>   	lmg	%r0,%r13,0(%r4)			# load guest gprs 0-13
>   	mvi	__TI_sie(%r14),1
> +	stosm	__SF_SIE_IRQ(%r15),0x03		# enable interrupts
>   	lctlg	%c1,%c1,__SF_SIE_GUEST_ASCE(%r15) # load primary asce
>   	lg	%r14,__SF_SIE_CONTROL(%r15)	# get control block pointer
>   	oi	__SIE_PROG0C+3(%r14),1		# we are going into SIE now
> @@ -212,6 +213,7 @@ SYM_FUNC_START(__sie64a)
>   	lg	%r14,__LC_CURRENT(%r14)
>   	mvi	__TI_sie(%r14),0
>   SYM_INNER_LABEL(sie_exit, SYM_L_GLOBAL)
> +	stnsm	__SF_SIE_IRQ(%r15),0xfc		# disable interrupts
>   	lg	%r14,__SF_SIE_SAVEAREA(%r15)	# load guest register save area
>   	stmg	%r0,%r13,0(%r14)		# save guest gprs 0-13
>   	xgr	%r0,%r0				# clear guest registers to
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index fa6b5150ca31e4d9f0bdafabc1fb1d90ef3f3d0d..3cad08662b3d80aaf6f5f8891fc08b383c3c44d4 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -5075,13 +5075,8 @@ int noinstr kvm_s390_enter_exit_sie(struct kvm_s390_sie_block *scb,
>   	 * The guest_state_{enter,exit}_irqoff() functions inform lockdep and
>   	 * tracing that entry to the guest will enable host IRQs, and exit from
>   	 * the guest will disable host IRQs.
> -	 *
> -	 * We must not use lockdep/tracing/RCU in this critical section, so we
> -	 * use the low-level arch_local_irq_*() helpers to enable/disable IRQs.
>   	 */
> -	arch_local_irq_enable();
>   	ret = sie64a(scb, gprs, gasce);
> -	arch_local_irq_disable();
>   
>   	guest_state_exit_irqoff();
>   
> 


  reply	other threads:[~2025-11-26 12:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26  5:33 [PATCH v2 0/3] KVM: s390: Use generic VIRT_XFER_TO_GUEST_WORK entry helpers Andrew Donnellan
2025-11-26  5:33 ` [PATCH v2 1/3] KVM: s390: Add signal_exits counter Andrew Donnellan
2025-11-26 12:23   ` Janosch Frank
2025-11-26  5:33 ` [PATCH v2 2/3] KVM: s390: Enable and disable interrupts in entry code Andrew Donnellan
2025-11-26 12:31   ` Janosch Frank [this message]
2025-11-26  5:33 ` [PATCH v2 3/3] KVM: s390: Use generic VIRT_XFER_TO_GUEST_WORK functions Andrew Donnellan
2025-11-27 14:37   ` Janosch Frank

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a717d9b-3771-41f2-9964-442fb6f68fb2@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=ajd@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=nicholas@linux.ibm.com \
    --cc=peterz@infradead.org \
    --cc=svens@linux.ibm.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox