Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6704 Discussions

Crypto library ippsDESGetSize error in linux kernel: function unable to handle kernel paging request

peifang_hungcipheriu
598 Views
Hi,
I am trying to include IPP crypto libraray to Linux kernel with static link.
Now i can pass the kernel compile without errors.
But when i try to run the encryption procedure, i got some errors below:
using ippsDESGetSize function!
[ 162.408451] BUG: unable to handle kernel paging request at virtual address c0390614
[ 162.408462] printing eip: c01fa12c *pde = 37c11163 *pte = 00390161
[ 162.408477] Oops: 0003
I am only using the basic function:
int ctxSize;
ippsDESGetSize(&ctxSize);

Any help will be appreciated.

Regard.
0 Kudos
14 Replies
Vladimir_Dudnik
Employee
598 Views
Hello,


Could you please provide simple test case which reproduce the issue?
The ippsDESGetSize function basically just returns some sizeof(internal struct) kind of info. No internal memory allocation or pointer dereferencing (except pointer to output value) inside this function.

Regards,
Vladimir
0 Kudos
peifang_hungcipheriu
598 Views
Quoting - Vladimir Dudnik
Hello,


Could you please provide simple test case which reproduce the issue?
The ippsDESGetSize function basically just returns some sizeof(internal struct) kind of info. No internal memory allocation or pointer dereferencing (except pointer to output value) inside this function.

Regards,
Vladimir
Hi, Vladimir Dudnik

I just added these two lines below into the Linux kernel des_encrypt() in des_generic.c
int ctxSize;
ippsDESGetSize(&ctxSize);
When i try to involk the encrypt function, i got the errors.
If i just reomoved these two lines code, the encrypt procedure will be work fine.
And the same code can work under Linux user space application.

Regards.
0 Kudos
Vladimir_Dudnik
Employee
598 Views
Ok, whatyour linker command line look like?

Vladimr
0 Kudos
peifang_hungcipheriu
598 Views
Quoting - Vladimir Dudnik
Ok, whatyour linker command line look like?

Vladimr
I added the include to the des_generic.c below:
#define IPPAPI(type,name,arg) extern type __STDCALL w7_##name arg;
#define IPPCALL(name) w7_##name
#include

and link with
libippcore.a, libippcpemerged.a, libippcpmerged.a

I only added these three ipp library into the linux kernel normal build procedure.
The kernel link command is shown below:


ld -m elf_i386 -m elf_i386 --emit-relocs --build-id -o .tmp_vmlinux1 -T arch/x86/kernel/vmlinux.lds arch/x86/kernel/head_32.o arch/x86/kernel/init_task.o init/built-in.o --start-group usr/built-in.o arch/x86/kernel/built-in.o arch/x86/mm/built-in.o arch/x86/mach-default/built-in.o arch/x86/crypto/built-in.o kernel/built-in.o mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o block/built-in.o lib/libippcore.a arch/x86/lib/libippcore.a lib/libippcpemerged.a arch/x86/lib/libippcpemerged.a lib/libippcpmerged.a arch/x86/lib/libippcpmerged.a lib/lib.a arch/x86/lib/lib.a lib/built-in.o arch/x86/lib/built-in.o drivers/built-in.o sound/built-in.o arch/x86/pci/built-in.o arch/x86/power/built-in.o arch/x86/video/built-in.o net/built-in.o --end-group

Regards.
0 Kudos
Vladimir_Dudnik
Employee
598 Views

If you use direct static linkage to processor specific code ('w7', for example), you do not need to link with *emerged libraries. Although pay attention to PIC or non-PIC IPP libraries, you may need to link with nonpic libraries for Linux kernel mode (check with Linux documentation for the details).

By the way, why library names happened twice in your command line, one with arch/x86/lib and second one with just lib?

Vladimir
0 Kudos
peifang_hungcipheriu
598 Views
Quoting - Vladimir Dudnik

If you use direct static linkage to processor specific code ('w7', for example), you do not need to link with *emerged libraries. Although pay attention to PIC or non-PIC IPP libraries, you may need to link with nonpic libraries for Linux kernel mode (check with Linux documentation for the details).

By the way, why library names happened twice in your command line, one with arch/x86/lib and second one with just lib?

Vladimir
Hi, Vladimir

Should i invoke any initial function for ippsDESGetSize() function? Or just involk the ippsDESGetSize() at the first.
I have compiled the library with non-PIC.
About why the library names happed twice. Cause when i compile the linux kernel, it will check those two, i don't know why.
If i removed one of them, procedure will complain that he can not find the library, so i just copy the library to there.

Mix
0 Kudos
Vladimir_Dudnik
Employee
598 Views
You may need to call ippStaticInit function.

Please refer to IPP kernel mode sample to see how to use IPP in Linux kernel mode

Vladimir

0 Kudos
peifang_hungcipheriu
598 Views
Quoting - Vladimir Dudnik
You may need to call ippStaticInit function.

Please refer to IPP kernel mode sample to see how to use IPP in Linux kernel mode

Vladimir

Vladimir,
Can you provide the IPP kernel mode sample link to me?
Thanks a lot :)
0 Kudos
Vladimir_Dudnik
Employee
598 Views

Hey, I thought you started from this!

Please download IPP sample package from IPP web page (you should be registered IPP user. You may register for evaluation or for free non-commercial license available for Linux developers).

Then you will find IPP kernel mode sample in folder advanced-usage/ippsdrv

Vladimir
0 Kudos
peifang_hungcipheriu
598 Views
Quoting - Vladimir Dudnik

Hey, I thought you started from this!

Please download IPP sample package from IPP web page (you should be registered IPP user. You may register for evaluation or for free non-commercial license available for Linux developers).

Then you will find IPP kernel mode sample in folder advanced-usage/ippsdrv

Vladimir
Vladimir,
Actually i have download this example before, and have checked this example.
As you mentioned, i will try the ippStaticInit() function to do some further test.
Thanks again :)
0 Kudos
peifang_hungcipheriu
598 Views
Vladimir,
Actually i have download this example before, and have checked this example.
As you mentioned, i will try the ippStaticInit() function to do some further test.
Thanks again :)
I found a document that mentioned "If you are using static linking with dispatching (E-Merged), ensure that you have called ippStaticInit first before calling other Intel IPP functions."
http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-intel-ipp-i-do-not-find-good-performance-with-intel-ipp-codec-functions-what-can-i-do/

Is it means if i use the static linking without dispatching (merged), i should not to call ippStaticInit()?
0 Kudos
Vladimir_Dudnik
Employee
598 Views
There is specially dedicated sample of how to use static library linkage without dispatcher, please take a look at advanced-usagelinkagemergedlib sample

Vladimir
0 Kudos
peifang_hungcipheriu
598 Views
Quoting - Vladimir Dudnik
There is specially dedicated sample of how to use static library linkage without dispatcher, please take a look at advanced-usagelinkagemergedlib sample

Vladimir
Hi Vladimir,

When i include the ippStaticInit(), i can not pass the compile. Then i found this in ippcore.h

/* /////////////////////////////////////////////////////////////////////////////
// Functions to control emerged library
///////////////////////////////////////////////////////////////////////////// */
/* /////////////////////////////////////////////////////////////////////////////
// Name: ippStaticInit
// Purpose: Automatic switching to best for current cpu library code using.
// Returns:
// ippStsNoErr - the best code (static) successfully set
// ippStsNonIntelCpu - px version (static) of code was set
// ippStsNoOperationInDll - function does nothing in the dynamic version of the library
//
// Parameter: nothing
//
// Notes: At the moment of this function execution no any other IPP function
// has to be working
*/
IPPAPI( IppStatus, ippStaticInit, ( void ))

I am not using the emerged library, so i guess that i don't need to invoke the ippStaticInit().
Am i right?

0 Kudos
Vladimir_Dudnik
Employee
598 Views
0 Kudos
Reply