mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-30 12:16:45 +07:00
2ab561a116
Add support for making ESI calls [1]. ESI stands for "Extensible SAL specification" and is basically a way for invoking firmware subroutines which are identified by a GUID. I don't know whether ESI is used by vendors other than HP (if you do, please let me know) but as firmware "backdoors" go, this seems one of the cleaner methods, so it seems reasonable to support it, even though I'm not aware of any publicly documented ESI calls. I'd have liked to make the ESI module completely stand-alone, but unfortunately that is not easily (or not at all) possible because in order to make ESI calls in physical mode, a small stub similar to the EFI stub is needed in the kernel proper. I did try to create a stub that would work in user-level, but it quickly got ugly beyond recognition (e.g., the stub had to make assumptions about how the module-loader generated call-stubs work) and I didn't even get it to work (that's probably fixable, but I didn't bother because I concluded it was too ugly anyhow). While it's not terribly elegant to have kernel code which isn't actively used in the kernel proper, I think it might be worth making an exception here for two reasons: the code is trivially small (all that's really needed is esi_stub.S) and by including it in the normal kernel distro, it might encourage other OEMs to also use ESI, which I think would be far better than each inventing their own firmware "backdoor". The code was originally written by Alex. I just massaged and packaged it a bit (and perhaps messed up some things along the way...). Changes since first version of patch that was posted to mailing list: * Export ia64_esi_call and ia64_esi_call_phys() as GPL symbols. * Disallow building esi.c as a module for now. Building as a module would currently lead to an unresolved reference to "sal_lock" on SMP kernels because that symbol doesn't get exported. * Export esi_call_phys() only if ESI is enabled. * Remove internal stuff from esi.h and add a "proc_type" argument to ia64_esi_call() such that serialization-requirements can be expressed (ESI follows SAL here, where procedure calls may have to be serialized, are MP-safe, or MP-safe andr reentrant). [1] h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,919,00.html Signed-off-by: David Mosberger <David.Mosberger@acm.org> Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
97 lines
2.8 KiB
ArmAsm
97 lines
2.8 KiB
ArmAsm
/*
|
|
* ESI call stub.
|
|
*
|
|
* Copyright (C) 2005 Hewlett-Packard Co
|
|
* Alex Williamson <alex.williamson@hp.com>
|
|
*
|
|
* Based on EFI call stub by David Mosberger. The stub is virtually
|
|
* identical to the one for EFI phys-mode calls, except that ESI
|
|
* calls may have up to 8 arguments, so they get passed to this routine
|
|
* through memory.
|
|
*
|
|
* This stub allows us to make ESI calls in physical mode with interrupts
|
|
* turned off. ESI calls may not support calling from virtual mode.
|
|
*
|
|
* Google for "Extensible SAL specification" for a document describing the
|
|
* ESI standard.
|
|
*/
|
|
|
|
/*
|
|
* PSR settings as per SAL spec (Chapter 8 in the "IA-64 System
|
|
* Abstraction Layer Specification", revision 2.6e). Note that
|
|
* psr.dfl and psr.dfh MUST be cleared, despite what this manual says.
|
|
* Otherwise, SAL dies whenever it's trying to do an IA-32 BIOS call
|
|
* (the br.ia instruction fails unless psr.dfl and psr.dfh are
|
|
* cleared). Fortunately, SAL promises not to touch the floating
|
|
* point regs, so at least we don't have to save f2-f127.
|
|
*/
|
|
#define PSR_BITS_TO_CLEAR \
|
|
(IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_RT | \
|
|
IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \
|
|
IA64_PSR_DFL | IA64_PSR_DFH)
|
|
|
|
#define PSR_BITS_TO_SET \
|
|
(IA64_PSR_BN)
|
|
|
|
#include <asm/processor.h>
|
|
#include <asm/asmmacro.h>
|
|
|
|
/*
|
|
* Inputs:
|
|
* in0 = address of function descriptor of ESI routine to call
|
|
* in1 = address of array of ESI parameters
|
|
*
|
|
* Outputs:
|
|
* r8 = result returned by called function
|
|
*/
|
|
GLOBAL_ENTRY(esi_call_phys)
|
|
.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
|
|
alloc loc1=ar.pfs,2,7,8,0
|
|
ld8 r2=[in0],8 // load ESI function's entry point
|
|
mov loc0=rp
|
|
.body
|
|
;;
|
|
ld8 out0=[in1],8 // ESI params loaded from array
|
|
;; // passing all as inputs doesn't work
|
|
ld8 out1=[in1],8
|
|
;;
|
|
ld8 out2=[in1],8
|
|
;;
|
|
ld8 out3=[in1],8
|
|
;;
|
|
ld8 out4=[in1],8
|
|
;;
|
|
ld8 out5=[in1],8
|
|
;;
|
|
ld8 out6=[in1],8
|
|
;;
|
|
ld8 out7=[in1]
|
|
mov loc2=gp // save global pointer
|
|
mov loc4=ar.rsc // save RSE configuration
|
|
mov ar.rsc=0 // put RSE in enforced lazy, LE mode
|
|
;;
|
|
ld8 gp=[in0] // load ESI function's global pointer
|
|
movl r16=PSR_BITS_TO_CLEAR
|
|
mov loc3=psr // save processor status word
|
|
movl r17=PSR_BITS_TO_SET
|
|
;;
|
|
or loc3=loc3,r17
|
|
mov b6=r2
|
|
;;
|
|
andcm r16=loc3,r16 // get psr with IT, DT, and RT bits cleared
|
|
br.call.sptk.many rp=ia64_switch_mode_phys
|
|
.ret0: mov loc5=r19 // old ar.bsp
|
|
mov loc6=r20 // old sp
|
|
br.call.sptk.many rp=b6 // call the ESI function
|
|
.ret1: mov ar.rsc=0 // put RSE in enforced lazy, LE mode
|
|
mov r16=loc3 // save virtual mode psr
|
|
mov r19=loc5 // save virtual mode bspstore
|
|
mov r20=loc6 // save virtual mode sp
|
|
br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
|
|
.ret2: mov ar.rsc=loc4 // restore RSE configuration
|
|
mov ar.pfs=loc1
|
|
mov rp=loc0
|
|
mov gp=loc2
|
|
br.ret.sptk.many rp
|
|
END(esi_call_phys)
|