From patchwork Tue Dec 13 17:09:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9472713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12D5260760 for ; Tue, 13 Dec 2016 17:11:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14088285CC for ; Tue, 13 Dec 2016 17:11:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08B6B285FF; Tue, 13 Dec 2016 17:11:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B554A285CC for ; Tue, 13 Dec 2016 17:11:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935485AbcLMRKf (ORCPT ); Tue, 13 Dec 2016 12:10:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935232AbcLMRKM (ORCPT ); Tue, 13 Dec 2016 12:10:12 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B19888B13D; Tue, 13 Dec 2016 17:10:01 +0000 (UTC) Received: from [10.36.117.12] (ovpn-117-12.ams2.redhat.com [10.36.117.12]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uBDH9v1p015679 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Dec 2016 12:09:59 -0500 Subject: Re: [PATCH v2 3/3] kvm: svm: Use the hardware provided GPA instead of page walk To: Brijesh Singh References: <147992048887.27638.17559991037474542240.stgit@brijesh-build-machine> <147992052008.27638.18095073174935903705.stgit@brijesh-build-machine> <65a10dd8-5fae-350f-b597-f8f0261da766@redhat.com> <9820037d-e3ca-0131-3b04-2e51f2abc883@amd.com> <657442146.2535029.1481298111651.JavaMail.zimbra@redhat.com> <6e1fd4ba-016c-99ea-5b98-24f89479da4b@amd.com> Cc: kvm@vger.kernel.org, thomas lendacky , rkrcmar@redhat.com, joro@8bytes.org, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, hpa@zytor.com, tglx@linutronix.de, bp@suse.de From: Paolo Bonzini Message-ID: <057d8a2e-0a3a-38d3-d9bf-9301e3eb8238@redhat.com> Date: Tue, 13 Dec 2016 18:09:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <6e1fd4ba-016c-99ea-5b98-24f89479da4b@amd.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 13 Dec 2016 17:10:02 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 12/12/2016 18:51, Brijesh Singh wrote: > As per the AMD BKDG [1] Section 2.7.1, we should not be using any of > these instruction for MMIO access, the behavior is undefined. > > The question is, do we really need to add logic to detect the cross-page > MMIO accesses and push/pop mem operations so that we pass the > kvm-unit-test or we should update the unit test? Like you said > cross-page MMIO access detection is going to be a bit tricky. Actually there is a nice trick you can do to support cross-page MMIO access detection: It fixes the testcase for push/pop with two memory ops too, but it's not reliable, so your change for TwoMemOp is still necessary. Feel free to include it in your patch! Regarding the replacement of emulator_is_string_op with emulator_is_two_memory_op, what about REP prefixes? In that case I think that you do need to reject string ops. So the function would have to reject all TwoMemOps, and REP-prefixed String operations. Paolo --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 37cd31645d45..754d251dc611 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4549,6 +4549,7 @@ static int emulator_read_write_onepage(unsigned long addr, void *val, */ if (vcpu->arch.gpa_available && !emulator_is_string_op(ctxt) && + (addr & ~PAGE_MASK) == (exception->address & ~PAGE_MASK) && vcpu_is_mmio_gpa(vcpu, addr, exception->address, write)) { gpa = exception->address; goto mmio;