path: root/drivers/lguest
AgeCommit message (Collapse)Author
2015-02-18Merge tag 'virtio-next-for-linus' of ↵Linus Torvalds
git:// Pull virtio updates from Rusty Russell: "OK, this has the big virtio 1.0 implementation, as specified by OASIS. On top of tht is the major rework of lguest, to use PCI and virtio 1.0, to double-check the implementation. Then comes the inevitable fixes and cleanups from that work" * tag 'virtio-next-for-linus' of git:// (80 commits) virtio: don't set VIRTIO_CONFIG_S_DRIVER_OK twice. virtio_net: unconditionally define struct virtio_net_hdr_v1. tools/lguest: don't use legacy definitions for net device in example launcher. virtio: Don't expose legacy net features when VIRTIO_NET_NO_LEGACY defined. tools/lguest: use common error macros in the example launcher. tools/lguest: give virtqueues names for better error messages tools/lguest: more documentation and checking of virtio 1.0 compliance. lguest: don't look in console features to find emerg_wr. tools/lguest: don't start devices until DRIVER_OK status set. tools/lguest: handle indirect partway through chain. tools/lguest: insert driver references from the 1.0 spec (4.1 Virtio Over PCI) tools/lguest: insert device references from the 1.0 spec (4.1 Virtio Over PCI) tools/lguest: rename virtio_pci_cfg_cap field to match spec. tools/lguest: fix features_accepted logic in example launcher. tools/lguest: handle device reset correctly in example launcher. virtual: Documentation: simplify and generalize paravirt_ops.txt lguest: remove NOTIFY call and eventfd facility. lguest: remove NOTIFY facility from demonstration launcher. lguest: use the PCI console device's emerg_wr for early boot messages. lguest: always put console in PCI slot #1. ...
2015-02-11lguest: remove NOTIFY call and eventfd facility.Rusty Russell
Disappointing, as this was kind of neat (especially getting to use RCU to manage the address -> eventfd mapping). But now the devices are PCI handled in userspace, we get rid of both the NOTIFY hypercall and the interface to connect an eventfd. Signed-off-by: Rusty Russell <>
2015-02-11lguest: remove support for lguest bus.Rusty Russell
The demonstration launcher now uses PCI entirely. Signed-off-by: Rusty Russell <>
2015-02-11lguest: add iomem region, where guest page faults get sent to userspace.Rusty Russell
This lets us implement PCI. Signed-off-by: Rusty Russell <>
2015-02-11lguest: send trap 13 through to userspace.Rusty Russell
We copy 7 bytes at eip for userspace's instruction decode; we have to carefully handle the case where eip is at the end of a page. We can't leave this to userspace since kernel has all the page table decode logic. The decode logic moves to userspace, basically unchanged. Signed-off-by: Rusty Russell <>
2015-02-11lguest: add infrastructure to check mappings.Rusty Russell
We normally abort the guest unconditionally when it gives us a bad address, but in the next patch we want to copy some bytes which may not be mapped. Signed-off-by: Rusty Russell <>
2015-02-11lguest: add infrastructure for userspace to deliver a trap to the guest.Rusty Russell
This is required for instruction emulation to move to userspace. Signed-off-by: Rusty Russell <>
2015-02-11lguest: write more information to userspace about pending traps.Rusty Russell
This is preparation for userspace handling MMIO and ioport accesses. Signed-off-by: Rusty Russell <>
2015-02-11lguest: add operations to get/set a register from the Launcher.Rusty Russell
We use the ptrace API struct, and we currently don't let them set anything but the normal registers (we'd have to filter the others). Signed-off-by: Rusty Russell <>
2015-02-04x86: Clean up cr4 manipulationAndy Lutomirski
CR4 manipulation was split, seemingly at random, between direct (write_cr4) and using a helper (set/clear_in_cr4). Unfortunately, the set_in_cr4 and clear_in_cr4 helpers also poke at the boot code, which only a small subset of users actually wanted. This patch replaces all cr4 access in functions that don't leave cr4 exactly the way they found it with new helpers cr4_set_bits, cr4_clear_bits, and cr4_set_bits_and_update_boot. Signed-off-by: Andy Lutomirski <> Reviewed-by: Thomas Gleixner <> Signed-off-by: Peter Zijlstra (Intel) <> Cc: Andrea Arcangeli <> Cc: Vince Weaver <> Cc: "hillf.zj" <> Cc: Valdis Kletnieks <> Cc: Paul Mackerras <> Cc: Arnaldo Carvalho de Melo <> Cc: Kees Cook <> Cc: Linus Torvalds <> Link: Signed-off-by: Ingo Molnar <>
2014-12-09virtio: allow finalize_features to failMichael S. Tsirkin
This will make it easy for transports to validate features and return failure. Signed-off-by: Michael S. Tsirkin <>
2014-12-09virtio: assert 32 bit features in transportsMichael S. Tsirkin
At this point, no transports set any of the high 32 feature bits. Since transports generally can't (yet) cope with such bits, add BUG_ON checks to make sure they are not set by mistake. Based on rproc patch by Rusty. Signed-off-by: Rusty Russell <> Signed-off-by: Michael S. Tsirkin <> Reviewed-by: David Hildenbrand <> Reviewed-by: Cornelia Huck <>
2014-12-09virtio: add support for 64 bit features.Michael S. Tsirkin
Change u32 to u64, and use BIT_ULL and 1ULL everywhere. Note: transports are unchanged, and only set low 32 bit. This guarantees that no transport sets e.g. VERSION_1 by mistake without proper support. Based on patch by Rusty. Signed-off-by: Rusty Russell <> Signed-off-by: Cornelia Huck <> Signed-off-by: Michael S. Tsirkin <> Reviewed-by: David Hildenbrand <> Reviewed-by: Cornelia Huck <>
2014-12-09virtio: use u32, not bitmap for featuresMichael S. Tsirkin
It seemed like a good idea to use bitmap for features in struct virtio_device, but it's actually a pain, and seems to become even more painful when we get more than 32 feature bits. Just change it to a u32 for now. Based on patch by Rusty. Suggested-by: David Hildenbrand <> Signed-off-by: Rusty Russell <> Signed-off-by: Cornelia Huck <> Signed-off-by: Michael S. Tsirkin <> Reviewed-by: Cornelia Huck <>
2014-08-06mm/vmalloc.c: clean up map_vm_area third argumentWANG Chao
Currently map_vm_area() takes (struct page *** pages) as third argument, and after mapping, it moves (*pages) to point to (*pages + nr_mappped_pages). It looks like this kind of increment is useless to its caller these days. The callers don't care about the increments and actually they're trying to avoid this by passing another copy to map_vm_area(). The caller can always guarantee all the pages can be mapped into vm_area as specified in first argument and the caller only cares about whether map_vm_area() fails or not. This patch cleans up the pointer movement in map_vm_area() and updates its callers accordingly. Signed-off-by: WANG Chao <> Cc: Zhang Yanfei <> Acked-by: Greg Kroah-Hartman <> Cc: Minchan Kim <> Cc: Nitin Gupta <> Cc: Rusty Russell <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2014-04-07drivers/lguest/page_tables.c: rename do_set_pte()Andrew Morton
"mm: introduce vm_ops->map_pages()" wants to export a do_set_pte() from core kernel. Rename lguest's do_set_pte() to something more lguest-specific. Cc: "Kirill A. Shutemov" <> Cc: Rusty Russell <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2013-11-07x86, asmlinkage, lguest: Pass in globals into assembler statementAndi Kleen
Tell the compiler that the inline assembler statement references lguest_entry. This fixes compile problems with LTO where the variable and the assembler code may end up in different files. Cc: Cc: Signed-off-by: Andi Kleen <> Signed-off-by: Rusty Russell <>
2013-10-29virtio_ring: change host notification APIHeinz Graalfs
Currently a host kick error is silently ignored and not reflected in the virtqueue of a particular virtio device. Changing the notify API for guest->host notification seems to be one prerequisite in order to be able to handle such errors in the context where the kick is triggered. This patch changes the notify API. The notify function must return a bool return value. It returns false if the host notification failed. Signed-off-by: Heinz Graalfs <> Signed-off-by: Rusty Russell <>
2013-09-06lguest: fix guest kernel stack overflow when TF bit set.Rusty Russell
The symptoms are that running gdb on a binary causes the guest to overflow the kernels stack (after some period of time), resulting in it finally being killed with a "Bad address" message. Reported-by: Sakari Ailus <> Signed-off-by: Rusty Russell <>
2013-09-06lguest: fix BUG_ON() in invalid guest page table.Rusty Russell
If we discover the entry is invalid, we kill the guest, but we must avoid calling gpte_addr() on the invalid pmd, otherwise: kernel BUG at drivers/lguest/page_tables.c:157! Signed-off-by: Rusty Russell <>
2013-07-04Merge branch 'for-linus' of ↵Linus Torvalds
git:// Pull trivial tree updates from Jiri Kosina: "The usual stuff from trivial tree" * 'for-linus' of git:// (34 commits) treewide: relase -> release Documentation/cgroups/memory.txt: fix stat file documentation sysctl/net.txt: delete reference to obsolete 2.4.x kernel spinlock_api_smp.h: fix preprocessor comments treewide: Fix typo in printk doc: device tree: clarify stuff in usage-model.txt. open firmware: "/aliasas" -> "/aliases" md: bcache: Fixed a typo with the word 'arithmetic' irq/generic-chip: fix a few kernel-doc entries frv: Convert use of typedef ctl_table to struct ctl_table sgi: xpc: Convert use of typedef ctl_table to struct ctl_table doc: clk: Fix incorrect wording Documentation/arm/IXP4xx fix a typo Documentation/networking/ieee802154 fix a typo Documentation/DocBook/media/v4l fix a typo Documentation/video4linux/si476x.txt fix a typo Documentation/virtual/kvm/api.txt fix a typo Documentation/early-userspace/README fix a typo Documentation/video4linux/soc-camera.txt fix a typo lguest: fix CONFIG_PAE -> CONFIG_x86_PAE in comment ...
2013-06-25x86, flags: Rename X86_EFLAGS_BIT1 to X86_EFLAGS_FIXEDH. Peter Anvin
Bit 1 in the x86 EFLAGS is always set. Name the macro something that actually tries to explain what it is all about, rather than being a tautology. Signed-off-by: H. Peter Anvin <> Cc: Rusty Russell <> Cc: Gleb Natapov <> Cc: Paolo Bonzini <> Link:
2013-05-29lguest: fix CONFIG_PAE -> CONFIG_x86_PAE in commentPaul Bolle
Signed-off-by: Paul Bolle <> Signed-off-by: Jiri Kosina <>
2013-05-08lguest: clear cached last cpu when guest_set_pgd() called.Rusty Russell
commit v3.9-rc1-53-g6d0cda9 "lguest: cache last cpu we ran on." missed one case, which causes a triple fault. The guest calls guest_set_pgd() on the top page, and we carefully remap the Switcher text page. But we didn't reset last_host_cpu, so map_switcher_in_guest() thinks the guest's regs and IDT/GDT etc are already mapped. Reported-by: Paul Bolle <> Tested-by: Paul Bolle <> Signed-off-by: Rusty Russell <>
2013-05-02Merge tag 'virtio-next-for-linus' of ↵Linus Torvalds
git:// Pull virtio & lguest updates from Rusty Russell: "Lots of virtio work which wasn't quite ready for last merge window. Plus I dived into lguest again, reworking the pagetable code so we can move the switcher page: our fixmaps sometimes take more than 2MB now..." Ugh. Annoying conflicts with the tcm_vhost -> vhost_scsi rename. Hopefully correctly resolved. * tag 'virtio-next-for-linus' of git:// (57 commits) caif_virtio: Remove bouncing email addresses lguest: improve code readability in lg_cpu_start. virtio-net: fill only rx queues which are being used lguest: map Switcher below fixmap. lguest: cache last cpu we ran on. lguest: map Switcher text whenever we allocate a new pagetable. lguest: don't share Switcher PTE pages between guests. lguest: expost switcher_pages array (as lg_switcher_pages). lguest: extract shadow PTE walking / allocating. lguest: make check_gpte et. al return bool. lguest: assume Switcher text is a single page. lguest: rename switcher_page to switcher_pages. lguest: remove RESERVE_MEM constant. lguest: check vaddr not pgd for Switcher protection. lguest: prepare to make SWITCHER_ADDR a variable. virtio: console: replace EMFILE with EBUSY for already-open port virtio-scsi: reset virtqueue affinity when doing cpu hotplug virtio-scsi: introduce multiqueue support virtio-scsi: push vq lock/unlock into virtscsi_vq_done virtio-scsi: pass struct virtio_scsi to virtqueue completion function ...
2013-04-29lguest: rename random32() to prandom_u32()Akinobu Mita
Use preferable function name which implies using a pseudo-random number generator. Signed-off-by: Akinobu Mita <> Acked-by: Rusty Russell <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2013-04-30lguest: improve code readability in lg_cpu_start.Cosmin Paraschiv
Make the container_of call friendlier and fix some comment slip-ups. Signed-off-by: Cosmin Paraschiv <> Cc: Daniel Baluta <> Signed-off-by: Rusty Russell <>
2013-04-22lguest: map Switcher below fixmap.Rusty Russell
Now we've adjusted all the code, we can simply set switcher_addr to wherever it needs to go below the fixmaps, rather than asserting that it should be so. With large NR_CPUS and PAE, people were hitting the "mapping switcher would thwack fixmap" message. Reported-by: Paul Bolle <> Signed-off-by: Rusty Russell <>
2013-04-22lguest: cache last cpu we ran on.Rusty Russell
This optimizes the frobbing of our Switcher map. Signed-off-by: Rusty Russell <>
2013-04-22lguest: map Switcher text whenever we allocate a new pagetable.Rusty Russell
It's always to same, so no need to put in the PTE every time we're about to run. Keep a flag to track whether the pagetable has the Switcher entries allocated, and when allocating always initialize the Switcher text PTE. Signed-off-by: Rusty Russell <>
2013-04-22lguest: don't share Switcher PTE pages between guests.Rusty Russell
We currently use the whole top PGD entry for the switcher, so we simply share a fixed page of PTEs between all guests (actually, it's one per Host CPU, to ensure isolation between guests). Changes to a scheme where every guest has its own mappings. Signed-off-by: Rusty Russell <>
2013-04-22lguest: expost switcher_pages array (as lg_switcher_pages).Rusty Russell
We will need this in page_table.c soon. Signed-off-by: Rusty Russell <>
2013-04-22lguest: extract shadow PTE walking / allocating.Rusty Russell
We want a separate find_pte() function so we can call it for populating the switcher PTE entries. We can also use it in page_writable(). Signed-off-by: Rusty Russell <>
2013-04-22lguest: make check_gpte et. al return bool.Rusty Russell
This is a bit neater: we can immediately return if a PTE/PGD/PMD entry is invalid (which also kills the guest). It means we don't risk using invalid entries as we reshuffle the code. Signed-off-by: Rusty Russell <>
2013-04-22lguest: assume Switcher text is a single page.Rusty Russell
ie. SHARED_SWITCHER_PAGES == 1. It is well under a page, and it's a minor simplification: it's nice to have *one* simplification in a patch series! Signed-off-by: Rusty Russell <>
2013-04-22lguest: rename switcher_page to switcher_pages.Rusty Russell
There is a single page with the Switcher in it, but it's followed by 2 pages per Host CPU. Signed-off-by: Rusty Russell <>
2013-04-22lguest: remove RESERVE_MEM constant.Rusty Russell
We can use switcher_addr directly. Signed-off-by: Rusty Russell <>
2013-04-22lguest: check vaddr not pgd for Switcher protection.Rusty Russell
We currently assume that the Switcher the top pgd; we want to remove this assumption, so check that vaddr is OK, rather then checking pgd index. Signed-off-by: Rusty Russell <>
2013-04-22lguest: prepare to make SWITCHER_ADDR a variable.Rusty Russell
We currently use the whole top PGD entry for the switcher, but that's hitting the fixmap in some configurations (mainly, large NR_CPUS). Introduce a variable, currently set to the constant. Signed-off-by: Rusty Russell <>
2013-03-07lguest: fix paths in commentsWanlong Gao
After commit 07fe997, lguest tool has already moved from Documentation/virtual/lguest/ to tools/lguest/. Signed-off-by: Wanlong Gao <> Signed-off-by: Rusty Russell <>
2013-02-26Merge tag 'virtio-next-for-linus' of ↵Linus Torvalds
git:// Pull virtio updates from Rusty Russell: "All trivial, thanks to the stuff which didn't quite make it time" * tag 'virtio-next-for-linus' of git:// virtio_console: Initialize guest_connected=true for rproc_serial virtio: use module_virtio_driver. virtio: Add module driver macro for virtio drivers. virtio_console: Use virtio device index to generate port name virtio: make pci_device_id const virtio: make config_ops const virtio-mmio: fix wrong comment about register offset virtio_console: Let unconnected rproc device receive data.
2013-02-21Merge tag 'tty-3.9-rc1' of ↵Linus Torvalds
git:// Pull tty/serial patches from Greg Kroah-Hartman: "Here's the big tty/serial driver patches for 3.9-rc1. More tty port rework and fixes from Jiri here, as well as lots of individual serial driver updates and fixes. All of these have been in the linux-next tree for a while." * tag 'tty-3.9-rc1' of git:// (140 commits) tty: mxser: improve error handling in mxser_probe() and mxser_module_init() serial: imx: fix uninitialized variable warning serial: tegra: assume CONFIG_OF TTY: do not update atime/mtime on read/write lguest: select CONFIG_TTY to build properly. ARM defconfigs: add missing inclusions of linux/platform_device.h fb/exynos: include platform_device.h ARM: sa1100/assabet: include platform_device.h directly serial: imx: Fix recursive locking bug pps: Fix build breakage from decoupling pps from tty tty: Remove ancient hardpps() pps: Additional cleanups in uart_handle_dcd_change pps: Move timestamp read into PPS code proper pps: Don't crash the machine when exiting will do pps: Fix a use-after free bug when unregistering a source. pps: Use pps_lookup_dev to reduce ldisc coupling pps: Add pps_lookup_dev() function tty: serial: uartlite: Support uartlite on big and little endian systems tty: serial: uartlite: Fix sparse and checkpatch warnings serial/arc-uart: Miscll DT related updates (Grant's review comments) ... Fix up trivial conflicts, mostly just due to the TTY config option clashing with the EXPERIMENTAL removal.
2013-02-11virtio: make config_ops constStephen Hemminger
It is just a table of function pointers, make it const for cleanliness and security reasons. Signed-off-by: Stephen Hemminger <> Signed-off-by: Rusty Russell <>
2013-01-18tty: Added a CONFIG_TTY option to allow removal of TTYJoe Millenbach
The option allows you to remove TTY and compile without errors. This saves space on systems that won't support TTY interfaces anyway. bloat-o-meter output is below. The bulk of this patch consists of Kconfig changes adding "depends on TTY" to various serial devices and similar drivers that require the TTY layer. Ideally, these dependencies would occur on a common intermediate symbol such as SERIO, but most drivers "select SERIO" rather than "depends on SERIO", and "select" does not respect dependencies. bloat-o-meter output comparing our previous minimal to new minimal by removing TTY. The list is filtered to not show removed entries with awk '$3 != "-"' as the list was very long. add/remove: 0/226 grow/shrink: 2/14 up/down: 6/-35356 (-35350) function old new delta chr_dev_init 166 170 +4 allow_signal 80 82 +2 static.__warned 143 142 -1 disallow_signal 63 62 -1 __set_special_pids 95 94 -1 unregister_console 126 121 -5 start_kernel 546 541 -5 register_console 593 588 -5 copy_from_user 45 40 -5 sys_setsid 128 120 -8 sys_vhangup 32 19 -13 do_exit 1543 1526 -17 bitmap_zero 60 40 -20 arch_local_irq_save 137 117 -20 release_task 674 652 -22 static.spin_unlock_irqrestore 308 260 -48 Signed-off-by: Joe Millenbach <> Reviewed-by: Jamey Sharp <> Reviewed-by: Josh Triplett <> Signed-off-by: Greg Kroah-Hartman <>
2013-01-11drivers/lguest: remove depends on CONFIG_EXPERIMENTALKees Cook
The CONFIG_EXPERIMENTAL config item has not carried much meaning for a while now and is almost always enabled by default. As agreed during the Linux kernel summit, remove it from any "depends on" lines in Kconfigs. CC: Rusty Russell <> Signed-off-by: Kees Cook <> Acked-by: Rusty Russell <>
2012-12-18lguest: fix typoAlex Russell
Signed-off-by: Alex Russell <> Signed-off-by: Rusty Russell <>
2012-10-07Merge branch 'virtio-next' of ↵Linus Torvalds
git:// Pull virtio changes from Rusty Russell: "New workflow: same git trees pulled by linux-next get sent straight to Linus. Git is awkward at shuffling patches compared with quilt or mq, but that doesn't happen often once things get into my -next branch." * 'virtio-next' of git:// (24 commits) lguest: fix occasional crash in example launcher. virtio-blk: Disable callback in virtblk_done() virtio_mmio: Don't attempt to create empty virtqueues virtio_mmio: fix off by one error allocating queue drivers/virtio/virtio_pci.c: fix error return code virtio: don't crash when device is buggy virtio: remove CONFIG_VIRTIO_RING virtio: add help to CONFIG_VIRTIO option. virtio: support reserved vqs virtio: introduce an API to set affinity for a virtqueue virtio-ring: move queue_index to vring_virtqueue virtio_balloon: not EXPERIMENTAL any more. virtio-balloon: dependency fix virtio-blk: fix NULL checking in virtblk_alloc_req() virtio-blk: Add REQ_FLUSH and REQ_FUA support to bio path virtio-blk: Add bio-based IO path for virtio-blk virtio: console: fix error handling in init() function tools: Fix pthread flag for Makefile of trace-agent used by virtio-trace tools: Add guest trace agent as a user tool virtio/console: Allocate scatterlist according to the current pipe size ...
2012-09-28virtio: support reserved vqsMichael S. Tsirkin
virtio network device multiqueue support reserves vq 3 for future use (useful both for future extensions and to make it pretty - this way receive vqs have even and transmit - odd numbers). Make it possible to skip initialization for specific vq numbers by specifying NULL for name. Document this usage as well as (existing) NULL callback. Drivers using this not coded up yet, so I simply tested with virtio-pci and verified that this patch does not break existing drivers. Signed-off-by: Michael S. Tsirkin <> Signed-off-by: Rusty Russell <>
2012-09-28virtio-ring: move queue_index to vring_virtqueueJason Wang
Instead of storing the queue index in transport-specific virtio structs, this patch moves them to vring_virtqueue and introduces an helper to get the value. This lets drivers simplify their management and tracing of virtqueues. Signed-off-by: Jason Wang <> Signed-off-by: Paolo Bonzini <> Signed-off-by: Rusty Russell <>
2012-09-18lguest, x86: handle guest TS bit for lazy/non-lazy fpu host modelsSuresh Siddha
Instead of using unlazy_fpu() check if user_has_fpu() and set/clear the host TS bits so that the lguest works fine with both the lazy/non-lazy FPU host models with minimal changes. Signed-off-by: Suresh Siddha <> Link: Cc: Rusty Russell <> Signed-off-by: H. Peter Anvin <>