18c2ecf20Sopenharmony_ci#!/bin/sh 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: LGPL-2.1 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciif [ $# -ne 1 ] ; then 58c2ecf20Sopenharmony_ci arch_x86_header_dir=tools/arch/x86/include/asm/ 68c2ecf20Sopenharmony_cielse 78c2ecf20Sopenharmony_ci arch_x86_header_dir=$1 88c2ecf20Sopenharmony_cifi 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cix86_msr_index=${arch_x86_header_dir}/msr-index.h 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci# Support all later, with some hash table, for now chop off 138c2ecf20Sopenharmony_ci# Just the ones starting with 0x00000 so as to have a simple 148c2ecf20Sopenharmony_ci# array. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciprintf "static const char *x86_MSRs[] = {\n" 178c2ecf20Sopenharmony_ciregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MSR_([[:alnum:]][[:alnum:]_]+)[[:space:]]+(0x00000[[:xdigit:]]+)[[:space:]]*.*' 188c2ecf20Sopenharmony_ciegrep $regex ${x86_msr_index} | egrep -v 'MSR_(ATOM|P[46]|AMD64|IA32_TSCDEADLINE|IDT_FCR4)' | \ 198c2ecf20Sopenharmony_ci sed -r "s/$regex/\2 \1/g" | sort -n | \ 208c2ecf20Sopenharmony_ci xargs printf "\t[%s] = \"%s\",\n" 218c2ecf20Sopenharmony_ciprintf "};\n\n" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci# Remove MSR_K6_WHCR, clashes with MSR_LSTAR 248c2ecf20Sopenharmony_ciregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MSR_([[:alnum:]][[:alnum:]_]+)[[:space:]]+(0xc0000[[:xdigit:]]+)[[:space:]]*.*' 258c2ecf20Sopenharmony_ciprintf "#define x86_64_specific_MSRs_offset " 268c2ecf20Sopenharmony_ciegrep $regex ${x86_msr_index} | sed -r "s/$regex/\2/g" | sort -n | head -1 278c2ecf20Sopenharmony_ciprintf "static const char *x86_64_specific_MSRs[] = {\n" 288c2ecf20Sopenharmony_ciegrep $regex ${x86_msr_index} | \ 298c2ecf20Sopenharmony_ci sed -r "s/$regex/\2 \1/g" | egrep -vw 'K6_WHCR' | sort -n | \ 308c2ecf20Sopenharmony_ci xargs printf "\t[%s - x86_64_specific_MSRs_offset] = \"%s\",\n" 318c2ecf20Sopenharmony_ciprintf "};\n\n" 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciregex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MSR_([[:alnum:]][[:alnum:]_]+)[[:space:]]+(0xc0010[[:xdigit:]]+)[[:space:]]*.*' 348c2ecf20Sopenharmony_ciprintf "#define x86_AMD_V_KVM_MSRs_offset " 358c2ecf20Sopenharmony_ciegrep $regex ${x86_msr_index} | sed -r "s/$regex/\2/g" | sort -n | head -1 368c2ecf20Sopenharmony_ciprintf "static const char *x86_AMD_V_KVM_MSRs[] = {\n" 378c2ecf20Sopenharmony_ciegrep $regex ${x86_msr_index} | \ 388c2ecf20Sopenharmony_ci sed -r "s/$regex/\2 \1/g" | sort -n | \ 398c2ecf20Sopenharmony_ci xargs printf "\t[%s - x86_AMD_V_KVM_MSRs_offset] = \"%s\",\n" 408c2ecf20Sopenharmony_ciprintf "};\n" 41