On 26.07.19 15:59, Ralf Ramsauer wrote:
> Intel and ARM are now basically the same. No more need for those level
            ^^^
Fixed on merge ;)

> of indirection. Consolidate it and save a lot of lines of code.
> 
> Signed-off-by: Ralf Ramsauer <[email protected]>
> ---
>  hypervisor/arch/x86/include/asm/vcpu.h |  7 ------
>  hypervisor/arch/x86/svm.c              |  7 ------
>  hypervisor/arch/x86/vcpu.c             | 33 ++++++++++----------------
>  hypervisor/arch/x86/vmx.c              |  7 ------
>  4 files changed, 12 insertions(+), 42 deletions(-)
> 
> diff --git a/hypervisor/arch/x86/include/asm/vcpu.h 
> b/hypervisor/arch/x86/include/asm/vcpu.h
> index 24872f55..37c9630b 100644
> --- a/hypervisor/arch/x86/include/asm/vcpu.h
> +++ b/hypervisor/arch/x86/include/asm/vcpu.h
> @@ -25,11 +25,6 @@
>        X86_CR0_MP | X86_CR0_PE)
>  #define X86_CR4_HOST_STATE   X86_CR4_PAE
>  
> -struct vcpu_io_bitmap {
> -     u8 *data;
> -     u32 size;
> -};
> -
>  struct vcpu_io_intercept {
>       u16 port;
>       unsigned int size;
> @@ -88,8 +83,6 @@ const u8 *vcpu_get_inst_bytes(const struct 
> guest_paging_structures *pg_structs,
>  
>  void vcpu_skip_emulated_instruction(unsigned int inst_len);
>  
> -void vcpu_vendor_get_cell_io_bitmap(struct cell *cell,
> -                                 struct vcpu_io_bitmap *out);
>  unsigned int vcpu_vendor_get_io_bitmap_pages(void);
>  
>  #define VCPU_CS_DPL_MASK     BIT_MASK(6, 5)
> diff --git a/hypervisor/arch/x86/svm.c b/hypervisor/arch/x86/svm.c
> index ae215ade..74abe652 100644
> --- a/hypervisor/arch/x86/svm.c
> +++ b/hypervisor/arch/x86/svm.c
> @@ -1007,13 +1007,6 @@ const u8 *vcpu_get_inst_bytes(const struct 
> guest_paging_structures *pg_structs,
>       }
>  }
>  
> -void vcpu_vendor_get_cell_io_bitmap(struct cell *cell,
> -                                 struct vcpu_io_bitmap *iobm)
> -{
> -     iobm->data = cell->arch.io_bitmap;
> -     iobm->size = IOPM_PAGES * PAGE_SIZE;
> -}
> -
>  unsigned int vcpu_vendor_get_io_bitmap_pages(void)
>  {
>       return IOPM_PAGES;
> diff --git a/hypervisor/arch/x86/vcpu.c b/hypervisor/arch/x86/vcpu.c
> index eb171605..2e3a1880 100644
> --- a/hypervisor/arch/x86/vcpu.c
> +++ b/hypervisor/arch/x86/vcpu.c
> @@ -81,9 +81,8 @@ int vcpu_cell_init(struct cell *cell)
>       const unsigned int io_bitmap_pages = vcpu_vendor_get_io_bitmap_pages();
>       const u8 *pio_bitmap = jailhouse_cell_pio_bitmap(cell->config);
>       u32 pio_bitmap_size = cell->config->pio_bitmap_size;
> -     struct vcpu_io_bitmap cell_iobm, root_cell_iobm;
>       unsigned int n, pm_timer_addr;
> -     u32 size;
> +     u32 size, iobm_size;
>       int err;
>       u8 *b;
>  
> @@ -97,18 +96,16 @@ int vcpu_cell_init(struct cell *cell)
>               return err;
>       }
>  
> -     vcpu_vendor_get_cell_io_bitmap(cell, &cell_iobm);
> -
>       /* initialize io bitmap to trap all accesses */
> -     memset(cell_iobm.data, -1, cell_iobm.size);
> +     iobm_size = io_bitmap_pages * PAGE_SIZE;
> +     memset(cell->arch.io_bitmap, -1, iobm_size);
>  
>       /* copy io bitmap from cell config */
> -     size = pio_bitmap_size > cell_iobm.size ?
> -                     cell_iobm.size : pio_bitmap_size;
> -     memcpy(cell_iobm.data, pio_bitmap, size);
> +     size = pio_bitmap_size > iobm_size ?  iobm_size : pio_bitmap_size;
> +     memcpy(cell->arch.io_bitmap, pio_bitmap, size);
>  
>       /* always intercept access to i8042 command register */
> -     cell_iobm.data[I8042_CMD_REG / 8] |= 1 << (I8042_CMD_REG % 8);
> +     cell->arch.io_bitmap[I8042_CMD_REG / 8] |= 1 << (I8042_CMD_REG % 8);
>  
>       /* but moderate only if the config allows i8042 access */
>       cell->arch.pio_i8042_allowed =
> @@ -121,20 +118,17 @@ int vcpu_cell_init(struct cell *cell)
>                * Shrink PIO access of root cell corresponding to new cell's
>                * access rights.
>                */
> -             vcpu_vendor_get_cell_io_bitmap(&root_cell, &root_cell_iobm);
> -             for (b = root_cell_iobm.data; pio_bitmap_size > 0;
> +             for (b = root_cell.arch.io_bitmap; pio_bitmap_size > 0;
>                    b++, pio_bitmap++, pio_bitmap_size--)
>                       *b |= ~*pio_bitmap;
>       }
>  
>       /* permit access to the PM timer if there is any */
>       pm_timer_addr = system_config->platform_info.x86.pm_timer_address;
> -     if (pm_timer_addr) {
> -             for (n = 0; n < 4; n++, pm_timer_addr++) {
> -                     b = cell_iobm.data;
> -                     b[pm_timer_addr / 8] &= ~(1 << (pm_timer_addr % 8));
> -             }
> -     }
> +     if (pm_timer_addr)
> +             for (n = 0; n < 4; n++, pm_timer_addr++)
> +                     cell->arch.io_bitmap[pm_timer_addr / 8] &=
> +                             ~(1 << (pm_timer_addr % 8));
>  
>       return 0;
>  }
> @@ -145,15 +139,12 @@ void vcpu_cell_exit(struct cell *cell)
>               jailhouse_cell_pio_bitmap(root_cell.config);
>       const u8 *pio_bitmap = jailhouse_cell_pio_bitmap(cell->config);
>       u32 pio_bitmap_size = cell->config->pio_bitmap_size;
> -     struct vcpu_io_bitmap root_cell_iobm;
>       u8 *b;
>  
> -     vcpu_vendor_get_cell_io_bitmap(&root_cell, &root_cell_iobm);
> -
>       if (root_cell.config->pio_bitmap_size < pio_bitmap_size)
>               pio_bitmap_size = root_cell.config->pio_bitmap_size;
>  
> -     for (b = root_cell_iobm.data; pio_bitmap_size > 0;
> +     for (b = root_cell.arch.io_bitmap; pio_bitmap_size > 0;
>            b++, pio_bitmap++, root_pio_bitmap++, pio_bitmap_size--)
>               *b &= *pio_bitmap | *root_pio_bitmap;
>  
> diff --git a/hypervisor/arch/x86/vmx.c b/hypervisor/arch/x86/vmx.c
> index 182e4de0..c4b7dbb6 100644
> --- a/hypervisor/arch/x86/vmx.c
> +++ b/hypervisor/arch/x86/vmx.c
> @@ -1219,13 +1219,6 @@ void vmx_entry_failure(void)
>       panic_stop();
>  }
>  
> -void vcpu_vendor_get_cell_io_bitmap(struct cell *cell,
> -                                 struct vcpu_io_bitmap *iobm)
> -{
> -     iobm->data = cell->arch.io_bitmap;
> -     iobm->size = PIO_BITMAP_PAGES * PAGE_SIZE;
> -}
> -
>  unsigned int vcpu_vendor_get_io_bitmap_pages(void)
>  {
>       return PIO_BITMAP_PAGES;
> 

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

-- 
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/26d99151-437b-0865-2e98-9430c3cd8651%40siemens.com.

Reply via email to