11.01.2013 Views

IBM AIX Continuous Availability Features - IBM Redbooks

IBM AIX Continuous Availability Features - IBM Redbooks

IBM AIX Continuous Availability Features - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

*(page+10)=10;<br />

if (mode>0){<br />

/*<br />

* Remove KKEY_VMM from current keyset. After this operation current keysey=<br />

* {KKEYSET_KERNEXT}<br />

*/<br />

if ((rc=kkeyset_remove_key(myset, KKEY_VMM, KA_RW))!=0){<br />

printf("kkeyset_remove_key() failed\n");<br />

return -1;<br />

}<br />

if ((rc=kkeyset_to_hkeyset(myset, &hwset))!=0){<br />

printf("kkeyset_to_hkeyset() failed: rc=%lx\n",rc);<br />

return -1;<br />

}<br />

/*<br />

* Set current keyset= {KKEYSET_KERNEXT} using the Protection Gate to current<br />

* kernel code path<br />

*/<br />

oldhwset1=hkeyset_replace(hwset);<br />

printf("hardware keyset w/o KKEY_VMM =%lx\n",hwset);<br />

/*<br />

* Try accessing the private heap using the current keyset={KKEYSET_KERNEXT}.<br />

* As the heap is protected by {KKEY_VMM} so this should<br />

* result in a DSI or system crash (as there is no default exception handler<br />

* defined for storage key exception- EXCEPT_SKEY<br />

*/<br />

*(page+10)=10;<br />

printf("never reaches here\n");<br />

}<br />

/*<br />

* Restore the hardware keyset to the value before module entry<br />

*/<br />

hkeyset_restore(hwset1);<br />

/*<br />

* Free the space occupied by data structures for kernel keyset<br />

*/<br />

xmfree(page, my_heap);<br />

heap_destroy (my_heap,0);<br />

kkeyset_delete(myset);<br />

return 0;<br />

The export file for kernel extension is shown in Example 3-23.<br />

Example 3-23 Export file for kernel extension:kkey_set.exp<br />

#!/unix<br />

kkey_test syscall64<br />

Sample code myprog.c is shown in Example 3-24.<br />

Example 3-24 User program for accessing kernel extension: myprog.c<br />

main(int argc, char** argv)<br />

{<br />

int param=0;<br />

Chapter 3. <strong>AIX</strong> advanced continuous availability tools and features 93

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!