Skip to content

Commit

Permalink
Merge branch 'master' into ag-i218lm-link-speed
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-grasso committed Oct 5, 2018
2 parents ffe8159 + 133f4c4 commit 94547f3
Show file tree
Hide file tree
Showing 136 changed files with 9,869 additions and 699 deletions.
16 changes: 11 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ QEMUIMG := qemu-img
SRCDIRS :=
SRCDIRS += libgcc
SRCDIRS += core
SRCDIRS += net net/oncrpc net/tcp net/udp net/infiniband net/80211
SRCDIRS += net net/tcp net/udp net/infiniband
SRCDIRS += image
SRCDIRS += drivers/bus
SRCDIRS += drivers/net
Expand All @@ -71,10 +71,6 @@ SRCDIRS += drivers/net/e1000e
SRCDIRS += drivers/net/igb
SRCDIRS += drivers/net/igbvf
SRCDIRS += drivers/net/phantom
SRCDIRS += drivers/net/rtl818x
SRCDIRS += drivers/net/ath
SRCDIRS += drivers/net/ath/ath5k
SRCDIRS += drivers/net/ath/ath9k
SRCDIRS += drivers/net/vxge
SRCDIRS += drivers/net/efi
SRCDIRS += drivers/net/tg3
Expand Down Expand Up @@ -105,6 +101,16 @@ SRCDIRS += hci/keymap
SRCDIRS += usr
SRCDIRS += config

# These directories contain code that is not eligible for UEFI Secure
# Boot signing.
#
SRCDIRS_INSEC += net/oncrpc
SRCDIRS_INSEC += net/80211
SRCDIRS_INSEC += drivers/net/rtl818x
SRCDIRS_INSEC += drivers/net/ath
SRCDIRS_INSEC += drivers/net/ath/ath5k
SRCDIRS_INSEC += drivers/net/ath/ath9k

# NON_AUTO_SRCS lists files that are excluded from the normal
# automatic build system.
#
Expand Down
45 changes: 33 additions & 12 deletions src/Makefile.housekeeping
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,17 @@ endif
# Inhibit this.
#
ifeq ($(CCTYPE),gcc)
WNA_TEST = $(CC) -Wno-address -x c -c /dev/null -o /dev/null >/dev/null 2>&1
WNA_TEST = $(CC) -Waddress -x c -c /dev/null -o /dev/null >/dev/null 2>&1
WNA_FLAGS := $(shell $(WNA_TEST) && $(ECHO) '-Wno-address')
WORKAROUND_CFLAGS += $(WNA_FLAGS)

# gcc 8.0 generates warnings for certain suspect string operations. Our
# sources have been vetted for correct usage. Turn off these warnings.
#
WNST_TEST = $(CC) -Wstringop-truncation -x c -c /dev/null -o /dev/null \
>/dev/null 2>&1
WNST_FLAGS := $(shell $(WNST_TEST) && $(ECHO) '-Wno-stringop-truncation')
WORKAROUND_CFLAGS += $(WNST_FLAGS)
endif

# Some versions of gas choke on division operators, treating them as
Expand Down Expand Up @@ -299,7 +307,7 @@ endif
#
# Select build architecture and platform based on $(BIN)
#
# BIN has the form bin[-[arch-]platform]
# BIN has the form bin[-[<arch>-]<platform>[-sb]]

ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
PLATFORMS := $(patsubst config/defaults/%.h,%,\
Expand All @@ -312,17 +320,18 @@ platforms :

ifdef BIN

# Determine architecture portion of $(BIN), if present
BIN_ARCH := $(strip $(foreach A,$(ARCHS),\
$(patsubst bin-$(A)-%,$(A),\
$(filter bin-$(A)-%,$(BIN)))))

# Determine platform portion of $(BIN), if present
ifeq ($(BIN_ARCH),)
BIN_PLATFORM := $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
# Split $(BIN) into architecture, platform, and security flag (where present)
BIN_ELEMENTS := $(subst -,$(SPACE),$(BIN))
BIN_APS := $(wordlist 2,4,$(BIN_ELEMENTS))
ifeq ($(lastword $(BIN_APS)),sb)
BIN_AP := $(wordlist 2,$(words $(BIN_APS)),discard $(BIN_APS))
BIN_SECUREBOOT := 1
else
BIN_PLATFORM := $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
BIN_AP := $(BIN_APS)
BIN_SECUREBOOT := 0
endif
BIN_PLATFORM := $(lastword $(BIN_AP))
BIN_ARCH := $(wordlist 2,$(words $(BIN_AP)),discard $(BIN_AP))

# Determine build architecture
DEFAULT_ARCH := i386
Expand All @@ -339,6 +348,13 @@ CFLAGS += -DPLATFORM=$(PLATFORM)
platform :
@$(ECHO) $(PLATFORM)

# Determine security flag
DEFAULT_SECUREBOOT := 0
SECUREBOOT := $(firstword $(BIN_SECUREBOOT) $(DEFAULT_SECUREBOOT))
CFLAGS += -DSECUREBOOT=$(SECUREBOOT)
secureboot :
@$(ECHO) $(SECUREBOOT)

endif # defined(BIN)

# Include architecture-specific Makefile
Expand All @@ -357,6 +373,11 @@ endif
#
# Source file handling

# Exclude known-insecure files from Secure Boot builds
ifeq ($(SECUREBOOT),0)
SRCDIRS += $(SRCDIRS_INSEC)
endif

# SRCDIRS lists all directories containing source files.
srcdirs :
@$(ECHO) $(SRCDIRS)
Expand Down Expand Up @@ -424,7 +445,7 @@ endif
CFLAGS += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
ASFLAGS += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
LDFLAGS += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
HOST_CFLAGS += -O2 -g
HOST_CFLAGS += $(WORKAROUND_CFLAGS) -O2 -g

# Inhibit -Werror if NO_WERROR is specified on make command line
#
Expand Down
4 changes: 4 additions & 0 deletions src/arch/arm32/Makefile.efi
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- makefile -*- : Force emacs to use Makefile mode

# UEFI requires that enums are always 32 bits
#
CFLAGS += -fno-short-enums

# Specify EFI image builder
#
ELF2EFI = $(ELF2EFI32)
Expand Down
13 changes: 12 additions & 1 deletion src/arch/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ SRCDIRS += arch/arm64/core

# ARM64-specific flags
#
CFLAGS += -mabi=lp64 -mlittle-endian -mcmodel=small
CFLAGS += -mlittle-endian -mcmodel=small
CFLAGS += -fomit-frame-pointer
ASFLAGS += -mabi=lp64 -EL

# We want to specify the LP64 model. There is an explicit -mabi=lp64
# on GCC 4.9 and later, and no guarantee as to which is the default
# model. In earlier versions of GCC, there is no -mabi option and the
# default appears to be LP64 anyway.
#
ifeq ($(CCTYPE),gcc)
LP64_TEST = $(CC) -mabi=lp64 -x c -c /dev/null -o /dev/null >/dev/null 2>&1
LP64_FLAGS := $(shell $(LP64_TEST) && $(ECHO) '-mabi=lp64')
WORKAROUND_CFLAGS += $(LP64_FLAGS)
endif

# EFI requires -fshort-wchar, and nothing else currently uses wchar_t
#
CFLAGS += -fshort-wchar
Expand Down
8 changes: 4 additions & 4 deletions src/arch/x86/Makefile.pcbios
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ NON_AUTO_MEDIA += fd0
$(Q)sync

# Special target for building Master Boot Record binary
$(BIN)/mbr.bin : $(BIN)/mbr.o
$(BIN)/mbr.tmp : $(BIN)/mbr.o
$(QM)$(ECHO) " [LD] $@"
$(Q)$(LD) $(LDFLAGS) -o $@ --oformat binary -e 0 $<
$(Q)$(LD) $(LDFLAGS) -o $@ -e mbr $<

# rule to make a USB disk image
$(BIN)/usbdisk.bin : $(BIN)/usbdisk.o
$(BIN)/usbdisk.tmp : $(BIN)/usbdisk.o
$(QM)$(ECHO) " [LD] $@"
$(Q)$(LD) $(LDFLAGS) -o $@ --oformat binary -e 0 $<
$(Q)$(LD) $(LDFLAGS) -o $@ -e mbr $<

NON_AUTO_MEDIA += usb
%usb: $(BIN)/usbdisk.bin %hd
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86/core/dumpregs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void __asmcall _dump_regs ( struct i386_all_regs *ix86 ) {
TEXT16_CODE ( ".globl dump_regs\n\t"
"\ndump_regs:\n\t"
VIRT_CALL ( _dump_regs )
"ret\n\t" ) );
"ret\n\t" ) : );

printf ( "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n"
"ESI=%08x EDI=%08x EBP=%08x ESP=%08x\n"
Expand Down
28 changes: 28 additions & 0 deletions src/arch/x86/drivers/hyperv/hyperv.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,29 @@ static int hv_check_features ( struct hv_hypervisor *hv ) {
return 0;
}

/**
* Check that Gen 2 UEFI firmware is not running
*
* @v hv Hyper-V hypervisor
* @ret rc Return status code
*
* We must not steal ownership from the Gen 2 UEFI firmware, since
* doing so will cause an immediate crash. Avoid this by checking for
* the guest OS identity known to be used by the Gen 2 UEFI firmware.
*/
static int hv_check_uefi ( struct hv_hypervisor *hv ) {
uint64_t guest_os_id;

/* Check for UEFI firmware's guest OS identity */
guest_os_id = rdmsr ( HV_X64_MSR_GUEST_OS_ID );
if ( guest_os_id == HV_GUEST_OS_ID_UEFI ) {
DBGC ( hv, "HV %p is owned by UEFI firmware\n", hv );
return -ENOTSUP;
}

return 0;
}

/**
* Map hypercall page
*
Expand Down Expand Up @@ -556,6 +579,10 @@ static int hv_probe ( struct root_device *rootdev ) {
if ( ( rc = hv_check_features ( hv ) ) != 0 )
goto err_check_features;

/* Check that Gen 2 UEFI firmware is not running */
if ( ( rc = hv_check_uefi ( hv ) ) != 0 )
goto err_check_uefi;

/* Allocate pages */
if ( ( rc = hv_alloc_pages ( hv, &hv->hypercall, &hv->synic.message,
&hv->synic.event, NULL ) ) != 0 )
Expand Down Expand Up @@ -587,6 +614,7 @@ static int hv_probe ( struct root_device *rootdev ) {
hv_free_pages ( hv, hv->hypercall, hv->synic.message, hv->synic.event,
NULL );
err_alloc_pages:
err_check_uefi:
err_check_features:
free ( hv );
err_alloc:
Expand Down
39 changes: 29 additions & 10 deletions src/arch/x86/drivers/net/undinet.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/netdevice.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/pci.h>
#include <ipxe/profile.h>
#include <undi.h>
#include <undinet.h>
Expand Down Expand Up @@ -807,6 +808,10 @@ struct undinet_irq_broken {
uint16_t pci_vendor;
/** PCI device ID */
uint16_t pci_device;
/** PCI subsystem vendor ID */
uint16_t pci_subsys_vendor;
/** PCI subsystem ID */
uint16_t pci_subsys;
};

/**
Expand All @@ -822,10 +827,10 @@ struct undinet_irq_broken {
*/
static const struct undinet_irq_broken undinet_irq_broken_list[] = {
/* HP XX70x laptops */
{ .pci_vendor = 0x8086, .pci_device = 0x1502 },
{ .pci_vendor = 0x8086, .pci_device = 0x1503 },
{ 0x8086, 0x1502, PCI_ANY_ID, PCI_ANY_ID },
{ 0x8086, 0x1503, PCI_ANY_ID, PCI_ANY_ID },
/* HP 745 G3 laptop */
{ .pci_vendor = 0x14e4, .pci_device = 0x1687 },
{ 0x14e4, 0x1687, PCI_ANY_ID, PCI_ANY_ID },
};

/**
Expand All @@ -836,14 +841,30 @@ static const struct undinet_irq_broken undinet_irq_broken_list[] = {
*/
static int undinet_irq_is_broken ( struct device_description *desc ) {
const struct undinet_irq_broken *broken;
struct pci_device pci;
uint16_t subsys_vendor;
uint16_t subsys;
unsigned int i;

/* Ignore non-PCI devices */
if ( desc->bus_type != BUS_TYPE_PCI )
return 0;

/* Read subsystem IDs */
pci_init ( &pci, desc->location );
pci_read_config_word ( &pci, PCI_SUBSYSTEM_VENDOR_ID, &subsys_vendor );
pci_read_config_word ( &pci, PCI_SUBSYSTEM_ID, &subsys );

/* Check for a match against the broken device list */
for ( i = 0 ; i < ( sizeof ( undinet_irq_broken_list ) /
sizeof ( undinet_irq_broken_list[0] ) ) ; i++ ) {
broken = &undinet_irq_broken_list[i];
if ( ( desc->bus_type == BUS_TYPE_PCI ) &&
( desc->vendor == broken->pci_vendor ) &&
( desc->device == broken->pci_device ) ) {
if ( ( broken->pci_vendor == desc->vendor ) &&
( broken->pci_device == desc->device ) &&
( ( broken->pci_subsys_vendor == subsys_vendor ) ||
( broken->pci_subsys_vendor == PCI_ANY_ID ) ) &&
( ( broken->pci_subsys == subsys ) ||
( broken->pci_subsys == PCI_ANY_ID ) ) ) {
return 1;
}
}
Expand Down Expand Up @@ -938,10 +959,9 @@ int undinet_probe ( struct undi_device *undi, struct device *dev ) {
memcpy ( netdev->ll_addr, undi_info.CurrentNodeAddress, ETH_ALEN );
undinic->irq = undi_info.IntNumber;
if ( undinic->irq > IRQ_MAX ) {
DBGC ( undinic, "UNDINIC %p has invalid IRQ %d\n",
DBGC ( undinic, "UNDINIC %p ignoring invalid IRQ %d\n",
undinic, undinic->irq );
rc = -EINVAL;
goto err_bad_irq;
undinic->irq = 0;
}
DBGC ( undinic, "UNDINIC %p has MAC address %s and IRQ %d\n",
undinic, eth_ntoa ( netdev->hw_addr ), undinic->irq );
Expand Down Expand Up @@ -984,7 +1004,6 @@ int undinet_probe ( struct undi_device *undi, struct device *dev ) {

err_register:
err_undi_get_iface_info:
err_bad_irq:
err_undi_get_information:
err_undi_initialize:
/* Shut down UNDI stack */
Expand Down
1 change: 1 addition & 0 deletions src/arch/x86/include/bits/errfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_acpipwr ( ERRFILE_ARCH | ERRFILE_CORE | 0x00100000 )
#define ERRFILE_cpuid ( ERRFILE_ARCH | ERRFILE_CORE | 0x00110000 )
#define ERRFILE_rdtsc_timer ( ERRFILE_ARCH | ERRFILE_CORE | 0x00120000 )
#define ERRFILE_acpi_timer ( ERRFILE_ARCH | ERRFILE_CORE | 0x00130000 )

#define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
#define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86/include/ipxe/rtc_entropy.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*
* @ret min_entropy min-entropy of each sample
*/
static inline __always_inline double
static inline __always_inline min_entropy_t
ENTROPY_INLINE ( rtc, min_entropy_per_sample ) ( void ) {

/* The min-entropy has been measured on several platforms
Expand All @@ -38,7 +38,7 @@ ENTROPY_INLINE ( rtc, min_entropy_per_sample ) ( void ) {
* safety margin to allow for some potential non-independence
* of samples.
*/
return 1.3;
return MIN_ENTROPY ( 1.3 );
}

extern uint8_t rtc_sample ( void );
Expand Down

0 comments on commit 94547f3

Please sign in to comment.