2011-05-13 04:54:01 +00:00
|
|
|
/*-
|
2012-10-26 13:40:12 +00:00
|
|
|
* Copyright (c) 2012 NetApp, Inc.
|
2011-05-13 04:54:01 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2012-10-26 13:40:12 +00:00
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <x86/mptable.h>
|
2011-05-13 04:54:01 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2014-01-23 20:35:32 +00:00
|
|
|
#include "acpi.h"
|
2012-12-13 01:58:11 +00:00
|
|
|
#include "bhyverun.h"
|
2012-10-26 13:40:12 +00:00
|
|
|
#include "mptbl.h"
|
|
|
|
|
|
|
|
#define MPTABLE_BASE 0xF0000
|
|
|
|
|
2013-03-01 02:26:28 +00:00
|
|
|
/* floating pointer length + maximum length of configuration table */
|
|
|
|
#define MPTABLE_MAX_LENGTH (65536 + 16)
|
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
#define LAPIC_PADDR 0xFEE00000
|
|
|
|
#define LAPIC_VERSION 16
|
|
|
|
|
|
|
|
#define IOAPIC_PADDR 0xFEC00000
|
|
|
|
#define IOAPIC_VERSION 0x11
|
|
|
|
|
|
|
|
#define MP_SPECREV 4
|
|
|
|
#define MPFP_SIG "_MP_"
|
|
|
|
|
|
|
|
/* Configuration header defines */
|
|
|
|
#define MPCH_SIG "PCMP"
|
|
|
|
#define MPCH_OEMID "BHyVe "
|
|
|
|
#define MPCH_OEMID_LEN 8
|
|
|
|
#define MPCH_PRODID "Hypervisor "
|
|
|
|
#define MPCH_PRODID_LEN 12
|
|
|
|
|
|
|
|
/* Processor entry defines */
|
|
|
|
#define MPEP_SIG_FAMILY 6 /* XXX bhyve should supply this */
|
|
|
|
#define MPEP_SIG_MODEL 26
|
|
|
|
#define MPEP_SIG_STEPPING 5
|
|
|
|
#define MPEP_SIG \
|
|
|
|
((MPEP_SIG_FAMILY << 8) | \
|
|
|
|
(MPEP_SIG_MODEL << 4) | \
|
|
|
|
(MPEP_SIG_STEPPING))
|
|
|
|
|
|
|
|
#define MPEP_FEATURES (0xBFEBFBFF) /* XXX Intel i7 */
|
|
|
|
|
MFC 258859,259081,259085,259205,259213,259275,259482,259537,259702,259779:
Several changes to the local APIC support in bhyve:
- Rename 'vm_interrupt_hostcpu()' to 'vcpu_notify_event()'.
- If a vcpu disables its local apic and then executes a 'HLT' then spin
down the vcpu and destroy its thread context. Also modify the 'HLT'
processing to ignore pending interrupts in the IRR if interrupts have
been disabled by the guest. The interrupt cannot be injected into the
guest in any case so resuming it is futile.
- Use callout(9) to drive the vlapic timer instead of clocking it on each
VM exit.
- When the guest is bringing up the APs in the x2APIC mode a write to the
ICR register will now trigger a return to userspace with an exitcode of
VM_EXITCODE_SPINUP_AP.
- Change the vlapic timer lock to be a spinlock because the vlapic can be
accessed from within a critical section (vm run loop) when guest is using
x2apic mode.
- Fix the vlapic version register.
- Add a command to bhyvectl to inject an NMI on a specific vcpu.
- Add an API to deliver message signalled interrupts to vcpus. This allows
callers to treat the MSI 'addr' and 'data' fields as opaque and also lets
bhyve implement multiple destination modes: physical, flat and clustered.
- Rename the ambiguously named 'vm_setup_msi()' and 'vm_setup_msix()' to
'vm_setup_pptdev_msi()' and 'vm_setup_pptdev_msix()' respectively.
- Consolidate the virtual apic initialization in a single function:
vlapic_reset()
- Add a generic routine to trigger an LVT interrupt that supports both
fixed and NMI delivery modes.
- Add an ioctl and bhyvectl command to trigger local interrupts inside a
guest. In particular, a global NMI similar to that raised by SERR# or
PERR# can be simulated by asserting LINT1 on all vCPUs.
- Extend the LVT table in the vCPU local APIC to support CMCI.
- Flesh out the local APIC error reporting a bit to cache errors and
report them via ESR when ESR is written to. Add support for asserting
the error LVT when an error occurs. Raise illegal vector errors when
attempting to signal an invalid vector for an interrupt or when sending
an IPI.
- Export table entries in the MADT and MP Table advertising the stock x86
config of LINT0 set to ExtInt and LINT1 wired to NMI.
2014-02-23 00:46:05 +00:00
|
|
|
/* Number of local intr entries */
|
|
|
|
#define MPEII_NUM_LOCAL_IRQ 2
|
|
|
|
|
2013-10-18 22:05:17 +00:00
|
|
|
/* Number of i/o intr entries */
|
2014-01-23 20:21:39 +00:00
|
|
|
#define MPEII_MAX_IRQ 24
|
2013-10-18 22:05:17 +00:00
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
/* Bus entry defines */
|
|
|
|
#define MPE_NUM_BUSES 2
|
|
|
|
#define MPE_BUSNAME_LEN 6
|
|
|
|
#define MPE_BUSNAME_ISA "ISA "
|
|
|
|
#define MPE_BUSNAME_PCI "PCI "
|
|
|
|
|
|
|
|
static void *oem_tbl_start;
|
|
|
|
static int oem_tbl_size;
|
2011-05-13 04:54:01 +00:00
|
|
|
|
|
|
|
static uint8_t
|
2012-10-26 13:40:12 +00:00
|
|
|
mpt_compute_checksum(void *base, size_t len)
|
2011-05-13 04:54:01 +00:00
|
|
|
{
|
2012-10-26 13:40:12 +00:00
|
|
|
uint8_t *bytes;
|
|
|
|
uint8_t sum;
|
|
|
|
|
|
|
|
for(bytes = base, sum = 0; len > 0; len--) {
|
2011-05-13 04:54:01 +00:00
|
|
|
sum += *bytes++;
|
|
|
|
}
|
2012-10-26 13:40:12 +00:00
|
|
|
|
|
|
|
return (256 - sum);
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-26 13:40:12 +00:00
|
|
|
mpt_build_mpfp(mpfps_t mpfp, vm_paddr_t gpa)
|
2011-05-13 04:54:01 +00:00
|
|
|
{
|
2012-10-26 13:40:12 +00:00
|
|
|
|
2011-05-13 04:54:01 +00:00
|
|
|
memset(mpfp, 0, sizeof(*mpfp));
|
2012-10-26 13:40:12 +00:00
|
|
|
memcpy(mpfp->signature, MPFP_SIG, 4);
|
|
|
|
mpfp->pap = gpa + sizeof(*mpfp);
|
|
|
|
mpfp->length = 1;
|
|
|
|
mpfp->spec_rev = MP_SPECREV;
|
|
|
|
mpfp->checksum = mpt_compute_checksum(mpfp, sizeof(*mpfp));
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-26 13:40:12 +00:00
|
|
|
mpt_build_mpch(mpcth_t mpch)
|
2011-05-13 04:54:01 +00:00
|
|
|
{
|
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
memset(mpch, 0, sizeof(*mpch));
|
|
|
|
memcpy(mpch->signature, MPCH_SIG, 4);
|
|
|
|
mpch->spec_rev = MP_SPECREV;
|
|
|
|
memcpy(mpch->oem_id, MPCH_OEMID, MPCH_OEMID_LEN);
|
|
|
|
memcpy(mpch->product_id, MPCH_PRODID, MPCH_PRODID_LEN);
|
|
|
|
mpch->apic_address = LAPIC_PADDR;
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-12-24 19:10:56 +00:00
|
|
|
mpt_build_proc_entries(proc_entry_ptr mpep, int ncpu)
|
2011-05-13 04:54:01 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
for (i = 0; i < ncpu; i++) {
|
2011-05-13 04:54:01 +00:00
|
|
|
memset(mpep, 0, sizeof(*mpep));
|
2012-10-26 13:40:12 +00:00
|
|
|
mpep->type = MPCT_ENTRY_PROCESSOR;
|
|
|
|
mpep->apic_id = i; // XXX
|
|
|
|
mpep->apic_version = LAPIC_VERSION;
|
|
|
|
mpep->cpu_flags = PROCENTRY_FLAG_EN;
|
|
|
|
if (i == 0)
|
|
|
|
mpep->cpu_flags |= PROCENTRY_FLAG_BP;
|
|
|
|
mpep->cpu_signature = MPEP_SIG;
|
2011-05-13 04:54:01 +00:00
|
|
|
mpep->feature_flags = MPEP_FEATURES;
|
|
|
|
mpep++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
MFC 258859,259081,259085,259205,259213,259275,259482,259537,259702,259779:
Several changes to the local APIC support in bhyve:
- Rename 'vm_interrupt_hostcpu()' to 'vcpu_notify_event()'.
- If a vcpu disables its local apic and then executes a 'HLT' then spin
down the vcpu and destroy its thread context. Also modify the 'HLT'
processing to ignore pending interrupts in the IRR if interrupts have
been disabled by the guest. The interrupt cannot be injected into the
guest in any case so resuming it is futile.
- Use callout(9) to drive the vlapic timer instead of clocking it on each
VM exit.
- When the guest is bringing up the APs in the x2APIC mode a write to the
ICR register will now trigger a return to userspace with an exitcode of
VM_EXITCODE_SPINUP_AP.
- Change the vlapic timer lock to be a spinlock because the vlapic can be
accessed from within a critical section (vm run loop) when guest is using
x2apic mode.
- Fix the vlapic version register.
- Add a command to bhyvectl to inject an NMI on a specific vcpu.
- Add an API to deliver message signalled interrupts to vcpus. This allows
callers to treat the MSI 'addr' and 'data' fields as opaque and also lets
bhyve implement multiple destination modes: physical, flat and clustered.
- Rename the ambiguously named 'vm_setup_msi()' and 'vm_setup_msix()' to
'vm_setup_pptdev_msi()' and 'vm_setup_pptdev_msix()' respectively.
- Consolidate the virtual apic initialization in a single function:
vlapic_reset()
- Add a generic routine to trigger an LVT interrupt that supports both
fixed and NMI delivery modes.
- Add an ioctl and bhyvectl command to trigger local interrupts inside a
guest. In particular, a global NMI similar to that raised by SERR# or
PERR# can be simulated by asserting LINT1 on all vCPUs.
- Extend the LVT table in the vCPU local APIC to support CMCI.
- Flesh out the local APIC error reporting a bit to cache errors and
report them via ESR when ESR is written to. Add support for asserting
the error LVT when an error occurs. Raise illegal vector errors when
attempting to signal an invalid vector for an interrupt or when sending
an IPI.
- Export table entries in the MADT and MP Table advertising the stock x86
config of LINT0 set to ExtInt and LINT1 wired to NMI.
2014-02-23 00:46:05 +00:00
|
|
|
static void
|
|
|
|
mpt_build_localint_entries(int_entry_ptr mpie)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Hardcode LINT0 as ExtINT on all CPUs. */
|
|
|
|
memset(mpie, 0, sizeof(*mpie));
|
|
|
|
mpie->type = MPCT_ENTRY_LOCAL_INT;
|
|
|
|
mpie->int_type = INTENTRY_TYPE_EXTINT;
|
|
|
|
mpie->int_flags = INTENTRY_FLAGS_POLARITY_CONFORM |
|
|
|
|
INTENTRY_FLAGS_TRIGGER_CONFORM;
|
|
|
|
mpie->dst_apic_id = 0xff;
|
|
|
|
mpie->dst_apic_int = 0;
|
|
|
|
mpie++;
|
|
|
|
|
|
|
|
/* Hardcode LINT1 as NMI on all CPUs. */
|
|
|
|
memset(mpie, 0, sizeof(*mpie));
|
|
|
|
mpie->type = MPCT_ENTRY_LOCAL_INT;
|
|
|
|
mpie->int_type = INTENTRY_TYPE_NMI;
|
|
|
|
mpie->int_flags = INTENTRY_FLAGS_POLARITY_CONFORM |
|
|
|
|
INTENTRY_FLAGS_TRIGGER_CONFORM;
|
|
|
|
mpie->dst_apic_id = 0xff;
|
|
|
|
mpie->dst_apic_int = 1;
|
|
|
|
}
|
|
|
|
|
2011-05-13 04:54:01 +00:00
|
|
|
static void
|
2012-10-26 13:40:12 +00:00
|
|
|
mpt_build_bus_entries(bus_entry_ptr mpeb)
|
2011-05-13 04:54:01 +00:00
|
|
|
{
|
2012-10-26 13:40:12 +00:00
|
|
|
|
2011-05-13 04:54:01 +00:00
|
|
|
memset(mpeb, 0, sizeof(*mpeb));
|
2012-10-26 13:40:12 +00:00
|
|
|
mpeb->type = MPCT_ENTRY_BUS;
|
2013-10-18 22:05:17 +00:00
|
|
|
mpeb->bus_id = 0;
|
|
|
|
memcpy(mpeb->bus_type, MPE_BUSNAME_PCI, MPE_BUSNAME_LEN);
|
2011-05-13 04:54:01 +00:00
|
|
|
mpeb++;
|
|
|
|
|
|
|
|
memset(mpeb, 0, sizeof(*mpeb));
|
2012-10-26 13:40:12 +00:00
|
|
|
mpeb->type = MPCT_ENTRY_BUS;
|
2013-10-18 22:05:17 +00:00
|
|
|
mpeb->bus_id = 1;
|
|
|
|
memcpy(mpeb->bus_type, MPE_BUSNAME_ISA, MPE_BUSNAME_LEN);
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-26 13:40:12 +00:00
|
|
|
mpt_build_ioapic_entries(io_apic_entry_ptr mpei, int id)
|
2011-05-13 04:54:01 +00:00
|
|
|
{
|
2012-10-26 13:40:12 +00:00
|
|
|
|
2011-05-13 04:54:01 +00:00
|
|
|
memset(mpei, 0, sizeof(*mpei));
|
2012-10-26 13:40:12 +00:00
|
|
|
mpei->type = MPCT_ENTRY_IOAPIC;
|
|
|
|
mpei->apic_id = id;
|
|
|
|
mpei->apic_version = IOAPIC_VERSION;
|
|
|
|
mpei->apic_flags = IOAPICENTRY_FLAG_EN;
|
|
|
|
mpei->apic_address = IOAPIC_PADDR;
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-10-18 22:05:17 +00:00
|
|
|
mpt_build_ioint_entries(int_entry_ptr mpie, int num_pins, int id)
|
2011-05-13 04:54:01 +00:00
|
|
|
{
|
|
|
|
int pin;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following config is taken from kernel mptable.c
|
|
|
|
* mptable_parse_default_config_ints(...), for now
|
|
|
|
* just use the default config, tweek later if needed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Run through all 16 pins. */
|
|
|
|
for (pin = 0; pin < num_pins; pin++) {
|
2013-10-18 22:05:17 +00:00
|
|
|
memset(mpie, 0, sizeof(*mpie));
|
|
|
|
mpie->type = MPCT_ENTRY_INT;
|
|
|
|
mpie->src_bus_id = 1;
|
|
|
|
mpie->dst_apic_id = id;
|
2011-05-13 04:54:01 +00:00
|
|
|
|
|
|
|
/*
|
2012-10-26 13:40:12 +00:00
|
|
|
* All default configs route IRQs from bus 0 to the first 16
|
|
|
|
* pins of the first I/O APIC with an APIC ID of 2.
|
2011-05-13 04:54:01 +00:00
|
|
|
*/
|
2013-10-18 22:05:17 +00:00
|
|
|
mpie->dst_apic_int = pin;
|
2011-05-13 04:54:01 +00:00
|
|
|
switch (pin) {
|
|
|
|
case 0:
|
|
|
|
/* Pin 0 is an ExtINT pin. */
|
2013-10-18 22:05:17 +00:00
|
|
|
mpie->int_type = INTENTRY_TYPE_EXTINT;
|
2011-05-13 04:54:01 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
/* IRQ 0 is routed to pin 2. */
|
2013-10-18 22:05:17 +00:00
|
|
|
mpie->int_type = INTENTRY_TYPE_INT;
|
|
|
|
mpie->src_bus_irq = 0;
|
2011-05-13 04:54:01 +00:00
|
|
|
break;
|
2014-01-23 20:35:32 +00:00
|
|
|
case SCI_INT:
|
|
|
|
/* ACPI SCI is level triggered and active-lo. */
|
|
|
|
mpie->int_flags = INTENTRY_FLAGS_POLARITY_ACTIVELO |
|
|
|
|
INTENTRY_FLAGS_TRIGGER_LEVEL;
|
|
|
|
mpie->int_type = INTENTRY_TYPE_INT;
|
|
|
|
mpie->src_bus_irq = SCI_INT;
|
|
|
|
break;
|
2011-05-13 04:54:01 +00:00
|
|
|
case 5:
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
/*
|
2014-01-23 20:35:32 +00:00
|
|
|
* PCI Irqs set to level triggered and active-lo.
|
2011-05-13 04:54:01 +00:00
|
|
|
*/
|
2014-01-23 20:35:32 +00:00
|
|
|
mpie->int_flags = INTENTRY_FLAGS_POLARITY_ACTIVELO |
|
|
|
|
INTENTRY_FLAGS_TRIGGER_LEVEL;
|
2013-10-18 22:05:17 +00:00
|
|
|
mpie->src_bus_id = 0;
|
|
|
|
/* fall through.. */
|
2011-05-13 04:54:01 +00:00
|
|
|
default:
|
|
|
|
/* All other pins are identity mapped. */
|
2013-10-18 22:05:17 +00:00
|
|
|
mpie->int_type = INTENTRY_TYPE_INT;
|
|
|
|
mpie->src_bus_irq = pin;
|
2011-05-13 04:54:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-10-18 22:05:17 +00:00
|
|
|
mpie++;
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
void
|
|
|
|
mptable_add_oemtbl(void *tbl, int tblsz)
|
|
|
|
{
|
|
|
|
|
|
|
|
oem_tbl_start = tbl;
|
|
|
|
oem_tbl_size = tblsz;
|
|
|
|
}
|
|
|
|
|
2011-05-13 04:54:01 +00:00
|
|
|
int
|
MFC r256657,r257018,r257347,r257423,r257729,r257767,
r257933,r258609,r258614,r258668,r258673,r258855
Pull in some minor bugfixes and functionality enhancements
from CURRENT. These are candidates to be moved to 10.0-release.
r258855
mdoc: quote string properly.
r258673
Don't create an initial value for the host filesystem of "/".
r258668
Allow bhyve and bhyveload to attach to tty devices.
r258614
The 22-bit Data Byte Count (DBC) field of a Physical Region Descriptor was
being read as a 32-bit quantity by the bhyve AHCI driver.
r258609
Fix discrepancy between the IOAPIC ID advertised by firmware tables and the
actual value read by the guest.
r257933
Route the legacy timer interrupt (IRQ0) to pin 2 of the IOAPIC.
r257767
Fix an off-by-one error when iterating over the emulated PCI BARs.
r257729
Add the VM name to the process name with setproctitle().
r257423
Make the virtual ioapic available unconditionally in a bhyve virtual machine.
r257347
Update copyright to include the author of the LPC bridge emulation code.
hand-merge r257018
Tidy usage messages for bhyve and bhyveload.
r256657
Add an option to bhyveload(8) that allows setting a loader environment variable
from the command line.
Discussed with: neel
2013-12-13 06:59:18 +00:00
|
|
|
mptable_build(struct vmctx *ctx, int ncpu)
|
2011-05-13 04:54:01 +00:00
|
|
|
{
|
2012-10-26 13:40:12 +00:00
|
|
|
mpcth_t mpch;
|
|
|
|
bus_entry_ptr mpeb;
|
|
|
|
io_apic_entry_ptr mpei;
|
2013-12-24 19:10:56 +00:00
|
|
|
proc_entry_ptr mpep;
|
2012-10-26 13:40:12 +00:00
|
|
|
mpfps_t mpfp;
|
2013-10-18 22:05:17 +00:00
|
|
|
int_entry_ptr mpie;
|
2012-10-26 13:40:12 +00:00
|
|
|
char *curraddr;
|
2011-05-13 04:54:01 +00:00
|
|
|
char *startaddr;
|
|
|
|
|
2013-03-18 22:38:30 +00:00
|
|
|
startaddr = paddr_guest2host(ctx, MPTABLE_BASE, MPTABLE_MAX_LENGTH);
|
2013-03-01 02:26:28 +00:00
|
|
|
if (startaddr == NULL) {
|
2012-10-26 13:40:12 +00:00
|
|
|
printf("mptable requires mapped mem\n");
|
|
|
|
return (ENOMEM);
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-01 02:26:28 +00:00
|
|
|
curraddr = startaddr;
|
2012-10-26 13:40:12 +00:00
|
|
|
mpfp = (mpfps_t)curraddr;
|
|
|
|
mpt_build_mpfp(mpfp, MPTABLE_BASE);
|
|
|
|
curraddr += sizeof(*mpfp);
|
2011-05-13 04:54:01 +00:00
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
mpch = (mpcth_t)curraddr;
|
|
|
|
mpt_build_mpch(mpch);
|
|
|
|
curraddr += sizeof(*mpch);
|
2011-05-13 04:54:01 +00:00
|
|
|
|
2013-12-24 19:10:56 +00:00
|
|
|
mpep = (proc_entry_ptr)curraddr;
|
2012-10-26 13:40:12 +00:00
|
|
|
mpt_build_proc_entries(mpep, ncpu);
|
|
|
|
curraddr += sizeof(*mpep) * ncpu;
|
|
|
|
mpch->entry_count += ncpu;
|
2011-05-13 04:54:01 +00:00
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
mpeb = (bus_entry_ptr) curraddr;
|
|
|
|
mpt_build_bus_entries(mpeb);
|
|
|
|
curraddr += sizeof(*mpeb) * MPE_NUM_BUSES;
|
|
|
|
mpch->entry_count += MPE_NUM_BUSES;
|
2011-05-13 04:54:01 +00:00
|
|
|
|
MFC r256657,r257018,r257347,r257423,r257729,r257767,
r257933,r258609,r258614,r258668,r258673,r258855
Pull in some minor bugfixes and functionality enhancements
from CURRENT. These are candidates to be moved to 10.0-release.
r258855
mdoc: quote string properly.
r258673
Don't create an initial value for the host filesystem of "/".
r258668
Allow bhyve and bhyveload to attach to tty devices.
r258614
The 22-bit Data Byte Count (DBC) field of a Physical Region Descriptor was
being read as a 32-bit quantity by the bhyve AHCI driver.
r258609
Fix discrepancy between the IOAPIC ID advertised by firmware tables and the
actual value read by the guest.
r257933
Route the legacy timer interrupt (IRQ0) to pin 2 of the IOAPIC.
r257767
Fix an off-by-one error when iterating over the emulated PCI BARs.
r257729
Add the VM name to the process name with setproctitle().
r257423
Make the virtual ioapic available unconditionally in a bhyve virtual machine.
r257347
Update copyright to include the author of the LPC bridge emulation code.
hand-merge r257018
Tidy usage messages for bhyve and bhyveload.
r256657
Add an option to bhyveload(8) that allows setting a loader environment variable
from the command line.
Discussed with: neel
2013-12-13 06:59:18 +00:00
|
|
|
mpei = (io_apic_entry_ptr)curraddr;
|
|
|
|
mpt_build_ioapic_entries(mpei, 0);
|
|
|
|
curraddr += sizeof(*mpei);
|
|
|
|
mpch->entry_count++;
|
2012-08-04 22:46:29 +00:00
|
|
|
|
2013-10-18 22:05:17 +00:00
|
|
|
mpie = (int_entry_ptr) curraddr;
|
MFC r256657,r257018,r257347,r257423,r257729,r257767,
r257933,r258609,r258614,r258668,r258673,r258855
Pull in some minor bugfixes and functionality enhancements
from CURRENT. These are candidates to be moved to 10.0-release.
r258855
mdoc: quote string properly.
r258673
Don't create an initial value for the host filesystem of "/".
r258668
Allow bhyve and bhyveload to attach to tty devices.
r258614
The 22-bit Data Byte Count (DBC) field of a Physical Region Descriptor was
being read as a 32-bit quantity by the bhyve AHCI driver.
r258609
Fix discrepancy between the IOAPIC ID advertised by firmware tables and the
actual value read by the guest.
r257933
Route the legacy timer interrupt (IRQ0) to pin 2 of the IOAPIC.
r257767
Fix an off-by-one error when iterating over the emulated PCI BARs.
r257729
Add the VM name to the process name with setproctitle().
r257423
Make the virtual ioapic available unconditionally in a bhyve virtual machine.
r257347
Update copyright to include the author of the LPC bridge emulation code.
hand-merge r257018
Tidy usage messages for bhyve and bhyveload.
r256657
Add an option to bhyveload(8) that allows setting a loader environment variable
from the command line.
Discussed with: neel
2013-12-13 06:59:18 +00:00
|
|
|
mpt_build_ioint_entries(mpie, MPEII_MAX_IRQ, 0);
|
2013-10-18 22:05:17 +00:00
|
|
|
curraddr += sizeof(*mpie) * MPEII_MAX_IRQ;
|
2012-10-26 13:40:12 +00:00
|
|
|
mpch->entry_count += MPEII_MAX_IRQ;
|
|
|
|
|
MFC 258859,259081,259085,259205,259213,259275,259482,259537,259702,259779:
Several changes to the local APIC support in bhyve:
- Rename 'vm_interrupt_hostcpu()' to 'vcpu_notify_event()'.
- If a vcpu disables its local apic and then executes a 'HLT' then spin
down the vcpu and destroy its thread context. Also modify the 'HLT'
processing to ignore pending interrupts in the IRR if interrupts have
been disabled by the guest. The interrupt cannot be injected into the
guest in any case so resuming it is futile.
- Use callout(9) to drive the vlapic timer instead of clocking it on each
VM exit.
- When the guest is bringing up the APs in the x2APIC mode a write to the
ICR register will now trigger a return to userspace with an exitcode of
VM_EXITCODE_SPINUP_AP.
- Change the vlapic timer lock to be a spinlock because the vlapic can be
accessed from within a critical section (vm run loop) when guest is using
x2apic mode.
- Fix the vlapic version register.
- Add a command to bhyvectl to inject an NMI on a specific vcpu.
- Add an API to deliver message signalled interrupts to vcpus. This allows
callers to treat the MSI 'addr' and 'data' fields as opaque and also lets
bhyve implement multiple destination modes: physical, flat and clustered.
- Rename the ambiguously named 'vm_setup_msi()' and 'vm_setup_msix()' to
'vm_setup_pptdev_msi()' and 'vm_setup_pptdev_msix()' respectively.
- Consolidate the virtual apic initialization in a single function:
vlapic_reset()
- Add a generic routine to trigger an LVT interrupt that supports both
fixed and NMI delivery modes.
- Add an ioctl and bhyvectl command to trigger local interrupts inside a
guest. In particular, a global NMI similar to that raised by SERR# or
PERR# can be simulated by asserting LINT1 on all vCPUs.
- Extend the LVT table in the vCPU local APIC to support CMCI.
- Flesh out the local APIC error reporting a bit to cache errors and
report them via ESR when ESR is written to. Add support for asserting
the error LVT when an error occurs. Raise illegal vector errors when
attempting to signal an invalid vector for an interrupt or when sending
an IPI.
- Export table entries in the MADT and MP Table advertising the stock x86
config of LINT0 set to ExtInt and LINT1 wired to NMI.
2014-02-23 00:46:05 +00:00
|
|
|
mpie = (int_entry_ptr)curraddr;
|
|
|
|
mpt_build_localint_entries(mpie);
|
|
|
|
curraddr += sizeof(*mpie) * MPEII_NUM_LOCAL_IRQ;
|
|
|
|
mpch->entry_count += MPEII_NUM_LOCAL_IRQ;
|
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
if (oem_tbl_start) {
|
|
|
|
mpch->oem_table_pointer = curraddr - startaddr + MPTABLE_BASE;
|
|
|
|
mpch->oem_table_size = oem_tbl_size;
|
|
|
|
memcpy(curraddr, oem_tbl_start, oem_tbl_size);
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
mpch->base_table_length = curraddr - (char *)mpch;
|
2013-04-05 22:14:07 +00:00
|
|
|
mpch->checksum = mpt_compute_checksum(mpch, mpch->base_table_length);
|
2011-05-13 04:54:01 +00:00
|
|
|
|
2012-10-26 13:40:12 +00:00
|
|
|
return (0);
|
2011-05-13 04:54:01 +00:00
|
|
|
}
|