summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* xen/pvh: place the trampoline at page 0x14.10.0-shim-comet-34.10.0-shim-cometRoger Pau Monne2018-01-172-2/+10
| | | | | | | | | | | | | | | Since PVH guest jump straight into trampoline_setup trampoline_phys is not initialized, thus the trampoline is relocated to address 0. This works, but has the undesirable effect of having VA 0 mapped to MFN 0, which means NULL pointed dereferences no longer trigger a page fault. In order to solve this, place the trampoline at page 0x1 and reserve the memory used by it. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com>
* firmware/shim: fix build process to use POSIX find optionsRoger Pau Monne2018-01-171-1/+2
| | | | | | | | The -printf find option is not POSIX compatible, so replace it with another rune. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com>
* x86/guest: use the vcpu_info area from shared_infoRoger Pau Monne2018-01-171-1/+2
| | | | | | | | | | | | If using less than 32 vCPUs (XEN_LEGACY_MAX_VCPUS). This is a workaround that should allow to boot the shim on hypervisors without commit "x86/upcall: inject a spurious event after setting upcall vector" as long as less than 32 vCPUs are assigned to the shim. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Jan Beulich <JBeulich@suse.com>
* -xen-attach is needed for pvh boot with qemu-xen4.10.0-shim-comet-2Michael Young2018-01-161-1/+1
| | | | | | | | | | | | | | | | | Currently the boot of a pvh guest using the qemu-xen device model fails with the error xen emulation not implemented (yet) in the qemu-dm log file. This patch adds the missing -xen-attach argument. V2: Use b_info->type != LIBXL_DOMAIN_TYPE_HVM instead of (b_info->type == LIBXL_DOMAIN_TYPE_PV) || (b_info->type == LIBXL_DOMAIN_TYPE_PVH) as recommended by Roger Pau Monné. Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com>
* xen/pvshim: map vcpu_info earlier for APsRoger Pau Monne2018-01-161-3/+3
| | | | | | | | Or else init_percpu_time is going to dereference a NULL pointer when trying to access vcpu_info. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Tested-by: George Dunlap <george.dunlap@citrix.com>
* xl: pvshim: Provide and document xl config4.10.0-shim-comet-1.1Ian Jackson2018-01-122-0/+49
| | | | | | | | | Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- v2: pvshim, not pvhshim works with type "pvh", not type "pv" pvshim_etc. options in config are not erroneously ignored
* libxl: pvshim: Introduce pvshim_extraIan Jackson2018-01-124-3/+7
| | | | | | | | | | And move the debugging options from the default config into a doc comment in libxl_types.idl. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- v2: pvshim, not pvhshim works with type "pvh", not type "pv"
* libxl: pvshim: Provide first-class config settings to enable shim modeIan Jackson2018-01-125-12/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is API-compatible because old callers are supposed to call libxl_*_init to initialise the struct; and the updated function clears these members. It is ABI-compatible because the new fields make this member of the guest type union larger but only within the existing size of that union. Unfortunately it is not easy to backport because it depends on the PVH domain type. Attempts to avoid use of the PVH domain type involved working with two views of the configuration: the "underlying" domain type and the "visible" type (and corresponding config info). Also there are different sets of config settings for PV and PVH, which callers would have to know to set. And, unfortunately, it will not be possible, with this approach, to enable the shim by default for all libxl callers. (Although it could perhaps be done in xl.) For now, our config defaults are: * if enabled, path is "xen-shim" in the xen firmware directory * if enabled, cmdline is the one we are currently debugging with The debugging arguments will be rationalised in a moment. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Signed-off-by: George Dunlap <george.dunlap@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- v2: pvshim, not pvhshim works with type "pvh", not type "pv"
* xen/shim: allow DomU to have as many vcpus as availableRoger Pau Monne2018-01-123-14/+46
| | | | | | | | | | | | | Since the shim VCPUOP_{up/down} hypercall is wired to the plug/unplug of CPUs to the shim itself, start the shim DomU with only the BSP online, and let the guest bring up other CPUs as it needs them. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Changes since v1: - Fix single line comment style. - Print Dom%u d->domain_id. - Change position of __start_xen comment.
* xen/shim: crash instead of reboot in shim modeRoger Pau Monne2018-01-122-1/+10
| | | | | | | | | | | | | | | All guest shutdown operations are forwarded to L0, so the only native calls to machine_restart happen from crash related paths inside the hypervisor, hence switch the reboot code to instead issue a crash shutdown. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com> [ wei: fix arm build ] Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- Changes since v1: - Use the ternary operator.
* xen/pvshim: use default position for the m2p mappingsRoger Pau Monne2018-01-121-1/+2
| | | | | | | | | | | | | | | | | | When running a 32bit kernel as Dom0 on a 64bit hypervisor the hypervisor will try to shrink the hypervisor hole to the minimum needed, and thus requires the Dom0 to use XENMEM_machphys_mapping in order to fetch the position of the start of the hypervisor virtual mappings. Disable this feature when running as a PV shim, since some DomU kernels don't implemented XENMEM_machphys_mapping and break if the m2p doesn't begin at the default address. NB: support for the XENMEM_machphys_mapping was added in Linux by commit 7e7750. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
* xen/shim: modify shim_mem parameter behaviourRoger Pau Monne2018-01-123-28/+29
| | | | | | | | | | | | | shim_mem will now account for both the memory used by the hypervisor loaded in memory and the free memory slack given to the shim for runtime usage. From experimental testing it seems like the total amount of MiB used by the shim (giving it ~1MB of free memory for runtime) is: memory/113 + 20 Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
* xen/pvshim: memory hotplugRoger Pau Monne2018-01-123-0/+143
| | | | | | | | | | | | Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Changes since v1: - Add an order parameter to batch_memory_op. - Add a TODO item regarding high order memory chunks to pv_shim_online_memory. - Use page_list_splice. - Make sure the shim handlers are not called multiple times when the hypercall is preempted.
* xen/pvshim: support vCPU hotplugRoger Pau Monne2018-01-124-12/+102
| | | | | | | | | Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Changes since v1: - Fix hotplug so that v->initialized is checked before attempting to bring up the physical CPU. - Fix ARM compilation.
* xen/pvshim: set max_pages to the value of tot_pagesRoger Pau Monne2018-01-121-0/+6
| | | | | | | | So that the guest is not able to deplete the memory pool of the shim itself by trying to balloon up. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
* xen/pvshim: add shim_mem cmdline parameterSergey Dyasli2018-01-124-1/+85
| | | | Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
* xen/pvshim: add migration supportRoger Pau Monne2018-01-128-15/+197
| | | | | | | | | | | | Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Changes since v1: - Use bitmap_zero instead of memset. - Don't drop the __init attribute of unshare_xen_page_with_guest, it's not needed for migration. - Remove BUG_ON to check correct mapping, map_domain_page cannot fail. - Reduce indentation level of pv_shim_shutdown.
* x86/pv-shim: shadow PV console's page for L2 DomUSergey Dyasli2018-01-125-4/+209
| | | | | | | | | | | Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> [remove notify_guest helper and directly use pv_shim_inject_evtchn] Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- Changes since v1: - Use pv_shim_inject_evtchn.
* xen/pvshim: add grant table operationsRoger Pau Monne2018-01-122-0/+170
| | | | | | | | | | | | Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: Anthony Liguori <aliguori@amazon.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- Changes since v1: - Use __ of copy_to_guest. - Return EOPNOTSUPP for not implemented grant table hypercalls. - Forward user provided buffer in GNTTABOP_query_size. - Rewrite grant table hypercall handler.
* xen/pvshim: forward evtchn ops between L0 Xen and L2 DomURoger Pau Monne2018-01-1210-46/+402
| | | | | | | | | | | | | | | | | | | | | | | Note that the unmask and the virq operations are handled by the shim itself, and that FIFO event channels are not exposed to the guest. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: Anthony Liguori <aliguori@amazon.com> Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> --- Changes since v1: - Use find_first_set_bit instead of ffsl. - Indent macro one more level. - Have a single evtchn_close struct in pv_shim_event_channel_op. - Add blank lines between switch cases. - Use -EOPNOTSUPP in order to signal lack of FIFO or PIRQ support. - Switch evtchn_bind_virq parameter to evtchn_port_t and use 0 signal allocation needed. - Switch evtchn helpers return type to int instead of long. - Re-write event channel hypercall table handler instead of adding hooks. - Remove the pv_domain variable and instead use a static variable in shim code.
* xen/pvshim: set correct domid valueRoger Pau Monne2018-01-127-6/+66
| | | | | | | | | | | | | | | | | | | If domid is not provided by L0 set domid to 1 by default. Note that L0 not provinding the domid can cause trouble if the guest tries to use it's domid instead of DOMID_SELF when performing hypercalls that are forwarded to the L0 hypervisor. Since the domain created is no longer the hardware domain add a hook to the domain shutdown path in order to forward shutdown operations to the L0 hypervisor. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> --- Changes since v1: - s/get_dom0_domid/get_initial_domain_id/. - Add a comment regarding why dom0 needs to be global. - Fix compilation of xen/common/domain.c on ARM.
* xen/pvshim: modify Dom0 builder in order to build a DomURoger Pau Monne2018-01-124-10/+126
| | | | | | | | | | | | | | | | | | | | According to the PV ABI the initial virtual memory regions should contain the xenstore and console pages after the start_info. Also set the correct values in the start_info for DomU operation. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Changes since v1: - Modify the position of the __init attribute in dom0_update_physmap. - Move the addition of sizeof(struct dom0_vga_console_info) to vstartinfo_end with an existing if branch. - Add a TODO item for fill_console_start_info in the !CONFIG_VIDEO case. - s/replace_va/replace_va_mapping/. - Remove call to free_domheap_pages in replace_va_mapping. put_page_and_type should already take care of freeing the page. - Use PFN_DOWN in SET_AND_MAP_PARAM macro. - Parenthesize va in SET_AND_MAP_PARAM macro when required.
* xen: mark xenstore/console pages as RAMRoger Pau Monne2018-01-125-0/+80
| | | | | | | | | | | | | | | | | | This si required so that later they can be shared with the guest if Xen is running in shim mode. Also prevent them from being used by Xen by marking them as bad pages in init_boot_pages. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- Changes since v1: - Remove adding the pages to dom_io, there's no need since they are already marked as bad pages. - Use a static global array to store the memory address of this special pages, so Xen avoids having to call xen_hypercall_hvm_get_param twice.
* xen/pvshim: skip Dom0-only domain builder partsRoger Pau Monne2018-01-122-1/+6
| | | | | | | | Do not allow access to any iomem or ioport by the shim, and also remove the check for Dom0 kernel support. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
* xen/pvh: do not mark the low 1MB as IO memRoger Pau Monne2018-01-121-2/+7
| | | | | | | | | | On PVH there's nothing special on the low 1MB. This is an optional patch that doesn't affect the functionality of the shim. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
* xen/x86: make VGA support selectableRoger Pau Monne2018-01-1211-5/+40
| | | | | | | | | | | Through a Kconfig option. Enable it by default, and disable it for the PV-in-PVH shim. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> --- Changes since v1: - Make the VGA option dependent on the shim one.
* tools/firmware: Build and install xen-shimAndrew Cooper2018-01-115-3/+172
| | | | | | | | | | | | | | | | | Link a minimum set of files to build the shim. The linkfarm rune can handle creation and deletion of files. Introduce build-shim and install-shim targets in xen/Makefile. We can do better by properly generate the dependency from the list of files but that's an improvement for later. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> [change default scheduler to credit] Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- v2: Introduce a top-level build-shim target. Split the xen-shim build with normal build.
* x86/shim: Kconfig and command line optionsAndrew Cooper2018-01-116-0/+116
| | | | | Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
* x86/guest: use PV console for Xen/Dom0 I/OSergey Dyasli2018-01-113-1/+23
| | | | | Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
* x86/guest: add PV console codeSergey Dyasli2018-01-115-0/+272
| | | | | | Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
* x86/guest: setup event channel upcall vectorRoger Pau Monne2018-01-112-0/+58
| | | | | | | | | | | | | | | | | And a dummy event channel upcall handler. Note that with the current code the underlying Xen (L0) must support HVMOP_set_evtchn_upcall_vector or else event channel setup is going to fail. This limitation can be lifted by implementing more event channel interrupt injection methods as a backup. Register callback_irq to trick toolstack to think the domain is enlightened. Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
* x86: don't swallow the first command line item in guest modeWei Liu2018-01-111-2/+2
| | | | Signed-off-by: Wei Liu <wei.liu2@citrix.com>
* x86: read wallclock from Xen when running in pvh modeWei Liu2018-01-111-4/+28
| | | | | Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* x86: APIC timer calibration when running as a guestWei Liu2018-01-111-8/+30
| | | | | | | | | The timer calibration currently depends on PIT. Introduce a variant to wait for a tick's worth of time to elapse when running as a PVH guest. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
* x86: xen pv clock time sourceWei Liu2018-01-111-0/+89
| | | | | | | | | | | It is a variant of TSC clock source. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Changes since v1: - Use the mapped vcpu_info.
* x86/guest: map per-cpu vcpu_info area.Roger Pau Monne2018-01-113-0/+66
| | | | | | | | | | | | | | Mapping the per-vcpu vcpu_info area is required in order to use more than XEN_LEGACY_MAX_VCPUS. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- Changes since v1: - Make vcpu_info_mapped static. - Add a BUG_ON in case VCPUOP_register_vcpu_info fails. - Remove one indentation level in hypervisor_setup. - Make xen_hypercall_vcpu_op return int.
* xen/guest: fetch vCPU ID from XenRoger Pau Monne2018-01-113-0/+34
| | | | | | | | | If available. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> [ wei: fix non-shim build ] Signed-off-by: Wei Liu <wei.liu2@citrix.com>
* x86/guest: map shared_info pageRoger Pau Monne2018-01-113-0/+35
| | | | | | | | | | | | | Use an unpopulated PFN in order to map it. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- Changes since v1: - Use an unpopulated PFN to map the shared_info page. - Mask all event channels. - Report XENMEM_add_to_physmap error code in case of failure.
* xen/pvshim: keep track of used PFN rangesWei Liu2018-01-113-0/+66
| | | | | | | | | | | | | | | | | | Simple infrastructure to keep track of PFN space usage, so that we can use unpopulated PFNs to map special pages like shared info and grant table. As rangeset depends on malloc being ready so hypervisor_setup is introduced for things that can be initialised late in the process. Note that the PFN is marked as reserved at least up to 4GiB (or more if the guest has more memory). This is not a perfect solution but avoids using the MMIO hole below 4GiB. Ideally the shim (L1) should have a way to ask the underlying Xen (L0) which memory regions are populated, unpopulated, or MMIO space. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
* xen: introduce rangeset_claim_rangeWei Liu2018-01-112-1/+55
| | | | | | | | | | | | | Reserve a hole in a rangeset. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- Changes since v1: - Change function name. - Use a local variable instead of *s. - Add unlikely to the !prev case. - Move the function prototype position in the header file.
* xen/console: Introduce console=xenWei Liu2018-01-112-0/+59
| | | | | | | | | This specifies whether to use Xen specific console output. There are two variants: one is the hypervisor console, the other is the magic debug port 0xe9. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
* x86/pvh: Retrieve memory map from XenWei Liu2018-01-116-3/+36
| | | | | | | | Signed-off-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- v2: fixed clang build, dropped rb tag
* x86/shutdown: Support for using SCHEDOP_{shutdown,reboot}Andrew Cooper2018-01-113-4/+65
| | | | | | | | | | Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> --- v2: 1. Use sched_shutdown 2. Move header inclusion
* x86/guest: Hypercall supportAndrew Cooper2018-01-116-0/+179
| | | | | | | Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- v2: append underscores to tmp.
* x86/entry: Probe for Xen early during bootAndrew Cooper2018-01-115-0/+127
| | | | | | Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- v2: Add __read_mostly.
* x86/boot: Map more than the first 16MBAndrew Cooper2018-01-111-2/+1
| | | | | | TODO: Replace somehow (bootstrap_map() ?) Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
* x86/entry: Early PVH boot codeWei Liu2018-01-118-4/+268
| | | | | | | | | | | | | Signed-off-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- v2: 1. Fix comment. 2. Use cmpb $0. 3. Address comments on pvh-boot.c. 4. Haven't changed the pritnk modifiers to accommodate future changes. 5. Missing a prerequisite patch to relocate pvh_info to make __va work reliably. [BLOCKER].
* x86: produce a binary that can be booted as PVHWei Liu2018-01-114-1/+26
| | | | | | | | | | | | | | Produce a binary that can be booted as PVH. It doesn't do much yet. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- v2: 1. Remove shim-y dependency. 2. Remove extraneous blank line. 3. Fix bugs in xen.lds.S. 4. Haven't split code into pvh.S because that will break later patches.
* x86: introduce ELFNOTE macroWei Liu2018-01-111-0/+12
| | | | | | | | | | | | It is needed later for introducing PVH entry point. Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- v2: 1. Specify section attribute and type. 2. Use p2align. 3. Align instructions. 4. Haven't used .L or turned it into assembly macro.
* x86/link: Relocate program headersAndrew Cooper2018-01-111-9/+13
| | | | | | | | | | | | | When the xen binary is loaded by libelf (in the future) we rely on the elf loader to load the binary accordingly. Specify the load address so that the resulting binary can make p_vaddr and p_paddr have different values. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Wei Liu <wei.liu2@citrix.com> --- v2: Clarify commit message. Haven't tested grub1 boot.