From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2525DC43218 for ; Sat, 27 Apr 2019 04:32:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E96B2206BF for ; Sat, 27 Apr 2019 04:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726005AbfD0ETZ convert rfc822-to-8bit (ORCPT ); Sat, 27 Apr 2019 00:19:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57700 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbfD0ETZ (ORCPT ); Sat, 27 Apr 2019 00:19:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1082F265D; Sat, 27 Apr 2019 04:19:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D1B9A66852; Sat, 27 Apr 2019 04:19:24 +0000 (UTC) Received: from zmail18.collab.prod.int.phx2.redhat.com (zmail18.collab.prod.int.phx2.redhat.com [10.5.83.21]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CC0C9181AC42; Sat, 27 Apr 2019 04:19:23 +0000 (UTC) Date: Sat, 27 Apr 2019 00:19:23 -0400 (EDT) From: Paolo Bonzini To: Sean Christopherson Cc: Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org, Simon Becherer , Iakov Karpov , Gabriele Balducci , Antti Antinoja , Takashi Iwai , Jiri Slaby , Greg Kroah-Hartman Message-ID: <496631087.15675835.1556338763312.JavaMail.zimbra@redhat.com> In-Reply-To: <20190426233846.3675-1-sean.j.christopherson@intel.com> References: <20190426233846.3675-1-sean.j.christopherson@intel.com> Subject: Re: [PATCH] KVM: x86: Whitelist port 0x7e for pre-incrementing %rip MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [93.56.166.5, 10.4.196.2, 10.5.100.50, 10.4.195.20] Thread-Topic: x86: Whitelist port 0x7e for pre-incrementing %rip Thread-Index: RxBe8junYw/a5lQTHhYFDi0C6QeBSQ== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sat, 27 Apr 2019 04:19:25 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org ----- Original Message ----- > From: "Sean Christopherson" > To: "Paolo Bonzini" , "Radim Krčmář" > Cc: kvm@vger.kernel.org, "Simon Becherer" , "Iakov Karpov" , "Gabriele Balducci" > , "Antti Antinoja" , "Takashi Iwai" , "Jiri Slaby" > , "Greg Kroah-Hartman" > Sent: Saturday, April 27, 2019 1:38:46 AM > Subject: [PATCH] KVM: x86: Whitelist port 0x7e for pre-incrementing %rip > > KVM's recent bug fix to update %rip after emulating I/O broke userspace > that relied on the previous behavior of incrementing %rip prior to > exiting to userspace. When running a Windows XP guest on AMD hardware, > Qemu may patch "OUT 0x7E" instructions in reaction to the OUT itself. > Because KVM's old behavior was to increment %rip before exiting to > userspace to handle the I/O, Qemu manually adjusted %rip to account for > the OUT instruction. > > Arguably this is a userspace bug as KVM requires userspace to re-enter > the kernel to complete instruction emulation before taking any other > actions. That being said, this is a bit of a grey area and breaking > userspace that has worked for many years is bad. > > Pre-increment %rip on OUT to port 0x7e before exiting to userspace to > hack around the issue. > > Fixes: 45def77ebf79e ("KVM: x86: update %rip after emulating IO") The patch should probably be tweaked to use the quirks mechanism. I'll post an adjusted version next Monday. Paolo