The PCI mmconfig base address was not exported to inmates, so Linux
running on non-root cells didn't had access to PCI Express extended
config space, at least in x86, because this is not accessible using port IO.
This patch adds the pci_mmconfig_base address to the comm_region struct
to export it to Linux inmates. I am sending, just after this,a patch
corresponding to necessary updates in Linux in order to get the
pci_mmconfig_base parameter and use it to access PCI mmconfig.
It is possible to test these patches by reading the PCI config space in
a Linux inmate and checking if the extented capabilites are accessible.
One sample I did to validate the proposed changes was the following
python script, based on the jailhouse-config-create tool, to look for
the Serial Number Capability and print it.
from __future__ import print_function
import sys
import os
import math
import re
import argparse
import struct
import fnmatch
def print_serial(device):
has_extended_caps = False
dir = '/sys/bus/pci/devices'
try:
f = open(os.path.join(dir, device, 'config'), 'rb')
except Exception as e:
print('Invalid device: ' + device)
print('File ' + os.path.join(dir, device, 'config') + ' not found.')
return
f.seek(0x06)
(status,) = struct.unpack('<H', f.read(2))
# capability list supported?
if (status & (1 << 4)) == 0:
print('No capabilities')
f.close()
return
# walk capability list
f.seek(0x34)
(next,) = struct.unpack('B', f.read(1))
while next != 0:
cap = next
msix_address = 0
f.seek(cap)
(id, next) = struct.unpack('<BB', f.read(2))
if id == 0x10: # Express
has_extended_caps = True
break;
if not has_extended_caps:
print('No extended capabilities')
return
next = 0x100
while next != 0:
cap = next
f.seek(cap)
(id, version_next) = struct.unpack('<HH', f.read(4))
next = version_next >> 4
if id == 0xffff:
print('No Device Serial Number extended capability')
break
elif id == 0x3: #Serial Number
f.seek(cap + 0x4)
serial = struct.unpack('<BBBBBBBB', f.read(8))
serial.reverse()
serial = [format(s, '02x') for s in serial]
break
f.close()
print_serial(sys.argv[1])
Otavio Pontes (1):
x86: Export PCI mmconfig base address to Linux inmates
hypervisor/arch/x86/control.c | 2 ++
hypervisor/arch/x86/include/asm/jailhouse_hypercall.h | 1 +
inmates/tools/x86/linux-loader.c | 2 ++
tools/jailhouse-cell-linux | 2 +-
4 files changed, 6 insertions(+), 1 deletion(-)
--
2.14.3
--
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].
For more options, visit https://groups.google.com/d/optout.