787 a->z_km(Z_R2,Z_R2); // get available KM functions
788 a->z_la(Z_R1,16,Z_R1); // next param block addr
789 a->z_kmc(Z_R2,Z_R2); // get available KMC functions
790 a->z_lghi(Z_RET,4);
791 a->z_br(Z_R14);
792
793 // Use EXTRACT CPU ATTRIBUTE instruction to get information about cache layout.
794 a->bind(getCPUFEATURES);
795 a->z_xgr(Z_R0,Z_R0); // as recommended in instruction documentation
796 a->z_ecag(Z_RET,Z_R0,0,Z_ARG3); // Extract information as requested by Z_ARG1 contents.
797 a->z_br(Z_R14);
798
799 // Use a vector instruction to verify OS support. Will fail with SIGFPE if OS support is missing.
800 a->bind(getVECTORFEATURES);
801 a->z_vtm(Z_V0,Z_V0); // non-destructive vector instruction. Will cause SIGFPE if not supported.
802 a->z_br(Z_R14);
803
804 address code_end = a->pc();
805 a->flush();
806
807 // Print the detection code.
808 bool printVerbose = Verbose || PrintAssembly || PrintStubCode;
809 if (printVerbose) {
810 ttyLocker ttyl;
811 tty->print_cr("Decoding CPU feature detection stub at " INTPTR_FORMAT " before execution:", p2i(code));
812 tty->print_cr("Stub length is %ld bytes, codebuffer reserves %d bytes, %ld bytes spare.",
813 code_end-code, cbuf_size, cbuf_size-(code_end-code));
814
815 // Use existing decode function. This enables the [Code] format which is needed to DecodeErrorFile.
816 Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
817 }
818
819 // Prepare for detection code execution and clear work buffer.
820 _nfeatures = 0;
821 _ncipher_features = 0;
822 unsigned long buffer[buf_len];
823
824 for (int i = 0; i < buf_len; i++) {
825 buffer[i] = 0L;
826 }
827
828 // execute code
829 // Illegal instructions will be replaced by 0 in signal handler.
830 // In case of problems, call_getFeatures will return a not-positive result.
831 long used_len = call_getFeatures(buffer, buf_len, 0);
832
833 bool ok;
834 if (used_len == 1) {
835 ok = true;
836 } else if (used_len > 1) {
|
787 a->z_km(Z_R2,Z_R2); // get available KM functions
788 a->z_la(Z_R1,16,Z_R1); // next param block addr
789 a->z_kmc(Z_R2,Z_R2); // get available KMC functions
790 a->z_lghi(Z_RET,4);
791 a->z_br(Z_R14);
792
793 // Use EXTRACT CPU ATTRIBUTE instruction to get information about cache layout.
794 a->bind(getCPUFEATURES);
795 a->z_xgr(Z_R0,Z_R0); // as recommended in instruction documentation
796 a->z_ecag(Z_RET,Z_R0,0,Z_ARG3); // Extract information as requested by Z_ARG1 contents.
797 a->z_br(Z_R14);
798
799 // Use a vector instruction to verify OS support. Will fail with SIGFPE if OS support is missing.
800 a->bind(getVECTORFEATURES);
801 a->z_vtm(Z_V0,Z_V0); // non-destructive vector instruction. Will cause SIGFPE if not supported.
802 a->z_br(Z_R14);
803
804 address code_end = a->pc();
805 a->flush();
806
807 cbuf.insts()->set_end(code_end);
808
809 // Print the detection code.
810 bool printVerbose = Verbose || PrintAssembly || PrintStubCode;
811 if (printVerbose) {
812 ttyLocker ttyl;
813 tty->print_cr("Decoding CPU feature detection stub at " INTPTR_FORMAT " before execution:", p2i(code));
814 tty->print_cr("Stub length is %ld bytes, codebuffer reserves %d bytes, %ld bytes spare.",
815 code_end-code, cbuf_size, cbuf_size-(code_end-code));
816
817 // Use existing decode function. This enables the [MachCode] format which is needed to DecodeErrorFile.
818 Disassembler::decode(&cbuf, code, code_end, tty);
819 }
820
821 // Prepare for detection code execution and clear work buffer.
822 _nfeatures = 0;
823 _ncipher_features = 0;
824 unsigned long buffer[buf_len];
825
826 for (int i = 0; i < buf_len; i++) {
827 buffer[i] = 0L;
828 }
829
830 // execute code
831 // Illegal instructions will be replaced by 0 in signal handler.
832 // In case of problems, call_getFeatures will return a not-positive result.
833 long used_len = call_getFeatures(buffer, buf_len, 0);
834
835 bool ok;
836 if (used_len == 1) {
837 ok = true;
838 } else if (used_len > 1) {
|