Commit Graph
133 Commits
Author SHA1 Message Date
Andrew Cooper 754a29cacf tools/hvmloader: Move various helpers to being static inlines
The IO port, MSR, IO-APIC and LAPIC accessors compile typically to single or
pairs of instructions, which is less overhead than even the stack manipulation
to call the helpers.

Move the implementations from util.c to being static inlines in util.h

In addition, turn ioapic_base_address into a constant as it is never modified
from 0xfec00000 (substantially shrinks the IO-APIC logic), and make use of the
"A" constraint for WRMSR/RDMSR like we already do for RDTSC.

Bloat-o-meter reports a net:
  add/remove: 0/13 grow/shrink: 0/18 up/down: 0/-790 (-790)

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2024-05-09 18:19:49 +01:00
Igor Druzhinin 8efa46516c hvmloader: indicate ACPI tables with "ACPI data" type in e820
Guest kernel does need to know in some cases where the tables are located
to treat these regions properly. One example is kexec process where
the first kernel needs to pass ACPI region locations to the second
kernel which is now a requirement in Linux after 02a3e3cdb7f12 ("x86/boot:
Parse SRAT table and count immovable memory regions") in order for kexec
transition to actually work.

That commit introduced accesses to XSDT and SRAT while the second kernel
is still using kexec transition tables. The transition tables do not have
e820 "reserved" regions mapped where those tables are located currently
in a Xen guest. Instead "ACPI data" regions are mapped with the transition
tables that was introduced by the following commit 6bbeb276b7 ("x86/kexec:
Add the EFI system tables and ACPI tables to the ident map").

Reserve 1MB (out of 16MB currently available) right after ACPI info page for
ACPI tables exclusively but populate this region on demand and only indicate
populated memory as "ACPI data" since according to ACPI spec that memory is
reclaimable by the guest if necessary. That is close to how we treat
the same ACPI data in PVH guests. 1MB should be enough for now but could be
later extended if required.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2020-09-09 17:56:13 +02:00
Wei Liu e4506f404c tools: load IPXE from standalone file
Do not embed IPXE into Rombios anymore. Instead, it is loaded by the
toolstack from a file as a separate module.

Ability to let user specify an IPXE blob will come later.

No user visible change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2018-07-16 16:09:01 +01:00
Wei Liu 210a239899 Revert "hvmloader, libxl: use the correct ACPI settings depending on device model"
This reverts commit 149c6bbbf7.
2017-08-29 15:02:54 +01:00
Igor Druzhinin 149c6bbbf7 hvmloader, libxl: use the correct ACPI settings depending on device model
We need to choose ACPI tables and ACPI IO port location
properly depending on the device model version we are running.
Previously, this decision was made by BIOS type specific
code in hvmloader, e.g. always load QEMU traditional specific
tables if it's ROMBIOS and always load QEMU Xen specific
tables if it's SeaBIOS.

This change saves this behavior (for compatibility) but adds
an additional way (xenstore key) to specify the correct
device model if we happen to run a non-default one. Toolstack
bit makes use of it.

The enforcement of BIOS type depending on QEMU version will
be lifted later when the rest of ROMBIOS compatibility fixes
are in place.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2017-08-22 16:36:48 +01:00
Jan Beulich 3619af2b2b x86/VMX: sanitize VM86 TSS handling
The present way of setting this up is flawed: Leaving the I/O bitmap
pointer at zero means that the interrupt redirection bitmap lives
outside (ahead of) the allocated space of the TSS. Similarly setting a
TSS limit of 255 when only 128 bytes get allocated means that 128 extra
bytes may be accessed by the CPU during I/O port access processing.

Introduce a new HVM param to set the allocated size of the TSS, and
have the hypervisor actually take care of setting namely the I/O bitmap
pointer. Both this and the segment limit now take the allocated size
into account.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2017-02-22 12:36:36 +01:00
Boris Ostrovsky 7fe907f2eb acpi/hvmloader: Include file/paths adjustments
In prepearation to moving acpi sources into generally available
libacpi:

1. Pass IOAPIC/LAPIC/PCI mask values via struct acpi_config
2. Modify include files search paths to point to acpi directory
3. Macro-ise include file for build.c that defines various
   utilities used by that file. Users of libacpi will be expected
   to define this macro when compiling build.c

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-09-28 14:32:05 +01:00
Wei Liu 94d3b9990b hvmloader: use bound checking in get_module_entry
Coverity complains:

overflow_before_widen: Potentially overflowing expression
info->nr_modules * 32U with type unsigned int (32 bits, unsigned) is
evaluated using 32-bit arithmetic, and then used in a context that
expects an expression of type uint64_t (64 bits, unsigned).

The overflow is unlikely to happen in reality because we only expect a
few modules.

Fix that by converting the check to use bound checking to placate
Coverity.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-08-22 14:20:19 +01:00
Anthony PERARD a1bac56e2a hvmloader: Always build-in SeaBIOS and OVMF loader
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-08-18 17:24:39 +01:00
Anthony PERARD dc35626a2d hvmloader: bios->bios_load() now needs to be defined
All BIOSes but ROMBIOS needs to be loaded via modules.

ROMBIOS is handled as a special case.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-08-18 17:24:39 +01:00
Anthony PERARD 8aa944d48e hvmloader: Locate the BIOS blob
The BIOS blob can be found an entry called "firmware" of the modlist of
the hvm_start_info struct.

The found BIOS blob is not loaded by this patch, but only passed as
argument to bios_load() function.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2016-08-18 17:24:39 +01:00
Anthony PERARD b11ca6ea38 hvmloader: Grab the hvm_start_info pointer
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-08-18 17:24:39 +01:00
Jan Beulich 8ef5b6e11b hvmloader: don't hard-code IO-APIC parameters
The IO-APIC address has variable bits determined by the PCI-to-ISA
bridge (albeit for now we refrain from actually evaluating them, as
there's still implicit rather than explicit agreement on the IO-APIC
base address between qemu and the hypervisor), and the IO-APIC version
should be read from the IO-APIC.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-08-04 10:08:48 +02:00
Ian Campbell 443701ef0c Replace FSF street address with canonical URL
As recommended in http://www.gnu.org/licenses/gpl-howto.en.html.

This is the result of:
$ git grep -El Mass\|Temple\|Franklin | xargs ./fsf.pl

Where fsf.pl is:
    #!/usr/bin/perl -w -pi.bak -0777
    my $repl = 'If not, see <http://www.gnu.org/licenses/>.';
    my $br = qr/(?:\s*\n\s*(?:[\*\#]|\/\/|\.\\" )?\s*|\s+)/;

    my $inwt = qr/[Ii]f${br}not,${br}write${br}(?:to${br})?the${br}Free${br}Software${br}Foundation,(?:${br}Inc\.,)?/;

    my $mass = qr/675${br}Mass${br}Ave,?${br}Cambridge,?${br}MA${br}02139,?${br}USA,?\.?/;
    my $franklin = qr/51${br}Franklin${br}St(?:reet)?(?:,${br}| - )Fifth${br}Floor,?${br}Boston,?${br}MA,?${br}02110-1301,?${br}USA,?\.?/;
    my $temple = qr/59${br}Temple${br}Place(?:,${br}| - )Suite${br}330,?${br}Boston,?${br}MA,?${br}021110?-1307,?${br}USA,?\.?/;

    s|$inwt$br$mass|$repl|m;
    s|$inwt$br$franklin|$repl|m;
    s|$inwt$br$temple|$repl|m;

The only remaining mentions of these addresses are in COPYING files which I
haven't touched.

Some of the changed files are imports from elsewhere, however
filtering them out is tricky, I think it is tolerable to have these
files be modified here and then perhaps reverted on the next sync,
since it's only 1-2 lines and obvious what is going on.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-29 11:14:07 +01:00
Tiejun Chen 07d73925ea hvmloader: get guest memory map into memory_map[]
Now we get this map layout by call XENMEM_memory_map then
save them into one global variable memory_map[]. It should
include lowmem range, rdm range and highmem range. Note
rdm range and highmem range may not exist in some cases.

And here we need to check if any reserved memory conflicts with
[RESERVED_MEMORY_DYNAMIC_START, RESERVED_MEMORY_DYNAMIC_END).
This range is used to allocate memory in hvmloder level, and
we would lead hvmloader failed in case of conflict since its
another rare possibility in real world.

CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2015-07-23 13:45:25 +01:00
Wei Liu 2edb2d8c4a hvmloader: retrieve vNUMA information from hypervisor
Hvmloader issues XENMEM_get_vnumainfo hypercall and stores the
information retrieved in scratch space for later use.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2015-02-17 14:34:31 +01:00
David Vrabel daacd357a9 hvmloader: add helper functions to get/set HVM params
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-06-27 14:13:21 +01:00
Jan Beulich 5f2875739b hvmloader: fix SeaBIOS interface
The SeaBIOS ROM image may validly exceed 128k in size, it's only our
interface code that so far assumed that it wouldn't. Remove that
restriction by setting the base address depending on image size.

Add a check to HVM loader so that too big images won't result in silent
guest failure anymore.

Uncomment the intended build-time size check for rombios, moving it
into a function so that it would actually compile.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2013-09-05 11:47:03 +02:00
David Vrabel 82639998a5 Fix emacs local variable block to use correct C style variable.
The emacs variable to set the C style from a local variable block is
c-file-style, not c-set-style.

Signed-off-by: David Vrabel <david.vrabel@citrix.com
2013-02-21 16:12:46 +00:00
Attilio Rao 0c2dccd724 hvmloader: drop the ovmf32 support and rename ovmf64 -> ovmf.
- Remove the 15cpus hack from ovmf because it should be unnecessary on
nowadays windows/EFI supported.

Signed-off-by: Attilio Rao <attilio.rao@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2012-02-29 13:33:51 +00:00
Attilio Rao 4775b620fb hvmloader: Add OVMF UEFI support and directly use it
...when specified in the guest configuration file.

This work is somewhat based on Bei Guan effort during the SoC 2011 and
relies on upstream edk2/ovmf Tianocore ROM to be built separately and
manually copied as:
Build/OvmfX64/DEBUG_GCC44/FV/OVMF.fd ->
tools/firmware/ovmf/ovmf-x64.bin
Build/OvmfIa32/DEBUG_GCC44/FV/OVMF.fd ->
toolf/firmware/ovmf/ovmf-ia32.bin

A way to integrate OVMF build directly into XEN has still be discussed
on the mailing list appropriately.

Signed-off-by: Attilio Rao <attilio.rao@citrix.com>

Disable CONFIG_OVMF by default as ovmf is not integrated into the
build.

Signed-off-by: Keir Fraser <keir@xen.org>
Committed-by: Keir Fraser <keir@xen.org>
2012-02-23 10:11:58 +00:00
Julian Pidancet cf3ee71e8b hvmloader: Move option ROM loading into a separate optionnal file
Make load_rom field in struct bios_config an optionnal callback rather
than a boolean value. It allow BIOS specific code to implement it's
own option ROM loading methods.

Facilities to scan PCI devices, extract an deploy ROMs are moved into
a separate file that can be compiled optionnaly.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2012-02-13 12:50:04 +00:00
Paul Durrant 9307335747 hvmloader: Move acpi_enabled out of hvm_info_table into xenstore
Since hvmloader has a xentore client, use a platform key in xenstore
to indicate whether ACPI is enabled or not rather than the shared
hvm_info_table structure.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:31:43 +00:00
Keir Fraser ab6e985fae hvmloader: Move init_vm86_tss() back into common code.
It is not BIOS specific.

Signed-off-by: Keir Fraser <keir@xen.org>
2011-08-09 11:33:40 +01:00
Keir Fraser 9f16877252 hvmloader: Enable SCI in QEMU has it disabled.
When booting a Windows guest, the OS report an issue with the ACPI (in
a BSOD). The exact issue is "SCI_EN never becomes set in PM1 Control
Register." (quoted from WinDbg help).

So this patch enables the flags SCI_EN if it is not yet enabled.

Reported-by: Tobias Geiger <tobias.geiger@vido.info>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Keir Fraser <keir@xen.org>
2011-07-28 15:40:54 +01:00
Keir Fraser 487f749f0f hvmloader: Allow default response to be specified to xenstore_read().
Signed-off-by: Keir Fraser <keir@xen.org>
2011-07-25 14:21:13 +01:00
Keir Fraser d31b9a4e40 hvmloader: Formatting cleanups.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-07-25 14:09:41 +01:00
Keir Fraser 62d1e95e70 hvmloader: Replace bios_relocate hook with bios_load hook
Used by OVMF BIOS handler.

Signed-off-by: Bei Guan <gbtju85@gmail.com>
Signed-off-by: Keir Fraser <keir@xen.org>
2011-07-25 13:57:49 +01:00
Ian Campbell e894fe2367 hvmloader: add code to generate a $PIR table.
Does not replace the table hardcoded in ROMBIOS (it ain't broke) but
is used for SeaBIOS.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:50:16 +01:00
Ian Campbell c25fb1ae7b hvmloader: refactor BIOS info setup
Currently we have ->bios_high_setup, which is called relatively early
and returns a cookie which is passed to ->bios_info_setup which runs
towards the end and creates the BIOS info, incorporating the cookie
which (in the case of ROMBIOS) happens to be the BIOS's high load
address . This is rather ROMBIOS specific.

Refactor to have ->bios_info_setup which is called early and prepares
the bios_info, ->bios_relocate which does any necessary relocation
(updating the BIOS info as necessary) and ->bios_info_finish which
finalises the info (e.g.  by calculating the checksum).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:47:04 +01:00
Ian Campbell 80766862aa hvmloader: Add a simple "scratch allocator"
Returns memory which is passed to the subsequent BIOS but can be
reused once the contents is consumed. An example of this would be a
BIOS table which the BIOS consumes by copying rather than simply
referencing.

Users which need a temporary scratch buffer for internal use
scratch_start which follows these allocations.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:46:28 +01:00
Ian Campbell 20f9f76007 hvmloader: make SMBIOS initialisation more general.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:45:05 +01:00
Ian Campbell 946863b141 hvmloader: make ACPI initialisation hook more general.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:44:31 +01:00
Ian Campbell 0ea8826c2e hvmloader: call SMP setup from common code again.
Previous refactoring was premature.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:43:52 +01:00
Ian Campbell 2e65685119 hvmloader: setup APICs in a common function again.
Previous refactoring was premature.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:43:29 +01:00
Ian Campbell b39d3fa428 hvmloader: setup PCI bus in a common function again.
Previous refactoring was premature.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:41:42 +01:00
Ian Campbell 1be247c03c hvmloader: allow per-BIOS decision on loading option ROMS
SeaBIOS has functionality to load ROMs from the PCI device directly,
it makes sense to use this when it is available.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-06-01 16:39:55 +01:00
Ian Campbell 5f82d0858d tools: support SeaBIOS. Use by default when upstream qemu is configured.
The SeaBIOS integration here is only semi-complete and is targetted at
developers and very early adopters who can be expected to cope with
some rough edges. In particular the user must clone, patch as
necessary and compile SeaBIOS themselves since this patchset does not
cover any of that (in the same way we currently do not integrate
upstream qemu clone+build). Include a big comment to that effect next
to the Config.mk option.

Many of the bios_config callback functions are not yet used by
SeaBIOS.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
2011-04-20 17:13:06 +01:00
Keir Fraser 576d39339e tools: hvmloader: attempt to SHUTDOWN_crash on BUG
Executing UD2 (invalid opcode) triggers a triple fault which signals
reboot to the toolstack, rather than crash.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Keir Fraser <keir@xen.org>
2011-04-18 18:34:45 +01:00
Ian Campbell 1e7545fd7c tools: hvmloader: select BIOS through xenstore.
Allow the toolstack to select the BIOS to use via a xenstore key.

Defaults to "rombios" for compatibility with toolstacks which do not
write the key (e.g. xend).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Keir Fraser <keir@xen.org>
2011-04-12 14:00:49 +01:00
Ian Campbell 575f9fbdfa tools: hvmloader: Refactor MP table setup into struct bios_config
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:47:16 +01:00
Ian Campbell 9134c2f6cf tools: hvmloader: Refactor ACPI table setup into struct bios_config
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:46:49 +01:00
Ian Campbell d195595bc3 tools: hvmloader: Refactor VM86 and E820 setup into struct bios_config
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2011-04-12 13:46:20 +01:00
Ian Campbell 6b4d8dbd51 tools: hvmloader: refactor highbios and bios_info setup into struct bios_config
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:45:59 +01:00
Ian Campbell 7128e9e70e tools: hvmloader: Refactor APIC, PCI and SMP setup into struct bios_config
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:45:31 +01:00
Ian Campbell 548977fea1 tools: hvmloader: add bios_config data structure
For now abstract away the actual ROM bits themselves and the various
load addresses.

Create a rombios.c to contain the ROMBIOS specific parts. ROMBIOS is
still statically selected for the time being.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:44:38 +01:00
Ian Campbell 79388968ed tools: hvmloader: rename roms.h to roms.inc
It's not really a header, it's an autogenerated data file.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:41:43 +01:00
Ian Campbell 364f616ba8 tools: hvmloader: remove rombios_sz, just use sizeof(rombios)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:40:49 +01:00
Ian Campbell 0891c42aea tools: hvmloader: pass option ROM end address around as a parameter.
Reduces the cross talk between ROMBIOS and hvmloader.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:38:38 +01:00
Ian Campbell 9978e0e2b7 tools: hvmloader: pass SMBIOS location as a runtime parameter.
Instead of hardcoding in a header.

Reduces the cross talk between ROMBIOS and hvmloader.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-04-12 13:38:01 +01:00