Linux s390 Architecture development
 help / color / mirror / Atom feed
From: "Christoph Schlameuss" <schlameuss@linux.ibm.com>
To: "Janosch Frank" <frankja@linux.ibm.com>,
	"Christoph Schlameuss" <schlameuss@linux.ibm.com>,
	<kvm@vger.kernel.org>, <linux-s390@vger.kernel.org>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Claudio Imbrenda" <imbrenda@linux.ibm.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Nico Boehr" <nrb@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Sean Christopherson" <seanjc@google.com>
Subject: Re: [PATCH v7 12/21] KVM: s390: vsie: Add helper unshadow_intercept()
Date: Thu, 22 Oct 2026 20:06:57 +0200	[thread overview]
Message-ID: <DMBKFB62ET87.2BDLICLXRFYNS@linux.ibm.com> (raw)
In-Reply-To: <45f3d2f6-75af-41eb-b8b5-a7cf42f345fa@linux.ibm.com>

On Wed Sep 23, 2026 at 4:04 PM CEST, Janosch Frank wrote:
> On 9/18/26 5:09 PM, Christoph Schlameuss wrote:
>> Extract helper method from existing code to reuse in new code.
>> 
>> unshadow_intercept() acts like unshadow_scb() but only copies intercept
>> information. Used where the rest of the scb is not yet shadowed.
>> 
>> Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
>> ---
>>   arch/s390/kvm/s390/vsie.c | 28 ++++++++++++++++++++--------
>>   1 file changed, 20 insertions(+), 8 deletions(-)
>> 
>> diff --git a/arch/s390/kvm/s390/vsie.c b/arch/s390/kvm/s390/vsie.c
>> index 95baac9a1ccb..c42e2df4c0ab 100644
>> --- a/arch/s390/kvm/s390/vsie.c
>> +++ b/arch/s390/kvm/s390/vsie.c
>> @@ -565,18 +565,27 @@ static void prepare_ibc(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
>>   	}
>>   }
>>   
>> -/* unshadow the scb, copying parameters back to the real scb */
>> -static void unshadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
>> +/*
>> + * Only write the interception fields back; avoid clobbering the timer and
>> + * guest-state fields in scb_o.
>> + */
>> +static inline void unshadow_intercept(struct kvm_s390_sie_block *scb_o,
>> +				      struct kvm_s390_sie_block *scb_s)
>>   {
>> -	struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;
>> -	struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;
>> -
>> -	/* interception */
>>   	scb_o->icptcode = scb_s->icptcode;
>>   	scb_o->icptstatus = scb_s->icptstatus;
>>   	scb_o->ipa = scb_s->ipa;
>>   	scb_o->ipb = scb_s->ipb;
>>   	scb_o->gbea = scb_s->gbea;
> I have the feeling that we make things difficult for ourselves by not 
> writing SIE entry validities into the scb_o directly. And I think you 
> somewhat recognized that problem since you chose to write the validity 
> to scb_o and not scb_s in _shadow_sca_cpu() but I have yet to fully read 
> that patch.
>
> For 99% of the validities we've never even entered SIE so we copy data 
> twice for absolutely no reason other than symmetry. out_unshadow in 
> kvm_s390_handle_vsie() isn't really necessary, if pin_blocks() fails we 
> can jump to unpin_scb() if we write the validity to scb_o.
>
> Maybe we could move (un)shadow_scb() into vsie_run() and be done with it.
>
> I have some more reading to do.

The problem I am addressing here is that we can encounter validity problems on
the primary/entering or secondary cpus that we do not actively run yet.
Since this would typically happen when we are shadowing the sca (directed to by
the first scb of that configuration) we need to write the validity somewhere
before potentially even having properly shadowed any scb.

I don't think I am a huge fan of the idea of pulling (un)shadow_scb() into
vsie_run(), as that would mean to also pull in (un)pin_blocks() or risk lots of
potential TOUTOC problems. We have to shadow before checking to avoid them.

Getting rid of the symmetry and writing to scb_o and failing from pin_blocks()
to out_put would be fine IMO. The counter argument here clearly is that this is
complication for the hopefully rather cold error path.

Cheers,
Christoph

  reply	other threads:[~2026-10-22 18:06 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 15:09 [PATCH v7 00/21] KVM: s390: vsie: Add VSIE SIGP ECALL and SRSI Interpretation Christoph Schlameuss
2026-09-18 15:09 ` [PATCH v7 01/21] KVM: s390: vsie: Add SCAO read and write helpers Christoph Schlameuss
2026-09-18 15:14   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 02/21] KVM: s390: vsie: Move SCAO validation into a function Christoph Schlameuss
2026-09-18 15:24   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 03/21] KVM: s390: vsie: Add vsie_interp_extf detection Christoph Schlameuss
2026-09-18 15:15   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 04/21] KVM: s390: vsie: Add ssca_block and ssca_entry structs Christoph Schlameuss
2026-09-18 15:14   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 05/21] KVM: s390: vsie: Move pin/unpin guest page Christoph Schlameuss
2026-09-18 15:16   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 06/21] KVM: s390: vsie: Move pin/unpin_scb methods Christoph Schlameuss
2026-09-18 15:24   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 07/21] KVM: s390: vsie: Move release/acquire gmap shadow Christoph Schlameuss
2026-09-18 15:16   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 08/21] KVM: s390: vsie: Create helpers to alloc and free vsie_pages Christoph Schlameuss
2026-09-18 15:19   ` sashiko-bot
2026-09-23 11:54   ` Janosch Frank
2026-09-24 11:32     ` Christoph Schlameuss
2026-09-18 15:09 ` [PATCH v7 09/21] KVM: s390: vsie: Replace radix_tree with xarray addr_to_page Christoph Schlameuss
2026-09-18 15:25   ` sashiko-bot
2026-09-23 12:40   ` Janosch Frank
2026-09-18 15:09 ` [PATCH v7 10/21] KVM: s390: vsie: Refactor kvm_s390_vsie_destroy and extract reusable methods Christoph Schlameuss
2026-09-18 15:22   ` sashiko-bot
2026-09-23 12:56   ` Janosch Frank
2026-09-18 15:09 ` [PATCH v7 11/21] KVM: s390: vsie: Add helper reset_vsie_page() and unshadow_intercept() Christoph Schlameuss
2026-09-18 15:25   ` sashiko-bot
2026-09-23 12:58   ` Janosch Frank
2026-09-18 15:09 ` [PATCH v7 12/21] KVM: s390: vsie: Add helper unshadow_intercept() Christoph Schlameuss
2026-09-18 15:27   ` sashiko-bot
2026-09-23 14:04   ` Janosch Frank
2026-10-22 18:06     ` Christoph Schlameuss [this message]
2026-09-18 15:09 ` [PATCH v7 13/21] KVM: s390: vsie: Lazily keep original scb pinned after vsie exit Christoph Schlameuss
2026-09-18 15:34   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 14/21] KVM: s390: vsie: Add helper to pin and unpin multiple guest pages Christoph Schlameuss
2026-09-18 15:31   ` sashiko-bot
2026-09-24 12:46   ` Janosch Frank
2026-09-18 15:09 ` [PATCH v7 15/21] KVM: s390: vsie: Add struct vsie_sca with pin and unpin methods Christoph Schlameuss
2026-09-18 15:33   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 16/21] KVM: s390: vsie: Shadow VSIE SCA in guest-1 Christoph Schlameuss
2026-09-18 15:41   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 17/21] KVM: s390: vsie: Allow guest-3 cpu add and remove with ssca Christoph Schlameuss
2026-09-18 15:41   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 18/21] KVM: s390: vsie: Add VSIE max shadow configuration Christoph Schlameuss
2026-09-18 15:45   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 19/21] KVM: s390: vsie: Add VSIE shadow stat counters Christoph Schlameuss
2026-09-18 15:39   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 20/21] KVM: s390: vsie: Create minimal scb shadows for not running g3 blocks Christoph Schlameuss
2026-09-18 15:50   ` sashiko-bot
2026-09-18 15:09 ` [PATCH v7 21/21] KVM: s390: vsie: Enable use of VSIE SSCA Christoph Schlameuss
2026-09-18 15:53   ` sashiko-bot

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=DMBKFB62ET87.2BDLICLXRFYNS@linux.ibm.com \
    --to=schlameuss@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@kernel.org \
    --cc=farman@linux.ibm.com \
    --cc=frankja@linux.ibm.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=seanjc@google.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