On 10.03.20 16:34, Jan Kiszka wrote:
> On 10.03.20 16:08, Jan Kiszka wrote:
>> On 10.03.20 15:41, Philipp Rosenberger wrote:
>>> Hi,
>>>
>>> I have managed to get virtio-ivshmem console and block running. But I
>>> observed a strange behavior. I do the following:
>>>
>>> 1. Boot up the board.
>>> 2. Enable the rootcell.
>>> 3. echo "110a 4106 110a 4106 ffc002 ffffff" > \
>>>    /sys/bus/pci/drivers/uio_ivshmem/new_id
>>> 4. virtio-ivshmem-block /dev/uio0 /path/to/disk.image
>>> 5. boot linux-inmate
>>> 6. virtio-ivshmem 0000:00:0f.0: backend not ready
>>> 7. kernel panic
>>>
>>> If I redo the sets 4 and 5 the inmates starts as expected and I can
>>> access the disk.image via /dev/vda.
>>>
>>> I found, the the virtio-ivshmem-block tool waits for an interrupt if
>>> 'state[peer_id] != VIRTIO_STATE_RESET'. But there is no interrupt.
>>
>> The state memory should be zeroed, provided the peer is not running. You 
>> will only get an interrupt during the peer setup when it switches it 
>> state from (expected) RESET to READY. Maybe we miss some proper 
>> initialization of the shared state memory in Jailhouse.
>>
>> Can you confirm that the state memory is in a random state on first 
>> startup? And that it changes as expected for the peer to READY once the 
>> non-root Linux boots?
> 
> Does this help?

Yeah, this works nicely.
Thank you!

Best regards,
Philipp

> diff --git a/hypervisor/ivshmem.c b/hypervisor/ivshmem.c
> index 22283a85..a5cdcf93 100644
> --- a/hypervisor/ivshmem.c
> +++ b/hypervisor/ivshmem.c
> @@ -101,13 +101,8 @@ static void ivshmem_trigger_interrupt(struct 
> ivshmem_endpoint *ive,
>       spin_unlock(&ive->irq_lock);
>  }
>  
> -static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
> +static u32 *ivshmem_map_state_table(struct ivshmem_endpoint *ive)
>  {
> -     const struct jailhouse_pci_device *dev_info = ive->device->info;
> -     u32 *state_table = (u32 *)TEMPORARY_MAPPING_BASE;
> -     struct ivshmem_endpoint *target_ive;
> -     unsigned int id;
> -
>       /*
>        * Cannot fail: upper levels of page table were already created by
>        * paging_init, and we always map single pages, thus only update the
> @@ -115,9 +110,20 @@ static void ivshmem_write_state(struct ivshmem_endpoint 
> *ive, u32 new_state)
>        */
>       paging_create(&this_cpu_data()->pg_structs,
>                     ive->shmem[0].phys_start, PAGE_SIZE,
> -                   (unsigned long)state_table, PAGE_DEFAULT_FLAGS,
> +                   TEMPORARY_MAPPING_BASE, PAGE_DEFAULT_FLAGS,
>                     PAGING_NON_COHERENT | PAGING_NO_HUGE);
>  
> +     return (u32 *)TEMPORARY_MAPPING_BASE;
> +}
> +
> +
> +static void ivshmem_write_state(struct ivshmem_endpoint *ive, u32 new_state)
> +{
> +     const struct jailhouse_pci_device *dev_info = ive->device->info;
> +     u32 *state_table = ivshmem_map_state_table(ive);
> +     struct ivshmem_endpoint *target_ive;
> +     unsigned int id;
> +
>       state_table[dev_info->shmem_dev_id] = new_state;
>       memory_barrier();
>  
> @@ -435,12 +441,15 @@ int ivshmem_init(struct cell *cell, struct pci_device 
> *device)
>       }
>  
>       link->peers++;
> -     ive = &link->eps[dev_info->shmem_dev_id];
> +     ive = &link->eps[id];
>  
>       ive->device = device;
>       ive->link = link;
>       ive->shmem = jailhouse_cell_mem_regions(cell->config) +
>               dev_info->shmem_regions_start;
> +     if (link->peers == 1)
> +             memset(ivshmem_map_state_table(ive), 0,
> +                    dev_info->shmem_peers * sizeof(u32));
>       device->ivshmem_endpoint = ive;
>  
>       device->cell = cell;
> 
> Jan
> 

-- 
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 0; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here):
https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH
Firmensitz (Registered Office): Uhldingen-Mühlhofen
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 806
Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/a7fddcbd-97ff-79dd-a80f-43bb703dceb5%40linutronix.de.

Reply via email to