lkml.org 
[lkml]   [2014]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/5] KVM: x86: Fix wrong masking on relative jump/call
On 5/7/14, 5:43 PM, Bandan Das wrote:
> Nadav Amit <namit@cs.technion.ac.il> writes:
>
>> Relative jumps and calls do the masking according to the operand size, and not
>> according to the address size as the KVM emulator does today. In 64-bit mode,
>> the resulting RIP is always 64-bit. Otherwise it is masked according to the
>> instruction operand-size. Note that when 16-bit address size is used, bits
>> 63:32 are unmodified.
>>
>> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
>> ---
>> arch/x86/kvm/emulate.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
>> index 6833b41..e406705 100644
>> --- a/arch/x86/kvm/emulate.c
>> +++ b/arch/x86/kvm/emulate.c
>> @@ -506,7 +506,9 @@ static void rsp_increment(struct x86_emulate_ctxt *ctxt, int inc)
>>
>> static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel)
>> {
>> - register_address_increment(ctxt, &ctxt->_eip, rel);
>> + /* 64-bit mode relative jumps are always 64-bit; otherwise mask */
>> + int op_bytes = ctxt->mode == X86EMUL_MODE_PROT64 ? 8 : ctxt->op_bytes;
>
> Just a nit, probably break this up for readability ?
>
I will make it more readable on the next version.

Thanks,
Nadav


\
 
 \ /
  Last update: 2014-05-08 21:21    [W:0.038 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site