RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 848328 - kvm emulates instructions with rip-relative addressing incorrectly
Summary: kvm emulates instructions with rip-relative addressing incorrectly
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: kernel
Version: 6.4
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Andrew Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 848325
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-15 09:34 UTC by Avi Kivity
Modified: 2013-04-22 16:02 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 848325
Environment:
Last Closed: 2013-04-18 07:18:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Avi Kivity 2012-08-15 09:34:56 UTC
+++ This bug was initially created as a clone of Bug #848325 +++

Description of problem:

The KVM x86 emulator does calculates rip-relative addresses incorrectly: if they contain an immediate operand, then the memory operand's address will be off by the size of the immediate operand.

Example:

  movl $0, somewhere(%rip)

Version-Release number of selected component (if applicable):
kvm-83-259.el5

How reproducible:
Never

Steps to Reproduce:
1. Find a guest which accesses mmio using an rip-relative instruction with an immediate
2. Run guest
3. Watch guest malfunction
  
Actual results:

Guest malfunctions

Expected results:

Guest works correctly

Additional info:

--- Additional comment from avi on 2012-08-15 12:33:58 IDT ---

Upstream fix:

commit cb16c348760ad2bc79b67b20aefac05529569ed7
Author: Avi Kivity <avi>
Date:   Sun Jun 19 19:21:11 2011 +0300

    KVM: x86 emulator: fix %rip-relative addressing with immediate source operand
    
    %rip-relative addressing is relative to the first byte of the next instruction,
    so we need to add %rip only after we've fetched any immediate bytes.
    
    Based on original patch by Li Xin <xin.li>.
    
    Signed-off-by: Avi Kivity <avi>
    Acked-by: Li Xin <xin.li>
    Signed-off-by: Marcelo Tosatti <mtosatti>

Comment 3 Andrew Jones 2013-04-02 13:48:23 UTC
afaict, rhel6 doesn't need this patch. rhel6's arch/x86/kvm/emulate.c is missing 69f55cb11e8d78, which was the patch that moved the 'effective address += rip' up above the immediate fetching. Thus, we shouldn't have to move it back down again (which is what cb16c348760ad does).

Setting needinfo on Gleb to ack that analysis. If acked we can close as NOTABUG.

Comment 4 Gleb Natapov 2013-04-18 06:03:18 UTC
Yes, it looks like you are correct. Good thing we have a unit test for this case now. You can run emulator.flat to be absolutely sure.

Comment 5 Andrew Jones 2013-04-22 16:02:20 UTC
(In reply to comment #4)
> Yes, it looks like you are correct. Good thing we have a unit test for this
> case now. You can run emulator.flat to be absolutely sure.

Thanks for the pointer. I ran it and the rip_relative test passed.


Note You need to log in before you can comment on or make changes to this bug.