Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Nico Boehr <nrb@linux.ibm.com>
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, thuth@redhat.com,
	pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v1 1/3] s390x: add library for skey-related functions
Date: Thu, 1 Dec 2022 17:46:34 +0100	[thread overview]
Message-ID: <20221201174634.57a1a44a@p-imbrenda> (raw)
In-Reply-To: <166991014258.186408.12012997417078839512@t14-nrb.local>

On Thu, 01 Dec 2022 16:55:42 +0100
Nico Boehr <nrb@linux.ibm.com> wrote:

> Quoting Claudio Imbrenda (2022-12-01 14:16:50)
> > On Thu,  1 Dec 2022 09:46:40 +0100
> > Nico Boehr <nrb@linux.ibm.com> wrote:  
> [...]
> > > diff --git a/lib/s390x/skey.c b/lib/s390x/skey.c
> > > new file mode 100644
> > > index 000000000000..100f0949a244  
> [...]
> > > +/*
> > > + * Set storage keys on pagebuf.  

... according to a pattern

> > 
> > surely you should explain better what the function does (e.g. how are
> > you setting the keys and why)  
> 
> Well there is the comment below which explains why the * 2 is needed, so what
> about this paragraph (after merging the commits as discussed before):
> 
>     * Each page's storage key is generated by taking the page's index in pagebuf,
>     * XOR-ing that with the given seed and then multipling the result with two.

looks good

> 
> (But really that's also easy to see from the code below, so I am not sure if
> this really adds value.)

if you want to add documentation, do it properly, otherwise there is no
point in having documentation at all :)

> 
> > > + * pagebuf must point to page_count consecutive pages.
> > > + */
> > > +void skey_set_keys(uint8_t *pagebuf, unsigned long page_count)  
> > 
> > this name does not make clear what the function is doing. at first one
> > would think that it sets the same key for all pages.
> > 
> > maybe something like set_storage_keys_test_pattern or
> > skey_set_test_pattern or something like that  
> 
> Oh that's a nice suggestion, thanks.
> 
> >   
> > > +{
> > > +     unsigned char key_to_set;
> > > +     unsigned long i;
> > > +
> > > +     for (i = 0; i < page_count; i++) {
> > > +             /*
> > > +              * Storage keys are 7 bit, lowest bit is always returned as zero
> > > +              * by iske.
> > > +              * This loop will set all 7 bits which means we set fetch
> > > +              * protection as well as reference and change indication for
> > > +              * some keys.
> > > +              */
> > > +             key_to_set = i * 2;
> > > +             set_storage_key(pagebuf + i * PAGE_SIZE, key_to_set, 1);  
> > 
> > why not just i * 2 instead of using key_to_set ?  
> 
> Well you answered that yourself :)
> 
> In patch 2, the key_to_set expression becomes a bit more complex, so the extra
> variable makes sense to me.

fair enough

  reply	other threads:[~2022-12-01 16:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01  8:46 [kvm-unit-tests PATCH v1 0/3] s390x: test storage keys during migration Nico Boehr
2022-12-01  8:46 ` [kvm-unit-tests PATCH v1 1/3] s390x: add library for skey-related functions Nico Boehr
2022-12-01 13:16   ` Claudio Imbrenda
2022-12-01 15:55     ` Nico Boehr
2022-12-01 16:46       ` Claudio Imbrenda [this message]
2022-12-02  9:03   ` Janosch Frank
2022-12-02  9:09     ` Thomas Huth
2022-12-02 10:44       ` Nico Boehr
2022-12-02 11:32         ` Thomas Huth
2022-12-02 11:56           ` Janosch Frank
2022-12-02 12:48             ` Thomas Huth
2022-12-02 12:56               ` Claudio Imbrenda
2022-12-09  9:02                 ` Nico Boehr
2022-12-02 10:39     ` Nico Boehr
2022-12-02 11:20       ` Janosch Frank
2022-12-02 11:29         ` Claudio Imbrenda
2022-12-01  8:46 ` [kvm-unit-tests PATCH v1 2/3] lib: s390x: skey: add seed value for storage keys Nico Boehr
2022-12-01 13:27   ` Claudio Imbrenda
2022-12-01 15:16     ` Nico Boehr
2022-12-01  8:46 ` [kvm-unit-tests PATCH v1 3/3] s390x: add storage key test during migration Nico Boehr

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=20221201174634.57a1a44a@p-imbrenda \
    --to=imbrenda@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=nrb@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.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