Re: [kvm-unit-tests PATCH v2 4/4] s390x: Test effect of storage keys on diag 308

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2022-05-17 at 16:52 +0200, Claudio Imbrenda wrote:
> On Tue, 17 May 2022 13:56:07 +0200
> Janis Schoetterl-Glausch <scgl@xxxxxxxxxxxxx> wrote:
> 
> > Test that key-controlled protection does not apply to diag 308.
> > 
> > Signed-off-by: Janis Schoetterl-Glausch <scgl@xxxxxxxxxxxxx>
> > ---
> >  s390x/skey.c | 26 ++++++++++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> > 
> > diff --git a/s390x/skey.c b/s390x/skey.c
> > index 60ae8158..c2d28ffd 100644
> > --- a/s390x/skey.c
> > +++ b/s390x/skey.c
> > @@ -285,6 +285,31 @@ static void test_store_cpu_address(void)
> >  	report_prefix_pop();
> >  }
> >  
> > +static void test_diag_308(void)
> > +{
> > +	uint16_t response;
> > +	uint32_t (*ipib)[1024] = (void *)pagebuf;
> 
> why not just uint32_t *ipib = (void *)pagebuf; ?
> 
> > +
> > +	report_prefix_push("DIAG 308");
> > +	(*ipib)[0] = 0; /* Invalid length */

In an intermediate version I had
memset(ipib, 0, sizeof(*ipib));
Also, if I could specify that the asm writes to a memory location that
is specified via an address in a register without displacement, it
would tell the compiler what memory would be read.
Alas that is not possible (correct me if I'm wrong), so I actually
would do
WRITE_ONCE(ipib[0], 0)
(an get rid of the pointer to array)
> 
> then you can simply do:
> 
> ipib[0] = 0;
> 
> > +	set_storage_key(ipib, 0x28, 0);
> > +	/* key-controlled protection does not apply */
> > +	asm volatile (
> > +		"lr	%%r2,%[ipib]\n\t"
> > +		"spka	0x10\n\t"
> > +		"diag	%%r2,%[code],0x308\n\t"
> > +		"spka	0\n\t"
> > +		"lr	%[response],%%r3\n"
> > +		: [response] "=d" (response)
> > +		: [ipib] "d" (ipib),
> > +		  [code] "d" (5)
> > +		: "%r2", "%r3"
> > +	);
> > +	report(response == 0x402, "no exception on fetch, response: invalid IPIB");
> > +	set_storage_key(ipib, 0x00, 0);
> > +	report_prefix_pop();
> > +}
> > +
> >  /*
> >   * Perform CHANNEL SUBSYSTEM CALL (CHSC)  instruction while temporarily executing
> >   * with access key 1.
> > @@ -714,6 +739,7 @@ int main(void)
> >  	test_chg();
> >  	test_test_protection();
> >  	test_store_cpu_address();
> > +	test_diag_308();
> >  	test_channel_subsystem_call();
> >  
> >  	setup_vm();
> 




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux