Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Oct 2016 22:02:36 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r306737 - in stable/11/sys: amd64/amd64 amd64/conf amd64/include conf modules modules/efirt
Message-ID:  <201610052202.u95M2aVL037893@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Wed Oct  5 22:02:36 2016
New Revision: 306737
URL: https://svnweb.freebsd.org/changeset/base/306737

Log:
  MFC r306097:
  Add kernel interfaces to call EFI Runtime Services.
  
  MFC r306104:
  Fix build of the module outside the kernel tree.
  
  MFC r306209 (by imp):
  Change the efi_get_table interface to a void **.
  
  MFC r306351:
  Handle TLB shootdown IPI during the EFI runtime calls, on SandyBridges.

Added:
  stable/11/sys/amd64/amd64/efirt.c   (contents, props changed)
     - copied, changed from r306097, head/sys/amd64/amd64/efirt.c
  stable/11/sys/modules/efirt/
     - copied from r306097, head/sys/modules/efirt/
Modified:
  stable/11/sys/amd64/conf/NOTES
  stable/11/sys/amd64/include/efi.h
  stable/11/sys/conf/files.amd64
  stable/11/sys/conf/options.amd64
  stable/11/sys/modules/Makefile
  stable/11/sys/modules/efirt/Makefile
Directory Properties:
  stable/11/   (props changed)

Copied and modified: stable/11/sys/amd64/amd64/efirt.c (from r306097, head/sys/amd64/amd64/efirt.c)
==============================================================================
--- head/sys/amd64/amd64/efirt.c	Wed Sep 21 11:31:58 2016	(r306097, copy source)
+++ stable/11/sys/amd64/amd64/efirt.c	Wed Oct  5 22:02:36 2016	(r306737)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/vmparam.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
+#include <vm/vm_map.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
 #include <vm/vm_pager.h>
@@ -301,6 +302,17 @@ efi_enter(void)
 		PMAP_UNLOCK(curpmap);
 		return (error);
 	}
+
+	/*
+	 * IPI TLB shootdown handler invltlb_pcid_handler() reloads
+	 * %cr3 from the curpmap->pm_cr3, which would disable runtime
+	 * segments mappings.  Block the handler's action by setting
+	 * curpmap to impossible value.  See also comment in
+	 * pmap.c:pmap_activate_sw().
+	 */
+	if (pmap_pcid_enabled && !invpcid_works)
+		PCPU_SET(curpmap, NULL);
+
 	load_cr3(VM_PAGE_TO_PHYS(efi_pml4_page) | (pmap_pcid_enabled ?
 	    curpmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid : 0));
 	/*
@@ -317,7 +329,9 @@ efi_leave(void)
 {
 	pmap_t curpmap;
 
-	curpmap = PCPU_GET(curpmap);
+	curpmap = &curproc->p_vmspace->vm_pmap;
+	if (pmap_pcid_enabled && !invpcid_works)
+		PCPU_SET(curpmap, curpmap);
 	load_cr3(curpmap->pm_cr3 | (pmap_pcid_enabled ?
 	    curpmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid : 0));
 	if (!pmap_pcid_enabled)
@@ -405,7 +419,7 @@ efi_uninit(void)
 }
 
 int
-efi_get_table(struct uuid *uuid, void *ptr)
+efi_get_table(struct uuid *uuid, void **ptr)
 {
 	struct efi_cfgtbl *ct;
 	u_long count;
@@ -416,7 +430,7 @@ efi_get_table(struct uuid *uuid, void *p
 	ct = efi_cfgtbl;
 	while (count--) {
 		if (!bcmp(&ct->ct_uuid, uuid, sizeof(*uuid))) {
-			ptr = (void *)PHYS_TO_DMAP(ct->ct_data);
+			*ptr = (void *)PHYS_TO_DMAP(ct->ct_data);
 			return (0);
 		}
 		ct++;

Modified: stable/11/sys/amd64/conf/NOTES
==============================================================================
--- stable/11/sys/amd64/conf/NOTES	Wed Oct  5 20:45:21 2016	(r306736)
+++ stable/11/sys/amd64/conf/NOTES	Wed Oct  5 22:02:36 2016	(r306737)
@@ -599,6 +599,9 @@ options 	ENABLE_ALART		# Control alarm o
 #
 options 	NKPT=31
 
+# EFI Runtime Services support (not functional yet).
+options 	EFIRT
+
 
 #####################################################################
 # ABI Emulation

Modified: stable/11/sys/amd64/include/efi.h
==============================================================================
--- stable/11/sys/amd64/include/efi.h	Wed Oct  5 20:45:21 2016	(r306736)
+++ stable/11/sys/amd64/include/efi.h	Wed Oct  5 22:02:36 2016	(r306737)
@@ -39,4 +39,21 @@
  */
 #define	EFIABI_ATTR	__attribute__((ms_abi))
 
+#ifdef _KERNEL
+struct uuid;
+struct efi_tm;
+
+int efi_get_table(struct uuid *uuid, void **ptr);
+int efi_get_time(struct efi_tm *tm);
+int efi_get_time_locked(struct efi_tm *tm);
+int efi_reset_system(void);
+int efi_set_time(struct efi_tm *tm);
+int efi_set_time_locked(struct efi_tm *tm);
+int efi_var_get(uint16_t *name, struct uuid *vendor, uint32_t *attrib,
+    size_t *datasize, void *data);
+int efi_var_nextname(size_t *namesize, uint16_t *name, struct uuid *vendor);
+int efi_var_set(uint16_t *name, struct uuid *vendor, uint32_t attrib,
+    size_t datasize, void *data);
+#endif
+
 #endif /* __AMD64_INCLUDE_EFI_H_ */

Modified: stable/11/sys/conf/files.amd64
==============================================================================
--- stable/11/sys/conf/files.amd64	Wed Oct  5 20:45:21 2016	(r306736)
+++ stable/11/sys/conf/files.amd64	Wed Oct  5 22:02:36 2016	(r306737)
@@ -110,6 +110,7 @@ amd64/amd64/cpu_switch.S	standard
 amd64/amd64/db_disasm.c		optional	ddb
 amd64/amd64/db_interface.c	optional	ddb
 amd64/amd64/db_trace.c		optional	ddb
+amd64/amd64/efirt.c		optional	efirt
 amd64/amd64/elf_machdep.c	standard
 amd64/amd64/exception.S		standard
 amd64/amd64/fpu.c		standard

Modified: stable/11/sys/conf/options.amd64
==============================================================================
--- stable/11/sys/conf/options.amd64	Wed Oct  5 20:45:21 2016	(r306736)
+++ stable/11/sys/conf/options.amd64	Wed Oct  5 22:02:36 2016	(r306737)
@@ -65,3 +65,6 @@ XENHVM			opt_global.h
 
 # options for the Intel C600 SAS driver (isci)
 ISCI_LOGGING	opt_isci.h
+
+# EFI Runtime services support
+EFIRT			opt_efirt.h

Modified: stable/11/sys/modules/Makefile
==============================================================================
--- stable/11/sys/modules/Makefile	Wed Oct  5 20:45:21 2016	(r306736)
+++ stable/11/sys/modules/Makefile	Wed Oct  5 22:02:36 2016	(r306737)
@@ -102,6 +102,7 @@ SUBDIR=	\
 	${_drm2} \
 	dummynet \
 	${_ed} \
+	${_efirt} \
 	${_elink} \
 	${_em} \
 	en \
@@ -666,6 +667,7 @@ _x86bios=	x86bios
 .endif
 
 .if ${MACHINE_CPUARCH} == "amd64"
+_efirt=		efirt
 _ioat=		ioat
 _ixl=		ixl
 _ixlv=		ixlv

Modified: stable/11/sys/modules/efirt/Makefile
==============================================================================
--- head/sys/modules/efirt/Makefile	Wed Sep 21 11:31:58 2016	(r306097)
+++ stable/11/sys/modules/efirt/Makefile	Wed Oct  5 22:02:36 2016	(r306737)
@@ -4,5 +4,6 @@
 
 KMOD=	efirt
 SRCS=	efirt.c
+SRCS+=  device_if.h bus_if.h
 
 .include <bsd.kmod.mk>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610052202.u95M2aVL037893>