New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass 32bits to 64bits arguments for SWSMI registers when using edk2 #492

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@BrunoPujos
Copy link

BrunoPujos commented Dec 13, 2018

When compiling Python for EFI (from EDK2) with the patch provided by chipsec the arguments pass to the edk2.swsmi are converted in 32 bits instead of 64 bits.

Test build was made using VS2017 on 64bits and EDK2 version from their git (and not UDK).

@ErikBjorge

This comment has been minimized.

Copy link
Member

ErikBjorge commented Dec 13, 2018

Thanks for the patch! We will need some time to do some validation and double check the assembly code being called to make sure everything works as expected.

@@ -47,7 +47,7 @@ PyDoc_STRVAR(edk2__doc__,
// -- Access to CPU MSRs
extern void _rdmsr( unsigned int msr_num, unsigned int* msr_lo, unsigned int* msr_hi );
extern void _wrmsr( unsigned int msr_num, unsigned int msr_hi, unsigned int msr_lo );
extern void _swsmi( unsigned int smi_code_data, unsigned int rax_value, unsigned int rbx_value, unsigned int rcx_value, unsigned int rdx_value, unsigned int rsi_value, unsigned int rdi_value );
extern void _swsmi( unsigned long long smi_code_data, unsigned long long rax_value, unsigned long long rbx_value, unsigned long long rcx_value, unsigned long long rdx_value, unsigned long long rsi_value, unsigned long long rdi_value );

This comment has been minimized.

@BrentHoltsclaw

BrentHoltsclaw Jan 3, 2019

Contributor

i understand that 32bit assembly currently does not support swsmi, however the code should be future proof. Please use the type UINTN opposed to long long.

@@ -6920,8 +6920,8 @@ Triggering Software SMI");
static PyObject *
posix_swsmi(PyObject *self, PyObject *args)
{
unsigned int smi_code_data, rax_value, rbx_value, rcx_value, rdx_value, rsi_value, rdi_value;
if (!PyArg_Parse(args, "(IIIIIII)", &smi_code_data, &rax_value, &rbx_value, &rcx_value, &rdx_value, &rsi_value, &rdi_value))
unsigned long long smi_code_data, rax_value, rbx_value, rcx_value, rdx_value, rsi_value, rdi_value;

This comment has been minimized.

@BrentHoltsclaw

BrentHoltsclaw Jan 3, 2019

Contributor

Same here change to UINTN

unsigned int smi_code_data, rax_value, rbx_value, rcx_value, rdx_value, rsi_value, rdi_value;
if (!PyArg_Parse(args, "(IIIIIII)", &smi_code_data, &rax_value, &rbx_value, &rcx_value, &rdx_value, &rsi_value, &rdi_value))
unsigned long long smi_code_data, rax_value, rbx_value, rcx_value, rdx_value, rsi_value, rdi_value;
if (!PyArg_Parse(args, "(KKKKKKK)", &smi_code_data, &rax_value, &rbx_value, &rcx_value, &rdx_value, &rsi_value, &rdi_value))

This comment has been minimized.

@BrentHoltsclaw

BrentHoltsclaw Jan 3, 2019

Contributor

create logic such as:

if(sizeof(UINTN) == 8){
    if (!PyArg_Parse(args, "(KKKKKKK)", &smi_code_data, &rax_value, &rbx_value, &rcx_value, &rdx_value, &rsi_value, &rdi_value))
         return NULL; }
else{
    if (!PyArg_Parse(args, "(IIIIIII)", &smi_code_data, &rax_value, &rbx_value, &rcx_value, &rdx_value, &rsi_value, &rdi_value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment