From: Fabiano Rosas <farosas@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>, linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH v2 1/2] KVM: PPC: Book3S PR: Disable SCV when AIL could be disabled
Date: Mon, 31 Jan 2022 14:34:57 -0300 [thread overview]
Message-ID: <87zgnbdd1a.fsf@linux.ibm.com> (raw)
In-Reply-To: <20220129072511.105523-2-npiggin@gmail.com>
Nicholas Piggin <npiggin@gmail.com> writes:
> PR KVM does not support running with AIL enabled, and SCV does is not
> supported with AIL disabled. Fix this by ensuring the SCV facility is
> disabled with FSCR while a CPU could be running with AIL=0.
>
> The PowerNV host supports disabling AIL on a per-CPU basis, so SCV just
> needs to be disabled when a vCPU is being run.
>
> The pSeries machine can only switch AIL on a system-wide basis, so it
> must disable SCV support at boot if the configuration can potentially
> run a PR KVM guest.
>
> Also ensure a the FSCR[SCV] bit can not be enabled when emulating
> mtFSCR for the guest.
>
> SCV is not emulated for the PR guest at the moment, this just fixes the
> host crashes.
>
> Alternatives considered and rejected:
> - SCV support can not be disabled by PR KVM after boot, because it is
> advertised to userspace with HWCAP.
> - AIL can not be disabled on a per-CPU basis. At least when running on
> pseries it is a per-LPAR setting.
> - Support for real-mode SCV vectors will not be added because they are
> at 0x17000 so making such a large fixed head space causes immediate
> value limits to be exceeded, requiring a lot rework and more code.
> - Disabling SCV for any PR KVM possible kernel will cause a slowdown
> when not using PR KVM.
> - A boot time option to disable SCV to use PR KVM is user-hostile.
> - System call instruction emulation for SCV facility unavailable
> instructions is too complex and old emulation code was subtly broken
> and removed.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> arch/powerpc/kernel/exceptions-64s.S | 4 ++++
> arch/powerpc/kernel/setup_64.c | 28 ++++++++++++++++++++++++++++
> arch/powerpc/kvm/Kconfig | 9 +++++++++
> arch/powerpc/kvm/book3s_pr.c | 20 ++++++++++++++------
> 4 files changed, 55 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index 55caeee37c08..b66dd6f775a4 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -809,6 +809,10 @@ __start_interrupts:
> * - MSR_EE|MSR_RI is clear (no reentrant exceptions)
> * - Standard kernel environment is set up (stack, paca, etc)
> *
> + * KVM:
> + * These interrupts do not elevate HV 0->1, so HV is not involved. PR KVM
> + * ensures that FSCR[SCV] is disabled whenever it has to force AIL off.
> + *
> * Call convention:
> *
> * syscall register convention is in Documentation/powerpc/syscall64-abi.rst
> diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
> index be8577ac9397..7f7da641e551 100644
> --- a/arch/powerpc/kernel/setup_64.c
> +++ b/arch/powerpc/kernel/setup_64.c
> @@ -197,6 +197,34 @@ static void __init configure_exceptions(void)
>
> /* Under a PAPR hypervisor, we need hypercalls */
> if (firmware_has_feature(FW_FEATURE_SET_MODE)) {
> + /*
> + * - PR KVM does not support AIL mode interrupts in the host
> + * while a PR guest is running.
> + *
> + * - SCV system call interrupt vectors are only implemented for
> + * AIL mode interrupts.
> + *
> + * - On pseries, AIL mode can only be enabled and disabled
> + * system-wide so when a PR VM is created on a pseries host,
> + * all CPUs of the host are set to AIL=0 mode.
> + *
> + * - Therefore host CPUs must not execute scv while a PR VM
> + * exists.
> + *
> + * - SCV support can not be disabled dynamically because the
> + * feature is advertised to host userspace. Disabling the
> + * facility and emulating it would be possible but is not
> + * implemented.
> + *
> + * - So SCV support is blanket diabled if PR KVM could possibly
disabled
Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
next prev parent reply other threads:[~2022-01-31 17:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-29 7:25 [PATCH v2 0/2] KVM: PPC: Book3S PR: Fixes for AIL and SCV Nicholas Piggin
2022-01-29 7:25 ` [PATCH v2 1/2] KVM: PPC: Book3S PR: Disable SCV when AIL could be disabled Nicholas Piggin
2022-01-31 17:34 ` Fabiano Rosas [this message]
2022-02-02 13:09 ` kernel test robot
2022-01-29 7:25 ` [PATCH v2 2/2] KVM: PPC: Book3S PR: Disallow AIL != 0 Nicholas Piggin
2022-01-31 17:30 ` Fabiano Rosas
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=87zgnbdd1a.fsf@linux.ibm.com \
--to=farosas@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.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;
as well as URLs for NNTP newsgroup(s).