From: Heiko Carstens <hca@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, borntraeger@de.ibm.com,
nsg@linux.ibm.com, nrb@linux.ibm.com, frankja@linux.ibm.com,
seiden@linux.ibm.com, agordeev@linux.ibm.com, gor@linux.ibm.com,
gerald.schaefer@linux.ibm.com, kvm@vger.kernel.org,
linux-s390@vger.kernel.org
Subject: Re: [PATCH v3 05/11] s390/mm/fault: Handle guest-related program interrupts in KVM
Date: Wed, 16 Oct 2024 12:05:14 +0200 [thread overview]
Message-ID: <20241016100514.16801-B-hca@linux.ibm.com> (raw)
In-Reply-To: <20241015164326.124987-6-imbrenda@linux.ibm.com>
On Tue, Oct 15, 2024 at 06:43:20PM +0200, Claudio Imbrenda wrote:
> Any program interrupt that happens in the host during the execution of
> a KVM guest will now short circuit the fault handler and return to KVM
> immediately. Guest fault handling (including pfault) will happen
> entirely inside KVM.
>
> When sie64a() returns zero, current->thread.gmap_int_code will contain
> the program interrupt number that caused the exit, or zero if the exit
> was not caused by a host program interrupt.
>
> KVM will now take care of handling all guest faults in vcpu_post_run().
>
> Since gmap faults will not be visible by the rest of the kernel, remove
> GMAP_FAULT, the linux fault handlers for secure execution faults, the
> exception table entries for the sie instruction, the nop padding after
> the sie instruction, and all other references to guest faults from the
> s390 code.
...
> diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
...
> @@ -317,9 +318,23 @@ void noinstr __do_pgm_check(struct pt_regs *regs)
> struct lowcore *lc = get_lowcore();
> irqentry_state_t state;
> unsigned int trapnr;
> + union teid teid = { .val = lc->trans_exc_code };
>
> regs->int_code = lc->pgm_int_code;
> - regs->int_parm_long = lc->trans_exc_code;
> + regs->int_parm_long = teid.val;
> +
> + /*
> + * In case of a guest fault, short-circuit the fault handler and return.
> + * This way the sie64a() function will return 0; fault address and
> + * other relevant bits are saved in current->thread.gmap_teid, and
> + * the fault number in current->thread.gmap_int_code. KVM will be
> + * able to use this information to handle the fault.
> + */
> + if (test_pt_regs_flag(regs, PIF_GUEST_FAULT) && (teid.as == PSW_BITS_AS_PRIMARY)) {
> + current->thread.gmap_teid.val = regs->int_parm_long;
> + current->thread.gmap_int_code = regs->int_code & 0xffff;
> + return;
> + }
This check looks suboptimal to me for two reasons:
- if PIF_GUEST_FAULT is set it should never happen that the normal
exception handling code is executed; it is clearly a bug if that
would happen, and with the above check this may or may not be
recognized with a kernel crash, if I'm not mistaken.
- __do_pgm_check() is executed for all program interruptions. This
includes those interruptions which do not write a teid. Therefore
the above check may do something unexpected depending on what teid a
previous program interruption wrote. I think the teid.as check
should be moved to kvm as well, and only be done for those cases
where it is known that the teid contains a valid value.
next prev parent reply other threads:[~2024-10-16 10:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 16:43 [PATCH v3 00/11] s390/kvm: Handle guest-related program interrupts in KVM Claudio Imbrenda
2024-10-15 16:43 ` [PATCH v3 01/11] s390/entry: Remove __GMAP_ASCE and use _PIF_GUEST_FAULT again Claudio Imbrenda
2024-10-15 16:43 ` [PATCH v3 02/11] s390/kvm: Remove kvm_arch_fault_in_page() Claudio Imbrenda
2024-10-15 16:43 ` [PATCH v3 03/11] s390/mm/gmap: Refactor gmap_fault() and add support for pfault Claudio Imbrenda
2024-10-21 9:41 ` Heiko Carstens
2024-10-15 16:43 ` [PATCH v3 04/11] s390/mm/gmap: Fix __gmap_fault() return code Claudio Imbrenda
2024-10-15 16:43 ` [PATCH v3 05/11] s390/mm/fault: Handle guest-related program interrupts in KVM Claudio Imbrenda
2024-10-16 10:05 ` Heiko Carstens [this message]
2024-10-16 14:34 ` Claudio Imbrenda
2024-10-15 16:43 ` [PATCH v3 06/11] s390/kvm: Stop using gmap_{en,dis}able() Claudio Imbrenda
2024-10-21 9:50 ` Heiko Carstens
2024-10-21 11:45 ` Claudio Imbrenda
2024-10-15 16:43 ` [PATCH v3 07/11] s390/mm/gmap: Remove gmap_{en,dis}able() Claudio Imbrenda
2024-10-21 9:50 ` Heiko Carstens
2024-10-15 16:43 ` [PATCH v3 08/11] s390: Remove gmap pointer from lowcore Claudio Imbrenda
2024-10-21 9:50 ` Heiko Carstens
2024-10-15 16:43 ` [PATCH v3 09/11] s390/mm: Simplify get_fault_type() Claudio Imbrenda
2024-10-15 16:43 ` [PATCH v3 10/11] s390/mm: Get rid of fault type switch statements Claudio Imbrenda
2024-10-15 16:43 ` [PATCH v3 11/11] s390/mm: Convert to LOCK_MM_AND_FIND_VMA Claudio Imbrenda
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=20241016100514.16801-B-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@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=nrb@linux.ibm.com \
--cc=nsg@linux.ibm.com \
--cc=seiden@linux.ibm.com \
/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