Re: [PATCH kvm-unit-tests 9/9] s390x: add test for (v)malloc

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

 



On 11.01.2018 13:09, Thomas Huth wrote:
> On 10.01.2018 22:53, David Hildenbrand wrote:
>> Let's test if basic allocation works and we get virtual addresses.
>>
>> Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
>> ---
>>  s390x/selftest.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/s390x/selftest.c b/s390x/selftest.c
>> index 76ed4bf..bf72d32 100644
>> --- a/s390x/selftest.c
>> +++ b/s390x/selftest.c
>> @@ -10,6 +10,7 @@
>>   */
>>  #include <libcflat.h>
>>  #include <util.h>
>> +#include <alloc.h>
>>  #include <asm/interrupt.h>
>>  
>>  static void test_fp(void)
>> @@ -37,6 +38,21 @@ static void test_pgm_int(void)
>>  	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
>>  }
>>  
>> +static void test_malloc(void)
>> +{
>> +	int *tmp = malloc(sizeof(int));
>> +	int *tmp2 = malloc(sizeof(int));
>> +
>> +	report("malloc: got vaddr", (uintptr_t)tmp & 0xffffffff00000000ul);
>> +	report("malloc: access works", (*tmp = 123456789));
> 
> Using the *tmp = 123456789 as condition for report() here looks somewhat
> weird. What about:

Can do that.

> 
> 	*tmp = 123456789;
> 	mb();
> 	report("malloc: access works", (*tmp == 123456789));
> 
> ?
> 
>> +	report("malloc: got 2nd vaddr", (uintptr_t)tmp2 & 0xffffffff00000000ul);
>> +	report("malloc: access works", (*tmp2 = 123456789));
>> +	report("malloc: addresses differ", tmp != tmp2);
> 
> Would it make sense to use the LOAD REAL ADDRESS instruction here to
> check that the VA != PA ?

As an alternative, I can disable DAT an make sure that I no longer can
access the value (PGM ADRESSING).

Thanks!

> 
>  Thomas
> 


-- 

Thanks,

David / dhildenb



[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