From: Janosch Frank <frankja@linux.ibm.com>
To: Christoph Schlameuss <schlameuss@linux.ibm.com>, kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Nico Boehr <nrb@linux.ibm.com>,
David Hildenbrand <david@redhat.com>,
Sven Schnelle <svens@linux.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH RFC v2 08/11] KVM: s390: Allow guest-3 cpu add and remove with vsie sigpif
Date: Tue, 11 Nov 2025 16:47:11 +0100 [thread overview]
Message-ID: <1a694540-3e7b-4453-8f7f-294eaf904afe@linux.ibm.com> (raw)
In-Reply-To: <20251110-vsieie-v2-8-9e53a3618c8c@linux.ibm.com>
On 11/10/25 18:16, Christoph Schlameuss wrote:
> As we are shadowing the SCA we need to add and remove the pointers to
> the shadowed control blocks and sca entries whenever the mcn changes.
>
> It is not expected that the mcn changes frequently for a already running
> guest-3 configuration. So we can simply re-init the ssca whenever the
> mcn changes.
> To detect the mcn change we store the expected mcn in the struct
> vsie_sca when running the ssca init.
>
> Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
> ---
> arch/s390/kvm/vsie.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
> index 72c794945be916cc107aba74e1609d3b4780d4b9..1e15220e1f1ecfd83b10aa0620ca84ff0ff3c1ac 100644
> --- a/arch/s390/kvm/vsie.c
> +++ b/arch/s390/kvm/vsie.c
> @@ -1926,12 +1926,27 @@ static int init_ssca(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page, struct
> return PTR_ERR(vsie_page_n);
> }
>
> +static bool sca_mcn_equals(struct vsie_sca *sca, u64 *mcn)
> +{
> + bool is_esca = test_bit(VSIE_SCA_ESCA, &sca->flags);
> + int i;
> +
> + if (!is_esca)
> + return ((struct bsca_block *)phys_to_virt(sca->ssca->osca))->mcn == *mcn;
> +
> + for (i = 0; i < 4; i++)
> + if (((struct esca_block *)phys_to_virt(sca->ssca->osca))->mcn[i] != sca->mcn[i])
> + return false;
You're reimplementing memcmp(), no?
Instead of casting which makes the comparison really messy you could use
offsetof.
Something like this (+- errors):
void *osca = phys_to_virt(sca->ssca->osca);
int offset = offsetof(struct bsca_block, mcn);
int size = 8;
if (test_bit(VSIE_SCA_ESCA, &sca->flags)) {
size = 8 * 4;
offset = offsetof(struct esca_block, mcn);
}
return !memcmp(osca + offset, mcn, size);
> + return true;
> +}
> +
> /*
> * Shadow the sca on vsie enter.
> */
> static int shadow_sca(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page, struct vsie_sca *sca)
> {
> struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
> + bool do_init_ssca;
> int rc;
>
> vsie_page->sca = sca;
> @@ -1947,8 +1962,9 @@ static int shadow_sca(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page, struct
> if (!use_vsie_sigpif_for(vcpu->kvm, vsie_page))
> return false;
>
> - /* skip if the guest does not have an usable sca */
> - if (!sca->ssca->osca) {
> + do_init_ssca = !sca->ssca->osca;
> + do_init_ssca = do_init_ssca || !sca_mcn_equals(sca, sca->mcn);
> + if (do_init_ssca) {
> rc = init_ssca(vcpu, vsie_page, sca);
> if (rc)
> return rc;
>
next prev parent reply other threads:[~2025-11-11 15:47 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 17:16 [PATCH RFC v2 00/11] KVM: s390: Add VSIE SIGP Interpretation (vsie_sigpif) Christoph Schlameuss
2025-11-10 17:16 ` [PATCH RFC v2 01/11] KVM: s390: Add SCAO read and write helpers Christoph Schlameuss
2025-11-11 13:45 ` Claudio Imbrenda
2025-11-11 14:37 ` Christoph Schlameuss
2025-11-11 14:55 ` Claudio Imbrenda
2025-11-10 17:16 ` [PATCH RFC v2 02/11] KVM: s390: Remove double 64bscao feature check Christoph Schlameuss
2025-11-10 21:32 ` Eric Farman
2025-11-11 8:13 ` Hendrik Brueckner
2025-11-11 13:20 ` Janosch Frank
2025-11-10 17:16 ` [PATCH RFC v2 03/11] KVM: s390: Move scao validation into a function Christoph Schlameuss
2025-11-10 21:30 ` Eric Farman
2025-11-11 8:48 ` Christoph Schlameuss
2025-11-10 17:16 ` [PATCH RFC v2 04/11] KVM: s390: Add vsie_sigpif detection Christoph Schlameuss
2025-11-10 17:16 ` [PATCH RFC v2 05/11] KVM: s390: Add ssca_block and ssca_entry structs for vsie_ie Christoph Schlameuss
2025-11-10 17:16 ` [PATCH RFC v2 06/11] KVM: s390: Add helper to pin multiple guest pages Christoph Schlameuss
2025-11-13 15:24 ` Janosch Frank
2025-11-10 17:16 ` [PATCH RFC v2 07/11] KVM: s390: Shadow VSIE SCA in guest-1 Christoph Schlameuss
2025-11-14 14:09 ` Janosch Frank
2025-11-17 15:39 ` Christoph Schlameuss
2025-11-17 15:22 ` Janosch Frank
2025-11-18 9:27 ` Christoph Schlameuss
2025-11-18 16:04 ` Janosch Frank
2025-11-21 15:10 ` Christoph Schlameuss
2025-11-20 11:15 ` Janosch Frank
2025-11-10 17:16 ` [PATCH RFC v2 08/11] KVM: s390: Allow guest-3 cpu add and remove with vsie sigpif Christoph Schlameuss
2025-11-11 15:47 ` Janosch Frank [this message]
2025-11-11 16:34 ` Christoph Schlameuss
2025-11-10 17:16 ` [PATCH RFC v2 09/11] KVM: s390: Allow guest-3 switch to extended sca " Christoph Schlameuss
2025-11-11 14:18 ` Janosch Frank
2025-11-10 17:16 ` [PATCH RFC v2 10/11] KVM: s390: Add VSIE shadow configuration Christoph Schlameuss
2025-11-20 11:02 ` Janosch Frank
2025-11-24 10:57 ` Christoph Schlameuss
2025-11-10 17:16 ` [PATCH RFC v2 11/11] KVM: s390: Add VSIE shadow stat counters Christoph Schlameuss
2025-11-20 11:07 ` Janosch Frank
2025-11-24 10:59 ` Christoph Schlameuss
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=1a694540-3e7b-4453-8f7f-294eaf904afe@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@redhat.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=schlameuss@linux.ibm.com \
--cc=shuah@kernel.org \
--cc=svens@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;
as well as URLs for NNTP newsgroup(s).