From ee44a92df6964df623f8bddca96b3007c80ce613 Mon Sep 17 00:00:00 2001 From: Dimitar Vlahovski Date: Tue, 6 Sep 2016 11:00:37 +0000 Subject: Revert "Intel(R) Memory Protection Extensions (Intel(R) MPX) support." This reverts commit rL280668 because the register tests fail on i386 Linux. I investigated a little bit what causes the failure - there are missing registers when running 'register read -a'. This is the output I got at the bottom: """ ... Memory Protection Extensions: bnd0 = {0x0000000000000000 0x0000000000000000} bnd1 = {0x0000000000000000 0x0000000000000000} bnd2 = {0x0000000000000000 0x0000000000000000} bnd3 = {0x0000000000000000 0x0000000000000000} unknown: 2 registers were unavailable. """ Also looking at the packets exchanged between the client and server: """ ... history[308] tid=0x7338 < 19> send packet: $qRegisterInfo4a#d7 history[309] tid=0x7338 < 130> read packet: $name:bnd0;bitsize:128;offset:1032;encoding:vector;format:vector-uint64;set:Memory Protection Extensions;ehframe:101;dwarf:101;#48 history[310] tid=0x7338 < 19> send packet: $qRegisterInfo4b#d8 history[311] tid=0x7338 < 130> read packet: $name:bnd1;bitsize:128;offset:1048;encoding:vector;format:vector-uint64;set:Memory Protection Extensions;ehframe:102;dwarf:102;#52 history[312] tid=0x7338 < 19> send packet: $qRegisterInfo4c#d9 history[313] tid=0x7338 < 130> read packet: $name:bnd2;bitsize:128;offset:1064;encoding:vector;format:vector-uint64;set:Memory Protection Extensions;ehframe:103;dwarf:103;#53 history[314] tid=0x7338 < 19> send packet: $qRegisterInfo4d#da history[315] tid=0x7338 < 130> read packet: $name:bnd3;bitsize:128;offset:1080;encoding:vector;format:vector-uint64;set:Memory Protection Extensions;ehframe:104;dwarf:104;#54 history[316] tid=0x7338 < 19> send packet: $qRegisterInfo4e#db history[317] tid=0x7338 < 76> read packet: $name:bndcfgu;bitsize:64;offset:1096;encoding:vector;format:vector-uint8;#99 history[318] tid=0x7338 < 19> send packet: $qRegisterInfo4f#dc history[319] tid=0x7338 < 78> read packet: $name:bndstatus;bitsize:64;offset:1104;encoding:vector;format:vector-uint8;#8e ... """ The bndcfgu and bndstatus registers don't have the 'Memory Protections Extension' set. I looked at the code and it seems that that is set correctly. So I'm not sure what's the problem or where does it come from. Also there is a second failure related to something like this in the tests: """ registerSet.GetName().lower() """ For some reason the registerSet.GetName() returns None. llvm-svn: 280703 --- .../Linux/NativeRegisterContextLinux_x86_64.cpp | 179 ++------------------- 1 file changed, 10 insertions(+), 169 deletions(-) (limited to 'lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp') diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp index 93ee50273b9..2080d2ede37 100755 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp @@ -130,21 +130,6 @@ namespace static_assert((sizeof(g_avx_regnums_i386) / sizeof(g_avx_regnums_i386[0])) - 1 == k_num_avx_registers_i386, " g_avx_regnums_i386 has wrong number of register infos"); - // x64 32-bit MPX registers. - static const uint32_t - g_mpx_regnums_i386[] = - { - lldb_bnd0_i386, - lldb_bnd1_i386, - lldb_bnd2_i386, - lldb_bnd3_i386, - lldb_bndcfgu_i386, - lldb_bndstatus_i386, - LLDB_INVALID_REGNUM // register sets need to end with this flag - }; - static_assert((sizeof(g_mpx_regnums_i386) / sizeof(g_mpx_regnums_i386[0])) - 1 == k_num_mpx_registers_i386, - "g_mpx_regnums_x86_64 has wrong number of register infos"); - // x86 64-bit general purpose registers. static const uint32_t g_gpr_regnums_x86_64[] = @@ -306,47 +291,29 @@ namespace static_assert((sizeof(g_avx_regnums_x86_64) / sizeof(g_avx_regnums_x86_64[0])) - 1 == k_num_avx_registers_x86_64, "g_avx_regnums_x86_64 has wrong number of register infos"); - // x86 64-bit MPX registers. - static const uint32_t - g_mpx_regnums_x86_64[] = - { - lldb_bnd0_x86_64, - lldb_bnd1_x86_64, - lldb_bnd2_x86_64, - lldb_bnd3_x86_64, - lldb_bndcfgu_x86_64, - lldb_bndstatus_x86_64, - LLDB_INVALID_REGNUM // register sets need to end with this flag - }; - static_assert((sizeof(g_mpx_regnums_x86_64) / sizeof(g_mpx_regnums_x86_64[0])) - 1 == k_num_mpx_registers_x86_64, - "g_mpx_regnums_x86_64 has wrong number of register infos"); - // Number of register sets provided by this context. enum { k_num_extended_register_sets = 1, - k_num_register_sets = 4 + k_num_register_sets = 3 }; // Register sets for x86 32-bit. static const RegisterSet g_reg_sets_i386[k_num_register_sets] = { - { "General Purpose Registers", "gpr", k_num_gpr_registers_i386, g_gpr_regnums_i386 }, - { "Floating Point Registers", "fpu", k_num_fpr_registers_i386, g_fpu_regnums_i386 }, - { "Advanced Vector Extensions", "avx", k_num_avx_registers_i386, g_avx_regnums_i386 }, - { "Memory Protection Extensions", "mpx", k_num_mpx_registers_i386, g_mpx_regnums_i386 } + { "General Purpose Registers", "gpr", k_num_gpr_registers_i386, g_gpr_regnums_i386 }, + { "Floating Point Registers", "fpu", k_num_fpr_registers_i386, g_fpu_regnums_i386 }, + { "Advanced Vector Extensions", "avx", k_num_avx_registers_i386, g_avx_regnums_i386 } }; // Register sets for x86 64-bit. static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = { - { "General Purpose Registers", "gpr", k_num_gpr_registers_x86_64, g_gpr_regnums_x86_64 }, - { "Floating Point Registers", "fpu", k_num_fpr_registers_x86_64, g_fpu_regnums_x86_64 }, - { "Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64, g_avx_regnums_x86_64 }, - { "Memory Protection Extensions", "mpx", k_num_mpx_registers_x86_64, g_mpx_regnums_x86_64 } - + { "General Purpose Registers", "gpr", k_num_gpr_registers_x86_64, g_gpr_regnums_x86_64 }, + { "Floating Point Registers", "fpu", k_num_fpr_registers_x86_64, g_fpu_regnums_x86_64 }, + { "Advanced Vector Extensions", "avx", k_num_avx_registers_x86_64, g_avx_regnums_x86_64 } }; } @@ -401,7 +368,6 @@ NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64 (const Arch m_fpr (), m_iovec (), m_ymm_set (), - m_mpx_set (), m_reg_info (), m_gpr_x86_64 () { @@ -413,7 +379,6 @@ NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64 (const Arch m_reg_info.num_gpr_registers = k_num_gpr_registers_i386; m_reg_info.num_fpr_registers = k_num_fpr_registers_i386; m_reg_info.num_avx_registers = k_num_avx_registers_i386; - m_reg_info.num_mpx_registers = k_num_mpx_registers_i386; m_reg_info.last_gpr = k_last_gpr_i386; m_reg_info.first_fpr = k_first_fpr_i386; m_reg_info.last_fpr = k_last_fpr_i386; @@ -425,10 +390,6 @@ NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64 (const Arch m_reg_info.last_xmm = lldb_xmm7_i386; m_reg_info.first_ymm = lldb_ymm0_i386; m_reg_info.last_ymm = lldb_ymm7_i386; - m_reg_info.first_mpxr = lldb_bnd0_i386; - m_reg_info.last_mpxr = lldb_bnd3_i386; - m_reg_info.first_mpxc = lldb_bndcfgu_i386; - m_reg_info.last_mpxc = lldb_bndstatus_i386; m_reg_info.first_dr = lldb_dr0_i386; m_reg_info.gpr_flags = lldb_eflags_i386; break; @@ -437,7 +398,6 @@ NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64 (const Arch m_reg_info.num_gpr_registers = k_num_gpr_registers_x86_64; m_reg_info.num_fpr_registers = k_num_fpr_registers_x86_64; m_reg_info.num_avx_registers = k_num_avx_registers_x86_64; - m_reg_info.num_mpx_registers = k_num_mpx_registers_x86_64; m_reg_info.last_gpr = k_last_gpr_x86_64; m_reg_info.first_fpr = k_first_fpr_x86_64; m_reg_info.last_fpr = k_last_fpr_x86_64; @@ -449,10 +409,6 @@ NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64 (const Arch m_reg_info.last_xmm = lldb_xmm15_x86_64; m_reg_info.first_ymm = lldb_ymm0_x86_64; m_reg_info.last_ymm = lldb_ymm15_x86_64; - m_reg_info.first_mpxr = lldb_bnd0_x86_64; - m_reg_info.last_mpxr = lldb_bnd3_x86_64; - m_reg_info.first_mpxc = lldb_bndcfgu_x86_64; - m_reg_info.last_mpxc = lldb_bndstatus_x86_64; m_reg_info.first_dr = lldb_dr0_x86_64; m_reg_info.gpr_flags = lldb_rflags_x86_64; break; @@ -598,28 +554,7 @@ NativeRegisterContextLinux_x86_64::ReadRegister (const RegisterInfo *reg_info, R return error; } } - if (reg >= m_reg_info.first_mpxr && reg <= m_reg_info.last_mpxr) - { - if (GetFPRType() == eFPRTypeXSAVE && CopyXSTATEtoMPX(reg)) - reg_value.SetBytes(m_mpx_set.mpxr[reg - m_reg_info.first_mpxr].bytes, reg_info->byte_size, - byte_order); - else - { - error.SetErrorString("failed to copy mpx register value"); - return error; - } - } - if (reg >= m_reg_info.first_mpxc && reg <= m_reg_info.last_mpxc) - { - if (GetFPRType() == eFPRTypeXSAVE && CopyXSTATEtoMPX(reg)) - reg_value.SetBytes(m_mpx_set.mpxc[reg - m_reg_info.first_mpxc].bytes, reg_info->byte_size, - byte_order); - else - { - error.SetErrorString("failed to copy mpx register value"); - return error; - } - } + if (reg_value.GetType() != RegisterValue::eTypeBytes) error.SetErrorString ("write failed - type was expected to be RegisterValue::eTypeBytes"); @@ -699,26 +634,6 @@ NativeRegisterContextLinux_x86_64::WriteRegister (const RegisterInfo *reg_info, if (!CopyYMMtoXSTATE(reg_index, GetByteOrder())) return Error ("CopyYMMtoXSTATE() failed"); } - if (reg_index >= m_reg_info.first_mpxr && reg_index <= m_reg_info.last_mpxr) - { - if (GetFPRType() != eFPRTypeXSAVE) - return Error("target processor does not support MPX"); - - ::memcpy(m_mpx_set.mpxr[reg_index - m_reg_info.first_mpxr].bytes, reg_value.GetBytes(), - reg_value.GetByteSize()); - if (!CopyMPXtoXSTATE(reg_index)) - return Error("CopyMPXtoXSTATE() failed"); - } - if (reg_index >= m_reg_info.first_mpxc && reg_index <= m_reg_info.last_mpxc) - { - if (GetFPRType() != eFPRTypeXSAVE) - return Error("target processor does not support MPX"); - - ::memcpy(m_mpx_set.mpxc[reg_index - m_reg_info.first_mpxc].bytes, reg_value.GetBytes(), - reg_value.GetByteSize()); - if (!CopyMPXtoXSTATE(reg_index)) - return Error("CopyMPXtoXSTATE() failed"); - } } else { @@ -762,12 +677,6 @@ NativeRegisterContextLinux_x86_64::WriteRegister (const RegisterInfo *reg_info, if (!CopyYMMtoXSTATE(reg_index, GetByteOrder())) return Error ("CopyYMMtoXSTATE() failed"); } - - if (IsMPX(reg_index)) - { - if (!CopyMPXtoXSTATE(reg_index)) - return Error("CopyMPXtoXSTATE() failed"); - } return Error (); } return Error ("failed - register wasn't recognized to be a GPR or an FPR, write strategy unknown"); @@ -818,17 +727,6 @@ NativeRegisterContextLinux_x86_64::ReadAllRegisterValues (lldb::DataBufferSP &da } } - for (uint32_t reg = m_reg_info.first_mpxr; reg <= m_reg_info.last_mpxc; ++reg) - { - if (!CopyXSTATEtoMPX(reg)) - { - error.SetErrorStringWithFormat( - "NativeRegisterContextLinux_x86_64::%s CopyXSTATEtoMPX() failed for reg num %" PRIu32, __FUNCTION__, - reg); - return error; - } - } - // Copy the extended register state including the assembled ymm registers. ::memcpy (dst, &m_fpr, sizeof (m_fpr)); } @@ -908,17 +806,6 @@ NativeRegisterContextLinux_x86_64::WriteAllRegisterValues (const lldb::DataBuffe return error; } } - - for (uint32_t reg = m_reg_info.first_mpxr; reg <= m_reg_info.last_mpxc; ++reg) - { - if (!CopyMPXtoXSTATE(reg)) - { - error.SetErrorStringWithFormat( - "NativeRegisterContextLinux_x86_64::%s CopyMPXtoXSTATE() failed for reg num %" PRIu32, __FUNCTION__, - reg); - return error; - } - } } return error; @@ -933,7 +820,7 @@ NativeRegisterContextLinux_x86_64::IsRegisterSetAvailable (uint32_t set_index) c if (GetFPRType () == eFPRTypeXSAVE) { // AVX is the first extended register set. - num_sets += 2; + ++num_sets; } return (set_index < num_sets); } @@ -983,8 +870,7 @@ NativeRegisterContextLinux_x86_64::IsFPR(uint32_t reg_index, FPRType fpr_type) c bool generic_fpr = IsFPR(reg_index); if (fpr_type == eFPRTypeXSAVE) - return generic_fpr || IsAVX(reg_index) || IsMPX(reg_index); - + return generic_fpr || IsAVX(reg_index); return generic_fpr; } @@ -1119,7 +1005,6 @@ NativeRegisterContextLinux_x86_64::ReadFPR () { const FPRType fpr_type = GetFPRType (); const lldb_private::ArchSpec& target_arch = GetRegisterInfoInterface().GetTargetArchitecture(); - switch (fpr_type) { case FPRType::eFPRTypeFXSAVE: @@ -1144,50 +1029,6 @@ NativeRegisterContextLinux_x86_64::ReadFPR () } } -bool -NativeRegisterContextLinux_x86_64::IsMPX(uint32_t reg_index) const -{ - return (m_reg_info.first_mpxr <= reg_index && reg_index <= m_reg_info.last_mpxc); -} - -bool -NativeRegisterContextLinux_x86_64::CopyXSTATEtoMPX(uint32_t reg) -{ - if (!IsMPX(reg)) - return false; - - if (reg >= m_reg_info.first_mpxr && reg <= m_reg_info.last_mpxr) - { - ::memcpy(m_mpx_set.mpxr[reg - m_reg_info.first_mpxr].bytes, - m_fpr.xstate.xsave.mpxr[reg - m_reg_info.first_mpxr].bytes, sizeof(MPXReg)); - } - else - { - ::memcpy(m_mpx_set.mpxc[reg - m_reg_info.first_mpxc].bytes, - m_fpr.xstate.xsave.mpxc[reg - m_reg_info.first_mpxc].bytes, sizeof(MPXCsr)); - } - return true; -} - -bool -NativeRegisterContextLinux_x86_64::CopyMPXtoXSTATE(uint32_t reg) -{ - if (!IsMPX(reg)) - return false; - - if (reg >= m_reg_info.first_mpxr && reg <= m_reg_info.last_mpxr) - { - ::memcpy(m_fpr.xstate.xsave.mpxr[reg - m_reg_info.first_mpxr].bytes, - m_mpx_set.mpxr[reg - m_reg_info.first_mpxr].bytes, sizeof(MPXReg)); - } - else - { - ::memcpy(m_fpr.xstate.xsave.mpxc[reg - m_reg_info.first_mpxc].bytes, - m_mpx_set.mpxc[reg - m_reg_info.first_mpxc].bytes, sizeof(MPXCsr)); - } - return true; -} - Error NativeRegisterContextLinux_x86_64::IsWatchpointHit(uint32_t wp_index, bool &is_hit) { -- cgit v1.2.3