All of lore.kernel.org
 help / color / mirror / Atom feed
* Generically, how to see a host-pci-device on guest?
@ 2021-09-28  7:33 Ajay Garg
  2021-09-28 14:54 ` Ajay Garg
  0 siblings, 1 reply; 3+ messages in thread
From: Ajay Garg @ 2021-09-28  7:33 UTC (permalink / raw)
  To: kvm

Hi All.

I have the following set up:

* Host : Ubuntu-16, on a amd64 hardware
* Guest : Ubuntu-21, as a VM on QEMU/KVM.


Now, I have a SD-MMC card-reader attached physically on the host,
which is listed as expected if I do lspci on the host :

############################################
ajay@ajay-Latitude-E6320:~/ldd3$ lspci
....
....
0a:00.0 SD Host controller: O2 Micro, Inc. OZ600FJ0/OZ900FJ0/OZ600FJS
SD/MMC Card Reader Controller (rev 05)
....
############################################


However, if I try doing lspci on the guest, this pci-device is not listed.




So, I have the following queries :

* Would it require enabling pci-passthrough (if not already) in the
guest-kernel, on a global basis?
* Does having raw-physical-access on the guest, require support from
the pci-device itself?


My ultimate aim is to get the sd-mmc-driver that I wrote for the
host-machine, to run unmodified on the guest-machine (obviously after
the sd-card-reader is detected on the guest, and the code recompiled
on the guest).


Will be grateful for any pointers.


Thanks and Regards,
Ajay

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Generically, how to see a host-pci-device on guest?
  2021-09-28  7:33 Generically, how to see a host-pci-device on guest? Ajay Garg
@ 2021-09-28 14:54 ` Ajay Garg
  2021-09-30  2:37   ` Ajay Garg
  0 siblings, 1 reply; 3+ messages in thread
From: Ajay Garg @ 2021-09-28 14:54 UTC (permalink / raw)
  To: kvm

Hi All.

I made some progress, but still pci-passthrough is not enabled.


Following are the bullet-points :

a)
On host, /proc/cpuinfo shows the following :

########################################
ajay@ajay-Latitude-E6320:~$ cat /proc/cpuinfo | grep vmx | wc -l
4
########################################


b)
On guest, /proc/cpuinfo shows the following :

########################################
ajay@ajay-Standard-PC-i440FX-PIIX-1996:~$ cat /proc/cpuinfo | grep vmx | wc -l
0
########################################



c)
Guest has been booted with intel_iommu on, as confirmed by the following logs :

########################################
Sep 28 20:05:46 ajay-Standard-PC-i440FX-PIIX-1996 kernel: [
0.025210] Kernel command line:
BOOT_IMAGE=/boot/vmlinuz-5.11.0-37-generic
root=UUID=a32e7e30-7796-464b-9efc-720eb4fc7706 ro quiet splash
intel_iommu=on vt.handoff=7
Sep 28 20:05:46 ajay-Standard-PC-i440FX-PIIX-1996 kernel: [
0.025301] DMAR: IOMMU enabled
########################################


Note that just one DMAR log is seen.


d)
On guest, following are the outputs, when trying to observe virtual
iommu devices/groups etc :

########################################
ajay@ajay-Standard-PC-i440FX-PIIX-1996:~$ ls -lrth /sys/kernel/iommu_groups/
total 0

ajay@ajay-Standard-PC-i440FX-PIIX-1996:~$ ls -lrth /sys/devices/virtual/iommu
ls: cannot access '/sys/devices/virtual/iommu': No such file or directory
########################################


What am I missing?




On Tue, Sep 28, 2021 at 1:03 PM Ajay Garg <ajaygargnsit@gmail.com> wrote:
>
> Hi All.
>
> I have the following set up:
>
> * Host : Ubuntu-16, on a amd64 hardware
> * Guest : Ubuntu-21, as a VM on QEMU/KVM.
>
>
> Now, I have a SD-MMC card-reader attached physically on the host,
> which is listed as expected if I do lspci on the host :
>
> ############################################
> ajay@ajay-Latitude-E6320:~/ldd3$ lspci
> ....
> ....
> 0a:00.0 SD Host controller: O2 Micro, Inc. OZ600FJ0/OZ900FJ0/OZ600FJS
> SD/MMC Card Reader Controller (rev 05)
> ....
> ############################################
>
>
> However, if I try doing lspci on the guest, this pci-device is not listed.
>
>
>
>
> So, I have the following queries :
>
> * Would it require enabling pci-passthrough (if not already) in the
> guest-kernel, on a global basis?
> * Does having raw-physical-access on the guest, require support from
> the pci-device itself?
>
>
> My ultimate aim is to get the sd-mmc-driver that I wrote for the
> host-machine, to run unmodified on the guest-machine (obviously after
> the sd-card-reader is detected on the guest, and the code recompiled
> on the guest).
>
>
> Will be grateful for any pointers.
>
>
> Thanks and Regards,
> Ajay

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Generically, how to see a host-pci-device on guest?
  2021-09-28 14:54 ` Ajay Garg
@ 2021-09-30  2:37   ` Ajay Garg
  0 siblings, 0 replies; 3+ messages in thread
From: Ajay Garg @ 2021-09-30  2:37 UTC (permalink / raw)
  To: kvm

Hi everyone.

I got it working, now I am learning/reading how things fit/work :)

For other newbies's benefit, here is what was required :

a)
On the host machine, ensured that virtualization is supported via
hardware/CPU/chipset.

b)
If a) is applicable, then, on the host machine, enabled IOMMU in the
kernel (via kernel command-line argument intel_iommu=on), and then
booted the host machine with this kernel.

c)
Then, attached a pci-device on to a KVM guest machine.

d)
After the guest machine finished booting, *lspci* showed the device
both on the host, as well as the guest.



Thanks and Regards,
Ajay


On Tue, Sep 28, 2021 at 8:24 PM Ajay Garg <ajaygargnsit@gmail.com> wrote:
>
> Hi All.
>
> I made some progress, but still pci-passthrough is not enabled.
>
>
> Following are the bullet-points :
>
> a)
> On host, /proc/cpuinfo shows the following :
>
> ########################################
> ajay@ajay-Latitude-E6320:~$ cat /proc/cpuinfo | grep vmx | wc -l
> 4
> ########################################
>
>
> b)
> On guest, /proc/cpuinfo shows the following :
>
> ########################################
> ajay@ajay-Standard-PC-i440FX-PIIX-1996:~$ cat /proc/cpuinfo | grep vmx | wc -l
> 0
> ########################################
>
>
>
> c)
> Guest has been booted with intel_iommu on, as confirmed by the following logs :
>
> ########################################
> Sep 28 20:05:46 ajay-Standard-PC-i440FX-PIIX-1996 kernel: [
> 0.025210] Kernel command line:
> BOOT_IMAGE=/boot/vmlinuz-5.11.0-37-generic
> root=UUID=a32e7e30-7796-464b-9efc-720eb4fc7706 ro quiet splash
> intel_iommu=on vt.handoff=7
> Sep 28 20:05:46 ajay-Standard-PC-i440FX-PIIX-1996 kernel: [
> 0.025301] DMAR: IOMMU enabled
> ########################################
>
>
> Note that just one DMAR log is seen.
>
>
> d)
> On guest, following are the outputs, when trying to observe virtual
> iommu devices/groups etc :
>
> ########################################
> ajay@ajay-Standard-PC-i440FX-PIIX-1996:~$ ls -lrth /sys/kernel/iommu_groups/
> total 0
>
> ajay@ajay-Standard-PC-i440FX-PIIX-1996:~$ ls -lrth /sys/devices/virtual/iommu
> ls: cannot access '/sys/devices/virtual/iommu': No such file or directory
> ########################################
>
>
> What am I missing?
>
>
>
>
> On Tue, Sep 28, 2021 at 1:03 PM Ajay Garg <ajaygargnsit@gmail.com> wrote:
> >
> > Hi All.
> >
> > I have the following set up:
> >
> > * Host : Ubuntu-16, on a amd64 hardware
> > * Guest : Ubuntu-21, as a VM on QEMU/KVM.
> >
> >
> > Now, I have a SD-MMC card-reader attached physically on the host,
> > which is listed as expected if I do lspci on the host :
> >
> > ############################################
> > ajay@ajay-Latitude-E6320:~/ldd3$ lspci
> > ....
> > ....
> > 0a:00.0 SD Host controller: O2 Micro, Inc. OZ600FJ0/OZ900FJ0/OZ600FJS
> > SD/MMC Card Reader Controller (rev 05)
> > ....
> > ############################################
> >
> >
> > However, if I try doing lspci on the guest, this pci-device is not listed.
> >
> >
> >
> >
> > So, I have the following queries :
> >
> > * Would it require enabling pci-passthrough (if not already) in the
> > guest-kernel, on a global basis?
> > * Does having raw-physical-access on the guest, require support from
> > the pci-device itself?
> >
> >
> > My ultimate aim is to get the sd-mmc-driver that I wrote for the
> > host-machine, to run unmodified on the guest-machine (obviously after
> > the sd-card-reader is detected on the guest, and the code recompiled
> > on the guest).
> >
> >
> > Will be grateful for any pointers.
> >
> >
> > Thanks and Regards,
> > Ajay

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-30  2:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28  7:33 Generically, how to see a host-pci-device on guest? Ajay Garg
2021-09-28 14:54 ` Ajay Garg
2021-09-30  2:37   ` Ajay Garg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.