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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

printf("hardware keyset after KERNEXT =%016lx\n",hwset);<br />

/*<br />

* Add kkey=KKEY_VMM to the current keyset. This is the key we will be<br />

* using to protect our memory pages<br />

*/<br />

if ((rc=kkeyset_add_key(myset, kkey ,KA_RW))!=0){<br />

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

return -1;<br />

}<br />

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

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

return -1;<br />

}<br />

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

/*<br />

* Create a heap protected by the key KKEY_VMM<br />

*/<br />

bzero(&heapattr, sizeof(heapattr));<br />

heapattr.hpa_eyec=EYEC_HEAPATTR;<br />

heapattr.hpa_version=HPA_VERSION;<br />

heapattr.hpa_flags=HPA_PINNED|HPA_SHARED;<br />

heapattr.hpa_debug_level=HPA_DEFAULT_DEBUG;<br />

/*<br />

* The heap will be protected by key==heapattr.hpa_kkey=KKEY_VMM<br />

* So other extensions/components should have KKEY_VMM in their keyset in<br />

* order to access it.<br />

*/<br />

heapattr.hpa_kkey=kkey;<br />

if ((rc=heap_create(&heapattr, &my_heap))!=0 ){<br />

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

return -1;<br />

}<br />

/*<br />

* Add current keyset={KKEYSET_KERNEXT, KKEY_VMM} to the current kernel<br />

* extension/system-call. This will be done through the help of a Protection<br />

* Gate. If you dont do this you will not be able to access the private heap<br />

* created in line#75 as thats protected by key KKEY_VMM<br />

*/<br />

oldhwset=hkeyset_replace(hwset);<br />

/*<br />

* Assign a page from our private kernel heap which is protected by<br />

* keyset={KKEYSET_KERNEXT, KKEY_VMM}.<br />

*/<br />

caddr_t page=xmalloc(4096, 12, my_heap);<br />

if (page==NULL){<br />

printf("xmalloc() failed");<br />

return -1;<br />

}<br />

/* Test KA_READ access on heap. Since we have the key in our keyset (from<br />

* line#52) so we will be able to access it. In case we haven't it would have<br />

* caused a DSI or machine crash.<br />

*/<br />

92 <strong>IBM</strong> <strong>AIX</strong> <strong>Continuous</strong> <strong>Availability</strong> <strong>Features</strong>

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

Saved successfully!

Ooh no, something went wrong!