|
| 1 | +/* |
| 2 | + * Copyright (c) 2020 Florian Becker <[email protected]> (VX APPS). |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are met: |
| 7 | + * |
| 8 | + * 1. Redistributions of source code must retain the above copyright notice, this |
| 9 | + * list of conditions and the following disclaimer. |
| 10 | + * |
| 11 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | + * this list of conditions and the following disclaimer in the documentation |
| 13 | + * and/or other materials provided with the distribution. |
| 14 | + * |
| 15 | + * 3. Neither the name of the copyright holder nor the names of its |
| 16 | + * contributors may be used to endorse or promote products derived from |
| 17 | + * this software without specific prior written permission. |
| 18 | + * |
| 19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 22 | + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 23 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 25 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 26 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 27 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | + */ |
| 30 | + |
| 31 | +/* stl header */ |
| 32 | +#include <iostream> |
| 33 | + |
| 34 | +/* modern.cpp.core header */ |
| 35 | +#include <CPU.h> |
| 36 | + |
| 37 | +/** SGX information leaf. */ |
| 38 | +constexpr unsigned int sgxLeaf = 12; |
| 39 | + |
| 40 | +/** Maximum subleafs to read out. */ |
| 41 | +constexpr unsigned int maximumSubLeafs = 10; |
| 42 | + |
| 43 | +int main() { |
| 44 | + |
| 45 | + VX::CPU cpu; |
| 46 | + std::cout << std::hex << cpu.eax() << " " << cpu.ebx() << " " << cpu.ecx() << " " << cpu.edx() << " " << std::dec << std::endl; |
| 47 | + |
| 48 | + std::cout << "Stepping: " << cpu.stepping() << std::endl; |
| 49 | + std::cout << "Model: " << cpu.model() << std::endl; |
| 50 | + std::cout << "Family: " << cpu.family() << std::endl; |
| 51 | + std::cout << "Type: " << cpu.type() << std::endl; |
| 52 | + std::cout << "Extended model: " << cpu.extendedModel() << std::endl; |
| 53 | + std::cout << "Extended family: " << cpu.extendedFamily() << std::endl; |
| 54 | + |
| 55 | + std::cout << "SMX support: " << cpu.smxSupport() << std::endl; |
| 56 | + |
| 57 | + std::cout << std::endl << "Extended features" << std::endl; |
| 58 | + |
| 59 | + std::cout << "SGX support: " << cpu.sgxSupport() << std::endl; |
| 60 | + std::cout << "SGX launch control support: " << cpu.sgxLaunchControlSupport() << std::endl; |
| 61 | + |
| 62 | + std::cout << std::endl << "SGX features" << std::endl; |
| 63 | + |
| 64 | + std::cout << "SGX version 1 support: " << cpu.sgxVersion1Support() << std::endl; |
| 65 | + std::cout << "SGX version 2 support: " << cpu.sgxVersion2Support() << std::endl; |
| 66 | + std::cout << "Maximum enclave size: " << cpu.maximumEnclaveSize() << std::endl; |
| 67 | + std::cout << "Maximum enclave size 64: " << cpu.maximumEnclaveSize64() << std::endl; |
| 68 | + |
| 69 | + for ( unsigned int i = 1; i < maximumSubLeafs; i++ ) { |
| 70 | + |
| 71 | + std::cout << std::endl << "SGX subleaf " << i << std::endl; |
| 72 | + cpu.updateNativeId( sgxLeaf, i ); |
| 73 | + std::cout << std::hex << cpu.eax() << " " << cpu.ebx() << " " << cpu.ecx() << " " << cpu.edx() << " " << std::endl; |
| 74 | + } |
| 75 | + return 0; |
| 76 | +} |
0 commit comments