€•†Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ"/translations/zh_CN/arch/sparc/adi”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/zh_TW/arch/sparc/adi”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/it_IT/arch/sparc/adi”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ja_JP/arch/sparc/adi”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ko_KR/arch/sparc/adi”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/sp_SP/arch/sparc/adi”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ Application Data Integrity (ADI)”h]”hŒ Application Data Integrity (ADI)”…””}”(hh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒWhen a task has not enabled ADI and attempts to set ADI version on a memory address, processor sends an MCD disabled trap. This trap is handled by hypervisor first and the hypervisor vectors this trap through to the kernel as Data Access Exception trap with fault type set to 0xa (invalid ASI). When this occurs, the kernel sends the task SIGSEGV signal with following info:: siginfo.si_signo = SIGSEGV; siginfo.errno = 0; siginfo.si_code = SEGV_ACCADI; siginfo.si_addr = addr; /* address that caused trap */ siginfo.si_trapno = 0; ”h]”(h¸)”}”(hXwWhen a task has not enabled ADI and attempts to set ADI version on a memory address, processor sends an MCD disabled trap. This trap is handled by hypervisor first and the hypervisor vectors this trap through to the kernel as Data Access Exception trap with fault type set to 0xa (invalid ASI). When this occurs, the kernel sends the task SIGSEGV signal with following info::”h]”hXvWhen a task has not enabled ADI and attempts to set ADI version on a memory address, processor sends an MCD disabled trap. This trap is handled by hypervisor first and the hypervisor vectors this trap through to the kernel as Data Access Exception trap with fault type set to 0xa (invalid ASI). When this occurs, the kernel sends the task SIGSEGV signal with following info:”…””}”(hjÅhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KŽhjÁubj)”}”(hŒ›siginfo.si_signo = SIGSEGV; siginfo.errno = 0; siginfo.si_code = SEGV_ACCADI; siginfo.si_addr = addr; /* address that caused trap */ siginfo.si_trapno = 0;”h]”hŒ›siginfo.si_signo = SIGSEGV; siginfo.errno = 0; siginfo.si_code = SEGV_ACCADI; siginfo.si_addr = addr; /* address that caused trap */ siginfo.si_trapno = 0;”…””}”hjÓsbah}”(h]”h ]”h"]”h$]”h&]”j!j"uh1jhŸh¶h K•hjÁubeh}”(h]”h ]”h"]”h$]”h&]”uh1jKhŸh¶h KŽhj°hžhubeh}”(h]”Œ mcd-disabled”ah ]”h"]”Œ mcd disabled”ah$]”h&]”uh1h¡hjÏhžhhŸh¶h KŒubh¢)”}”(hhh]”(h§)”}”(hŒSample program to use ADI”h]”hŒSample program to use ADI”…””}”(hjòhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjïhžhhŸh¶h Kubh¸)”}”(hŒRFollowing sample program is meant to illustrate how to use the ADI functionality::”h]”hŒQFollowing sample program is meant to illustrate how to use the ADI functionality:”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hŸh¶h KŸhjïhžhubj)”}”(hX#include #include #include #include #include #include #include #include #ifndef AT_ADI_BLKSZ #define AT_ADI_BLKSZ 48 #endif #ifndef AT_ADI_NBITS #define AT_ADI_NBITS 49 #endif #ifndef PROT_ADI #define PROT_ADI 0x10 #endif #define BUFFER_SIZE 32*1024*1024UL main(int argc, char* argv[], char* envp[]) { unsigned long i, mcde, adi_blksz, adi_nbits; char *shmaddr, *tmp_addr, *end, *veraddr, *clraddr; int shmid, version; Elf64_auxv_t *auxv; adi_blksz = 0; while(*envp++ != NULL); for (auxv = (Elf64_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) { switch (auxv->a_type) { case AT_ADI_BLKSZ: adi_blksz = auxv->a_un.a_val; break; case AT_ADI_NBITS: adi_nbits = auxv->a_un.a_val; break; } } if (adi_blksz == 0) { fprintf(stderr, "Oops! ADI is not supported\n"); exit(1); } printf("ADI capabilities:\n"); printf("\tBlock size = %ld\n", adi_blksz); printf("\tNumber of bits = %ld\n", adi_nbits); if ((shmid = shmget(2, BUFFER_SIZE, IPC_CREAT | SHM_R | SHM_W)) < 0) { perror("shmget failed"); exit(1); } shmaddr = shmat(shmid, NULL, 0); if (shmaddr == (char *)-1) { perror("shm attach failed"); shmctl(shmid, IPC_RMID, NULL); exit(1); } if (mprotect(shmaddr, BUFFER_SIZE, PROT_READ|PROT_WRITE|PROT_ADI)) { perror("mprotect failed"); goto err_out; } /* Set the ADI version tag on the shm segment */ version = 10; tmp_addr = shmaddr; end = shmaddr + BUFFER_SIZE; while (tmp_addr < end) { asm volatile( "stxa %1, [%0]0x90\n\t" : : "r" (tmp_addr), "r" (version)); tmp_addr += adi_blksz; } asm volatile("membar #Sync\n\t"); /* Create a versioned address from the normal address by placing * version tag in the upper adi_nbits bits */ tmp_addr = (void *) ((unsigned long)shmaddr << adi_nbits); tmp_addr = (void *) ((unsigned long)tmp_addr >> adi_nbits); veraddr = (void *) (((unsigned long)version << (64-adi_nbits)) | (unsigned long)tmp_addr); printf("Starting the writes:\n"); for (i = 0; i < BUFFER_SIZE; i++) { veraddr[i] = (char)(i); if (!(i % (1024 * 1024))) printf("."); } printf("\n"); printf("Verifying data..."); fflush(stdout); for (i = 0; i < BUFFER_SIZE; i++) if (veraddr[i] != (char)i) printf("\nIndex %lu mismatched\n", i); printf("Done.\n"); /* Disable ADI and clean up */ if (mprotect(shmaddr, BUFFER_SIZE, PROT_READ|PROT_WRITE)) { perror("mprotect failed"); goto err_out; } if (shmdt((const void *)shmaddr) != 0) perror("Detach failure"); shmctl(shmid, IPC_RMID, NULL); exit(0); err_out: if (shmdt((const void *)shmaddr) != 0) perror("Detach failure"); shmctl(shmid, IPC_RMID, NULL); exit(1); }”h]”hX#include #include #include #include #include #include #include #include #ifndef AT_ADI_BLKSZ #define AT_ADI_BLKSZ 48 #endif #ifndef AT_ADI_NBITS #define AT_ADI_NBITS 49 #endif #ifndef PROT_ADI #define PROT_ADI 0x10 #endif #define BUFFER_SIZE 32*1024*1024UL main(int argc, char* argv[], char* envp[]) { unsigned long i, mcde, adi_blksz, adi_nbits; char *shmaddr, *tmp_addr, *end, *veraddr, *clraddr; int shmid, version; Elf64_auxv_t *auxv; adi_blksz = 0; while(*envp++ != NULL); for (auxv = (Elf64_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) { switch (auxv->a_type) { case AT_ADI_BLKSZ: adi_blksz = auxv->a_un.a_val; break; case AT_ADI_NBITS: adi_nbits = auxv->a_un.a_val; break; } } if (adi_blksz == 0) { fprintf(stderr, "Oops! ADI is not supported\n"); exit(1); } printf("ADI capabilities:\n"); printf("\tBlock size = %ld\n", adi_blksz); printf("\tNumber of bits = %ld\n", adi_nbits); if ((shmid = shmget(2, BUFFER_SIZE, IPC_CREAT | SHM_R | SHM_W)) < 0) { perror("shmget failed"); exit(1); } shmaddr = shmat(shmid, NULL, 0); if (shmaddr == (char *)-1) { perror("shm attach failed"); shmctl(shmid, IPC_RMID, NULL); exit(1); } if (mprotect(shmaddr, BUFFER_SIZE, PROT_READ|PROT_WRITE|PROT_ADI)) { perror("mprotect failed"); goto err_out; } /* Set the ADI version tag on the shm segment */ version = 10; tmp_addr = shmaddr; end = shmaddr + BUFFER_SIZE; while (tmp_addr < end) { asm volatile( "stxa %1, [%0]0x90\n\t" : : "r" (tmp_addr), "r" (version)); tmp_addr += adi_blksz; } asm volatile("membar #Sync\n\t"); /* Create a versioned address from the normal address by placing * version tag in the upper adi_nbits bits */ tmp_addr = (void *) ((unsigned long)shmaddr << adi_nbits); tmp_addr = (void *) ((unsigned long)tmp_addr >> adi_nbits); veraddr = (void *) (((unsigned long)version << (64-adi_nbits)) | (unsigned long)tmp_addr); printf("Starting the writes:\n"); for (i = 0; i < BUFFER_SIZE; i++) { veraddr[i] = (char)(i); if (!(i % (1024 * 1024))) printf("."); } printf("\n"); printf("Verifying data..."); fflush(stdout); for (i = 0; i < BUFFER_SIZE; i++) if (veraddr[i] != (char)i) printf("\nIndex %lu mismatched\n", i); printf("Done.\n"); /* Disable ADI and clean up */ if (mprotect(shmaddr, BUFFER_SIZE, PROT_READ|PROT_WRITE)) { perror("mprotect failed"); goto err_out; } if (shmdt((const void *)shmaddr) != 0) perror("Detach failure"); shmctl(shmid, IPC_RMID, NULL); exit(0); err_out: if (shmdt((const void *)shmaddr) != 0) perror("Detach failure"); shmctl(shmid, IPC_RMID, NULL); exit(1); }”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”j!j"uh1jhŸh¶h K¢hjïhžhubeh}”(h]”Œsample-program-to-use-adi”ah ]”h"]”Œsample program to use adi”ah$]”h&]”uh1h¡hjÏhžhhŸh¶h Kubeh}”(h]”Œadi-related-traps”ah ]”h"]”Œadi related traps”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K]ubeh}”(h]”Œapplication-data-integrity-adi”ah ]”h"]”Œ application data integrity (adi)”ah$]”h&]”uh1h¡hhhžhhŸh¶h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h¶uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¦NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”j{Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jVŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h¶Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j1j.jÌjÉj)j&j.j+j­jªjìjéj!juŒ nametypes”}”(j1‰j̉j)‰j.‰j­‰jì‰j!‰uh}”(j.h£jÉjj&jÏj+jîjªj1jéj°jjïuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.