On Wednesday, March 7, 2018 at 2:07:25 AM UTC-5, J. Kiszka wrote:
> On 2018-03-06 19:19, anilapp...@gmail.com wrote:
> > Jan,
> > we are tying to access( read & write) from shared memory region between 
> > root cell and non rootcell. I cant use ivshm-shared.bin file because  I 
> > want to load another linux kernel on non rootcell. After booting into non 
> > rootcell, how can I write into shared memory region and trigger interrupt 
> > so that root cell can receive it. I am using minimal file system in non 
> > rootcell and I cant compile and create some application on non rootcell.
> > Can I create ivshm-shared memory application instead of binary in rootcell. 
> > If yes, I can use this application to run on non rootcell to write into 
> > share memory region.
> > please suggest me is there any way to achieve this.
> 
> Have a look at Documentation/inter-cell-communication.txt and
> specifically also https://github.com/henning-schild-work/ivshmem-guest-code.
> 
> Jan
> 
> -- 
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> Corporate Competence Center Embedded Linux


Hi,

we followed the steps as mentioned in the below two files.
        https://github.com/henning-schild-work/ivshmem-guest-code
        Documentation/inter-cell-communication.txt

We are running QEMU in X86_64 laptop.

scenario-1:
----------
able to enable root-cell for shared memory.
loaded ivshmem-demo.bin application for non-root-cell successfully.
interrupts are been sent from demo apps and able to receive "hello from ivshmem 
" when we run shmem_test.py.
I assume after we receive above "hello ..." message , communication is 
established and shared memory is tested successfully. Please clarify my 
assumption or understanding.
ivshmem-demo.c is from the jailhouse tree and we did not do any modification.

scenario-2
------------
tried to communicate between root-cell and non-root-cell linux using shared 
memory.
followed all steps for enabling root-cell and then non-root-cell-linux.
we tried to verify whether shared memory is present is not using uio_send / 
uio_read.
parameters given to uio_send is below:
        uio_send /dev/uio0 3 3 /dev/uio0
parameters given to uio_read is below:
        uio_read /dev/uio0 3

I afraid whether the above parameters given is correct or am i missing some 
detail.

attached root-cell-linux and non-root-cell-linux config file for reference.
also attached log file(non-root-cell-linux-log.txt) of non-root-cell-linux when 
booting.

kindly help here as we tried in all ways to establish root-cell-linux <--> 
non-root-cell-linux shared memory communication, but could not succeed.

-- 
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 jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
 Adding virtual PCI device 00:0e.0 to cell "linux-x86-demo"
Shared memory connection established: "linux-x86-demo" <--> "RootCell"
Adding virtual PCI device 00:0f.0 to cell "linux-x86-demo"
Created cell "linux-x86-demo"
Page pool usage after cell creation: mem 279/16328, remap 65605/131072
Cell "linux-x86-demo" can be loaded
CPU 2 received SIPI, vector 100
CPU 3 received SIPI, vector 100
Started cell "linux-x86-demo"
[    0.000000] Linux version 4.14.18 
(root@centqemu-Standard-PC-i440FX-PIIX-1996) (gcc version 5.4.0 20160609 
(Ubuntu 5.4.0-6ubuntu1~16.04.4)) #2 SMP Fri Feb 23 10:50:39 IST 2018
[    0.000000] Command line: console=ttyS0,115200
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   Centaur CentaurHauls
[    0.000000] x86/fpu: x87 FPU will use FXSAVE
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x00000000000fffff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x0000000000100fff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000300000-0x000000001bdfffff] usable
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] extended physical RAM map:
[    0.000000] reserve setup_data: [mem 0x0000000000000000-0x0000000000006fff] 
usable
[    0.000000] reserve setup_data: [mem 0x0000000000007000-0x0000000000007127] 
usable
[    0.000000] reserve setup_data: [mem 0x0000000000007128-0x00000000000fffff] 
usable
[    0.000000] reserve setup_data: [mem 0x0000000000100000-0x0000000000100fff] 
reserved
[    0.000000] reserve setup_data: [mem 0x0000000000300000-0x000000001bdfffff] 
usable
[    0.000000] DMI not present or invalid.
[    0.000000] Hypervisor detected: Jailhouse
[    0.000000] e820: last_pfn = 0x1be00 max_arch_pfn = 0x400000000
[    0.000000] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WC  UC- UC  
[    0.000000] x2apic: enabled by BIOS, switching to x2apic ops
[    0.000000] Scanning 2 areas for low memory corruption
[    0.000000] RAMDISK: [mem 0x04684000-0x047d3fff]
[    0.000000] No NUMA configuration found
[    0.000000] Faking a node at [mem 0x0000000000000000-0x000000001bdfffff]
[    0.000000] NODE_DATA(0) allocated [mem 0x1bdd4000-0x1bdfefff]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000001000-0x0000000000ffffff]
[    0.000000]   DMA32    [mem 0x0000000001000000-0x000000001bdfffff]
[    0.000000]   Normal   empty
[    0.000000]   Device   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000001000-0x000000000009ffff]
[    0.000000]   node   0: [mem 0x0000000000300000-0x000000001bdfffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000001000-0x000000001bdfffff]
[    0.000000] SFI: Simple Firmware Interface v0.81 http://simplefirmware.org
[    0.000000] Setting APIC routing to physical x2apic.
[    0.000000] IOAPIC[0]: apic_id 0, version 32, address 0xfec00000, GSI 0-23
[    0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs
[    0.000000] PM: Registered nosave memory: [mem 0x00000000-0x00000fff]
[    0.000000] PM: Registered nosave memory: [mem 0x00007000-0x00007fff]
[    0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000fffff]
[    0.000000] PM: Registered nosave memory: [mem 0x00100000-0x00100fff]
[    0.000000] PM: Registered nosave memory: [mem 0x00101000-0x002fffff]
[    0.000000] e820: [mem 0x1be00000-0xffffffff] available for PCI devices
[    0.000000] Booting paravirtualized kernel on bare hardware
[    0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 
0xffffffff, max_idle_ns: 7645519600211568 ns
[    0.000000] random: get_random_bytes called from start_kernel+0x96/0x4a9 
with crng_init=0
[    0.000000] setup_percpu: NR_CPUS:8192 nr_cpumask_bits:2 nr_cpu_ids:2 
nr_node_ids:1
[    0.000000] percpu: Embedded 45 pages/cpu @ffff94449ba00000 s146968 r8192 
d29160 u1048576
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 111770
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: console=ttyS0,115200
[    0.000000] PID hash table entries: 2048 (order: 2, 16384 bytes)
[    0.000000] Memory: 414732K/454268K available (12300K kernel code, 2475K 
rwdata, 3960K rodata, 2340K init, 2364K bss, 39536K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] Kernel/User page tables isolation: enabled
[    0.000000] ftrace: allocating 37759 entries in 148 pages
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=2.
[    0.000000]  Tasks RCU enabled.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS: 524544, nr_irqs: 424, preallocated irqs: 0
[    0.000000] Console: colour dummy device 80x25
[    0.000000] console [ttyS0] enabled
[    0.000000] tsc: Detected 2194.930 MHz processor
[    0.000015] Calibrating delay loop (skipped), value calculated using timer 
frequency.. 4389.86 BogoMIPS (lpj=8779720)
[    0.001171] pid_max: default: 32768 minimum: 301
[    0.001704] Security Framework initialized
[    0.002162] Yama: becoming mindful.
[    0.002559] AppArmor: AppArmor initialized
[    0.003106] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes)
[    0.004000] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes)
[    0.004000] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes)
[    0.004000] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes)
[    0.004000] CPU: Physical Processor ID: 3
[    0.004000] mce: CPU supports 10 MCE banks
[    0.004000] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.004000] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0
[    0.004000] Spectre V2 : Vulnerable: Minimal generic ASM retpoline
[    0.004000] Freeing SMP alternatives memory: 36K
[    0.004000] smpboot: Max logical packages: 2
[    0.004000] smpboot: CPU 0 Converting physical 3 to logical package 0
[    0.004000] smpboot: CPU0: Intel Common KVM processor (family: 0xf, model: 
0x6, stepping: 0x1)
[    0.004000] Performance Events: unsupported Netburst CPU model 6 no PMU 
driver, software events only.
[    0.004000] Hierarchical SRCU implementation.
[    0.004000] NMI watchdog: Perf event create on CPU 0 failed with -2
[    0.004000] NMI watchdog: Perf NMI watchdog permanently disabled
[    0.004044] smp: Bringing up secondary CPUs ...
[    0.004582] x86: Booting SMP configuration:
CPU 2 received SIPI, vector 9a
[    0.005018] .... node  #0, CPUs:      #1
[    0.004000] smpboot: CPU 1 Converting physical 2 to logical package 1
[    0.100030] smp: Brought up 1 node, 2 CPUs
[    0.100550] smpboot: Total of 2 processors activated (8774.08 BogoMIPS)
[    0.101602] devtmpfs: initialized
[    0.101602] x86/mm: Memory block size: 128MB
[    0.101602] evm: security.selinux
[    0.101602] evm: security.SMACK64
[    0.101816] evm: security.SMACK64EXEC
[    0.104005] evm: security.SMACK64TRANSMUTE
[    0.104438] evm: security.SMACK64MMAP
[    0.104867] evm: security.ima
[    0.105220] evm: security.capability
[    0.105683] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, 
max_idle_ns: 7645041785100000 ns
[    0.105683] futex hash table entries: 512 (order: 3, 32768 bytes)
[    0.105999] pinctrl core: initialized pinctrl subsystem
[    0.108120] RTC time:  8:42:32, date: 03/07/18
[    0.108747] NET: Registered protocol family 16
[    0.109409] cpuidle: using governor ladder
[    0.109409] cpuidle: using governor menu
[    0.109409] PCI: Using configuration type 1 for base access
[    0.109600] PCI: MMCONFIG for domain 0000 [bus 00-ff] at [mem 
0xb0000000-0xbfffffff] (base 0xb0000000)
[    0.113595] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[    0.113595] ACPI: Interpreter disabled.
[    0.116085] vgaarb: loaded
[    0.116593] SCSI subsystem initialized
[    0.117237] usbcore: registered new interface driver usbfs
[    0.118122] usbcore: registered new interface driver hub
[    0.119080] usbcore: registered new device driver usb
[    0.120172] EDAC MC: Ver: 3.0.0
[    0.120753] dmi: Firmware registration failed.
[    0.121492] PCI: Probing PCI hardware
[    0.122047] PCI host bridge to bus 0000:00
[    0.122547] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.123239] pci_bus 0000:00: root bus resource [mem 0x00000000-0xffffffffff]
[    0.124026] pci_bus 0000:00: No busn resource found for root bus, will use 
[bus 00-ff]
 PCI_config_ALLOW 
  PCI_config_ALLOW 
  PCI_TYPE_IVSHMEM matches calling ivshmem_pci_cfg_write 
  PCI_config_ALLOW 
  PCI_config_ALLOW 
  PCI_TYPE_IVSHMEM matches calling ivshmem_pci_cfg_write 
 [    0.530529] NetLabel: Initializing
[    0.530979] NetLabel:  domain hash size = 128
[    0.531489] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    0.533169] NetLabel:  unlabeled traffic allowed by default
[    0.536142] clocksource: Switched to clocksource refined-jiffies
[    0.557324] VFS: Disk quotas dquot_6.6.0
[    0.557747] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.558943] AppArmor: AppArmor Filesystem Enabled
[    0.560071] pnp: PnP ACPI: disabled
[    0.568101] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, 
max_idle_ns: 2085701024 ns
[    0.569127] clocksource: Switched to clocksource acpi_pm
[    0.569966] pci 0000:00:0e.0: BAR 0: assigned [mem 0x100000000-0x1000000ff 
64bit]
 PCI_config_ALLOW 
  PCI_config_ALLOW 
 [    0.571759] pci 0000:00:0f.0: BAR 0: assigned [mem 0x100000100-0x1000001ff 
64bit]
 PCI_config_ALLOW 
  PCI_config_ALLOW 
 [    0.572463] pci 0000:00:0e.0: BAR 4: assigned [mem 0x100000200-0x10000021f 
64bit]
 PCI_config_ALLOW 
  PCI_config_ALLOW 
 [    0.574263] pci 0000:00:0f.0: BAR 4: assigned [mem 0x100000220-0x10000023f 
64bit]
 PCI_config_ALLOW 
  PCI_config_ALLOW 
 [    0.576176] NET: Registered protocol family 2
[    0.577015] TCP established hash table entries: 4096 (order: 3, 32768 bytes)
[    0.578128] TCP bind hash table entries: 4096 (order: 4, 65536 bytes)
[    0.578818] TCP: Hash tables configured (established 4096 bind 4096)
[    0.579473] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    0.580009] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    0.580617] NET: Registered protocol family 1
[    0.581105] Unpacking initramfs...
[    0.583278] Freeing initrd memory: 1344K
[    0.583691] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 
0x1fa37d7e77c, max_idle_ns: 440795251160 ns
[    0.584651] clocksource: Switched to clocksource tsc
[    0.585145] Scanning for low memory corruption every 60 seconds
[    0.585889] audit: initializing netlink subsys (disabled)
[    0.586821] Initialise system trusted keyrings
[    0.587289] Key type blacklist registered
[    0.587684] audit: type=2000 audit(0.584:1): state=initialized 
audit_enabled=0 res=1
[    0.588448] workingset: timestamp_bits=36 max_order=17 bucket_order=0
[    0.589897] zbud: loaded
[    0.591683] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.593629] fuse init (API version 7.26)
[    0.597071] random: fast init done
[    0.598803] Key type asymmetric registered
[    0.599417] Asymmetric key parser 'x509' registered
[    0.600237] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 
247)
[    0.601472] io scheduler noop registered
[    0.602099] io scheduler deadline registered
[    0.602807] io scheduler cfq registered (default)
[    0.603566] io scheduler mq-deadline registered
[    0.604283] io scheduler kyber registered
[    0.605166] virtio-pci 0000:00:0e.0: enabling device (0000 -> 0002)
 PCI_config_ALLOW 
 [    0.606518] virtio-pci 0000:00:0f.0: enabling device (0000 -> 0002)
 PCI_config_ALLOW 
 [    0.607944] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled
[    0.631884] serial8250: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is 
a 16550A
[    0.656299] serial8250: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is 
a 16550A
[    0.658555] Linux agpgart interface v0.103
[    0.664217] loop: module loaded
[    0.664871] libphy: Fixed MDIO Bus: probed
[    0.665411] tun: Universal TUN/TAP device driver, 1.6
[    0.666078] PPP generic driver version 2.4.2
[    0.666840] ivshmem-net: probe of 0000:00:0e.0 failed with error -22
[    0.667490] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.668096] ehci-pci: EHCI PCI platform driver
[    0.668510] ehci-platform: EHCI generic platform driver
[    0.668991] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.669556] ohci-pci: OHCI PCI platform driver
[    0.669970] ohci-platform: OHCI generic platform driver
[    0.670459] uhci_hcd: USB Universal Host Controller Interface driver
[    0.671211] mousedev: PS/2 mouse device common for all mice
[    0.671838] i2c /dev entries driver
[    0.672211] device-mapper: uevent: version 1.0.3
[    0.672741] device-mapper: ioctl: 4.37.0-ioctl (2017-09-20) initialised: 
dm-de...@redhat.com
[    0.673561] ledtrig-cpu: registered to indicate activity on CPUs
[    0.674473] NET: Registered protocol family 10
[    0.676895] Segment Routing with IPv6
[    0.677316] NET: Registered protocol family 17
[    0.677732] Key type dns_resolver registered
[    0.678280] sched_clock: Marking stable (678255814, 0)->(1593226946, 
-914971132)
[    0.679494] registered taskstats version 1
[    0.679895] Loading compiled-in X.509 certificates
[    0.681911] Loaded X.509 cert 'Build time autogenerated kernel key: 
4bac2a6dc3fb47a7a43e0edf945205c3b64fd976'
[    0.683115] zswap: loaded using pool lzo/zbud
[    0.686652] Key type big_key registered
[    0.687207] Key type trusted registered
[    0.689443] Key type encrypted registered
[    0.689866] AppArmor: AppArmor sha1 policy hashing enabled
[    0.690604] ima: No TPM chip found, activating TPM-bypass! (rc=-19)
[    0.691624] evm: HMAC attrs: 0x1
[    0.692284]   Magic number: 10:38:725
[    0.692868] block loop5: hash matches
[    0.693465] hctosys: unable to open rtc device (rtc0)
[    0.694367] BIOS EDD facility v0.16 2004-Jun-25, 0 devices found
[    0.695331] EDD information not available.
[    0.697852] Freeing unused kernel memory: 2340K
[    0.698421] Write protecting the kernel read-only data: 18432k
[    0.699571] Freeing unused kernel memory: 2008K
[    0.700420] Freeing unused kernel memory: 136K
[    0.706756] x86/mm: Checked W+X mappings: passed, no W+X pages found.
[    0.707537] x86/mm: Checking user space page tables
[    0.713765] x86/mm: Checked W+X mappings: passed, no W+X pages found.
Starting logging: OK
Initializing random number generator... done.
Starting network: OK

Welcome to Buildroot
buildroot login: root
# 
/*
 * Jailhouse, a Linux-based partitioning hypervisor
 *
 * Copyright (c) Siemens AG, 2014-2017
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 *
 * Alternatively, you can use or redistribute this file under the following
 * BSD license:
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Configuration for QEMU Standard PC (Q35 + ICH9, 2009)
 * created with '/usr/local/libexec/jailhouse/jailhouse config create --mem-inmates 448M x86-root-448.c'
 *
 * NOTE: This config expects the following to be appended to your kernel cmdline
 *       "memmap=0x20000000$0x3b000000"
 */

#include <jailhouse/types.h>
#include <jailhouse/cell-config.h>

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

struct {
	struct jailhouse_system header;
	__u64 cpus[1];
	struct jailhouse_memory mem_regions[27];
	struct jailhouse_irqchip irqchips[1];
	__u8 pio_bitmap[0x2000];
	struct jailhouse_pci_device pci_devices[9];
	struct jailhouse_pci_capability pci_caps[3];
} __attribute__((packed)) config = {
	.header = {
		.signature = JAILHOUSE_SYSTEM_SIGNATURE,
		.revision = JAILHOUSE_CONFIG_REVISION,
		.hypervisor_memory = {
			.phys_start = 0x3b000000,
			.size = 0x4000000,
		},
		.debug_console = {
			.address = 0x3f8,
			.flags = JAILHOUSE_CON1_TYPE_8250 |
				 JAILHOUSE_CON1_ACCESS_PIO |
				 JAILHOUSE_CON1_REGDIST_1 |
				 JAILHOUSE_CON2_TYPE_ROOTPAGE,
		},
		.platform_info = {
			.pci_mmconfig_base = 0xb0000000,
			.pci_mmconfig_end_bus = 0xff,
			.x86 = {
				.pm_timer_address = 0x608,
				.vtd_interrupt_limit = 128,
				.iommu_units = {
					{
						.base = 0xfed90000,
						.size = 0x1000,
					},
				},
			},
		},
		.root_cell = {
			.name = "RootCell",
			.cpu_set_size = sizeof(config.cpus),
			.num_memory_regions = ARRAY_SIZE(config.mem_regions),
			.num_irqchips = ARRAY_SIZE(config.irqchips),
			.pio_bitmap_size = ARRAY_SIZE(config.pio_bitmap),
			.num_pci_devices = ARRAY_SIZE(config.pci_devices),
			.num_pci_caps = ARRAY_SIZE(config.pci_caps),
		},
	},

	.cpus = {
		0x000000000000000f,
	},

	.mem_regions = {
		/* MemRegion: 00000000-00000fff : Reserved */
		{
			.phys_start = 0x0,
			.virt_start = 0x0,
			.size = 0x1000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: 00001000-0009fbff : System RAM */
		{
			.phys_start = 0x1000,
			.virt_start = 0x1000,
			.size = 0x9f000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA,
		},
		/* MemRegion: 0009fc00-0009ffff : Reserved */
		{
			.phys_start = 0x9fc00,
			.virt_start = 0x9fc00,
			.size = 0x1000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: 000a0000-000bffff : PCI Bus 0000:00 */
		{
			.phys_start = 0xa0000,
			.virt_start = 0xa0000,
			.size = 0x20000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: 000f0000-000fffff : System ROM */
		{
			.phys_start = 0xf0000,
			.virt_start = 0xf0000,
			.size = 0x10000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: 00100000-3affffff : System RAM */
		{
			.phys_start = 0x100000,
			.virt_start = 0x100000,
			.size = 0x3af00000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA,
		},
		/* MemRegion: 3b000000-5affffff : Reserved */
		{
			.phys_start = 0x3b000000,
			.virt_start = 0x3b000000,
			.size = 0x20000000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: 5b000000-7ffdefff : System RAM */
		{
			.phys_start = 0x5b000000,
			.virt_start = 0x5b000000,
			.size = 0x24fdf000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA,
		},
		/* MemRegion: 7ffdf000-7fffffff : Reserved */
		{
			.phys_start = 0x7ffdf000,
			.virt_start = 0x7ffdf000,
			.size = 0x21000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: fd000000-fd15ffff : efifb */
		{
			.phys_start = 0xfd000000,
			.virt_start = 0xfd000000,
			.size = 0x160000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: feb80000-febbffff : 0000:00:02.0 */
		{
			.phys_start = 0xfeb80000,
			.virt_start = 0xfeb80000,
			.size = 0x40000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: febc0000-febdffff : e1000 */
		{
			.phys_start = 0xfebc0000,
			.virt_start = 0xfebc0000,
			.size = 0x20000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: febf0000-febf3fff : ICH HD audio */
		{
			.phys_start = 0xfebf0000,
			.virt_start = 0xfebf0000,
			.size = 0x4000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: febf4000-febf4fff : 0000:00:01.0 */
		{
			.phys_start = 0xfebf4000,
			.virt_start = 0xfebf4000,
			.size = 0x1000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: febf5000-febf5fff : ahci */
		{
			.phys_start = 0xfebf5000,
			.virt_start = 0xfebf5000,
			.size = 0x1000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: fed00000-fed003ff : PNP0103:00 */
		{
			.phys_start = 0xfed00000,
			.virt_start = 0xfed00000,
			.size = 0x1000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: fed1f410-fed1f414 : iTCO_wdt.0.auto */
		{
			.phys_start = 0xfed1f410,
			.virt_start = 0xfed1f410,
			.size = 0x1000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: feffc000-feffffff : Reserved */
		{
			.phys_start = 0xfeffc000,
			.virt_start = 0xfeffc000,
			.size = 0x4000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: fffc0000-ffffffff : Reserved */
		{
			.phys_start = 0xfffc0000,
			.virt_start = 0xfffc0000,
			.size = 0x40000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: 100000000-1049fffff : System RAM */
		{
			.phys_start = 0x100000000,
			.virt_start = 0x100000000,
			.size = 0x4a00000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA,
		},
		/* MemRegion: 104a00000-106ffffff : Kernel */
		{
			.phys_start = 0x104a00000,
			.virt_start = 0x104a00000,
			.size = 0x2600000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA,
		},
		/* MemRegion: 107000000-13fffffff : System RAM */
		{
			.phys_start = 0x107000000,
			.virt_start = 0x107000000,
			.size = 0x39000000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA,
		},
		/* MemRegion: 140000000-93fffffff : PCI Bus 0000:00 */
		{
			.phys_start = 0x140000000,
			.virt_start = 0x140000000,
			.size = 0x800000000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: 000c0000-000dffff : ROMs */
		{
			.phys_start = 0xc0000,
			.virt_start = 0xc0000,
			.size = 0x20000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: 3f000000-5affffff : JAILHOUSE Inmate Memory */
		{
			.phys_start = 0x3f000000,
			.virt_start = 0x3f000000,
			.size = 0x1c000000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},

		/* IVSHMEM shared memory region - JH dis idx at 25*/
                {
                        .phys_start = 0x3f2ff000,
                        .virt_start = 0x3f2ff000,
                        .size = 0x1000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
                },

	},

	.irqchips = {
		/* IOAPIC 0, GSI base 0 */
		{
			.address = 0xfec00000,
			.id = 0xff00,
			.pin_bitmap = {
				0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
			},
		},
	},

	.pio_bitmap = {
		[     0/8 ...   0x3f/8] = -1,
		[  0x40/8 ...   0x47/8] = 0xf0, /* PIT */
		[  0x48/8 ...   0x5f/8] = -1,
		[  0x60/8 ...   0x67/8] = 0xec, /* HACK: NMI status/control */
		[  0x68/8 ...   0x6f/8] = -1,
		[  0x70/8 ...   0x77/8] = 0x7c,/*0xfc,*/ /* RTC */
		[  0x78/8 ...  0x3af/8] = -1,
		[ 0x3b0/8 ...  0x3df/8] = 0x00, /* VGA */
		[ 0x3e0/8 ...  0xcff/8] = -1,
		[ 0xd00/8 ... 0xffff/8] = 0, /* HACK: PCI bus */
	},

	.pci_devices = {
		/* PCIDevice: 00:00.0 */
		{
			.type = JAILHOUSE_PCI_TYPE_DEVICE,
			.iommu = 0,
			.domain = 0x0,
			.bdf = 0x0,
			.bar_mask = {
				0x00000000, 0x00000000, 0x00000000,
				0x00000000, 0x00000000, 0x00000000,
			},
			.caps_start = 0,
			.num_caps = 0,
			.num_msi_vectors = 0,
			.msi_64bits = 0,
			.num_msix_vectors = 0,
			.msix_region_size = 0x0,
			.msix_address = 0x0,
		},
		/* PCIDevice: 00:01.0 */
		{
			.type = JAILHOUSE_PCI_TYPE_DEVICE,
			.iommu = 0,
			.domain = 0x0,
			.bdf = 0x8,
			.bar_mask = {
				0xff000000, 0x00000000, 0xfffff000,
				0x00000000, 0x00000000, 0x00000000,
			},
			.caps_start = 0,
			.num_caps = 0,
			.num_msi_vectors = 0,
			.msi_64bits = 0,
			.num_msix_vectors = 0,
			.msix_region_size = 0x0,
			.msix_address = 0x0,
		},
		/* PCIDevice: 00:02.0 */
		{
			.type = JAILHOUSE_PCI_TYPE_DEVICE,
			.iommu = 0,
			.domain = 0x0,
			.bdf = 0x10,
			.bar_mask = {
				0xfffe0000, 0xffffffc0, 0x00000000,
				0x00000000, 0x00000000, 0x00000000,
			},
			.caps_start = 0,
			.num_caps = 0,
			.num_msi_vectors = 0,
			.msi_64bits = 0,
			.num_msix_vectors = 0,
			.msix_region_size = 0x0,
			.msix_address = 0x0,
		},
		/* PCIDevice: 00:1b.0 */
		{
			.type = JAILHOUSE_PCI_TYPE_DEVICE,
			.iommu = 0,
			.domain = 0x0,
			.bdf = 0xd8,
			.bar_mask = {
				0xffffc000, 0x00000000, 0x00000000,
				0x00000000, 0x00000000, 0x00000000,
			},
			.caps_start = 0,
			.num_caps = 1,
			.num_msi_vectors = 1,
			.msi_64bits = 1,
			.num_msix_vectors = 0,
			.msix_region_size = 0x0,
			.msix_address = 0x0,
		},
		/* PCIDevice: 00:1f.0 */
		{
			.type = JAILHOUSE_PCI_TYPE_DEVICE,
			.iommu = 0,
			.domain = 0x0,
			.bdf = 0xf8,
			.bar_mask = {
				0x00000000, 0x00000000, 0x00000000,
				0x00000000, 0x00000000, 0x00000000,
			},
			.caps_start = 0,
			.num_caps = 0,
			.num_msi_vectors = 0,
			.msi_64bits = 0,
			.num_msix_vectors = 0,
			.msix_region_size = 0x0,
			.msix_address = 0x0,
		},
		/* PCIDevice: 00:1f.2 */
		{
			.type = JAILHOUSE_PCI_TYPE_DEVICE,
			.iommu = 0,
			.domain = 0x0,
			.bdf = 0xfa,
			.bar_mask = {
				0x00000000, 0x00000000, 0x00000000,
				0x00000000, 0xffffffe0, 0xfffff000,
			},
			.caps_start = 1,
			.num_caps = 2,
			.num_msi_vectors = 1,
			.msi_64bits = 1,
			.num_msix_vectors = 0,
			.msix_region_size = 0x0,
			.msix_address = 0x0,
		},
		/* PCIDevice: 00:1f.3 */
		{
			.type = JAILHOUSE_PCI_TYPE_DEVICE,
			.iommu = 0,
			.domain = 0x0,
			.bdf = 0xfb,
			.bar_mask = {
				0x00000000, 0x00000000, 0x00000000,
				0x00000000, 0xffffffc0, 0x00000000,
			},
			.caps_start = 0,
			.num_caps = 0,
			.num_msi_vectors = 0,
			.msi_64bits = 0,
			.num_msix_vectors = 0,
			.msix_region_size = 0x0,
			.msix_address = 0x0,
		},



		/* 00:0e.0 - JH*/
		 {
                        .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
			.iommu = 1,
                        .domain = 0x0,
                        .bdf = 0x0e << 3,/*0x0e << 3,*/
                        .bar_mask = {
                                0xffffff00, 0xffffffff, 0x00000000,
                                0x00000000, 0xffffffe0, 0xffffffff,
                        },
                        .num_msix_vectors = 1,
                        .shmem_region = 25,
                        .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
                },

	},

	.pci_caps = {
		/* PCIDevice: 00:1b.0 */
		{
			.id = 0x5,
			.start = 0x60,
			.len = 14,
			.flags = JAILHOUSE_PCICAPS_WRITE,
		},
		/* PCIDevice: 00:1f.2 */
		{
			.id = 0x5,
			.start = 0x80,
			.len = 14,
			.flags = JAILHOUSE_PCICAPS_WRITE,
		},
		{
			.id = 0x12,
			.start = 0xa8,
			.len = 2,
			.flags = 0,
		},
	},
};
/*
 * Jailhouse, a Linux-based partitioning hypervisor
 *
 * Configuration for Linux inmate, 1 CPU, ~60 MB RAM, ~1MB shmem, serial ports
 *
 * Copyright (c) Siemens AG, 2013-2015
 *
 * Authors:
 *  Jan Kiszka <jan.kis...@siemens.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 */

#include <jailhouse/types.h>
#include <jailhouse/cell-config.h>

#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])

struct {
	struct jailhouse_cell_desc cell;
	__u64 cpus[1];
#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
	struct jailhouse_memory mem_regions[9];
#else
	struct jailhouse_memory mem_regions[5];
#endif
	struct jailhouse_cache cache_regions[1];
	struct jailhouse_irqchip irqchips[1];
	__u8 pio_bitmap[0x2000];
#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
	struct jailhouse_pci_device pci_devices[3];
#else
	struct jailhouse_pci_device pci_devices[2];
#endif
	struct jailhouse_pci_capability pci_caps[6];
} __attribute__((packed)) config = {
	.cell = {
		.signature = JAILHOUSE_CELL_DESC_SIGNATURE,
		.revision = JAILHOUSE_CONFIG_REVISION,
		.name = "linux-x86-demo",
		.flags = JAILHOUSE_CELL_PASSIVE_COMMREG |
			JAILHOUSE_CELL_DEBUG_CONSOLE,

		.cpu_set_size = sizeof(config.cpus),
		.num_memory_regions = ARRAY_SIZE(config.mem_regions),
		.num_cache_regions = ARRAY_SIZE(config.cache_regions),
		.num_irqchips = ARRAY_SIZE(config.irqchips),
		.pio_bitmap_size = ARRAY_SIZE(config.pio_bitmap),
		.num_pci_devices = ARRAY_SIZE(config.pci_devices),
		.num_pci_caps = ARRAY_SIZE(config.pci_caps),
	},

	.cpus = {
		0xc,
	},

	.mem_regions = {
		/* low RAM */ {
			.phys_start = 0x3f000000,/*0x3b600000,*/
			.virt_start = 0,
			.size = 0x00100000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
				JAILHOUSE_MEM_LOADABLE,
		},
		/* communication region */ {
			.virt_start = 0x00100000,
			.size = 0x00001000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_COMM_REGION,
		},
		/* high RAM */ {
			.phys_start = 0x3f300000,/*0x3f100000,*/
			.virt_start = 0x00300000,
			.size = 0x1bc00000,/*0x1be00000,*/
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_DMA |
				JAILHOUSE_MEM_LOADABLE,
		},

		/* IVSHMEM shared memory region - JH(linux) */
                {
                        .phys_start = /*0x5af00000,*/0x3f2ff000,
                        .virt_start = /*0x5af00000,*/0x3f2ff000,
                        .size = 0x1000,
                        .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
                                JAILHOUSE_MEM_ROOTSHARED,
                },

		/* IVSHMEM shared memory region - demo */
		{
			.phys_start = 0x3f200000,/*0x5ae00000,*/
			.virt_start = 0x3f200000,/*0x5ae00000,*/
			.size = 0xff000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
				JAILHOUSE_MEM_ROOTSHARED,
		},

#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
		/* MemRegion: feb40000-feb7ffff : 0000:00:02.0 */
		{
			.phys_start = 0xfeb40000,
			.virt_start = 0xfeb40000,
			.size = 0x40000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: feb80000-feb9ffff : e1000e */
		{
			.phys_start = 0xfeb80000,
			.virt_start = 0xfeb80000,
			.size = 0x20000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: feba0000-febbffff : e1000e */
		{
			.phys_start = 0xfeba0000,
			.virt_start = 0xfeba0000,
			.size = 0x20000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
		/* MemRegion: febd1000-febd3fff : e1000e */
		{
			.phys_start = 0xfebd1000,
			.virt_start = 0xfebd1000,
			.size = 0x3000,
			.flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
		},
#endif
	},

	.cache_regions = {
		{
			.start = 0,
			.size = 2,
			.type = JAILHOUSE_CACHE_L3,
		},
	},

	.irqchips = {
		/* IOAPIC */ {
			.address = 0xfec00000,
			.id = 0xff00,
			.pin_bitmap = {
				(1 << 3) | (1 << 4),
			},
		},
	},

	.pio_bitmap = {
		[     0/8 ...  0x27/8] = -1,
		[  0x28/8 ...  0x2f/8] = 0,
 		[  0x30/8 ...  0x47/8] = -1,
		[  0x48/8 ...  0x4f/8] = 0,
  		[  0x50/8 ...  0x6f/8] = -1, 
		[  0x70/8 ...  0x77/8] = 0,			
 		[  0x78/8 ...  0x2e7/8] = -1,
		[ 0x2e8/8 ...  0x2ef/8] = 0,
  		[ 0x2f0/8 ...  0x2f7/8] = -1,
		[ 0x2f8/8 ...  0x2ff/8] = 0, /* serial2 */
		[ 0x300/8 ...  0x3e7/8] = -1,
		[ 0x3e8/8 ...  0x3ef/8] = 0,
 		[ 0x3f0/8 ...  0x3f7/8] = -1,
		[ 0x3f8/8 ...  0x3ff/8] = 0, /* serial1 */
		[ 0x400/8 ... 0xe00f/8] = -1,
		[0xe010/8 ... 0xe017/8] = 0, /* OXPCIe952 serial1 */
		[0xe018/8 ... 0xffff/8] = -1,
	},

	.pci_devices = {

		{
			.type = JAILHOUSE_PCI_TYPE_IVSHMEM,
			.domain = 0x0,
			.bdf = 0x0e << 3,
			.bar_mask = {
				0xffffff00, 0xffffffff, 0x00000000,
				0x00000000, 0xffffffe0, 0xffffffff,
			},
			.num_msix_vectors = 1,
			.shmem_region = 3,
			.shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
		},

		/* 00:0f.0 - JH*/
                {
                        .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
                        .domain = 0x0000,
                        .bdf = 0x0f << 3,
                        .bar_mask = {
                                0xffffff00, 0xffffffff, 0x00000000,
                                0x00000000, 0xffffffe0, 0xffffffff,
                        },
                        .num_msix_vectors = 1,
                        .shmem_region = 4,
			.shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
                },


#ifdef CONFIG_QEMU_E1000E_ASSIGNMENT
		{ /* e1000e */
			.type = JAILHOUSE_PCI_TYPE_DEVICE,
			.domain = 0x0000,
			.bdf = 0x0010,
			.bar_mask = {
				0xfffe0000, 0xfffe0000, 0xffffffe0,
				0xffffc000, 0x00000000, 0x00000000,
			},
			.caps_start = 0,
			.num_caps = 6,
			.num_msi_vectors = 1,
			.msi_64bits = 1,
			.num_msix_vectors = 5,
			.msix_region_size = 0x1000,
			.msix_address = 0xfebd0000,
		},
#endif
	},

	.pci_caps = {
		{ /* e1000e */
			.id = 0x1,
			.start = 0xc8,
			.len = 8,
			.flags = JAILHOUSE_PCICAPS_WRITE,
		},
		{
			.id = 0x5,
			.start = 0xd0,
			.len = 14,
			.flags = JAILHOUSE_PCICAPS_WRITE,
		},
		{
			.id = 0x10,
			.start = 0xe0,
			.len = 20,
			.flags = JAILHOUSE_PCICAPS_WRITE,
		},
		{
			.id = 0x11,
			.start = 0xa0,
			.len = 12,
			.flags = JAILHOUSE_PCICAPS_WRITE,
		},
		{
			.id = 0x1 | JAILHOUSE_PCI_EXT_CAP,
			.start = 0x100,
			.len = 4,
			.flags = 0,
		},
		{
			.id = 0x3 | JAILHOUSE_PCI_EXT_CAP,
			.start = 0x140,
			.len = 4,
			.flags = 0,
		},
	}
};

Reply via email to