Re: Why trap interrupts with GIC v3 on arm64?

2018-10-22 Thread posk . devel
On Sunday, October 21, 2018 at 4:57:58 AM UTC-7, J. Kiszka wrote:
> On 19.10.18 17:18, posk.de...@gmail.com wrote:
> > Hello!
> > 
> > GICv3 on ARM provides the ability to route interrupts to specific cores, 
> > see e.g. "Affinity routing and assignment" here: 
> > https://static.docs.arm.com/100336/0002/corelink_gic600_generic_interrupt_controller_technical_reference_manual_100336_0002_01_en.pdf
> > 
> > A paper on Jailhouse (https://arxiv.org/abs/1705.06932) measures interrupt 
> > delays introduced by trapping them in hypervisor and re-injecting into 
> > cells/VMs. Why can't GIC be programmed by the hypervisor to route 
> > interrupts directly to CPUs controlled by a cell, thus eliminating the 
> > extra hop to the hypervisor?
> 
> Only GICv4 introduces a way to inject a physical interrupt directly into the 
> virtual CPU. I'm sure we will eventually support that, but I'm not yet aware 
> of 
> any physical hardware implementing GICv4 (GICv3 adoption is still "in 
> process").
> 

But GICv3 can route interrupts to specific physical CPUs, so JH can
program it to route specific interrupts to specific cells. What am I
missing here?

-- 
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.


x86 architecture system hangs on sudo tools/jailhouse cell destroy apic-demo, Broke affinity for irq 125, smpboot: CPU 3 is now offline

2018-10-22 Thread Ashok kumar
Hi,


I am using x86 i3 core processor

I have added
 void vcpu_park(void)
 {
 #ifdef CONFIG_CRASH_CELL_ON_PANIC
-   if (this_cpu_data()->failed) {
+   if (this_cpu_public()->failed) {
this_cpu_data()->vmcb.rip = 0;
return;
}

 void vcpu_park(void)
 {
 #ifdef CONFIG_CRASH_CELL_ON_PANIC
-   if (this_cpu_data()->failed) {
+   if (this_cpu_public()->failed) {
vmcs_write64(GUEST_RIP, 0);
return;
}


in the corresponding files arch/hypervisor/arch/x86/vmx.c
  arch/hypervisor/arch/x86/svm.c
and after executing  command

sudo tools/jailhouse enable configs/x86/sysconfig.cell

in syslog the following message is I get


texsonics kernel: [  174.219041]  The Jailhouse is opening.
Oct 22 18:01:01 texsonics kernel: [  244.918968] Broke affinity for irq 125
Oct 22 18:01:01 texsonics kernel: [  244.920002] smpboot: CPU 3 is now
offline

sudo tools/jailhouse cell create configs/x86/apic-demo.cell

smpboot: CPU 3 is now offline
Oct 22 18:01:01 texsonics kernel: [  244.947989] Created Jailhouse cell
"apic-demo"
Oct 22 18:01:03 texsonics /usr/sbin/irqbalance: WARNING, didn't collect
load info for all cpus, balancing is broken
Oct 22 18:02:43 texsonics /usr/sbin/irqbalance: message repeated 16 times:
[ WARNING, didn't collect load info for all cpus, balancing is broken]
Oct 22 18:02:53 texsonics /usr/sbin/irqbalance: WARNING, didn't collect
load info for all cpus, balancing is broken

sudo tools/jailhouse cell destroy apic-demo

smpboot: Booting Node 0 Processor 3 APIC 0x3
Oct 22 18:05:04 texsonics kernel: [  488.138877] Destroyed Jailhouse cell
"apic-demo"

and my system gets hangs and in my UART  I get

Stopped APIC demo
Closing cell "apic-demo"
Page pool usage after cell destruction mem 295/15823, remap 16394/131072
cpu 3 received SIPI,vector 97

kindly help me to solve this issue, so that I should able to destroy
jailhouse cell and jailhouse disable and the system should not hangs

I have attached the jailhouse-hardware-check
hardware check details
and the corresponding file sysconfig.c vmx.c svm.c grub

Thank you
Ashokkumar

-- 
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.


jailhouse
Description: Binary data
/*
 * 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 System manufacturer System Product Name
 * created with 'tools/jailhouse config create sysconfig.c'
 *
 * NOTE: This config expects the following to be appended to your kernel cmdline
 *   "memmap=0x420$0x3a00"
 */

#include 
#include 

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

struct {
	struct jailhouse_system header;
	__u64 cpus[1];
	struct jailhouse_memory mem_regions[53];
	struct jailhouse_irqchip irqchips[1];
	__u8 pio_bitmap[0x2000];
	struct jailhouse_pci_device pci_devices[13];
	struct jailhouse_pci_capability pci_caps[34];
} __attribute__((packed)) config = {
	.header = {
		.signature = JAILHOUSE_SYSTEM_SIGNATURE,
		.revision = JAILHOUSE_CONFIG_REVISION,
		.flags = JAILHOUSE_SYS_VIRTUAL_DEBUG_CONSOLE,
		.hypervisor_memory = {
			.phys_start = 0x3a00,
			.size = 0x400,
		},
		.debug_console = {
			

Re: [PATCH] x86: Fix CONFIG_CRASH_CELL_ON_PANIC

2018-10-22 Thread Ashok kumar
Hi,

I have added
 void vcpu_park(void)
 {
 #ifdef CONFIG_CRASH_CELL_ON_PANIC
-   if (this_cpu_data()->failed) {
+   if (this_cpu_public()->failed) {
this_cpu_data()->vmcb.rip = 0;
return;
}

 void vcpu_park(void)
 {
 #ifdef CONFIG_CRASH_CELL_ON_PANIC
-   if (this_cpu_data()->failed) {
+   if (this_cpu_public()->failed) {
vmcs_write64(GUEST_RIP, 0);
return;
}


in the corresponding files arch/hypervisor/arch/x86/vmx.c
  arch/hypervisor/arch/x86/svm.c
and after executing  command

sudo tools/jailhouse enable configs/x86/sysconfig.cell

in syslog the following message is I get


texsonics kernel: [  174.219041]  The Jailhouse is opening.
Oct 22 18:01:01 texsonics kernel: [  244.918968] Broke affinity for irq 125
Oct 22 18:01:01 texsonics kernel: [  244.920002] smpboot: CPU 3 is now
offline

sudo tools/jailhouse cell create configs/x86/apic-demo.cell

smpboot: CPU 3 is now offline
Oct 22 18:01:01 texsonics kernel: [  244.947989] Created Jailhouse cell
"apic-demo"
Oct 22 18:01:03 texsonics /usr/sbin/irqbalance: WARNING, didn't collect
load info for all cpus, balancing is broken
Oct 22 18:02:43 texsonics /usr/sbin/irqbalance: message repeated 16 times:
[ WARNING, didn't collect load info for all cpus, balancing is broken]
Oct 22 18:02:53 texsonics /usr/sbin/irqbalance: WARNING, didn't collect
load info for all cpus, balancing is broken

sudo tools/jailhouse cell destroy apic-demo

smpboot: Booting Node 0 Processor 3 APIC 0x3
Oct 22 18:05:04 texsonics kernel: [  488.138877] Destroyed Jailhouse cell
"apic-demo"

and my system gets hangs and in my UART  I get

Stopped APIC demo
Closing cell "apic-demo"
Page pool usage after cell destruction mem 295/15823, remap 16394/131072
cpu 3 received SIPI,vector 97

kindly help me to solve this issue, so that I should able to destroy
jailhouse cell and jailhouse disable

Thank you
Ashokkumar


On Wed, Oct 17, 2018 at 6:37 PM Jan Kiszka  wrote:

> As it is not enabled by default, this became silently broken.
>
> Fixes: 13c472715e29 ("core: Move failed into public per-cpu section")
> Signed-off-by: Jan Kiszka 
> ---
>  hypervisor/arch/x86/svm.c | 2 +-
>  hypervisor/arch/x86/vmx.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hypervisor/arch/x86/svm.c b/hypervisor/arch/x86/svm.c
> index 1808e74e..eb757a87 100644
> --- a/hypervisor/arch/x86/svm.c
> +++ b/hypervisor/arch/x86/svm.c
> @@ -980,7 +980,7 @@ vmentry:
>  void vcpu_park(void)
>  {
>  #ifdef CONFIG_CRASH_CELL_ON_PANIC
> -   if (this_cpu_data()->failed) {
> +   if (this_cpu_public()->failed) {
> this_cpu_data()->vmcb.rip = 0;
> return;
> }
> diff --git a/hypervisor/arch/x86/vmx.c b/hypervisor/arch/x86/vmx.c
> index 29967015..27e6e4e8 100644
> --- a/hypervisor/arch/x86/vmx.c
> +++ b/hypervisor/arch/x86/vmx.c
> @@ -910,7 +910,7 @@ void vcpu_nmi_handler(void)
>  void vcpu_park(void)
>  {
>  #ifdef CONFIG_CRASH_CELL_ON_PANIC
> -   if (this_cpu_data()->failed) {
> +   if (this_cpu_public()->failed) {
> vmcs_write64(GUEST_RIP, 0);
> return;
> }
> --
> 2.16.4
>
> --
> 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.
>

-- 
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.


PCI INTA intr for AHCI host controller in non-root cell

2018-10-22 Thread minskey guo
I am trying to pass AHCI controller to non-root cell on Intel NUC7i5D. Should i 
pass IOAPIC to non-root cell as well or something else to achieve that goal ?

My hardware is:
   00:17.0 SATA controller: Intel Corporation Sunrise Point-LP SATA Controller 
[AHCI mode] (rev 21) (prog-if 01 [AHCI 1.0])
Subsystem: Intel Corporation Sunrise Point-LP SATA Controller [AHCI 
mode]
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- 
Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- 
SERR- 
Kernel driver in use: ahci
Kernel modules: ahci


During non-root cell booting, I get the following error :


[1.952370] ahci :00:17.0: enabling device (0400 -> 0403)
[1.958152] ahci :00:17.0: can't find IRQ for PCI INT A; please try 
using pci=biosirq
/home/test/work/jailhouse/hypervisor/arch/x86/pci.c:349: irq ret=133
/home/test/work/jailhouse/hypervisor/arch/x86/pci.c:363: irq vector=133
[1.978770] ahci :00:17.0: AHCI 0001.0301 32 slots 1 ports 6 Gbps 0x1 
impl SATA mode
[1.987013] ahci :00:17.0: flags: 64bit ncq pm led clo only pio slum 
part deso sadm sd 
[1.995961] WARNING: CPU: 0 PID: 1 at drivers/ata/libata-core.c:6632 
ata_host_activate+0x3b
[1.19] Modules linked in:
[1.19] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.0-rc7+ #17
[1.19] RIP: 0010:ata_host_activate+0x33/0xfb
[1.19] Code: ce 41 55 49 89 d5 41 54 4d 89 c4 55 89 f5 53 48 89 fb 41 
51 e8 01 b7 ff f
[1.19] RSP: :c901bcb0 EFLAGS: 00010282
[1.19] RAX:  RBX: 880003f6f200 RCX: 0001
[1.19] RDX: 0001 RSI:  RDI: 
[1.19] RBP:  R08: 8001 R09: ea0c0f08
[1.19] R10: 0005 R11:  R12: 820e1640
[1.19] R13: 815002d3 R14: 0080 R15: 880003eb08a8
[1.19] FS:  () GS:88000440() 
knlGS:
[1.19] CS:  0010 DS:  ES:  CR0: 80050033
[1.19] CR2: c90bc000 CR3: 0200a001 CR4: 003626b0
[1.19] DR0:  DR1:  DR2: 
[1.19] DR3:  DR6: fffe0ff0 DR7: 0400
[1.19] Call Trace:
[1.19]  ahci_init_one+0xa74/0xad4
[1.19]  ? pm_runtime_deactivate_timer+0x5/0x2d

and then,

2.516932] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[7.590677] ata1.00: qc timeout (cmd 0xec)
[7.595870] ata1.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[7.916948] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[   18.086679] ata1.00: qc timeout (cmd 0xec)
[   18.091872] ata1.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[   18.097995] ata1: limiting SATA link speed to 3.0 Gbps
[   18.416935] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 320)
[   48.550679] ata1.00: qc timeout (cmd 0xec)
[   48.555871] ata1.00: failed to IDENTIFY (I/O error, err_mask=0x4)
[   48.876933] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 320)
[   48.884284] VFS: Cannot open root device "sda3" or unknown-block(0,0): error 
-6
[   48.891640] Please append a correct "root=" boot option; here are the 
available partitions:
[   48.900035] 0100   65536 ram0 
[   48.900036]  (driver?)



thanks,
-Minskey




-- 
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.


Re: Run Linux in non-root cell on NUC

2018-10-22 Thread minskey guo
On Monday, October 22, 2018 at 2:16:17 PM UTC+8, J. Kiszka wrote:
> On 22.10.18 06:30, minskey guo wrote:
> > On Monday, October 22, 2018 at 9:46:30 AM UTC+8, minskey guo wrote:
> >> On Sunday, October 21, 2018 at 7:34:12 PM UTC+8, J. Kiszka wrote:
> >>> On 19.10.18 11:19, Jan Kiszka wrote:
>  On 19.10.18 09:42, minskey guo wrote:
> >
> >>>
> >>> to get a bzImage for non-root cell.  Now, the COM1 has output now 
> >>> during
> >>> booting non-root-cell linux , but I run into another issue:
> >>>
> >>>    1.797742] RAPL PMU: API unit is 2^-32 Joules, 5 fixed 
> >>> counters, 655360
> >>> ms ovfl timer
> >>> [    1.805696] RAPL PMU: hw unit of domain pp0-core 2^-14 Joules
> >>> [    1.811470] RAPL PMU: hw unit of domain package 2^-14 Joules
> >>> [    1.817155] RAPL PMU: hw unit of domain dram 2^-14 Joules
> >>> [    1.822574] RAPL PMU: hw unit of domain pp1-gpu 2^-14 Joules
> >>> [    1.828254] RAPL PMU: hw unit of domain psys 2^-14 Joules
> >>> [    1.833679] clocksource: tsc: mask: 0x max_cycles:
> >>> 0x2717868ea45, max_idle_s
> >>> [    1.843722] clocksource: Switched to clocksource tsc
> >>> FATAL: Invalid PIO read, port: 87 size: 1
> >>
> >> That's a legacy resources, and that indicates your kernel lacks 
> >> Jailhouse
> >> awareness (CONFIG_JAILHOUSE_GUEST). There kernel will also report 
> >> during boot if
> >> it detected (and is aware of) Jailhouse.
> >
> > My kconfig has CONFIG_JAILHOUSE_GUEST.  Just realized that 87 is hex, 
> > so it is
> > DMA page register port.   Currently, I set pio_bitmap[] for that port 
> > to 1 in
> > both root and non-root cell. What else should I do ?
> >
> 
>  You should not (have to) hand this over. I thought to remember it was 
>  disabled
>  by one of the platform hooks in x86 that we have for Jailhouse, but 
>  maybe it was
>  some driver that should rather be turned off.
> 
>  Try deriving your config from the one we using in jailhouse-images.
> >>>
> >>> Actually, we have the issue in jailhouse-image as well. Will send out a 
> >>> patch
> >>> these days, but the trick to resolve it is simple: disable 
> >>> CONFIG_ISA_DMA_API
> >>> (requires CONFIG_EXPERT). The issue started with 4.18
> >>>
> >>> Jan
> >>>
> >>> -- 
> >>> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> >>> Corporate Competence Center Embedded Linux
> >>
> >> Can u send me the patch for a try ?
> >>
> >> thanks,
> >> -Minskey
> > 
> > I tried to disable ISA/DMA & DMA_ZONE in kconfig, the issue is still there. 
> > Should I disable all ATA/SATA driver as well ?  The attachment is my 
> > kconfig.
> > 
> 
> At least inside QEMU/KVM I was successfully testing the non-root cell boot 
> with 
> https://github.com/siemens/jailhouse-images/commit/6be7e7b7334638ace946149d7ad7b0456e4cfef8
>  
> and a 4.18-rt kernel. Will send out a 4.19 later today.
> 
> Are you sure your configuration change made it to the kernel image you tried? 
> A 
> common mistake, somewhere in the production line, that tends to happen to me 
> as 
> well. If yes, check the IP register value Jailhouse reports against the 
> kernel 
> symbols, where this comes from exactly.
> 
> Jan
> 
> -- 
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> Corporate Competence Center Embedded Linux



I toggle the pio bits for non-root cell as follows since Linux tries to probe 
VGA/EGA and results in a violation, now it fails at mounting rootfs because I 
am trying to pass a SATA to non-root cell. Will report back when it dones. 
thank u very much ! 

   .pio_bitmap = {
#if 1
[   0x0/8 ...  0x1ff/8] = -1,
[ 0x200/8 ...  0x2f7/8] = 0,
[ 0x2f8/8 ...  0x2ff/8] = 0, /* serial2 */
[ 0x300/8 ...  0x3f7/8] = 0, // -1,
[ 0x3f8/8 ...  0x3ff/8] = 0, /* serial1 */
[ 0x400/8 ... 0xdfff/8] = -1,
[0xe000/8 ... 0xe007/8] = 0, /* OXPCIe952 serial2 */
[0xe008/8 ... 0x/8] = -1,
#else
[0x0/8 ... 0x/8] = -1,
#endif
},

And the rootcell pio:

 .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] = 0xfc, /* RTC */
[  0x78/8 ...  0x3af/8] = -1,
[ 0x3b0/8 ...  0x3df/8] = 0x00, /* VGA */
[ 0x3e0/8 ...  0x3f7/8] = -1,
[ 0x3f8/8 ...  0x3ff/8] = 0,  /* disable UART0 in root-cell, 
and leave it to RT console */
[ 0x400/8 ...  0xcff/8] = -1,
[ 0xd00/8 ... 0x/8] = 0, /* HACK: PCI bus */
},

-- 
You received this message because